smile 0.3.0 → 0.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/.gitignore ADDED
@@ -0,0 +1,14 @@
1
+ # Files
2
+ *.swp
3
+ *.jpg
4
+ .DS_Store
5
+
6
+ # Dir
7
+ tmp/
8
+ coverage/
9
+ scratch_directory/
10
+ rdoc/
11
+ pkg/
12
+ doc/
13
+
14
+
data/Rakefile CHANGED
@@ -1,5 +1,7 @@
1
1
  require 'rubygems'
2
2
  require 'rake'
3
+ require 'metric_fu'
4
+ require 'config/metric_fu_config'
3
5
 
4
6
  begin
5
7
  require 'jeweler'
data/VERSION.yml CHANGED
@@ -1,4 +1,4 @@
1
1
  ---
2
- :patch: 0
3
2
  :major: 0
4
3
  :minor: 3
4
+ :patch: 1
data/bin/smile ADDED
@@ -0,0 +1,21 @@
1
+ #!/usr/bin/env ruby
2
+ # -*- mode: ruby -*-
3
+
4
+ require 'optparse'
5
+ require 'rubygems'
6
+ #require File.join(File.dirname(__FILE__), '../lib/smile' )
7
+
8
+ options ={}
9
+ opts = OptionParser.new do |opts|
10
+ opts.banner = "Usage smile [command] [options]"
11
+ end
12
+
13
+ unless( Dir.exists?( '~/.smile/' ) )
14
+ puts 'it is not there'
15
+ end
16
+
17
+
18
+ if( ARGV.empty? )
19
+ puts opts
20
+ exit
21
+ end
@@ -0,0 +1,31 @@
1
+ MetricFu::Configuration.run do |config|
2
+ #define which metrics you want to use
3
+ config.metrics = [:churn, :saikuro, :flog, :flay, :reek, :roodi, :rcov]
4
+ config.graphs = [:flog, :flay, :reek, :roodi, :rcov]
5
+ config.flay = { :dirs_to_flay => ['lib'],
6
+ :minimum_score => 100 }
7
+ config.flog = { :dirs_to_flog => ['lib'] }
8
+ config.reek = { :dirs_to_reek => ['lib'] }
9
+ config.roodi = { :dirs_to_roodi => ['lib'] }
10
+ config.saikuro = { :output_directory => 'scratch_directory/saikuro',
11
+ :input_directory => ['lib'],
12
+ :cyclo => "",
13
+ :filter_cyclo => "0",
14
+ :warn_cyclo => "5",
15
+ :error_cyclo => "7",
16
+ :formater => "text"} #this needs to be set to "text"
17
+ config.churn = { :start_date => "1 year ago", :minimum_churn_count => 10}
18
+ config.rcov = { :environment => 'test',
19
+ :test_files => ['test/*_test.rb'],
20
+ :rcov_opts => ["--sort coverage",
21
+ "--no-html",
22
+ "--text-coverage",
23
+ "--profile",
24
+ "--exclude /gems/,/Library/,spec"]}
25
+ config.graph_engine = :bluff
26
+ end
27
+
28
+ namespace :metrics do
29
+ TEST_PATHS_FOR_RCOV = ['test/*_test.rb']
30
+ end
31
+
data/lib/smile/album.rb CHANGED
@@ -1,86 +1,95 @@
1
- # Result
2
- # STANDARD RESPONSE
3
- #
4
- # array Albums
5
- # Album
6
- # integer id
7
- # string Key
8
- # string Title
9
- # struct Category
10
- # string id
11
- # string Name
12
- # struct SubCategory
13
- # string id
14
- # string Name
15
- #
16
- # HEAVY RESPONSE
17
- #
18
- # array Albums
19
- # Album
20
- # integer id
21
- # string Key
22
- # string Title
23
- # struct Category
24
- # string id
25
- # string Name
26
- # struct SubCategory
27
- # string id
28
- # string Name
29
- # string Description
30
- # string Keywords
31
- # boolean Geography (owner)
32
- # integer Position
33
- # struct Hightlight (owner)
34
- # string id
35
- # integer ImageCount
36
- # string LastUpdated
37
- # boolean Header (owner, power & pro only)
38
- # boolean Clean (owner)
39
- # boolean EXIF (owner)
40
- # boolean Filenames (owner)
41
- # struct Template (owner)
42
- # string id
43
- # string SortMethod (owner)
44
- # boolean SortDirection (owner)
45
- # string Password (owner)
46
- # string PasswordHint (owner)
47
- # boolean Public (owner)
48
- # boolean WorldSearchable (owner)
49
- # boolean SmugSearchable (owner)
50
- # boolean External (owner)
51
- # boolean Protected (owner, power & pro only)
52
- # boolean Watermarking (owner, pro only)
53
- # struct Watermark (owner, pro only)
54
- # string id
55
- # boolean HideOwner (owner)
56
- # boolean Larges (owner, pro only)
57
- # boolean XLarges (owner, pro only)
58
- # boolean X2Larges (owner)
59
- # boolean X3Larges (owner)
60
- # boolean Originals (owner)
61
- # boolean CanRank (owner)
62
- # boolean FriendEdit (owner)
63
- # boolean FamilyEdit (owner)
64
- # boolean Comments (owner)
65
- # boolean Share (owner)
66
- # boolean Printable (owner)
67
- # int ColorCorrection (owner)
68
- # boolean DefaultColor (owner, pro only) deprecated
69
- # integer ProofDays (owner, pro only)
70
- # string Backprinting (owner, pro only)
71
- # float UnsharpAmount (owner, power & pro only)
72
- # float UnsharpRadius (owner, power & pro only)
73
- # float UnsharpThreshold (owner, power & pro only)
74
- # float UnsharpSigma (owner, power & pro only)
75
- # struct Community (owner)
76
- # string id
77
- #
78
- # Created by Zac Kleinpeter on 2009-04-28.
79
- # Copyright 2009 Cajun Country. All rights reserved.
1
+ # The Album class will fetch any public/private album hosted on SmugMug.
2
+ # The Album Objects will have the following fields on the response
3
+ #
4
+ # Result
5
+ #
6
+ # STANDARD RESPONSE
80
7
  #
