lib/desoto-photoapp.rb in desoto-photoapp-0.1.3 vs lib/desoto-photoapp.rb in desoto-photoapp-0.1.4
- old
+ new
@@ -9,10 +9,16 @@
def gem_dir(*paths)
File.expand_path(File.join(File.dirname(__FILE__), '..', *paths))
end
+ # Handle printing
+ def print(path)
+ system "lpr #{path}"
+ end
+
+
class Session
attr_accessor :photos, :print, :upload
ROOT = File.expand_path('~/cave.pics') # where photos are stored
@@ -63,35 +69,37 @@
def process
logo = Magick::Image.read(config['watermark']).first
photos = []
tmp = root('.tmp')
- FileUtils.mkdir_p(tmp)
+ FileUtils.mkdir_p tmp
if empty_print_queue?
FileUtils.rm_rf(config['print'])
end
load_photos.each do |f|
- FileUtils.mv f, tmp
path = File.join(tmp, File.basename(f))
+ FileUtils.mv f, path
`automator -i #{path} #{Photoapp.gem_dir("lib/adjust-image.workflow")}`
photos << Photo.new(path, logo, self)
end
photos.each do |p|
p.write
p.add_to_photos
- p.print
+ Photoapp.print(p.print_dest)
end
+ upload
+
FileUtils.rm_rf tmp
end
def load_photos
files = ['*.jpg', '*.JPG', '*.JPEG', '*.jpeg'].map! { |f| File.join(config['source'], f) }
- Dir[*files]
+ Dir[*files].uniq
end
def empty_print_queue?
if printer = `lpstat -d`
if printer = printer.scan(/:\s*(.+)/).flatten.first