smile 0.4.1 → 0.4.3

Sign up to get free protection for your applications and to get access to all the features.
data/README.rdoc CHANGED
@@ -5,7 +5,23 @@ This gem wraps the 1.2.0 interface.
5
5
 
6
6
  == Features
7
7
 
8
- === NEW Upload Images/Vids
8
+ === Configure
9
+ Smile::Base.configure do |config|
10
+ config.log = Log.new( STDOUT )
11
+ config.logger_on = true
12
+ config.api_key = 'your key from smugmug'
13
+ end
14
+
15
+
16
+ new methods
17
+
18
+ album.reload!
19
+ photo.reload!
20
+
21
+ Exceptions!!!!
22
+ Hey it shows you better exceptions now when something goes wrong from the site or lib
23
+
24
+ === Upload Images/Vids
9
25
 
10
26
  smug = Smile.auth( 'foo@bar.com', 'pass' )
11
27
  album = smug.albums.first
data/VERSION.yml CHANGED
@@ -1,4 +1,4 @@
1
1
  ---
2
- :minor: 4
3
- :patch: 1
2
+ :patch: 3
4
3
  :major: 0
4
+ :minor: 4
data/lib/smile/album.rb CHANGED
@@ -166,7 +166,7 @@ class Smile::Album < Smile::Base
166
166
  # Community
167
167
  # @option options [optional, Fixnum] :community_id ( 0 ) join the group
168
168
  def create( title, options )
169
- json = web_method_call( { :method => 'smugmug.albums.create', :AlbumID => album_id })
169
+ json = web_method_call( { :method => 'smugmug.albums.create', :album_id => album_id })
170
170
 
171
171
  self.from_json( json )
172
172
  end
@@ -237,7 +237,7 @@ class Smile::Album < Smile::Base
237
237
  # Community
238
238
  # @option options [optional, Fixnum] :community_id join the group
239
239
  def update( options )
240
- json = web_method_call( { :method => 'smugmug.albums.changeSettings', :AlbumID => album_id } )
240
+ json = web_method_call( { :method => 'smugmug.albums.changeSettings', :album_id => album_id } )
241
241
 
242
242
  true
243
243
  end
@@ -253,9 +253,9 @@ class Smile::Album < Smile::Base
253
253
  json = web_method_call(
254
254
  {
255
255
  :method => 'smugmug.images.get',
256
- :AlbumID => self.album_id,
257
- :AlbumKey => self.key,
258
- :Heavy => 1
256
+ :album_id => album_id,
257
+ :album_key => key,
258
+ :heavy => 1
259
259
  },
260
260
  options
261
261
  )
@@ -270,7 +270,7 @@ class Smile::Album < Smile::Base
270
270
  # @option options [optional, 1 or 0] :heavy more details
271
271
  def stats( options =nil )
272
272
  json = web_method_call(
273
- { :method => 'smugmug.albums.getStats', :AlbumID => album_id, :month => Date.today.month, :year => Date.today.year },
273
+ { :method => 'smugmug.albums.getStats', :album_id => album_id, :month => Date.today.month, :year => Date.today.year },
274
274
  options
275
275
  )
276
276
 
@@ -316,23 +316,23 @@ class Smile::Album < Smile::Base
316
316
 
317
317
  # Want to get rid of that album? Call this guy and see what gets removed!
318
318
  def delete!
319
- json = web_method_call( { :method => 'smugmug.albums.delete', :AlbumID => album_id })
319
+ json = web_method_call( { :method => 'smugmug.albums.delete', :album_id => album_id })
320
320
 
321
321
  nil
322
322
  end
323
323
 
324
- # This method will re-sort all the photos inside of the album specified by AlbumID.
324
+ # This method will re-sort all the photos inside of the album specified by album_id.
325
325
  #
326
326
  # @option options [String] :by valid values: FileName, Caption, DateTime
327
327
  # @option options [String] :direction valid values: ASC, DESC
328
328
  def resort!( options =nil )
329
- json = web_method_call( { :method => 'smugmug.albums.reSort', :AlbumID => album_id }, options)
329
+ json = web_method_call( { :method => 'smugmug.albums.reSort', :album_id => album_id }, options)
330
330
 
331
331
  nil
332
332
  end
333
333
 
334
334
  def reload!
335
- @attributes = Smile::Album.find( { :AlbumID => self.album_id } ).attributes
335
+ @attributes = Smile::Album.find( { :album_id => album_id } ).attributes
336
336
  self
337
337
  end
338
338
 
data/lib/smile/common.rb CHANGED
@@ -12,17 +12,19 @@ module Smile
12
12
 
13
13
  # This will be included in every request once you have logged in
14
14
  def default_params
15
- @params ||= { :APIKey => session.api_key }
16
- @params.merge!( :SessionID => session.id ) if( session.id )
17
- @params
15
+ @params ||= { :api_key => session.api_key }
16
+ @params.merge!( :session_id => session.id ) if( session.id )
17
+ @params = Smile::ParamConverter.clean_hash_keys( @params )
18
18
  end
19
19
 
20
20
  # This is the base work that will need to be done on ALL
21
21
  # web calls. Given a set of web options and other params
22
22
  # call the web service and convert it to json
23
23
  def web_method_call( web_options, options = {} )
24
- params = default_params.merge( web_options )
25
24
  options = Smile::ParamConverter.clean_hash_keys( options )
25
+ web_options = Smile::ParamConverter.clean_hash_keys( web_options )
26
+
27
+ params = default_params.merge( web_options )
26
28
  params.merge!( options ) if( options )
27
29
 
28
30
  logger.info( params.inspect )
@@ -35,8 +37,10 @@ module Smile
35
37
  # web calls. Given a set of web options and other params
36
38
  # call the web service and convert it to json
37
39
  def secure_web_method_call( web_options, options = {} )
38
- params = default_params.merge( web_options )
39
40
  options = Smile::ParamConverter.clean_hash_keys( options )
41
+ web_options = Smile::ParamConverter.clean_hash_keys( web_options )
42
+
43
+ params = default_params.merge( web_options )
40
44
  params.merge!( options ) if( options )
41
45
 
42
46
  logger.info( params.inspect )
data/lib/smile/json.rb CHANGED
@@ -3,6 +3,7 @@ module Smile
3
3
 
4
4
  class << self
5
5
  def parse( text )
6
+ Smile::Base.logger.info( text )
6
7
  @result = JSON.parse(text) # This is the default JSON parse
7
8
  raise_exception! if has_error?
8
9
  @result
@@ -9,22 +9,29 @@ module Smile::ParamConverter
9
9
  :nickname_recent, :nickname_popular, :user_comments, :geo_user,
10
10
  :geo_album
11
11
  first_letter_downcase( param.to_s.classify ).to_sym
12
- when :size
12
+ when :size
13
13
  value = value.titlecase
14
14
  :Size
15
15
  when :data, :type, :description, :keywords, :geography, :position, :header,
16
- :clean, :filenames, :password, :public, :external, :protected, :watermarking,
16
+ :clean, :filenames, :public, :external, :protected, :watermarking,
17
17
  :larges, :originals, :comments, :share, :printable, :backprinting
18
18
  param.to_s.upcase.to_sym
19
19
  when :image_id, :image_key, :image_count, :nick_name, :category_id,
20
- :sub_category_id, :album_template_id, :highlight_id, :square_thumbs,
20
+ :sub_category_id, :album_key, :album_template_id, :highlight_id, :square_thumbs,
21
21
  :template_id, :sort_method, :sort_direction, :password_hint, :word_searchable,
22
22
  :smug_searchable, :watermark_id, :hide_owner, :x_larges, :x2_larges, :x3_larges,
23
23
  :can_rank, :friend_edit, :family_edit, :color_correction, :default_color, :proof_days,
24
- :unsharp_amount, :unsharp_radius, :unsharp_sigma, :community_id
24
+ :unsharp_amount, :unsharp_radius, :unsharp_sigma, :community_id, :password, :email_address,
25
+ :heavy
25
26
  param.to_s.classify.to_sym
26
27
  when :exif
27
28
  :EXIF
29
+ when :api_key
30
+ :APIKey
31
+ when :session_id
32
+ :SessionID
33
+ when :album_id
34
+ :AlbumID
28
35
  else
29
36
  key = param
30
37
  end
data/lib/smile/photo.rb CHANGED
@@ -8,6 +8,7 @@ class Smile::Photo < Smile::Base
8
8
  class << self
9
9
  # Convert the given xml into photo objects to play with
10
10
  def from_json( json )
11
+ logger.info( json )
11
12
  json["images"].map do |image_upper|
12
13
  image = upper_hash_to_lower_hash( image_upper )
13
14
  image.merge!( :image_id => image["id"] )
@@ -199,4 +200,9 @@ class Smile::Photo < Smile::Base
199
200
  @attributes = Smile::Photo.find( { :ImageID => self.image_id, :ImageKey => self.key } ).attributes
200
201
  self
201
202
  end
203
+
204
+ def encode64( size = :smallurl )
205
+ url = @attributes.send( size )
206
+ [open(url){ |io| io.read }].pack('m')
207
+ end
202
208
  end
data/smile.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{smile}
8
- s.version = "0.4.1"
8
+ s.version = "0.4.3"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["cajun"]
12
- s.date = %q{2010-05-14}
12
+ s.date = %q{2010-07-09}
13
13
  s.default_executable = %q{smile}
14
14
  s.email = %q{zac@kleinpeter.org}
15
15
  s.executables = ["smile"]
@@ -41,7 +41,7 @@ Gem::Specification.new do |s|
41
41
  s.rdoc_options = ["--charset=UTF-8"]
42
42
  s.require_paths = ["lib"]