8
+ # array Albums
9
+ # Album
10
+ # integer id
11
+ # string Key
12
+ # string Title
13
+ # struct Category
14
+ # string id
15
+ # string Name
16
+ # string id
17
+ # string Name
18
+ # struct SubCategory
19
+ # string id
20
+ # string Name
21
+ # string id
22
+ # string Name
23
+ #
24
+ # HEAVY RESPONSE
25
+ #
26
+ # array Albums
27
+ # Album
28
+ # integer id
29
+ # string Key
30
+ # string Title
31
+ # struct Category
32
+ # string id
33
+ # string Name
34
+ # struct SubCategory
35
+ # string id
36
+ # string Name
37
+ # string Description
38
+ # string Keywords
39
+ # boolean Geography (owner)
40
+ # integer Position
41
+ # struct Hightlight (owner)
42
+ # string id
43
+ # integer ImageCount
44
+ # string LastUpdated
45
+ # boolean Header (owner, power & pro only)
46
+ # boolean Clean (owner)
47
+ # boolean EXIF (owner)
48
+ # boolean Filenames (owner)
49
+ # struct Template (owner)
50
+ # string id
51
+ # string SortMethod (owner)
52
+ # boolean SortDirection (owner)
53
+ # string Password (owner)
54
+ # string PasswordHint (owner)
55
+ # boolean Public (owner)
56
+ # boolean WorldSearchable (owner)
57
+ # boolean SmugSearchable (owner)
58
+ # boolean External (owner)
59
+ # boolean Protected (owner, power & pro only)
60
+ # boolean Watermarking (owner, pro only)
61
+ # struct Watermark (owner, pro only)
62
+ # string id
63
+ # boolean HideOwner (owner)
64
+ # boolean Larges (owner, pro only)
65
+ # boolean XLarges (owner, pro only)
66
+ # boolean X2Larges (owner)
67
+ # boolean X3Larges (owner)
68
+ # boolean Originals (owner)
69
+ # boolean CanRank (owner)
70
+ # boolean FriendEdit (owner)
71
+ # boolean FamilyEdit (owner)
72
+ # boolean Comments (owner)
73
+ # boolean Share (owner)
74
+ # boolean Printable (owner)
75
+ # int ColorCorrection (owner)
76
+ # boolean DefaultColor (owner, pro only) deprecated
77
+ # integer ProofDays (owner, pro only)
78
+ # string Backprinting (owner, pro only)
79
+ # float UnsharpAmount (owner, power & pro only)
80
+ # float UnsharpRadius (owner, power & pro only)
81
+ # float UnsharpThreshold (owner, power & pro only)
82
+ # float UnsharpSigma (owner, power & pro only)
83
+ # struct Community (owner)
84
+ # string id
85
+ #
86
+ # @author Zac Kleinpeter
87
+ # @date 2009-04-28.
81
88
  class Smile::Album < Smile::Base
82
89
 
83
90
  class << self
91
+ # Converts the json results from the web service into
92
+ # Album object to use
84
93
  def from_json( json, session_id )
85
94
  result = JSON.parse( json )
86
95
  result["Albums"].map do |album_upcase|
@@ -94,22 +103,23 @@ class Smile::Album < Smile::Base
94
103
  end
95
104
  end
96
105
 
97
- # This will pull a single album from the smugmug
106
+ # This will pull a single album from the smugmug.
107
+ # The Site ID is auto passed if you are logged in.
98
108
  #
99
- # * SessionID - string. ( by default if logged in)
100
- # * AlbumID - string.
101
- # * Password - string (optional).
102
- # * SitePassword - string (optional).
103
- # * AlbumKey - string.
104
- #
109
+ # @param [Hash] :options yes this is the has you will put stuff
110
+ # @param options [String] :album_id This is the ID of the album you want to find
111
+ # @param options [String] :album_key This is the KEY for the albums
112
+ # @param options [optional, String] :password password for the albums
113
+ # @param options [optional, String] :site_password password for the site
105
114
  def find( options={} )
106
115
  params = default_params.merge(
107
116
  :method => 'smugmug.albums.getInfo'
108
117
  )
109
118
 
119
+ options = Smile::ParamConverter.clean_hash_keys( options )
110
120
  params.merge!( options ) if( options )
111
121
 
112
- json = RestClient.post Smile::Base::BASE, params
122
+ json = RestClient.post( Smile::Base::BASE, params ).body
113
123
 
114
124
  album_upper = JSON.parse(json)
115
125
 
@@ -120,15 +130,172 @@ class Smile::Album < Smile::Base
120
130
  a.session_id = session_id
121
131
  a
122
132
  end
133
+
134
+ # Update the album from the following params
135
+ #
136
+ # @param [String] title What you want to call it
137
+ # @param [optional, Hash] options wow it's a hash
138
+ #
139
+ # Essentials
140
+ # @option options [Fixnum] :category_id it is what it is
141
+ # @option options [optional, Fixnum] :sub_category_id ( 0 ) guess what this is
142
+ # @option options [optional, String] :description what am i looking at
143
+ # @option options [optional, String] :keywords space seperated or comman don't know
144
+ # @option options [optional, Fixnum] :album_template_id ( 1 ) yup
145
+ # @option options [optional, Boolean] :geography ( 0 ) huh?
146
+ # @option options [optional, Fixnum] :highlight_id you guess is as good as mine
147
+ # @option options [optional, Fixnum] :position I'm just the dev
148
+ #
149
+ # Look & Feel
150
+ # @option options [optional, Boolean] :header ( 0 ) yup
151
+ # @option options [optional, Boolean] :clean ( 0 ) @see http://smugmug.com
152
+ # @option options [optional, Boolean] :exif ( 1 ) @see http://smugmug.com
153
+ # @option options [optional, Boolean] :filenames ( 0 ) show file names
154
+ # @option options [optional, Boolean] :square_thumbs ( 1 ) user square ones
155
+ # @option options [optional, Fixnum] :template_id ( 0 ) 0:Viewer Choice 3:SmugMug 4:Traditional 7:All Thumbs 8:Slideshow 9:Journal 10:SmugMug Small 11:Filmstrip
156
+ # @option options [optional, String] :sort_method ( 'Position' ) %w( Position Caption FileName Date DateTime DateTimeOriginal )
157
+ # @option options [optional, 1 or 0] :sort_direction 0: Ascending (1-99, A-Z, 1980-2004, etc) 1: Descending (99-1, Z-A, 2004-1980, etc)
158
+ #
159
+ # Security & Privacy
160
+ # @option options [optional, String] :password want one?
161
+ # @option options [optional, String] :password_hint need one?
162
+ # @option options [optional, Boolean] :public ( 1 ) is it?
163
+ # @option options [optional, Boolean] :world_searchable ( 1 ) can i?
164
+ # @option options [optional, Boolean] :smug_searchable ( 1 ) please?
165
+ # @option options [optional, Boolean] :external ( 1 ) let everyone know
166
+ # @option options [optional, Boolean] :protected ( 0 ) MINE!!!
167
+ # @option options [optional, Boolean] :watermarking ( 0 ) kinda cool
168
+ # @option options [optional, Fixnum] :watermark_id ( 0 ) which one
169
+ # @option options [optional, Boolean] :hide_owner ( 0 ) you can't see me
170
+ # @option options [optional, Boolean] :larges ( 1 ) show bigens
171
+ # @option options [optional, Boolean] :x_larges ( 1 ) show X bigens
172
+ # @option options [optional, Boolean] :x2_larges ( 1 ) show XX bigens
173
+ # @option options [optional, Boolean] :x3_larges ( 1 ) show XXX bigens
174
+ # @option options [optional, Boolean] :originals ( 1 ) show what i uploaded
175
+ #
176
+ # Social
177
+ # @option options [optional, Boolean] :can_rank ( 1 ) well...yesss
178
+ # @option options [optional, Boolean] :friend_edit ( 0 ) yeah i have friends!!!
179
+ # @option options [optional, Boolean] :family_edit ( 0 ) go ahead ma
180
+ # @option options [optional, Boolean] :comments ( 1 ) I just wanted to say....
181
+ # @option options [optional, Boolean] :share ( 1 ) here you go
182
+ #
183
+ # Printing & Sales
184
+ # @option options [optional, Boolean] :printable ( 1 ) yes
185
+ # @option options [optional, Fixnum] :color_correction ( 2 ) 0:No 1:Yes 2:Injerit
186
+ # @option options [optional, Boolean] :default_color ( 0 ) ( pro only deprecated ) 1:Auto 0: True
187
+ # @option options [optional, Fixnum] :proof_days ( 0 ) yep ( pro only )
188
+ # @option options [optional, String] :back_printing what you want to see behind you
189
+ #
190
+ # Photo Sharpening
191
+ # @option options [optional, Float] :unsharp_amount ( 0.200 ) numbers
192
+ # @option options [optional, Float] :unsharp_radius ( 1.000 ) more numbers
193
+ # @option options [optional, Float] :unsharp_threshold ( 0.050 ) I'm a dev what does this mean?
194
+ # @option options [optional, Float] :unsharp_sigma ( 1.000 ) and more numbers
195
+ #
196
+ # Community
197
+ # @option options [optional, Fixnum] :community_id ( 0 ) join the group
198
+ def create( title, options )
199
+ params = default_params.merge(
200
+ :method => 'smugmug.albums.create',
201
+ :AlbumID => album_id
202
+ )
203
+ options = Smile::ParamConverter.clean_hash_keys( options )
204
+ params.merge!( options ) if( options )
205
+
206
+ json = RestClient.post( BASE, params ).body
207
+ json = JSON.parse( json )
208
+ raise json["message"] if json["stat"] == 'fail'
209
+ find( :album_id => json["Album"]["id"], :album_key => json["Album"]["key"] )
210
+ true
211
+ end
123
212
  end
124
213
 
