cajun-smile 0.1.2 → 0.1.3
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/README.rdoc +25 -11
- data/Rakefile +1 -1
- data/VERSION.yml +2 -2
- data/lib/smile/base.rb +9 -0
- data/lib/smile/smug.rb +1 -0
- data/lib/smile.rb +106 -4
- data/smile.gemspec +55 -0
- metadata +5 -6
- data/README +0 -0
data/README.rdoc
CHANGED
|
@@ -2,23 +2,37 @@
|
|
|
2
2
|
|
|
3
3
|
Smile is a simple gem to talk to SmugMug.com.
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
smug.auth_anonymously
|
|
7
|
-
|
|
5
|
+
New auth accessors
|
|
6
|
+
smug = Smile.auth_anonymously
|
|
7
|
+
_and_
|
|
8
|
+
smug = Smile.auth( 'nick', 'pass' )
|
|
8
9
|
|
|
9
|
-
album = albums.first # just test the first one
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
smug = Smile::Smug.new
|
|
12
|
+
smug.auth_anonymously
|
|
13
|
+
albums = smug.albums( :NickName => 'kleinpeter' )
|
|
12
14
|
|
|
13
|
-
|
|
15
|
+
album = albums.first # just test the first one
|
|
16
|
+
|
|
17
|
+
album.photos # and see the pretty pics
|
|
18
|
+
|
|
19
|
+
== or
|
|
14
20
|
|
|
15
|
-
smug = Smile::Smug.new
|
|
16
|
-
smug.auth( 'my_nick', 'my_pass' )
|
|
17
|
-
albums = smug.albums # theses are mine
|
|
21
|
+
smug = Smile::Smug.new
|
|
22
|
+
smug.auth( 'my_nick', 'my_pass' )
|
|
23
|
+
albums = smug.albums # theses are mine
|
|
24
|
+
|
|
25
|
+
album = albums.first # just test the first one
|
|
26
|
+
|
|
27
|
+
album.photos # and see the pretty pics
|
|
28
|
+
|
|
18
29
|
|
|
19
|
-
|
|
30
|
+
== TODO
|
|
31
|
+
* Clean up params so they are not case sensitive
|
|
32
|
+
* Add in RSS/Atom feeds as search options
|
|
33
|
+
* Update Documentation
|
|
34
|
+
* Plugin in Cucumber
|
|
20
35
|
|
|
21
|
-
album.photos # and see the pretty pics
|
|
22
36
|
|
|
23
37
|
== Copyright
|
|
24
38
|
|
data/Rakefile
CHANGED
|
@@ -5,7 +5,7 @@ begin
|
|
|
5
5
|
require 'jeweler'
|
|
6
6
|
Jeweler::Tasks.new do |gem|
|
|
7
7
|
gem.name = "smile"
|
|
8
|
-
gem.summary = %Q{
|
|
8
|
+
gem.summary = %Q{Simple API for talking to SmugMug}
|
|
9
9
|
gem.email = "zac@kleinpeter.org"
|
|
10
10
|
gem.homepage = "http://github.com/cajun/smile"
|
|
11
11
|
gem.authors = ["cajun"]
|
data/VERSION.yml
CHANGED
data/lib/smile/base.rb
CHANGED
|
@@ -16,11 +16,20 @@ module Smile
|
|
|
16
16
|
# This will be included in every request once you have logged in
|
|
17
17
|
def default_params
|
|
18
18
|
base = { :APIKey => API }
|
|
19
|
+
#set_session
|
|
19
20
|
if( session_id )
|
|
20
21
|
base.merge!( :SessionID => session_id )
|
|
21
22
|
end
|
|
22
23
|
base
|
|
23
24
|
end
|
|
25
|
+
|
|
26
|
+
def set_session
|
|
27
|
+
if( session_id.nil? )
|
|
28
|
+
smug = Smug.new
|
|
29
|
+
smug.auth_anonymously
|
|
30
|
+
self.session_id = smug.session_id
|
|
31
|
+
end
|
|
32
|
+
end
|
|
24
33
|
end
|
|
25
34
|
|
|
26
35
|
attr_accessor :session_id
|
data/lib/smile/smug.rb
CHANGED
data/lib/smile.rb
CHANGED
|
@@ -1,7 +1,109 @@
|
|
|
1
1
|
require 'activesupport'
|
|
2
2
|
require 'restclient'
|
|
3
3
|
require 'ostruct'
|
|
4
|
-
require 'smile/base'
|
|
5
|
-
require 'smile/smug'
|
|
6
|
-
require 'smile/album'
|
|
7
|
-
require 'smile/photo'
|
|
4
|
+
require 'lib/smile/base'
|
|
5
|
+
require 'lib/smile/smug'
|
|
6
|
+
require 'lib/smile/album'
|
|
7
|
+
require 'lib/smile/photo'
|
|
8
|
+
require 'cgi'
|
|
9
|
+
require 'rss'
|
|
10
|
+
|
|
11
|
+
module Smile
|
|
12
|
+
def auth_anonymously
|
|
13
|
+
smug = Smile::Smug.new
|
|
14
|
+
smug.auth_anonymously
|
|
15
|
+
smug
|
|
16
|
+
end
|
|
17
|
+
module_function( :auth_anonymously )
|
|
18
|
+
|
|
19
|
+
def auth( user, pass )
|
|
20
|
+
smug = Smile::Smug.new
|
|
21
|
+
smug.auth( user, pass )
|
|
22
|
+
smug
|
|
23
|
+
end
|
|
24
|
+
module_function( :auth )
|
|
25
|
+
|
|
26
|
+
def base_feed( options={} )
|
|
27
|
+
options.merge!( :format => 'rss' )
|
|
28
|
+
url = "http://api.smugmug.com/hack/feed.mg?"
|
|
29
|
+
url_params =[]
|
|
30
|
+
options.each_pair do |k,value|
|
|
31
|
+
case k.to_s.downcase.to_sym
|
|
32
|
+
when :popular_category
|
|
33
|
+
key = :popularCategory
|
|
34
|
+
when :geo_all
|
|
35
|
+
key = :geoAll
|
|
36
|
+
when :geo_keyword
|
|
37
|
+
key = :geoKeyword
|
|
38
|
+
when :geo_search
|
|
39
|
+
key = :geoSearch
|
|
40
|
+
when :geo_community
|
|
41
|
+
key = :geoCommunity
|
|
42
|
+
when :open_search_keyword
|
|
43
|
+
key = :openSearchKeyword
|
|
44
|
+
when :user_keyword
|
|
45
|
+
key = :userkeyword
|
|
46
|
+
when :nickname_recent
|
|
47
|
+
key = :nicknameRecent
|
|
48
|
+
when :nickname_popular
|
|
49
|
+
key = :nicknamePopular
|
|
50
|
+
when :user_comments
|
|
51
|
+
key = :userComments
|
|
52
|
+
when :geo_user
|
|
53
|
+
key = :geoUser
|
|
54
|
+
when :geo_album
|
|
55
|
+
key = :geoAlbum
|
|
56
|
+
when :size
|
|
57
|
+
key = :Size
|
|
58
|
+
value = value.titlecase
|
|
59
|
+
when :image_count
|
|
60
|
+
key = :ImageCount
|
|
61
|
+
else
|
|
62
|
+
key = k
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
url_params << "#{key.to_s}=#{ CGI.escape( value ) }"
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
content = RestClient.get( url + url_params.join( "&" ) )
|
|
69
|
+
RSS::Parser.parse( content, false )
|
|
70
|
+
end
|
|
71
|
+
module_function( :base_feed )
|
|
72
|
+
|
|
73
|
+
# Search SmugMug for pics.
|
|
74
|
+
# By Default it will use the keyword search.
|
|
75
|
+
#
|
|
76
|
+
# options
|
|
77
|
+
# type => [
|
|
78
|
+
# keyword
|
|
79
|
+
# popular # Use term all or today
|
|
80
|
+
# popularCategory # Use term category ( e.g. cars )
|
|
81
|
+
# geoAll
|
|
82
|
+
# geoKeyword
|
|
83
|
+
# geoSearch
|
|
84
|
+
# geoCommunity
|
|
85
|
+
# openSearchKeyword
|
|
86
|
+
# userkeyword # Use term nickname
|
|
87
|
+
# gallery # Use term albumID_albumKey
|
|
88
|
+
# nickname # Use term nickname
|
|
89
|
+
# nicknameRecent # Use term nickname
|
|
90
|
+
# nicknamePopular # Use term nickname
|
|
91
|
+
# usercomments # Use term nickname
|
|
92
|
+
# geoUser # Use term nickname
|
|
93
|
+
# geoAlbum # Use term albumID_albumKey
|
|
94
|
+
# ]
|
|
95
|
+
def search( data, options={} )
|
|
96
|
+
rss = search_raw( data, options )
|
|
97
|
+
rss.items.map{ |item| item.guid.content }
|
|
98
|
+
|
|
99
|
+
end
|
|
100
|
+
module_function( :search )
|
|
101
|
+
|
|
102
|
+
# Get the RAW feed
|
|
103
|
+
def search_raw( data, options={} )
|
|
104
|
+
options.merge!( :type => 'keyword', :data => data )
|
|
105
|
+
base_feed( options )
|
|
106
|
+
end
|
|
107
|
+
module_function( :search_raw )
|
|
108
|
+
end
|
|
109
|
+
|
data/smile.gemspec
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
|
2
|
+
|
|
3
|
+
Gem::Specification.new do |s|
|
|
4
|
+
s.name = %q{smile}
|
|
5
|
+
s.version = "0.1.3"
|
|
6
|
+
|
|
7
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
|
8
|
+
s.authors = ["cajun"]
|
|
9
|
+
s.date = %q{2009-06-16}
|
|
10
|
+
s.email = %q{zac@kleinpeter.org}
|
|
11
|
+
s.extra_rdoc_files = [
|
|
12
|
+
"LICENSE",
|
|
13
|
+
"README.rdoc"
|
|
14
|
+
]
|
|
15
|
+
s.files = [
|
|
16
|
+
"LICENSE",
|
|
17
|
+
"README.rdoc",
|
|
18
|
+
"Rakefile",
|
|
19
|
+
"VERSION.yml",
|
|
20
|
+
"lib/smile.rb",
|
|
21
|
+
"lib/smile/album.rb",
|
|
22
|
+
"lib/smile/base.rb",
|
|
23
|
+
"lib/smile/photo.rb",
|
|
24
|
+
"lib/smile/smug.rb",
|
|
25
|
+
"smile.gemspec",
|
|
26
|
+
"test/smile_test.rb",
|
|
27
|
+
"test/test_helper.rb"
|
|
28
|
+
]
|
|
29
|
+
s.homepage = %q{http://github.com/cajun/smile}
|
|
30
|
+
s.rdoc_options = ["--charset=UTF-8"]
|
|
31
|
+
s.require_paths = ["lib"]
|
|
32
|
+
s.rubyforge_project = %q{cajun-gems}
|
|
33
|
+
s.rubygems_version = %q{1.3.4}
|
|
34
|
+
s.summary = %q{Simple API for talking to SmugMug}
|
|
35
|
+
s.test_files = [
|
|
36
|
+
"test/smile_test.rb",
|
|
37
|
+
"test/test_helper.rb"
|
|
38
|
+
]
|
|
39
|
+
|
|
40
|
+
if s.respond_to? :specification_version then
|
|
41
|
+
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
|
42
|
+
s.specification_version = 3
|
|
43
|
+
|
|
44
|
+
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
|
|
45
|
+
s.add_runtime_dependency(%q<rest-client>, [">= 0"])
|
|
46
|
+
s.add_runtime_dependency(%q<activesupport>, [">= 0"])
|
|
47
|
+
else
|
|
48
|
+
s.add_dependency(%q<rest-client>, [">= 0"])
|
|
49
|
+
s.add_dependency(%q<activesupport>, [">= 0"])
|
|
50
|
+
end
|
|
51
|
+
else
|
|
52
|
+
s.add_dependency(%q<rest-client>, [">= 0"])
|
|
53
|
+
s.add_dependency(%q<activesupport>, [">= 0"])
|
|
54
|
+
end
|
|
55
|
+
end
|
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.1.
|
|
4
|
+
version: 0.1.3
|
|
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-
|
|
12
|
+
date: 2009-06-16 00:00:00 -07:00
|
|
13
13
|
default_executable:
|
|
14
14
|
dependencies:
|
|
15
15
|
- !ruby/object:Gem::Dependency
|
|
@@ -40,7 +40,6 @@ extensions: []
|
|
|
40
40
|
|
|
41
41
|
extra_rdoc_files:
|
|
42
42
|
- LICENSE
|
|
43
|
-
- README
|
|
44
43
|
- README.rdoc
|
|
45
44
|
files:
|
|
46
45
|
- LICENSE
|
|
@@ -52,10 +51,10 @@ files:
|
|
|
52
51
|
- lib/smile/base.rb
|
|
53
52
|
- lib/smile/photo.rb
|
|
54
53
|
- lib/smile/smug.rb
|
|
54
|
+
- smile.gemspec
|
|
55
55
|
- test/smile_test.rb
|
|
56
56
|
- test/test_helper.rb
|
|
57
|
-
|
|
58
|
-
has_rdoc: true
|
|
57
|
+
has_rdoc: false
|
|
59
58
|
homepage: http://github.com/cajun/smile
|
|
60
59
|
post_install_message:
|
|
61
60
|
rdoc_options:
|
|
@@ -80,7 +79,7 @@ rubyforge_project: cajun-gems
|
|
|
80
79
|
rubygems_version: 1.2.0
|
|
81
80
|
signing_key:
|
|
82
81
|
specification_version: 3
|
|
83
|
-
summary:
|
|
82
|
+
summary: Simple API for talking to SmugMug
|
|
84
83
|
test_files:
|
|
85
84
|
- test/smile_test.rb
|
|
86
85
|
- test/test_helper.rb
|
data/README
DELETED
|
File without changes
|