smile 0.1.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/LICENSE +20 -0
- data/README +0 -0
- data/README.rdoc +7 -0
- data/Rakefile +88 -0
- data/VERSION.yml +4 -0
- data/lib/smile/album.rb +35 -0
- data/lib/smile/base.rb +16 -0
- data/lib/smile/photo.rb +14 -0
- data/lib/smile/smug.rb +60 -0
- data/lib/smile.rb +7 -0
- data/test/smile_test.rb +7 -0
- data/test/test_helper.rb +10 -0
- metadata +86 -0
data/LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2009 cajun
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README
ADDED
File without changes
|
data/README.rdoc
ADDED
data/Rakefile
ADDED
@@ -0,0 +1,88 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'rake'
|
3
|
+
|
4
|
+
begin
|
5
|
+
require 'jeweler'
|
6
|
+
Jeweler::Tasks.new do |gem|
|
7
|
+
gem.name = "smile"
|
8
|
+
gem.summary = %Q{TODO}
|
9
|
+
gem.email = "zac@kleinpeter.org"
|
10
|
+
gem.homepage = "http://github.com/cajun/smile"
|
11
|
+
gem.authors = ["cajun"]
|
12
|
+
gem.files << "lib/**/*"
|
13
|
+
gem.add_dependency( 'rest-client' )
|
14
|
+
gem.add_dependency( 'activesupport' )
|
15
|
+
gem.rubyforge_project = 'cajun-gems'
|
16
|
+
|
17
|
+
# gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
|
18
|
+
end
|
19
|
+
rescue LoadError
|
20
|
+
puts "Jeweler not available. Install it with: sudo gem install technicalpickles-jeweler -s http://gems.github.com"
|
21
|
+
end
|
22
|
+
|
23
|
+
# These are new tasks
|
24
|
+
# These are new tasks
|
25
|
+
begin
|
26
|
+
require 'rake/contrib/sshpublisher'
|
27
|
+
namespace :rubyforge do
|
28
|
+
|
29
|
+
desc "Release gem and RDoc documentation to RubyForge"
|
30
|
+
task :release => ["rubyforge:release:gem", "rubyforge:release:docs"]
|
31
|
+
|
32
|
+
namespace :release do
|
33
|
+
desc "Publish RDoc to RubyForge."
|
34
|
+
task :docs => [:rdoc] do
|
35
|
+
config = YAML.load(
|
36
|
+
File.read(File.expand_path('~/.rubyforge/user-config.yml'))
|
37
|
+
)
|
38
|
+
|
39
|
+
host = "#{config['username']}@rubyforge.org"
|
40
|
+
remote_dir = "/var/www/gforge-projects/cajun-gems/"
|
41
|
+
local_dir = 'rdoc'
|
42
|
+
|
43
|
+
Rake::SshDirPublisher.new(host, remote_dir, local_dir).upload
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
rescue LoadError
|
48
|
+
puts "Rake SshDirPublisher is unavailable or your rubyforge environment is not configured."
|
49
|
+
end
|
50
|
+
|
51
|
+
require 'rake/testtask'
|
52
|
+
Rake::TestTask.new(:test) do |test|
|
53
|
+
test.libs << 'lib' << 'test'
|
54
|
+
test.pattern = 'test/**/*_test.rb'
|
55
|
+
test.verbose = true
|
56
|
+
end
|
57
|
+
|
58
|
+
begin
|
59
|
+
require 'rcov/rcovtask'
|
60
|
+
Rcov::RcovTask.new do |test|
|
61
|
+
test.libs << 'test'
|
62
|
+
test.pattern = 'test/**/*_test.rb'
|
63
|
+
test.verbose = true
|
64
|
+
end
|
65
|
+
rescue LoadError
|
66
|
+
task :rcov do
|
67
|
+
abort "RCov is not available. In order to run rcov, you must: sudo gem install spicycode-rcov"
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
|
72
|
+
task :default => :test
|
73
|
+
|
74
|
+
require 'rake/rdoctask'
|
75
|
+
Rake::RDocTask.new do |rdoc|
|
76
|
+
if File.exist?('VERSION.yml')
|
77
|
+
config = YAML.load(File.read('VERSION.yml'))
|
78
|
+
version = "#{config[:major]}.#{config[:minor]}.#{config[:patch]}"
|
79
|
+
else
|
80
|
+
version = ""
|
81
|
+
end
|
82
|
+
|
83
|
+
rdoc.rdoc_dir = 'rdoc'
|
84
|
+
rdoc.title = "smile #{version}"
|
85
|
+
rdoc.rdoc_files.include('README*')
|
86
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
87
|
+
end
|
88
|
+
|
data/VERSION.yml
ADDED
data/lib/smile/album.rb
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
class Smile::Album < Smile::Base
|
2
|
+
|
3
|
+
class << self
|
4
|
+
def from_xml( xml, session_id )
|
5
|
+
hash = Hash.from_xml( xml )["rsp"]
|
6
|
+
hash["albums"]["album"].map do |album|
|
7
|
+
album.merge!( :album_id => album["id"] )
|
8
|
+
a = Smile::Album.new( album )
|
9
|
+
a.session_id = session_id
|
10
|
+
a
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
=begin
|
16
|
+
* SessionID - string.
|
17
|
+
* AlbumID - integer.
|
18
|
+
* Heavy - boolean (optional).
|
19
|
+
* Password - string (optional).
|
20
|
+
* SitePassword - string (optional).
|
21
|
+
* AlbumKey - string.
|
22
|
+
=end
|
23
|
+
def photos( options=nil )
|
24
|
+
params = default_params.merge(
|
25
|
+
:method => 'smugmug.images.get',
|
26
|
+
:AlbumID => album_id,
|
27
|
+
:AlbumKey => key,
|
28
|
+
:Heavy => 1
|
29
|
+
)
|
30
|
+
|
31
|
+
params.merge!( options ) if( options )
|
32
|
+
xml = RestClient.post BASE, params
|
33
|
+
Smile::Photo.from_xml( xml, sesson_id )
|
34
|
+
end
|
35
|
+
end
|
data/lib/smile/base.rb
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
module Smile
|
2
|
+
class Base < OpenStruct
|
3
|
+
BASE = 'http://api.smugmug.com/hack/rest/1.2.0/'
|
4
|
+
BASE_SECURE = 'https://api.smugmug.com/hack/rest/1.2.0/'
|
5
|
+
API = 'HSoqGCJ8ilF42BeThMGDZqqqOgj1eXqN'
|
6
|
+
|
7
|
+
attr_accessor :session_id
|
8
|
+
def default_params
|
9
|
+
base = { :APIKey => API }
|
10
|
+
if( session_id )
|
11
|
+
base.merge!( :SessionID => session_id )
|
12
|
+
end
|
13
|
+
base
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
data/lib/smile/photo.rb
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
class Smile::Photo < Smile::Base
|
2
|
+
|
3
|
+
class << self
|
4
|
+
def from_xml( xml, session_id )
|
5
|
+
hash = Hash.from_xml( xml )["rsp"]
|
6
|
+
hash["images"]["image"].map do |image|
|
7
|
+
image.merge!( :image_id => image["id"] )
|
8
|
+
a = Smile::Photo.new( image )
|
9
|
+
a.session_id = session_id
|
10
|
+
a
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
data/lib/smile/smug.rb
ADDED
@@ -0,0 +1,60 @@
|
|
1
|
+
module Smile
|
2
|
+
class Smug < Smile::Base
|
3
|
+
|
4
|
+
def auth( email, pass )
|
5
|
+
params = default_params.merge(
|
6
|
+
:method => 'smugmug.login.withPassword',
|
7
|
+
:EmailAddress => email,
|
8
|
+
:Password => pass
|
9
|
+
)
|
10
|
+
|
11
|
+
xml = RestClient.post( BASE, params )
|
12
|
+
result = Hash.from_xml( xml )["rsp"]["login"]
|
13
|
+
self.session_id = result["session"]["id"]
|
14
|
+
result
|
15
|
+
rescue NoMethodError => e
|
16
|
+
nil
|
17
|
+
end
|
18
|
+
|
19
|
+
def auth_anonymously
|
20
|
+
params = default_params.merge(
|
21
|
+
:method => 'smugmug.login.anonymously'
|
22
|
+
)
|
23
|
+
|
24
|
+
xml = RestClient.post( BASE, params )
|
25
|
+
result = Hash.from_xml( xml )["rsp"]["login"]
|
26
|
+
self.session_id = result["session"]["id"]
|
27
|
+
result
|
28
|
+
rescue NoMethodError => e
|
29
|
+
nil
|
30
|
+
end
|
31
|
+
|
32
|
+
def logout
|
33
|
+
params = default_params.merge(
|
34
|
+
:method => 'smugmug.logout'
|
35
|
+
)
|
36
|
+
|
37
|
+
RestClient.post( BASE, params )
|
38
|
+
end
|
39
|
+
|
40
|
+
=begin
|
41
|
+
* SessionID - string.
|
42
|
+
* NickName - string (optional).
|
43
|
+
* Heavy - boolean (optional).
|
44
|
+
* SitePassword - string (optional).
|
45
|
+
|
46
|
+
=end
|
47
|
+
def albums( options=nil )
|
48
|
+
params = default_params.merge(
|
49
|
+
:method => 'smugmug.albums.get',
|
50
|
+
:heavy => 1
|
51
|
+
)
|
52
|
+
|
53
|
+
params = params.merge( options ) if( options )
|
54
|
+
xml = RestClient.post BASE, params
|
55
|
+
Smile::Album.from_xml( xml, session_id )
|
56
|
+
rescue
|
57
|
+
nil
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
data/lib/smile.rb
ADDED
data/test/smile_test.rb
ADDED
data/test/test_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,86 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: smile
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- cajun
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2009-04-15 00:00:00 -05:00
|
13
|
+
default_executable:
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: rest-client
|
17
|
+
type: :runtime
|
18
|
+
version_requirement:
|
19
|
+
version_requirements: !ruby/object:Gem::Requirement
|
20
|
+
requirements:
|
21
|
+
- - ">="
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: "0"
|
24
|
+
version:
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: activesupport
|
27
|
+
type: :runtime
|
28
|
+
version_requirement:
|
29
|
+
version_requirements: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: "0"
|
34
|
+
version:
|
35
|
+
description:
|
36
|
+
email: zac@kleinpeter.org
|
37
|
+
executables: []
|
38
|
+
|
39
|
+
extensions: []
|
40
|
+
|
41
|
+
extra_rdoc_files:
|
42
|
+
- LICENSE
|
43
|
+
- README
|
44
|
+
- README.rdoc
|
45
|
+
files:
|
46
|
+
- LICENSE
|
47
|
+
- README.rdoc
|
48
|
+
- Rakefile
|
49
|
+
- VERSION.yml
|
50
|
+
- lib/smile.rb
|
51
|
+
- lib/smile/album.rb
|
52
|
+
- lib/smile/base.rb
|
53
|
+
- lib/smile/photo.rb
|
54
|
+
- lib/smile/smug.rb
|
55
|
+
- test/smile_test.rb
|
56
|
+
- test/test_helper.rb
|
57
|
+
- README
|
58
|
+
has_rdoc: true
|
59
|
+
homepage: http://github.com/cajun/smile
|
60
|
+
post_install_message:
|
61
|
+
rdoc_options:
|
62
|
+
- --charset=UTF-8
|
63
|
+
require_paths:
|
64
|
+
- lib
|
65
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
66
|
+
requirements:
|
67
|
+
- - ">="
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: "0"
|
70
|
+
version:
|
71
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: "0"
|
76
|
+
version:
|
77
|
+
requirements: []
|
78
|
+
|
79
|
+
rubyforge_project: cajun-gems
|
80
|
+
rubygems_version: 1.3.1
|
81
|
+
signing_key:
|
82
|
+
specification_version: 2
|
83
|
+
summary: TODO
|
84
|
+
test_files:
|
85
|
+
- test/smile_test.rb
|
86
|
+
- test/test_helper.rb
|