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.
- data/README.rdoc +11 -4
- data/VERSION.yml +2 -2
- data/lib/smile/album.rb +36 -18
- data/lib/smile/base.rb +1 -0
- data/lib/smile/photo.rb +5 -5
- data/smile.gemspec +2 -2
- metadata +2 -2
data/README.rdoc
CHANGED
@@ -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
|
-
==
|
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
|
-
===
|
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
|
|
data/VERSION.yml
CHANGED
data/lib/smile/album.rb
CHANGED
@@ -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
|
-
|
165
|
-
OpenStruct.new(
|
164
|
+
|
165
|
+
stat = upper_hash_to_lower_hash( json['Album'] )
|
166
|
+
OpenStruct.new( stat )
|
166
167
|
end
|
167
168
|
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
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 #{
|
201
|
+
raise Exception.new( "Cannot find file #{image}." )
|
184
202
|
end
|
185
203
|
end
|
186
204
|
|
data/lib/smile/base.rb
CHANGED
data/lib/smile/photo.rb
CHANGED
@@ -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
|
-
#
|
31
|
-
#
|
32
|
-
#
|
33
|
-
#
|
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 )
|
data/smile.gemspec
CHANGED
@@ -2,11 +2,11 @@
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |s|
|
4
4
|
s.name = %q{smile}
|
5
|
-
s.version = "0.
|
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-
|
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.
|
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-
|
12
|
+
date: 2009-08-25 00:00:00 -07:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|