smile 0.4.0 → 0.4.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/VERSION.yml CHANGED
@@ -1,4 +1,4 @@
1
1
  ---
2
2
  :minor: 4
3
- :patch: 0
3
+ :patch: 1
4
4
  :major: 0
data/lib/smile/album.rb CHANGED
@@ -77,6 +77,7 @@ class Smile::Album < Smile::Base
77
77
  json["albums"].map do |album_upper|
78
78
  album = upper_hash_to_lower_hash( album_upper )
79
79
  album.merge!( :album_id => album["id"] )
80
+ album.merge!( :album_key => album["key"] )
80
81
 
81
82
  Smile::Album.new( album )
82
83
  end
@@ -95,6 +96,7 @@ class Smile::Album < Smile::Base
95
96
 
96
97
  album = json['album']
97
98
  album.merge!( :album_id => album["id"] )
99
+ album.merge!( :album_key => album["key"] )
98
100
 
99
101
  Smile::Album.new( album )
100
102
  end
@@ -330,12 +332,12 @@ class Smile::Album < Smile::Base
330
332
  end
331
333
 
332
334
  def reload!
333
- replace_with = Smile::Album.find(self.album_id, self.album_key )
334
- # self = replace_with
335
+ @attributes = Smile::Album.find( { :AlbumID => self.album_id } ).attributes
336
+ self
335
337
  end
336
338
 
337
339
  def category
338
- ['category']
340
+ @attributes['category']
339
341
  end
340
342
 
341
343
  def subcategory
data/lib/smile/base.rb CHANGED
@@ -6,9 +6,10 @@
6
6
  # Copyright 2009 Cajun Country. All rights reserved.
7
7
  #
8
8
  module Smile
9
- class Base < OpenStruct
9
+ class Base
10
10
  include Smile::Common
11
-
11
+ attr_accessor :attributes
12
+
12
13
  class << self
13
14
  include Smile::Common
14
15
 
@@ -21,5 +22,12 @@ module Smile
21
22
  end
22
23
  end
23
24
 
25
+ def initialize( options={} )
26
+ @attributes = OpenStruct.new( options )
27
+ end
28
+
29
+ def method_missing( name, *args )
30
+ @attributes.send(name,args)
31
+ end
24
32
  end
25
33
  end
data/lib/smile/common.rb CHANGED
@@ -31,6 +31,19 @@ module Smile
31
31
  upper_hash_to_lower_hash(Smile::Json.parse( json ) )
32
32
  end
33
33
 
34
+ # This is the base work that will need to be done on ALL
35
+ # web calls. Given a set of web options and other params
36
+ # call the web service and convert it to json
37
+ def secure_web_method_call( web_options, options = {} )
38
+ params = default_params.merge( web_options )
39
+ options = Smile::ParamConverter.clean_hash_keys( options )
40
+ params.merge!( options ) if( options )
41
+
42
+ logger.info( params.inspect )
43
+
44
+ json = RestClient.post( BASE_SECURE, params ).body
45
+ upper_hash_to_lower_hash(Smile::Json.parse( json ) )
46
+ end
34
47
  # This converts a hash that has mixed case
35
48
  # into all lower case
36
49
  def upper_hash_to_lower_hash( upper )
data/lib/smile/photo.rb CHANGED
@@ -32,6 +32,9 @@ class Smile::Photo < Smile::Base
32
32
  options
33
33
  )
34
34
 
35
+ image = image['image']
36
+ logger.info( image )
37
+
35
38
  image.merge!( :image_id => image["id"] )
36
39
  image.merge!( :album_key => image["album"]["key"] )
37
40
  image.merge!( :album_id => image["album"]["id"] )
@@ -189,6 +192,11 @@ class Smile::Photo < Smile::Base
189
192
  end
190
193
 
191
194
  def album
192
- Smile::Album.find( :AlbumID => self.album_id, :AlbumKey => self.album_key )
195
+ @album ||= Smile::Album.find( :AlbumID => self.album_id, :AlbumKey => self.album_key )
196
+ end
197
+
198
+ def reload!
199
+ @attributes = Smile::Photo.find( { :ImageID => self.image_id, :ImageKey => self.key } ).attributes
200
+ self
193
201
  end
194
202
  end
data/lib/smile/smug.rb CHANGED
@@ -15,7 +15,7 @@ module Smile
15
15
  #
16
16
  # @return [Smile::SmugMug.new] An Smug object that has been authenticated
17
17
  def auth( email, pass )
18
- json = web_method_call(
18
+ json = secure_web_method_call(
19
19
  { :method => 'smugmug.login.withPassword', :EmailAddress => email, :Password => pass }
20
20
  )
21
21
 
@@ -28,7 +28,7 @@ module Smile
28
28
  #
29
29
  # @return [Smile::SmugMug.new] An Smug object that has been authenticated
30
30
  def auth_anonymously
31
- json = web_method_call( { :method => 'smugmug.login.anonymously' } )
31
+ json = secure_web_method_call( { :method => 'smugmug.login.anonymously' } )
32
32
 
33
33
  self.session.id = json["login"]["session"]["id"]
34
34
  json
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.0"
8
+ s.version = "0.4.1"
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-13}
12
+ s.date = %q{2010-05-14}
13
13
  s.default_executable = %q{smile}
14
14
  s.email = %q{zac@kleinpeter.org}
15
15
  s.executables = ["smile"]
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,8 +34,14 @@ 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'])
38
-
37
+ test( 'we can reload albums from the site', ['album']) do
38
+ album = @smug.albums( :nick_name => 'kleinpeter' ).first
39
+ old_title = album.title
40
+ album.title = 'foo'
41
+ album.reload!
42
+ old_title == album.title
43
+ end
44
+
39
45
  test 'checking to see if we have photos in the albums', ['album'] do
40
46
  album = @smug.albums( :nick_name => 'kleinpeter' ).first
41
47
  !album.photos.empty?
@@ -47,6 +53,15 @@ Shindo.tests 'checking all the cool things smile can do' do
47
53
  album.album_id == photo.album.album_id &&
48
54
  album.key == photo.album.key
49
55
  end
56
+
57
+ test( 'we can reload photos from the site', ['photo']) do
58
+ album = @smug.albums( :nick_name => 'kleinpeter' ).first
59
+ photo = album.photos.first
60
+ old_url = photo.tinyurl
61
+ photo.tinyurl = 'foo'
62
+ photo.reload!
63
+ old_url == photo.tinyurl
64
+ end
50
65
  end
51
66
 
52
67
  tests 'confirm configuration settings', ['config'] do
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 4
8
- - 0
9
- version: 0.4.0
8
+ - 1
9
+ version: 0.4.1
10
10
  platform: ruby
11
11
  authors:
12
12
  - cajun
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2010-05-13 00:00:00 -05:00
17
+ date: 2010-05-14 00:00:00 -05:00
18
18
  default_executable: smile
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency