desoto-photoapp 0.3.8 → 0.3.9

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 44b0bf77f0cf05ddb572648d3a435d26e6607bea
4
- data.tar.gz: 2cba2ec59cc911a932d11c2d787a69ecc983ba26
3
+ metadata.gz: ce8ae58a89f14ed5b1ec87ae694da4ef7ee8f28c
4
+ data.tar.gz: 25f765308e87d93cdd8559f1d4b85e471cd4f6ad
5
5
  SHA512:
6
- metadata.gz: fb8ccd155daf0e2afa2b3aed7ca1676afa9142385a95e2b514d10e11c42c08e0f23d3b49532935fc22808089d4a6aab1ef0dbb51091897748f7acd8059593c29
7
- data.tar.gz: 914444f49c58d81c4963f93db494de75e765f3c18c0689c64bd36f4e38a79929d2f05f30b321747689da2ac7c5317457999fc961996c52a3cd84965cee4c30ae
6
+ metadata.gz: b5f6ef244f4252c3f3a8859c6c15c00b75295b81f2468fee1ec292fc87d88306237fcd564400996ae099c09988160c4089bc955063352030adfe4762bb78f238
7
+ data.tar.gz: fc4bb1abdc1c86c3449e50802b4f73dcdfcf32aed4f98b977bb31c7176dd0b02ed474835d96aef168898b5bbf9aa3069f5b4aaae3af24ddc52af29d8bb3da575
@@ -59,11 +59,8 @@
59
59
  <key>ActionParameters</key>
60
60
  <dict>
61
61
  <key>COMMAND_STRING</key>
62
- <string>say "reprinting photos"
63
- for f in "$@"
64
- do
65
- lpr $f
66
- done</string>
62
+ <string>source ~/.bash_profile
63
+ photoapp reprint | say</string>
67
64
  <key>CheckedForUserDefaultShell</key>
68
65
  <true/>
69
66
  <key>inputMethod</key>
@@ -87,6 +84,8 @@ done</string>
87
84
  </array>
88
85
  <key>Class Name</key>
89
86
  <string>RunShellScriptAction</string>
87
+ <key>Disabled</key>
88
+ <false/>
90
89
  <key>InputUUID</key>
91
90
  <string>A88305AF-F481-4120-9873-CA58EDCA65B3</string>
92
91
  <key>Keywords</key>
@@ -52,27 +52,25 @@ if options['version']
52
52
  abort
53
53
  end
54
54
 
55
- if ARGV.first == 'test'
56
- ARGV.shift
55
+ cmd = ARGV.shift
56
+
57
+ case cmd
58
+ when 'test'
57
59
  path = ARGV.join('')
58
60
  session = Photoapp::Session.new(options)
59
61
  session.test_image(path)
60
- elsif ARGV.first == 'setup'
61
- ARGV.shift
62
+ when 'setup'
62
63
  setup
63
- elsif ARGV.first == 'update'
64
- ARGV.shift
64
+ when 'update'
65
65
  update
66
- elsif ARGV.first == 'set-actions'
67
- ARGV.shift
66
+ when 'set-actions'
68
67
  actions
69
- else
70
- if ARGV.first == 'process'
71
- ARGV.shift
72
- options['source'] = ARGV.shift
73
- Photoapp::Session.new(options).process
74
- elsif ARGV.first == 'upload'
75
- Photoapp::Session.new(options).upload
76
- end
68
+ when 'process'
69
+ options['source'] = ARGV.shift
70
+ Photoapp::Session.new(options).process
71
+ when 'upload'
72
+ Photoapp::Session.new(options).upload
73
+ when 'reprint'
74
+ Photoapp::Session.new(options).reprint
77
75
  end
78
76
 
@@ -19,16 +19,21 @@ module Photoapp
19
19
  class Session
20
20
  attr_accessor :photos, :print, :upload
21
21
 
22
- ROOT = File.expand_path('~/cave.pics') # where photos are stored
23
-
24
22
  # relative to root
25
23
  CONFIG_FILE = 'photoapp.yml'
26
24
  UPLOAD = 'upload'
