cajun-smile 0.2.1 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -3,14 +3,21 @@
3
3
  Smile is a simple gem to talk to SmugMug.com.
4
4
  This gem wraps the 1.2.0 interface.
5
5
 
6
- == New Features
6
+ == Features
7
+
8
+ === NEW Upload Images/Vids
9
+
10
+ smug = Smile.auth( 'foo@bar.com', 'pass' )
11
+ album = smug.albums.first
12
+
13
+ album.add( '/path/to/image.ext' ) # => Smile::Photo (:
7
14
 
8
15
  === Search feeds
9
16
  Smile.search( 'blueberries' ) => [Smile::Photo]
10
17
  Smile.search_rss( 'bison' ) => RSS::Parser Feed
11
18
  Smile.search_raw( 'grand' ) => Raw response from the feed
12
19
 
13
- ===New auth accessors
20
+ === auth accessors
14
21
  smug = Smile.auth_anonymously
15
22
  smug = Smile.auth( 'nick', 'pass' )
16
23
 
@@ -34,9 +41,9 @@ This gem wraps the 1.2.0 interface.
34
41
 
35
42
 
36
43
  == TODO
37
- * Clean up params so they are not case sensitive
44
+ * Clean up params so they are not case sensitive ( Lots of cases have been handled)
38
45
  * Create better exception handlers
39
- * Update Documentation ( getting there. it's being published on rdoc.info now )
46
+ * Update Documentation ( getting there. it's being published on rdoc.info now http://rdoc.info/projects/cajun/smile )
40
47
  * Plugin in Cucumber
41
48
 
42
49
 
@@ -1,4 +1,4 @@
1
1
  ---
2
- :patch: 1
2
+ :patch: 0
3
3
  :major: 0
4
- :minor: 2
4
+ :minor: 3
@@ -112,6 +112,7 @@ class Smile::Album < Smile::Base
112
112
  json = RestClient.post Smile::Base::BASE, params
113
113
 
114
114
  album_upper = JSON.parse(json)
115
+
115
116
  album = upper_hash_to_lower_hash( album_upper['Album'] )
116
117
  album.merge!( :album_id => album["id"] )
117
118
 
@@ -160,27 +161,44 @@ class Smile::Album < Smile::Base
160
161
 
161
162
  json = JSON.parse( json )
162
163
  raise json["message"] if json["stat"] == 'fail'
163
-
164
- image = upper_hash_to_lower_hash( json['Album'] )
165
- OpenStruct.new( hash )
164
+
165
+ stat = upper_hash_to_lower_hash( json['Album'] )
166
+ OpenStruct.new( stat )
166
167
  end
167
168
 
168
- def add( payload, options={} )
169
- if( File.exists?( payload ) )
170
- RestClient.put BASE, payload,
171
- :content_length => File.size( payload ),
172
- :content_md5 => '?',
173
- :x_smug_sessionid => session_id,
174
- :x_smug_version => VERSION,
175
- :x_smug_albumid => album_id,
176
- :x_smug_filename => File.basename( payload ),
177
- :x_smug_caption => options[:caption],
178
- :x_smug_keywords => options[:keywords],
179
- :x_smug_latitude => options[:latitude],
180
- :x_smug_longitude => options[:longitude],
181
- :x_smug_altitude => options[:altitude]
169
+ # Add an image or vid to the existing album
170
+ #
171
+ # @param [String] image path to image
172
+ # @param [options,Hash] options Extra params that are accepted
173
+ # @option options [optional, String] :caption For multi-line captions, use a carriage return between lines
174
+ # @option options [optional, String] :keywords Sets the Keywords on the image
175
+ # @option options [optional, Decimal] :latitude Sets the Latitude of the image (in the form D.d, such as 37.430096)
176
+ # @option options [optional, Decimal] :longitude Sets the Longitude of the image (in the form D.d, such as -122.152269)
177
+ # @option options [optional, Decimal] :altitude Sets the Altitude of the image (in meters)
178
+ def add( image, options={} )
179
+ if( File.exists?( image ) )
180
+ json = RestClient.put UPLOAD + "/#{image}", File.read( image ),
181
+ :content_length => File.size( image ),
182
+ :content_md5 => MD5.hexdigest( File.read( image ) ),
183
+ :x_smug_sessionid => session_id,
184
+ :x_smug_version => VERSION,
185
+ :x_smug_responseType => "JSON",
186
+ :x_smug_albumid => album_id,
187
+ :x_smug_filename => File.basename( image ),
188
+ :x_smug_caption => options[:caption],
189
+ :x_smug_keywords => options[:keywords],
190
+ :x_smug_latitude => options[:latitude],
191
+ :x_smug_longitude => options[:longitude],
192
+ :x_smug_altitude => options[:altitude]
193
+
194
+ image = JSON.parse( json )
195
+ if( image && image["Image"] && image["Image"]["id"] )
196
+ Smile::Photo.find( :image_id => image["Image"]["id"] )
197
+ else
198
+ raise Exception.new( "Failed to upload #{image}" )
199
+ end
182
200
  else
183
- Exception.new( "Cannot find file #{payload}." )
201
+ raise Exception.new( "Cannot find file #{image}." )
184
202
  end
185
203
  end
186
204
 
@@ -10,6 +10,7 @@ module Smile
10
10
  BASE = 'http://api.smugmug.com/hack/json/1.2.0/'
11
11
  BASE_SECURE = 'https://api.smugmug.com/hack/json/1.2.0/'
12
12
  API = 'HSoqGCJ8ilF42BeThMGDZqqqOgj1eXqN'
13
+ UPLOAD = "http://upload.smugmug.com/"
13
14
 
14
15
  VERSION = '1.2.0'
15
16
 
@@ -27,11 +27,11 @@ class Smile::Photo < Smile::Base
27
27
 
28
28
  # This will pull a single image from the smugmug
29
29
  #
30
- # * int image_id
31
- # * String Password optional
32
- # * String SitePassword optional
33
- # * String ImageKey
34
- #
30
+ # @param [options,Hash] options the hash of options that you have heard about so much in ruby
31
+ # @option options [int] :image_id The id of the image you want to find
32
+ # @option options [optional, String] :password The id of the image you want to find
33
+ # @option options [optional, String] :site_password password word for the site
34
+ # @option options [optional, String] :image_key image key maybe?
35
35
  def find( options={} )
36
36
  set_session if( session_id.nil? )
37
37
  options = Smile::ParamConverter.clean_hash_keys( options )
@@ -2,11 +2,11 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = %q{smile}
5
- s.version = "0.2.1"
5
+ s.version = "0.3.0"
6
6
 
7
7
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
8
8
  s.authors = ["cajun"]
9
- s.date = %q{2009-08-21}
9
+ s.date = %q{2009-08-25}
10
10
  s.email = %q{zac@kleinpeter.org}
11
11
  s.extra_rdoc_files = [
12
12
  "LICENSE",
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cajun-smile
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - cajun
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-08-21 00:00:00 -07:00
12
+ date: 2009-08-25 00:00:00 -07:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency