imgur-api 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +9 -2
- data/lib/imgur.rb +87 -0
- data/lib/imgur/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2fca4f2901127f08b3469d5f5d9322cd7005e734
|
4
|
+
data.tar.gz: 617e6ecdf5ef33f59989a29dfefbd5747cfc01e0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2e724cb092784e1bd15f22b8e0ae1bf4bde57eb8f4803d3b7e999b7572cb1d7a637fc9258a38fc521d58518f5cd34e04b9d25f63a6b470f2f2e21b2863b0e4d1
|
7
|
+
data.tar.gz: 0785fb1577dee1779c4057e370ecac752964e36aa95ce1071155dc6ef47e9337341fe41fe5aad1d56be6c9772192ef0ef4d6ab8b1c4f8acc50ffe7b66ccdae8b
|
data/README.md
CHANGED
@@ -4,12 +4,19 @@ Ruby wrapper for the Imgur API.
|
|
4
4
|
|
5
5
|
## Installation
|
6
6
|
|
7
|
-
|
7
|
+
Install with RubyGems:
|
8
8
|
|
9
9
|
```ruby
|
10
|
-
gem
|
10
|
+
gem install 'imgur-api'
|
11
11
|
```
|
12
12
|
|
13
|
+
Or add to your Gemfile:
|
14
|
+
|
15
|
+
```ruby
|
16
|
+
gem 'imgur-api'
|
17
|
+
```
|
18
|
+
|
19
|
+
|
13
20
|
## Usage
|
14
21
|
|
15
22
|
For anonymous usage, create a new client with your Client-ID
|
data/lib/imgur.rb
CHANGED
@@ -9,6 +9,7 @@ module Imgur
|
|
9
9
|
IMAGE_PATH = 'image/'
|
10
10
|
ALBUM_GET_PATH = 'album/'
|
11
11
|
ALBUM_CREATE_PATH = 'album'
|
12
|
+
ACCOUNT_PATH = 'account/'
|
12
13
|
|
13
14
|
class Client
|
14
15
|
attr_accessor :client_id
|
@@ -36,6 +37,17 @@ module Imgur
|
|
36
37
|
resp = get(url).parsed_response
|
37
38
|
Album.new resp['data']
|
38
39
|
end
|
40
|
+
|
41
|
+
def get_account(username)
|
42
|
+
url = API_PATH + ACCOUNT_PATH + username
|
43
|
+
resp = get(url).parsed_response
|
44
|
+
# The Imgur API doesn't send the username back
|
45
|
+
Account.new resp['data'], username
|
46
|
+
end
|
47
|
+
|
48
|
+
def me
|
49
|
+
get_account 'me'
|
50
|
+
end
|
39
51
|
|
40
52
|
def upload(local_file)
|
41
53
|
local_file.file.rewind
|
@@ -82,6 +94,81 @@ module Imgur
|
|
82
94
|
end
|
83
95
|
|
84
96
|
end
|
97
|
+
|
98
|
+
class Account
|
99
|
+
attr_accessor :id
|
100
|
+
attr_accessor :url
|
101
|
+
attr_accessor :bio
|
102
|
+
attr_accessor :reputation
|
103
|
+
attr_accessor :created
|
104
|
+
attr_accessor :pro_expiration
|
105
|
+
attr_accessor :username
|
106
|
+
|
107
|
+
def initialize(data, username=nil)
|
108
|
+
@id = data['id']
|
109
|
+
@url = data['url']
|
110
|
+
@bio = data['bio']
|
111
|
+
@reputation = data['reputation']
|
112
|
+
@created = Time.at data['created']
|
113
|
+
if data['pro_expiration'].is_a? Integer
|
114
|
+
@pro = Time.at
|
115
|
+
end
|
116
|
+
@username = username
|
117
|
+
end
|
118
|
+
|
119
|
+
end
|
120
|
+
|
121
|
+
class Comment
|
122
|
+
attr_accessor :id
|
123
|
+
attr_accessor :image_id
|
124
|
+
attr_accessor :caption
|
125
|
+
attr_accessor :author
|
126
|
+
attr_accessor :author
|
127
|
+
attr_accessor :author_id
|
128
|
+
attr_accessor :on_album
|
129
|
+
attr_accessor :ups
|
130
|
+
attr_accessor :downs
|
131
|
+
attr_accessor :points
|
132
|
+
attr_accessor :date
|
133
|
+
attr_accessor :parent_id
|
134
|
+
attr_accessor :deleted
|
135
|
+
attr_accessor :children
|
136
|
+
|
137
|
+
def initialize(data)
|
138
|
+
@id = data['id']
|
139
|
+
@image_id = data['image_id']
|
140
|
+
@caption = data['caption']
|
141
|
+
@author = data['author']
|
142
|
+
@author_id = data['author_id']
|
143
|
+
@on_album = data['on_album']
|
144
|
+
@ups = data['ups']
|
145
|
+
@downs = data['downs']
|
146
|
+
@points = data['points']
|
147
|
+
@date = Time.at data['datetime']
|
148
|
+
@parent_id = data['parent_id']
|
149
|
+
@deleted = deleted
|
150
|
+
end
|
151
|
+
|
152
|
+
def on_album?
|
153
|
+
@on_album
|
154
|
+
end
|
155
|
+
|
156
|
+
def upvotes
|
157
|
+
@ups
|
158
|
+
end
|
159
|
+
|
160
|
+
def downvotes
|
161
|
+
@downs
|
162
|
+
end
|
163
|
+
|
164
|
+
def has_parent?
|
165
|
+
@parent_id != nil
|
166
|
+
end
|
167
|
+
|
168
|
+
def deleted?
|
169
|
+
@deleted
|
170
|
+
end
|
171
|
+
end
|
85
172
|
|
86
173
|
class Album
|
87
174
|
attr_accessor :id
|
data/lib/imgur/version.rb
CHANGED