43
43
  s.rubyforge_project = %q{cajun-gems}
44
- s.rubygems_version = %q{1.3.6}
44
+ s.rubygems_version = %q{1.3.7}
45
45
  s.summary = %q{Simple API for talking to SmugMug}
46
46
  s.test_files = [
47
47
  "test/smile_test.rb",
@@ -52,7 +52,7 @@ Gem::Specification.new do |s|
52
52
  current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
53
53
  s.specification_version = 3
54
54
 
55
- if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
55
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
56
56
  s.add_runtime_dependency(%q<rest-client>, [">= 0"])
57
57
  s.add_runtime_dependency(%q<activesupport>, [">= 0"])
58
58
  else
data/test/smile_test.rb CHANGED
@@ -7,7 +7,7 @@ Shindo.tests 'checking all the cool things smile can do' do
7
7
  # this resets the config to the base state before every test
8
8
  Smile::Base.clear_config!
9
9
  Smile::Base.configure do |config|
10
- # config.logger_on = true
10
+ config.logger_on = true
11
11
  end
12
12
 
13
13
  @smug = Smile::Smug.new
@@ -34,7 +34,7 @@ Shindo.tests 'checking all the cool things smile can do' do
34
34
  @smug.albums( :nick_name => 'kleinpeter' )
35
35
  end
36
36
 
37
- test( 'we can reload albums from the site', ['album']) do
37
+ test( 'we can reload albums from the site', ['album', 'reload']) do
38
38
  album = @smug.albums( :nick_name => 'kleinpeter' ).first
39
39
  old_title = album.title
40
40
  album.title = 'foo'
@@ -54,7 +54,7 @@ Shindo.tests 'checking all the cool things smile can do' do
54
54
  album.key == photo.album.key
55
55
  end
56
56
 
57
- test( 'we can reload photos from the site', ['photo']) do
57
+ test( 'we can reload photos from the site', ['photo', 'reload']) do
58
58
  album = @smug.albums( :nick_name => 'kleinpeter' ).first
59
59
  photo = album.photos.first
60
60
  old_url = photo.tinyurl
metadata CHANGED
@@ -1,12 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: smile
3
3
  version: !ruby/object:Gem::Version
4
+ hash: 9
4
5
  prerelease: false
5
6
  segments:
6
7
  - 0
7
8
  - 4
8
- - 1
9
- version: 0.4.1
9
+ - 3
10
+ version: 0.4.3
10
11
  platform: ruby
11
12
  authors:
12
13
  - cajun
@@ -14,16 +15,18 @@ autorequire:
14
15
  bindir: bin
15
16
  cert_chain: []
16
17
 
17
- date: 2010-05-14 00:00:00 -05:00
18
+ date: 2010-07-09 00:00:00 -05:00
18
19
  default_executable: smile
19
20
  dependencies:
20
21
  - !ruby/object:Gem::Dependency
21
22
  name: rest-client
22
23
  prerelease: false
23
24
  requirement: &id001 !ruby/object:Gem::Requirement
25
+ none: false
24
26
  requirements:
25
27
  - - ">="
26
28
  - !ruby/object:Gem::Version
29
+ hash: 3
27
30
  segments:
28
31
  - 0
29
32
  version: "0"
@@ -33,9 +36,11 @@ dependencies:
33
36
  name: activesupport
34
37
  prerelease: false
35
38
  requirement: &id002 !ruby/object:Gem::Requirement
39
+ none: false
36
40
  requirements:
37
41
  - - ">="
38
42
  - !ruby/object:Gem::Version
43
+ hash: 3
39
44
  segments:
40
45
  - 0
41
46
  version: "0"
@@ -69,6 +74,7 @@ files:
69
74
  - smile.gemspec
70
75
  - test/smile_test.rb
71
76
  - test/test_helper.rb
77
+ - bin/smile
72
78
  has_rdoc: true
73
79
  homepage: http://github.com/cajun/smile
74
80
  licenses: []
@@ -79,23 +85,27 @@ rdoc_options:
79
85
  require_paths:
80
86
  - lib
81
87
  required_ruby_version: !ruby/object:Gem::Requirement
88
+ none: false
82
89
  requirements:
83
90
  - - ">="
84
91
  - !ruby/object:Gem::Version
92
+ hash: 3
85
93
  segments:
86
94
  - 0
87
95
  version: "0"
88
96
  required_rubygems_version: !ruby/object:Gem::Requirement
97
+ none: false
89
98
  requirements:
90
99
  - - ">="
91
100
  - !ruby/object:Gem::Version
101
+ hash: 3
92
102
  segments:
93
103
  - 0
94
104
  version: "0"
95
105
  requirements: []
96
106
 
97
107
  rubyforge_project: cajun-gems
98
- rubygems_version: 1.3.6
108
+ rubygems_version: 1.3.7
99
109
  signing_key:
100
110
  specification_version: 3
101
111
  summary: Simple API for talking to SmugMug