27
25
  PRINT = 'print'
26
+ ROOT = File.expand_path('~/cave.pics') # where photos are stored
27
+
28
28
 
29
29
  def initialize(options={})
30
30
  @photos = []
31
31
  @config = config(options)
32
+ FileUtils.mkdir_p(config['reprint'])
33
+ end
34
+
35
+ def root(path='')
36
+ File.expand_path(File.join(ROOT, path))
32
37
  end
33
38
 
34
39
  def config(options={})
@@ -42,7 +47,8 @@ module Photoapp
42
47
  'font_size' => 30,
43
48
  'config' => 'photoapp.yml',
44
49
  'upload' => 'upload',
45
- 'print' => 'print'
50
+ 'print' => 'print',
51
+ 'reprint' => 'reprint'
46
52
  }
47
53
 
48
54
  config_file = root(options['config'] || config['config'])
@@ -55,6 +61,7 @@ module Photoapp
55
61
 
56
62
  config['upload'] = root(config['upload'])
57
63
  config['print'] = root(config['print'])
64
+ config['reprint'] = root(config['reprint'])
58
65
 
59
66
  config
60
67
  end
@@ -65,18 +72,12 @@ module Photoapp
65
72
  @logo ||= Magick::Image.read(config['watermark']).first
66
73
  end
67
74
 
68
- def root(path='')
69
- File.expand_path(File.join(ROOT, path))
70
- end
71
-
72
75
  def process
73
76
  photos = []
74
77
  tmp = root('.tmp')
78
+ import = root('.import/')
75
79
  FileUtils.mkdir_p tmp
76
-
77
- if empty_print_queue?
78
- FileUtils.rm_rf(config['print'])
79
- end
80
+ FileUtils.mkdir_p import
80
81
 
81
82
  load_photos.each do |f|
82
83
  photos << process_image(f, tmp)
@@ -84,13 +85,17 @@ module Photoapp
84
85
 
85
86
  photos.each do |p|
86
87
  p.write
87
- p.add_to_photos
88
+ FileUtils.cp p.print_dest, import
88
89
  Photoapp.print(p.print_dest)
89
90
  end
90
91
 
92
+ `automator -i #{import} #{Photoapp.gem_dir("lib/import-photos.workflow")}`
93
+
91
94
  upload
92
95
 
93
96
  FileUtils.rm_rf tmp
97
+ FileUtils.rm_rf import
98
+ FileUtils.rm_rf config['print']
94
99
  end
95
100
 
96
101
  def process_image(photo, destination)
@@ -120,6 +125,24 @@ module Photoapp
120
125
  FileUtils.rm_rf config['upload']
121
126
  end
122
127
 
128
+ def reprint
129
+ files = ['*.jpg', '*.JPG', '*.JPEG', '*.jpeg'].map! { |f| File.join(config['reprint'], f) }
130
+ photos = Dir[*files].uniq
131
+ if !photos.empty?
132
+ system "lpr #{photos.join(' ')}"
133
+ if photos.size == 1
134
+ puts "Printing #{photos.size} photo"
135
+ else
136
+ puts "Printing #{photos.size} photos"
137
+ end
138
+ else
139
+ puts "No photos to print"
140
+ end
141
+
142
+ sleep 4
143
+ FileUtils.rm(photos)
144
+ end
145
+
123
146
  # For processing a single image for testing purposes
124
147
  #
125
148
  def test_image(photo)
@@ -66,10 +66,6 @@ module Photoapp
66
66
  end
67
67
  end
68
68
 
69
- def add_to_photos
70
- `automator -i #{print_dest} #{Photoapp.gem_dir("lib/import-photos.workflow")}`
71
- end
72
-
73
69
  def cleanup
74
70
  watermark.destroy!
75
71
  with_url.destroy!
@@ -1,3 +1,3 @@
1
1
  module Photoapp
2
- VERSION = "0.3.8"
2
+ VERSION = "0.3.9"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: desoto-photoapp
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.8
4
+ version: 0.3.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brandon Mathis
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2015-06-18 00:00:00.000000000 Z
11
+ date: 2015-06-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rmagick