214
+ # Update the album from the following params
215
+ #
216
+ # @param [optional, Hash] options wow it's a hash
217
+ #
218
+ # Essentials
219
+ # @option options [optional, String] :title the title maybe?
220
+ # @option options [optional, Fixnum] :category_id it is what it is
221
+ # @option options [optional, Fixnum] :sub_category_id guess what this is
222
+ # @option options [optional, String] :description what am i looking at
223
+ # @option options [optional, String] :keywords space seperated or comman don't know
224
+ # @option options [optional, Fixnum] :album_template_id yup
225
+ # @option options [optional, Boolean] :geography huh?
226
+ # @option options [optional, Fixnum] :highlight_id you guess is as good as mine
227
+ # @option options [optional, Fixnum] :position I'm just the dev
228
+ #
229
+ # Look & Feel
230
+ # @option options [optional, Boolean] :header yup
231
+ # @option options [optional, Boolean] :clean @see http://smugmug.com
232
+ # @option options [optional, Boolean] :exif @see http://smugmug.com
233
+ # @option options [optional, Boolean] :filenames show file names
234
+ # @option options [optional, Boolean] :square_thumbs user square ones
235
+ # @option options [optional, Fixnum] :template_id 0:Viewer Choice 3:SmugMug 4:Traditional 7:All Thumbs 8:Slideshow 9:Journal 10:SmugMug Small 11:Filmstrip
236
+ # @option options [optional, String] :sort_method %w( Position Caption FileName Date DateTime DateTimeOriginal )
237
+ # @option options [optional, 1 or 0] :sort_direction 0: Ascending (1-99, A-Z, 1980-2004, etc) 1: Descending (99-1, Z-A, 2004-1980, etc)
238
+ #
239
+ # Security & Privacy
240
+ # @option options [optional, String] :password want one?
241
+ # @option options [optional, String] :password_hint need one?
242
+ # @option options [optional, Boolean] :public is it?
243
+ # @option options [optional, Boolean] :world_searchable can i?
244
+ # @option options [optional, Boolean] :smug_searchable please?
245
+ # @option options [optional, Boolean] :external let everyone know
246
+ # @option options [optional, Boolean] :protected MINE!!!
247
+ # @option options [optional, Boolean] :watermarking kinda cool
248
+ # @option options [optional, Fixnum] :watermark_id which one
249
+ # @option options [optional, Boolean] :hide_owner you can't see me
250
+ # @option options [optional, Boolean] :larges show bigens
251
+ # @option options [optional, Boolean] :x_larges show X bigens
252
+ # @option options [optional, Boolean] :x2_larges show XX bigens
253
+ # @option options [optional, Boolean] :x3_larges show XXX bigens
254
+ # @option options [optional, Boolean] :originals show what i uploaded
255
+ #
256
+ # Social
257
+ # @option options [optional, Boolean] :can_rank well...yesss
258
+ # @option options [optional, Boolean] :friend_edit yeah i have friends!!!
259
+ # @option options [optional, Boolean] :family_edit go ahead ma
260
+ # @option options [optional, Boolean] :comments I just wanted to say....
261
+ # @option options [optional, Boolean] :share here you go
262
+ #
263
+ # Printing & Sales
264
+ # @option options [optional, Boolean] :printable yes
265
+ # @option options [optional, Fixnum] :color_correction 0:No 1:Yes 2:Injerit
266
+ # @option options [optional, Boolean] :default_color ( pro only deprecated ) 1:Auto 0: True
267
+ # @option options [optional, Fixnum] :proof_days yep ( pro only )
268
+ # @option options [optional, String] :back_printing what you want to see behind you
269
+ #
270
+ # Photo Sharpening
271
+ # @option options [optional, Float] :unsharp_amount numbers
272
+ # @option options [optional, Float] :unsharp_radius more numbers
273
+ # @option options [optional, Float] :unsharp_threshold I'm a dev what does this mean?
274
+ # @option options [optional, Float] :unsharp_sigma and more numbers
275
+ #
276
+ # Community
277
+ # @option options [optional, Fixnum] :community_id join the group
278
+ def update( options )
279
+ params = default_params.merge(
280
+ :method => 'smugmug.albums.changeSettings',
281
+ :AlbumID => album_id
282
+ )
283
+ options = Smile::ParamConverter.clean_hash_keys( options )
284
+ params.merge!( options ) if( options )
285
+
286
+ json = RestClient.post( BASE, params ).body
287
+ json = JSON.parse( json )
288
+ raise json["message"] if json["stat"] == 'fail'
289
+ true
290
+ end
291
+
125
292
  # This will pull all the photos for a given album
126
- # * SessionID - string. ( by default if logged in)
127
- # * AlbumID - integer.
128
- # * Heavy - boolean (optional).
129
- # * Password - string (optional).
130
- # * SitePassword - string (optional).
131
- # * AlbumKey - string.
293
+ #
294
+ # @param [optional, Hash] options wow it's a hash
295
+ #
296
+ # @option options [optional, boolean] :heavy ( true ) default is true
297
+ # @option options [optional, string] :password password for the pics
298
+ # @option options [optional, string] :site_password access via site password
132
299
  def photos( options=nil )
133
300
  params = default_params.merge(
134
301
  :method => 'smugmug.images.get',
@@ -136,17 +303,20 @@ class Smile::Album < Smile::Base
136
303
  :AlbumKey => key,
137
304
  :Heavy => 1
138
305
  )
139
-
306
+ options = Smile::ParamConverter.clean_hash_keys( options )
140
307
  params.merge!( options ) if( options )
141
308
 
142
- json = RestClient.post BASE, params
309
+ json = RestClient.post( BASE, params ).body
310
+
143
311
  Smile::Photo.from_json( json, session_id )
144
312
  end
145
313
 
146
- # * integer AlbumID
147
- # * integer Month
148
- # * integer Year
149
- # * boolean Heavy (optional)
314
+ # Pull stats for an Album for a given Month and Year
315
+ #
316
+ # @param [optional, Hash] options wow it's a hash
317
+ # @option options [optional, Fixnum] :month (Date.today.month) month field
318
+ # @option options [optional, Fixnum] :year (Date.today.year) the year and stuff
319
+ # @option options [optional, 1 or 0] :heavy more details
150
320
  def stats( options =nil )
