smirk 0.0.3 → 0.0.4

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.3
1
+ 0.0.4
data/lib/smirk/album.rb CHANGED
@@ -1,14 +1,15 @@
1
1
  module Smirk
2
2
  class Album < Client
3
3
 
4
- attr_reader :id, :key, :title, :category_id, :category_name, :session_id
4
+ attr_reader :session_id
5
5
 
6
- def initialize(id, key, title, category_id, category_name, session_id)
7
- @id = id
8
- @key = key
9
- @title = title
10
- @category_id = category_id
11
- @category_name = category_name
6
+ def initialize(session_id, info)
7
+ info.each do |key, value|
8
+ instance_variable_set("@#{key.downcase}", value)
9
+ Album.instance_eval do
10
+ attr_reader key.downcase.to_sym
11
+ end
12
+ end
12
13
  @session_id = session_id
13
14
  end
14
15
 
@@ -16,7 +17,7 @@ module Smirk
16
17
  params = default_params.merge!({:method => "smugmug.images.get", :AlbumID => id, :AlbumKey => key})
17
18
  json = get(HOST, params)["Album"]["Images"]
18
19
  json.inject([]) do |images, i|
19
- images << Smirk::Image.new(i["id"], i["Key"], session_id)
20
+ images << Smirk::Image.new(session_id, i)
20
21
  end
21
22
  end
22
23
 
@@ -1,13 +1,15 @@
1
1
  module Smirk
2
2
  class Category < Client
3
3
 
4
- attr_reader :id, :name, :nice_name, :kind, :session_id
4
+ attr_reader :session_id
5
5
 
6
- def initialize(id, name, nice_name, kind, session_id)
7
- @id = id
8
- @name = name
9
- @nice_name = nice_name
10
- @kind = kind
6
+ def initialize(session_id, info)
7
+ info.each do |key, value|
8
+ instance_variable_set("@#{key.downcase}", value)
9
+ Category.instance_eval do
10
+ attr_reader key.downcase.to_sym
11
+ end
12
+ end
11
13
  @session_id = session_id
12
14
  end
13
15
 
data/lib/smirk/client.rb CHANGED
@@ -5,14 +5,6 @@ module Smirk
5
5
  API_KEY = "26Kw6kit9TBk2yFcYEwv2wWajATGYs1F"
6
6
  HOST = "api.smugmug.com/services/api/json/1.2.2/"
7
7
 
8
- def self.version
9
- '0.0.3'
10
- end
11
-
12
- def self.gem_version_string
13
- "smirk-gem/#{version}"
14
- end
15
-
16
8
  attr_reader :user, :password, :session_id
17
9
 
18
10
  def initialize(user, password)
@@ -31,7 +23,7 @@ module Smirk
31
23
  params = default_params.merge!(:method => "smugmug.albums.get")
32
24
  json = get(HOST, params)["Albums"]
33
25
  json.inject([]) do |albums, a|
34
- albums << Smirk::Album.new(a["id"], a["Key"], a["Title"], a["Category"]["id"], a["Category"]["Name"], session_id)
26
+ albums << Smirk::Album.new(session_id, a)
35
27
  end
36
28
  end
37
29
 
@@ -39,20 +31,20 @@ module Smirk
39
31
  params = default_params.merge!(:method => "smugmug.categories.get")
40
32
  json = get(HOST, params)["Categories"]
41
33
  json.inject([]) do |categories, c|
42
- categories << Smirk::Category.new(c["id"], c["Name"], c["NiceName"], c["Type"], session_id)
34
+ categories << Smirk::Category.new(session_id, c)
43
35
  end
44
36
  end
45
37
 
46
38
  def find_album(id, key)
47
39
  params = default_params.merge!({:method => "smugmug.albums.getInfo", :AlbumID => id, :AlbumKey => key})
48
40
  a = get(HOST, params)["Album"]
49
- Smirk::Album.new(a["id"], a["Key"], a["Title"], a["Category"]["id"], a["Category"]["Name"], session_id)
41
+ Smirk::Album.new(session_id, a)
50
42
  end
51
43
 
52
44
  def find_image(id, key)
53
45
  params = default_params.merge!({:method => "smugmug.images.getInfo", :ImageID => id, :ImageKey => key})
54
46
  i = get(HOST, params)["Image"]
55
- Smirk::Image.new(i["id"], i["Key"], session_id)
47
+ Smirk::Image.new(session_id, i)
56
48
  end
57
49
 
58
50
  private
data/lib/smirk/image.rb CHANGED
@@ -1,11 +1,15 @@
1
1
  module Smirk
2
2
  class Image < Client
3
3
 
4
- attr_reader :id, :key, :session_id
4
+ attr_reader :session_id
5
5
 
6
- def initialize(id, key, session_id)
7
- @id = id
8
- @key = key
6
+ def initialize(session_id, info)
7
+ info.each do |key, value|
8
+ instance_variable_set("@#{key.downcase}", value)
9
+ Image.instance_eval do
10
+ attr_reader key.downcase.to_sym
11
+ end
12
+ end
9
13
  @session_id = session_id
10
14
  end
11
15
 
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.3
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - James Miller
@@ -42,7 +42,7 @@ dependencies:
42
42
  - !ruby/object:Gem::Version
43
43
  version: 1.2.0
44
44
  version:
45
- description: Smirk is a simple ruby wrapper for the SmugMug 1.2.2 API specification. It currently supports initiating a session, finding albums, images, and categories.
45
+ description: Smirk is a simple Ruby wrapper for the SmugMug 1.2.2 API specification. It currently supports initiating a session, finding albums, images, and categories.
46
46
  email: james@jk-tech.com
47
47
  executables: []
48
48