smirk 0.2.1 → 0.2.2

Sign up to get free protection for your applications and to get access to all the features.
data/lib/smirk/album.rb CHANGED
@@ -1,21 +1,20 @@
1
1
  module Smirk
2
2
  class Album < Client
3
3
 
4
- def initialize(session_id, info)
4
+ def initialize(info)
5
5
  info.each do |key, value|
6
6
  instance_variable_set("@#{key}", value)
7
7
  Album.instance_eval do
8
8
  attr_reader key.to_sym
9
9
  end
10
10
  end
11
- @session_id = session_id
12
11
  end
13
12
 
14
13
  def images(heavy = false)
15
14
  params = default_params.merge!({:method => "smugmug.images.get", :AlbumID => id, :AlbumKey => key, :Heavy => heavy})
16
15
  json = get(params)["Album"]["Images"]
17
16
  json.inject([]) do |images, i|
18
- images << Smirk::Image.new(@session_id, upper_hash_to_lower_hash(i))
17
+ images << Smirk::Image.new(upper_hash_to_lower_hash(i))
19
18
  end
20
19
  end
21
20
 
@@ -1,14 +1,13 @@
1
1
  module Smirk
2
2
  class Category < Client
3
3
 
4
- def initialize(session_id, info)
4
+ def initialize(info)
5
5
  info.each do |key, value|
6
6
  instance_variable_set("@#{key}", value)
7
7
  Category.instance_eval do
8
8
  attr_reader key.to_sym
9
9
  end
10
10
  end
11
- @session_id = session_id
12
11
  end
13
12
 
14
13
  end
data/lib/smirk/client.rb CHANGED
@@ -4,14 +4,10 @@ module Smirk
4
4
 
5
5
  API_KEY = "26Kw6kit9TBk2yFcYEwv2wWajATGYs1F"
6
6
  HOST = "api.smugmug.com/services/api/json/1.2.2/"
7
-
8
- attr_reader :session_id
9
-
7
+
10
8
  def initialize(user, password)
11
- @user = user
12
- @password = password
13
9
  params = { :method => "smugmug.login.withPassword", :APIKey => API_KEY, :EmailAddress => user, :Password => password }
14
- @session_id = get(params, true)['Login']['Session']['id']
10
+ @@session_id = get(params, true)['Login']['Session']['id']
15
11
  end
16
12
 
17
13
  def logout
@@ -23,7 +19,7 @@ module Smirk
23
19
  params = default_params.merge!({:method => "smugmug.albums.get", :Heavy => heavy})
24
20
  json = get(params)["Albums"]
25
21
  json.inject([]) do |albums, a|
26
- albums << Smirk::Album.new(session_id, upper_hash_to_lower_hash(a))
22
+ albums << Smirk::Album.new(upper_hash_to_lower_hash(a))
27
23
  end
28
24
  end
29
25
 
@@ -31,26 +27,26 @@ module Smirk
31
27
  params = default_params.merge!(:method => "smugmug.categories.get")
32
28
  json = get(params)["Categories"]
33
29
  json.inject([]) do |categories, c|
34
- categories << Smirk::Category.new(session_id, upper_hash_to_lower_hash(c))
30
+ categories << Smirk::Category.new(upper_hash_to_lower_hash(c))
35
31
  end
36
32
  end
37
33
 
38
34
  def find_album(id, key)
39
35
  params = default_params.merge!({:method => "smugmug.albums.getInfo", :AlbumID => id, :AlbumKey => key})
40
36
  a = get(params)["Album"]
41
- Smirk::Album.new(session_id, upper_hash_to_lower_hash(a))
37
+ Smirk::Album.new(upper_hash_to_lower_hash(a))
42
38
  end
43
39
 
44
40
  def find_image(id, key)
45
41
  params = default_params.merge!({:method => "smugmug.images.getInfo", :ImageID => id, :ImageKey => key})
46
42
  i = get(params)["Image"]
47
- Smirk::Image.new(session_id, upper_hash_to_lower_hash(i))
43
+ Smirk::Image.new(upper_hash_to_lower_hash(i))
48
44
  end
49
45
 
50
46
  def find_image_exif(id, key)
51
47
  params = default_params.merge!({:method => "smugmug.images.getEXIF", :ImageID => id, :ImageKey => key})
52
48
  i = get(params)["Image"]
53
- Smirk::Image.new(session_id, upper_hash_to_lower_hash(i))
49
+ Smirk::Image.new(upper_hash_to_lower_hash(i))
54
50
  end
55
51
 
56
52
  private
@@ -61,7 +57,7 @@ module Smirk
61
57
  end
62
58
 
63
59
  def default_params
64
- { :APIKey => API_KEY, :SessionID => session_id }
60
+ { :APIKey => API_KEY, :SessionID => @@session_id }
65
61
  end
66
62
 
67
63
  def upper_hash_to_lower_hash(upper)
data/lib/smirk/image.rb CHANGED
@@ -1,14 +1,13 @@
1
1
  module Smirk
2
2
  class Image < Client
3
3
 
4
- def initialize(session_id, info)
4
+ def initialize(info)
5
5
  info.each do |key, value|
6
6
  instance_variable_set("@#{key}", value)
7
7
  Image.instance_eval do
8
8
  attr_reader key.to_sym
9
9
  end
10
10
  end
11
- @session_id = session_id
12
11
  end
13
12
 
14
13
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: smirk
3
3
  version: !ruby/object:Gem::Version
4
- hash: 21
4
+ hash: 19
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 2
9
- - 1
10
- version: 0.2.1
9
+ - 2
10
+ version: 0.2.2
11
11
  platform: ruby
12
12
  authors:
13
13
  - James Miller
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-05-18 00:00:00 -07:00
18
+ date: 2010-07-17 00:00:00 -07:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -68,7 +68,6 @@ files:
68
68
  - lib/smirk/client.rb
69
69
  - lib/smirk/image.rb
70
70
  - lib/smirk.rb
71
- - lib/try.rb
72
71
  - test/helper.rb
73
72
  - test/test_smirk.rb
74
73
  has_rdoc: true
data/lib/try.rb DELETED
@@ -1,26 +0,0 @@
1
- require 'rubygems'
2
- require 'smirk'
3
-
4
- def test
5
- smug = Smirk::Client.new("info@studiocastillero.com", "freestyle")
6
-
7
- smug.albums(true).each do |a|
8
- puts a.title
9
- # puts a.id
10
- # puts [a.id, a.key].join(" - ")
11
- # puts a.images(true).map(&:filename).join(", ")
12
- # if a.respond_to? :highlight
13
- # puts a.highlight[:key]
14
- # end
15
- # puts a.inspect
16
- end
17
-
18
- puts smug.find_image_exif("519912731", "pNN8q").model
19
- puts smug.find_album(10992869, "9x9Xe").title
20
-
21
- puts smug.categories.map(&:nicename).join(", ")
22
- ensure
23
- smug.logout
24
- end
25
-
26
- test