151
321
  params = default_params.merge(
152
322
  :method => 'smugmug.albums.getStats',
@@ -154,10 +324,11 @@ class Smile::Album < Smile::Base
154
324
  :month => Date.today.month,
155
325
  :year => Date.today.year
156
326
  )
327
+ options = Smile::ParamConverter.clean_hash_keys( options )
157
328
 
158
329
  params.merge!( options ) if( options )
159
330
 
160
- json = RestClient.post Smile::Base::BASE, params
331
+ json = RestClient.post( Smile::Base::BASE, params ).body
161
332
 
162
333
  json = JSON.parse( json )
163
334
  raise json["message"] if json["stat"] == 'fail'
@@ -177,7 +348,8 @@ class Smile::Album < Smile::Base
177
348
  # @option options [optional, Decimal] :altitude Sets the Altitude of the image (in meters)
178
349
  def add( image, options={} )
179
350
  if( File.exists?( image ) )
180
- json = RestClient.put UPLOAD + "/#{image}", File.read( image ),
351
+ options = Smile::ParamConverter.clean_hash_keys( options )
352
+ json = RestClient.put( UPLOAD + "/#{image}", File.read( image ),
181
353
  :content_length => File.size( image ),
182
354
  :content_md5 => MD5.hexdigest( File.read( image ) ),
183
355
  :x_smug_sessionid => session_id,
@@ -189,7 +361,7 @@ class Smile::Album < Smile::Base
189
361
  :x_smug_keywords => options[:keywords],
190
362
  :x_smug_latitude => options[:latitude],
191
363
  :x_smug_longitude => options[:longitude],
192
- :x_smug_altitude => options[:altitude]
364
+ :x_smug_altitude => options[:altitude] ).body
193
365
 
194
366
  image = JSON.parse( json )
195
367
  if( image && image["Image"] && image["Image"]["id"] )
@@ -202,7 +374,48 @@ class Smile::Album < Smile::Base
202
374
  end
203
375
  end
204
376
 
377
+ # Want to get rid of that album? Call this guy and see what gets removed!
378
+ def delete!
379
+ params = default_params.merge(
380
+ :method => 'smugmug.albums.delete',
381
+ :AlbumID => album_id
382
+ )
383
+
384
+ options = Smile::ParamConverter.clean_hash_keys( options )
385
+
386
+ params.merge!( options ) if( options )
387
+
388
+ json = RestClient.post( Smile::Base::BASE, params ).body
389
+
390
+ json = JSON.parse( json )
391
+ raise json["message"] if json["stat"] == 'fail'
392
+
393
+ album_id = nil
394
+ album_key = nil
395
+ nil
396
+ end
397
+
398
+ # This method will re-sort all the photos inside of the album specified by AlbumID.
399
+ #
400
+ # @option options [String] :by valid values: FileName, Caption, DateTime
401
+ # @option options [String] :direction valid values: ASC, DESC
402
+ def resort!( options =nil )
403
+ params = default_params.merge(
404
+ :method => 'smugmug.albums.reSort',
405
+ :AlbumID => album_id
406
+ )
407
+
408
+ json = RestClient.post( Smile::Base::BASE, params ).body
409
+
410
+ json = JSON.parse( json )
411
+ raise json["message"] if json["stat"] == 'fail'
412
+
413
+ album_id = nil
414
+ album_key = nil
415
+ nil
416
+ end
417
+
205
418
  def category
206
419
  ['category']
207
420
  end
208
- end
421
+ end
@@ -3,48 +3,102 @@ module Smile::ParamConverter
3
3
 
4
4
  def convert( param, value=nil )
5
5
  key = nil
6
- case param.to_s.downcase.to_sym
6
+ key = case param.to_s.downcase.to_sym
7
7
  when :popular_category
8
- key = :popularCategory
8
+ :popularCategory
9
9
  when :geo_all
10
- key = :geoAll
10
+ :geoAll
11
11
  when :geo_keyword
12
- key = :geoKeyword
12
+ :geoKeyword
13
13
  when :geo_search
14
- key = :geoSearch
14
+ :geoSearch
15
15
  when :geo_community
16
- key = :geoCommunity
16
+ :geoCommunity
17
17
  when :open_search_keyword
18
- key = :openSearchKeyword
18
+ :openSearchKeyword
19
19
  when :user_keyword
20
- key = :userkeyword
20
+ :userkeyword
21
21
  when :nickname_recent
22
- key = :nicknameRecent
22
+ :nicknameRecent
23
23
  when :nickname_popular
24
- key = :nicknamePopular
24
+ :nicknamePopular
25
25
  when :user_comments
26
- key = :userComments
26
+ :userComments
27
27
  when :geo_user
28
- key = :geoUser
28
+ :geoUser
29
29
  when :geo_album
30
- key = :geoAlbum
30
+ :geoAlbum
31
31
  when :size
32
- key = :Size
33
32
  value = value.titlecase
33
+ :Size
34
34
  when :image_count
35
- key = :ImageCount
36
- when :data
37
- key = :Data
38
- when :type
39
- key = :Type
35
+ :ImageCount
36
+ when :data, :type, :description, :keywords, :geography, :position, :header,
37
+ :clean, :filenames, :password, :public, :external, :protected, :watermarking,
38
+ :larges, :originals, :comments, :share, :printable, :backprinting
39
+ param.to_s.upcase.to_sym
40
40
  when :image_id
41
- key = :ImageID
41
+ :ImageID
42
42
  when :image_key
43
- key = :ImageKey
43
+ :ImageKey
44
44
  when :image_count
45
- key = :ImageCount
45
+ :ImageCount
46
46
  when :nickname, :nick_name
47
- key = :NickName
47
+ :NickName
48
+ when :category_id
49
+ :CategoryID
50
+ when :sub_categroy_id
51
+ :SubCategoryID
52
+ when :album_template_id
53
+ :AlbumTemplateID
54
+ when :highlight_id
55
+ :HighlightID
56
+ when :exif
57
+ :EXIF
58
+ when :square_thumbs
59
+ :Square_Thumbs
60
+ when :tempate_id
61
+ :TemplateID
62
+ when :sort_method
63
+ :SortMethod
64
+ when :sort_direction
65
+ :SortDirection
66
+ when :password_hint
67
+ :PasswordHint
68
+ when :word_searchable
69
+ :WordSearchable
70
+ when :smug_searchable
71
+ :SmugSearchable
72
+ when :watermark_id
73
+ :WatermarkID
74
+ when :hide_owner
75
+ :HideOwner
76
+ when :x_larges, :xlarges
77
+ :XLarges
78
+ when :x2_larges, :x2larges
79
+ :X2Larges
80
+ when :x3_larges, :x3larges
81
+ :X3Larges
82
+ when :can_rank
83
+ :CanRank
84
+ when :friend_edit
85
+ :FriendEdit
86
+ when :family_edit
87
+ :FamilyEdit
88
+ when :color_correction
89
+ :ColorCorrection
90
+ when :default_color
91
+ :DefaultColor
92
+ when :proof_days
93
+ :ProofDays
94
+ when :unsharp_amount
95
+ :UnsharpAmount
96
+ when :unsharp_radius
97
+ :UnsharpRadius
98
+ when :unsharp_sigma
99
+ :UnsharpSigma
100
+ when :community_id
101
+ :CommunityID
48
102
  else
49
103
  key = param
50
104
  end
@@ -56,8 +110,8 @@ module Smile::ParamConverter
56
110
  cleaned_hash ={}
57
111
  hash_to_clean.each_pair do |key,value|
58
112
  cleaned_hash[convert( key ).first] = value
59
- end
113
+ end if( hash_to_clean )
60
114
  cleaned_hash
61
115
  end
62
116
 
63
- end
117
+ end
data/lib/smile/photo.rb CHANGED
@@ -3,8 +3,6 @@
3
3
  # smile
4
4
  #
5
5
  # Created by Zac Kleinpeter on 2009-04-28.
6
- # Copyright 2009 Cajun Country. All rights reserved.
7
- #
8
6
  class Smile::Photo < Smile::Base
9
7
 
10
8
  class << self
@@ -41,7 +39,7 @@ class Smile::Photo < Smile::Base
41
39
  )
42
40
 
43
41
  params.merge!( options ) if( options )
44
- json = RestClient.post Smile::Base::BASE, params
42
+ json = RestClient.post( Smile::Base::BASE, params ).body
45
43
  image_upper = JSON.parse( json )
46
44
  image = upper_hash_to_lower_hash( image_upper['Image'] )
47
45
 
@@ -64,40 +62,40 @@ class Smile::Photo < Smile::Base
64
62
  #
65
63
  # Arguments:*
66
64
  #
67
- # String Password optional
68
- # String SitePassword optional
69
- #
70
65
  # Result:* struct "Image" [some, none, or all may be returned]
71
- #
72
- # int "id"
73
- # String "DateTime"
74
- # String "DateTimeOriginal"
75
- # String "DateTimeDigitized"
76
- # String "Make"
77
- # String "Model"
78
- # String "ExposureTime"
79
- # String "Aperture"
80
- # int "ISO"
81
- # String "FocalLength"
82
- # int "FocalLengthIn35mmFilm"
83
- # String "CCDWidth"
84
- # String "CompressedBitsPerPixel"
85
- # int "Flash"
86
- # int "Metering"
87
- # int "ExposureProgram"
88
- # String "ExposureBiasValue"
89
- # int "ExposureMode"
90
- # int "LightSource"
91
- # int "WhiteBalance"
92
- # String "DigitalZoomRatio"
93
- # int "Contrast"
94
- # int "Saturation"
95
- # int "Sharpness"
96
- # String "SubjectDistance"
97
- # int "SubjectDistanceRange"
98
- # int "SensingMethod"
99
- # String "ColorSpace"
100
- # String "Brightness"
66
+ # int "id"
67
+ # String "DateTime"
68
+ # String "DateTimeOriginal"
69
+ # String "DateTimeDigitized"
70
+ # String "Make"
71
+ # String "Model"
72
+ # String "ExposureTime"
73
+ # String "Aperture"
74
+ # int "ISO"
75
+ # String "FocalLength"
76
+ # int "FocalLengthIn35mmFilm"
77
+ # String "CCDWidth"
78
+ # String "CompressedBitsPerPixel"
79
+ # int "Flash"
80
+ # int "Metering"
81
+ # int "ExposureProgram"
82
+ # String "ExposureBiasValue"
83
+ # int "ExposureMode"
84
+ # int "LightSource"
85
+ # int "WhiteBalance"
86
+ # String "DigitalZoomRatio"
87
+ # int "Contrast"
88
+ # int "Saturation"
89
+ # int "Sharpness"
90
+ # String "SubjectDistance"
91
+ # int "SubjectDistanceRange"
92
+ # int "SensingMethod"
93
+ # String "ColorSpace"
94
+ # String "Brightness"
95
+ #
96
+ # @param [options,Hash] options ruby and hashes are like.......
97
+ # @option options [String] :password a password field
98
+ # @option options [String] :site_password site password field
101
99
  def details( options =nil )
102
100
  params = default_params.merge(
103
101
  :method => "smugmug.images.getEXIF",
@@ -106,7 +104,7 @@ class Smile::Photo < Smile::Base
106
104
  )
