smirk 0.0.6 → 0.0.7

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.6
1
+ 0.0.7
data/lib/smirk/album.rb CHANGED
@@ -3,9 +3,9 @@ module Smirk
3
3
 
4
4
  def initialize(session_id, info)
5
5
  info.each do |key, value|
6
- instance_variable_set("@#{key.downcase}", value)
6
+ instance_variable_set("@#{key}", value)
7
7
  Album.instance_eval do
8
- attr_reader key.downcase.to_sym
8
+ attr_reader key.to_sym
9
9
  end
10
10
  end
11
11
  @session_id = session_id
@@ -15,7 +15,7 @@ module Smirk
15
15
  params = default_params.merge!({:method => "smugmug.images.get", :AlbumID => id, :AlbumKey => key, :Heavy => heavy})
16
16
  json = get(params)["Album"]["Images"]
17
17
  json.inject([]) do |images, i|
18
- images << Smirk::Image.new(@session_id, i)
18
+ images << Smirk::Image.new(@session_id, upper_hash_to_lower_hash(i))
19
19
  end
20
20
  end
21
21
 
@@ -3,7 +3,7 @@ module Smirk
3
3
 
4
4
  def initialize(session_id, info)
5
5
  info.each do |key, value|
6
- instance_variable_set("@#{key.downcase}", value)
6
+ instance_variable_set("@#{key}", value)
7
7
  Category.instance_eval do
8
8
  attr_reader key.downcase.to_sym
9
9
  end
data/lib/smirk/client.rb CHANGED
@@ -23,7 +23,7 @@ module Smirk
23
23
  params = default_params.merge!({:method => "smugmug.albums.get", :Heavy => heavy})
24
24
  json = get(params)["Albums"]
25
25
  json.inject([]) do |albums, a|
26
- albums << Smirk::Album.new(session_id, a)
26
+ albums << Smirk::Album.new(session_id, upper_hash_to_lower_hash(a))
27
27
  end
28
28
  end
29
29
 
@@ -31,31 +31,44 @@ module Smirk
31
31
  params = default_params.merge!(:method => "smugmug.categories.get")
32
32
  json = get(params)["Categories"]
33
33
  json.inject([]) do |categories, c|
34
- categories << Smirk::Category.new(session_id, c)
34
+ categories << Smirk::Category.new(session_id, upper_hash_to_lower_hash(c))
35
35
  end
36
36
  end
37
37
 
38
38
  def find_album(id, key)
39
39
  params = default_params.merge!({:method => "smugmug.albums.getInfo", :AlbumID => id, :AlbumKey => key})
40
40
  a = get(params)["Album"]
41
- Smirk::Album.new(session_id, a)
41
+ Smirk::Album.new(session_id, upper_hash_to_lower_hash(a))
42
42
  end
43
43
 
44
44
  def find_image(id, key)
45
45
  params = default_params.merge!({:method => "smugmug.images.getInfo", :ImageID => id, :ImageKey => key})
46
46
  i = get(params)["Image"]
47
- Smirk::Image.new(session_id, i)
47
+ Smirk::Image.new(session_id, upper_hash_to_lower_hash(i))
48
48
  end
49
49
 
50
50
  private
51
51
 
52
52
  def get(params = {}, ssl = false)
53
53
  proto = ssl ? "https://" : "http://"
54
- JSON.parse(RestClient.post proto+HOST, params)
54
+ JSON.parse(RestClient.post(proto+HOST, params))
55
55
  end
56
56
 
57
57
  def default_params
58
58
  { :APIKey => API_KEY, :SessionID => session_id }
59
59
  end
60
+
61
+ def upper_hash_to_lower_hash(upper)
62
+ if Hash === upper
63
+ lower = {}
64
+ upper.each_pair do |key, value|
65
+ lower[key.downcase.to_sym] = upper_hash_to_lower_hash(value)
66
+ end
67
+ lower
68
+ else
69
+ upper
70
+ end
71
+ end
72
+
60
73
  end
61
74
  end
data/lib/smirk/image.rb CHANGED
@@ -3,7 +3,7 @@ module Smirk
3
3
 
4
4
  def initialize(session_id, info)
5
5
  info.each do |key, value|
6
- instance_variable_set("@#{key.downcase}", value)
6
+ instance_variable_set("@#{key}", value)
7
7
  Image.instance_eval do
8
8
  attr_reader key.downcase.to_sym
9
9
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: smirk
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.6
4
+ version: 0.0.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - James Miller
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2010-02-12 00:00:00 -08:00
12
+ date: 2010-02-17 00:00:00 -08:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency