class PhotoHelper::Instagram

Public Class Methods

album() click to toggle source
# File lib/photo-helper/instagram.rb, line 11
def self.album
     "Instagram"
end
folders() click to toggle source
# File lib/photo-helper/instagram.rb, line 7
def self.folders
    ["instagram"]
      end
osascript(script) click to toggle source
# File lib/photo-helper/instagram.rb, line 20
def self.osascript(script)
              system 'osascript', *script.split(/\n/).map { |line| ['-e', line] }.flatten
            end

Public Instance Methods

load(folder=nil) click to toggle source
# File lib/photo-helper/instagram.rb, line 24
          def load(folder=nil)
      folder ||= options[:folder]

      search_path = File.expand_path(folder)

      files =
        if options[:recursive]
          Dir["#{search_path}/**/*"]
        else
          Dir["#{search_path}/*"]
        end

        pictures = []

        files.each do |file|
                folder = FileHelper.directory(file).downcase
                next unless PhotoHelper::Instagram.folders.include? (folder)
                pictures.concat([file])
              end
        return unless pictures.any?

        PhotoHelper::Instagram.osascript <<-END
                                 tell application "Photos"
                                   activate
                                   delay 2
                                   set ablum to get album "#{PhotoHelper::Instagram.album}"
                                   set imageList to {"#{pictures.join('","')}"}
                                   import imageList into ablum skip check duplicates no
                                 end tell
                                END

      end