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 +1 -1
- data/lib/smirk/album.rb +9 -8
- data/lib/smirk/category.rb +8 -6
- data/lib/smirk/client.rb +4 -12
- data/lib/smirk/image.rb +8 -4
- metadata +2 -2
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
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 :
|
4
|
+
attr_reader :session_id
|
5
5
|
|
6
|
-
def initialize(
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
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(
|
20
|
+
images << Smirk::Image.new(session_id, i)
|
20
21
|
end
|
21
22
|
end
|
22
23
|
|
data/lib/smirk/category.rb
CHANGED
@@ -1,13 +1,15 @@
|
|
1
1
|
module Smirk
|
2
2
|
class Category < Client
|
3
3
|
|
4
|
-
attr_reader :
|
4
|
+
attr_reader :session_id
|
5
5
|
|
6
|
-
def initialize(
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
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(
|
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(
|
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(
|
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(
|
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 :
|
4
|
+
attr_reader :session_id
|
5
5
|
|
6
|
-
def initialize(
|
7
|
-
|
8
|
-
|
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.
|
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
|
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
|
|