107
105
 
108
106
  params.merge!( options ) if( options )
109
- json = RestClient.post Smile::Base::BASE, params
107
+ json = RestClient.post( Smile::Base::BASE, params ).body
110
108
 
111
109
  json = JSON.parse( json )
112
110
  raise json["message"] if json["stat"] == 'fail'
@@ -165,7 +163,7 @@ class Smile::Photo < Smile::Base
165
163
  )
166
164
 
167
165
  params.merge!( options ) if( options )
168
- json = RestClient.post Smile::Base::BASE, params
166
+ json = RestClient.post( Smile::Base::BASE, params ).body
169
167
 
170
168
  json = JSON.parse( json )
171
169
  raise json["message"] if json["stat"] == 'fail'
@@ -216,7 +214,7 @@ class Smile::Photo < Smile::Base
216
214
  )
217
215
 
218
216
  params.merge!( options ) if( options )
219
- json = RestClient.post Smile::Base::BASE, params
217
+ json = RestClient.post( Smile::Base::BASE, params ).body
220
218
 
221
219
  json = JSON.parse( json )
222
220
  raise json["message"] if json["stat"] == 'fail'
@@ -230,4 +228,4 @@ class Smile::Photo < Smile::Base
230
228
  def album
231
229
  Smile::Album.find( :AlbumID => album_id, :AlbumKey => album_key )
232
230
  end
233
- end
231
+ end
data/lib/smile/smug.rb CHANGED
@@ -21,7 +21,7 @@ module Smile
21
21
  :Password => pass
22
22
  )
23
23
 
24
- json = RestClient.post( BASE, params )
24
+ json = RestClient.post( BASE, params ).body
25
25
  result = JSON.parse( json )
26
26
 
27
27
  self.session_id = result["Login"]["Session"]["id"]
@@ -39,7 +39,7 @@ module Smile
39
39
  :method => 'smugmug.login.anonymously'
40
40
  )
41
41
 
42
- json = RestClient.post( BASE, params )
42
+ json = RestClient.post( BASE, params ).body
43
43
  result = JSON.parse( json )
44
44
  self.session_id = result["Login"]["Session"]["id"]
45
45
  result
@@ -53,7 +53,7 @@ module Smile
53
53
  :method => 'smugmug.logout'
54
54
  )
55
55
 
56
- RestClient.post( BASE, params )
56
+ RestClient.post( BASE, params ).body
57
57
  end
58
58
 
59
59
 
@@ -77,12 +77,13 @@ module Smile
77
77
  :heavy => 1
78
78
  )
79
79
 
80
+ options = Smile::ParamConverter.clean_hash_keys( options )
80
81
  params = params.merge( options ) if( options )
81
- json = RestClient.post BASE, params
82
-
82
+ json = RestClient.post( BASE, params ).body
83
+
83
84
  Smile::Album.from_json( json, session_id )
84
85
  rescue
85
86
  nil
86
87
  end
87
88
  end
88
- end
89
+ end
data/lib/smile.rb CHANGED
@@ -1,4 +1,4 @@
1
- require 'activesupport'
1
+ require 'active_support'
2
2
  require 'restclient'
3
3
  require 'ostruct'
4
4
  require 'lib/smile/base'
@@ -46,7 +46,7 @@ module Smile
46
46
  url_params << "#{key.to_s}=#{ CGI.escape( value ) }"
47
47
  end
48
48
 
49
- RestClient.get( url + url_params.join( "&" ) )
49
+ RestClient.get( url + url_params.join( "&" ) ).body
50
50
  end
51
51
  private( :base_feed )
52
52
 
data/smile.gemspec CHANGED
@@ -1,23 +1,29 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run `rake gemspec`
1
4
  # -*- encoding: utf-8 -*-
2
5
 
3
6
  Gem::Specification.new do |s|
4
7
  s.name = %q{smile}
5
- s.version = "0.3.0"
8
+ s.version = "0.3.1"
6
9
 
7
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
8
11
  s.authors = ["cajun"]
9
- s.date = %q{2009-08-25}
12
+ s.date = %q{2010-04-17}
13
+ s.default_executable = %q{smile}
10
14
  s.email = %q{zac@kleinpeter.org}
15
+ s.executables = ["smile"]
11
16
  s.extra_rdoc_files = [
12
17
  "LICENSE",
13
18
  "README.rdoc"
14
19
  ]
15
20
  s.files = [
16
- ".yardoc",
21
+ ".gitignore",
17
22
  "LICENSE",
18
23
  "README.rdoc",
19
24
  "Rakefile",
20
25
  "VERSION.yml",
26
+ "config/metric_fu_config.rb",
21
27
  "lib/smile.rb",
22
28
  "lib/smile/album.rb",
23
29
  "lib/smile/base.rb",
@@ -32,7 +38,7 @@ Gem::Specification.new do |s|
32
38
  s.rdoc_options = ["--charset=UTF-8"]
33
39
  s.require_paths = ["lib"]
34
40
  s.rubyforge_project = %q{cajun-gems}
35
- s.rubygems_version = %q{1.3.5}
41
+ s.rubygems_version = %q{1.3.6}
36
42
  s.summary = %q{Simple API for talking to SmugMug}
37
43
  s.test_files = [
38
44
  "test/smile_test.rb",
data/test/smile_test.rb CHANGED
@@ -1,4 +1,4 @@
1
- require 'test_helper'
1
+ require File.dirname(__FILE__) + '/test_helper'
2
2
 
3
3
  class SmileTest < Test::Unit::TestCase
4
4
  def setup
@@ -12,20 +12,20 @@ class SmileTest < Test::Unit::TestCase
12
12
 
13
13
  def test_have_albums
14
14
  assert_nothing_raised(Exception) do
15
- assert_not_nil( @smug.albums( :NickName => 'kleinpeter' ) )
15
+ assert_not_nil( @smug.albums( :nick_name => 'kleinpeter' ) )
16
16
  end
17
17
  end
18
18
 
19
19
  def test_have_photos
20
20
  assert_nothing_raised(Exception) do
21
- album = @smug.albums( :NickName => 'kleinpeter' ).first
21
+ album = @smug.albums( :nick_name => 'kleinpeter' ).first
22
22
  assert_not_nil( album.photos )
23
23
  end
24
24
  end
25
25
 
26
26
  def test_photo_has_album
27
27
  assert_nothing_raised(Exception) do
28
- album = @smug.albums( :NickName => 'kleinpeter' ).first
28
+ album = @smug.albums( :nick_name => 'kleinpeter' ).first
29
29
  photo = album.photos.first
30
30
  assert_equal( album.album_id, photo.album.album_id )
31
31
  assert_equal( album.key, photo.album.key )
@@ -34,7 +34,7 @@ class SmileTest < Test::Unit::TestCase
34
34
 
35
35
  def test_photo_has_album_has_photo
36
36
  assert_nothing_raised(Exception) do
37
- album = @smug.albums( :NickName => 'kleinpeter' ).first
37
+ album = @smug.albums( :nick_name => 'kleinpeter' ).first
38
38
  photo = album.photos.first
39
39
  alt_photo = photo.album.photos.first
40
40
 
@@ -45,14 +45,14 @@ class SmileTest < Test::Unit::TestCase
45
45
  # NOTE have to be logged in to test this one
46
46
  # def test_album_stats
47
47
  # assert_nothing_raised(Exception) do
48
- # album = @smug.albums( :NickName => 'kleinpeter' ).first
48
+ # album = @smug.albums( :nick_name => 'kleinpeter' ).first
49
49
  # assert_not_nil( album.stats )
50
50
  # end
51
51
  # end
52
52
 
53
53
  def test_photo_extras
54
54
  assert_nothing_raised(Exception) do
55
- album = @smug.albums( :NickName => 'kleinpeter' ).first
55
+ album = @smug.albums( :nick_name => 'kleinpeter' ).first
56
56
  photo = album.photos.first
57
57
 
58
58
  assert_not_nil( photo.details )
metadata CHANGED
@@ -1,7 +1,12 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: smile
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ prerelease: false
5
+ segments:
6
+ - 0
7
+ - 3
8
+ - 1
9
+ version: 0.3.1
5
10
  platform: ruby
6
11
  authors:
7
12
  - cajun
@@ -9,44 +14,49 @@ autorequire:
9
14
  bindir: bin
10
15
  cert_chain: []
11
16
 
12
- date: 2009-08-25 00:00:00 -05:00
13
- default_executable:
17
+ date: 2010-04-17 00:00:00 -05:00
18
+ default_executable: smile
14
19
  dependencies:
15
20
  - !ruby/object:Gem::Dependency
16
21
  name: rest-client
17
- type: :runtime
18
- version_requirement:
19
- version_requirements: !ruby/object:Gem::Requirement
22
+ prerelease: false
23
+ requirement: &id001 !ruby/object:Gem::Requirement
20
24
  requirements:
21
25
  - - ">="
22
26
  - !ruby/object:Gem::Version
27
+ segments:
28
+ - 0
23
29
  version: "0"
24
- version:
30
+ type: :runtime
31
+ version_requirements: *id001
25
32
  - !ruby/object:Gem::Dependency
26
33
  name: activesupport
27
- type: :runtime
28
- version_requirement:
29
- version_requirements: !ruby/object:Gem::Requirement
34
+ prerelease: false
35
+ requirement: &id002 !ruby/object:Gem::Requirement
30
36
  requirements:
31
37
  - - ">="
32
38
  - !ruby/object:Gem::Version
39
+ segments:
40
+ - 0
33
41
  version: "0"
34
- version:
42
+ type: :runtime
43
+ version_requirements: *id002
35
44
  description:
36
45
  email: zac@kleinpeter.org
37
- executables: []
38
-
46
+ executables:
47
+ - smile
39
48
  extensions: []
40
49
 
41
50
  extra_rdoc_files:
42
51
  - LICENSE
43
52
  - README.rdoc
44
53
  files:
45
- - .yardoc
54
+ - .gitignore
46
55
  - LICENSE
47
56
  - README.rdoc
48
57
  - Rakefile
49
58
  - VERSION.yml
59
+ - config/metric_fu_config.rb
50
60
  - lib/smile.rb
51
61
  - lib/smile/album.rb
52
62
  - lib/smile/base.rb
@@ -69,18 +79,20 @@ required_ruby_version: !ruby/object:Gem::Requirement
69
79
  requirements:
70
80
  - - ">="
71
81
  - !ruby/object:Gem::Version
82
+ segments:
83
+ - 0
72
84
  version: "0"
73
- version:
74
85
  required_rubygems_version: !ruby/object:Gem::Requirement
75
86
  requirements:
76
87
  - - ">="
77
88
  - !ruby/object:Gem::Version
89
+ segments:
90
+ - 0
78
91
  version: "0"
79
- version:
80
92
  requirements: []
81
93
 
82
94
  rubyforge_project: cajun-gems
83
- rubygems_version: 1.3.5
95
+ rubygems_version: 1.3.6
84
96
  signing_key:
85
97
  specification_version: 3
86
98
  summary: Simple API for talking to SmugMug
data/.yardoc DELETED
Binary file