redd 0.6.5 → 0.7.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +34 -33
- data/.rspec +3 -4
- data/.rubocop.yml +5 -5
- data/.travis.yml +9 -7
- data/{LICENSE.md → LICENSE.txt} +22 -22
- data/README.md +126 -241
- data/Rakefile +5 -6
- data/{RedditKit.LICENSE.md → RedditKit.LICENSE.txt} +13 -13
- data/lib/redd.rb +50 -4
- data/lib/redd/access.rb +76 -0
- data/lib/redd/clients/base.rb +178 -0
- data/lib/redd/clients/base/account.rb +20 -0
- data/lib/redd/clients/base/identity.rb +22 -0
- data/lib/redd/clients/base/none.rb +27 -0
- data/lib/redd/clients/base/privatemessages.rb +28 -0
- data/lib/redd/clients/base/read.rb +66 -0
- data/lib/redd/clients/base/stream.rb +74 -0
- data/lib/redd/clients/base/submit.rb +54 -0
- data/lib/redd/clients/base/utilities.rb +80 -0
- data/lib/redd/clients/base/wikiread.rb +33 -0
- data/lib/redd/clients/installed.rb +55 -0
- data/lib/redd/clients/script.rb +37 -0
- data/lib/redd/clients/userless.rb +31 -0
- data/lib/redd/clients/web.rb +57 -0
- data/lib/redd/error.rb +138 -153
- data/lib/redd/objects/base.rb +36 -0
- data/lib/redd/objects/comment.rb +22 -0
- data/lib/redd/objects/listing.rb +29 -0
- data/lib/redd/objects/more_comments.rb +10 -0
- data/lib/redd/objects/private_message.rb +18 -0
- data/lib/redd/objects/submission.rb +72 -0
- data/lib/redd/objects/subreddit.rb +152 -0
- data/lib/redd/objects/thing.rb +33 -0
- data/lib/redd/objects/thing/editable.rb +22 -0
- data/lib/redd/objects/thing/hideable.rb +18 -0
- data/lib/redd/objects/thing/inboxable.rb +25 -0
- data/lib/redd/objects/thing/messageable.rb +34 -0
- data/lib/redd/objects/thing/moderatable.rb +43 -0
- data/lib/redd/objects/thing/refreshable.rb +14 -0
- data/lib/redd/objects/thing/saveable.rb +21 -0
- data/lib/redd/objects/thing/votable.rb +33 -0
- data/lib/redd/objects/user.rb +52 -0
- data/lib/redd/objects/wiki_page.rb +15 -0
- data/lib/redd/rate_limit.rb +50 -49
- data/lib/redd/response/parse_json.rb +17 -33
- data/lib/redd/response/raise_error.rb +16 -25
- data/lib/redd/version.rb +4 -5
- data/redd.gemspec +30 -31
- data/spec/redd/objects/base_spec.rb +1 -0
- data/spec/redd/rate_limit_spec.rb +29 -29
- data/spec/redd/response/parse_json_spec.rb +12 -0
- data/spec/redd/response/raise_error_spec.rb +11 -0
- data/spec/redd_spec.rb +7 -5
- data/spec/spec_helper.rb +69 -50
- metadata +73 -136
- data/.yardopts +0 -1
- data/lib/redd/base.rb +0 -56
- data/lib/redd/client/authenticated.rb +0 -83
- data/lib/redd/client/authenticated/account.rb +0 -13
- data/lib/redd/client/authenticated/apps.rb +0 -13
- data/lib/redd/client/authenticated/flair.rb +0 -71
- data/lib/redd/client/authenticated/gold.rb +0 -13
- data/lib/redd/client/authenticated/links_comments.rb +0 -189
- data/lib/redd/client/authenticated/live.rb +0 -13
- data/lib/redd/client/authenticated/moderation.rb +0 -126
- data/lib/redd/client/authenticated/multis.rb +0 -9
- data/lib/redd/client/authenticated/private_messages.rb +0 -73
- data/lib/redd/client/authenticated/subreddits.rb +0 -172
- data/lib/redd/client/authenticated/users.rb +0 -9
- data/lib/redd/client/authenticated/wiki.rb +0 -9
- data/lib/redd/client/oauth2.rb +0 -71
- data/lib/redd/client/oauth2/authorization.rb +0 -108
- data/lib/redd/client/oauth2/identity.rb +0 -16
- data/lib/redd/client/oauth2_script.rb +0 -24
- data/lib/redd/client/oauth2_script/authorization.rb +0 -21
- data/lib/redd/client/unauthenticated.rb +0 -118
- data/lib/redd/client/unauthenticated/account.rb +0 -30
- data/lib/redd/client/unauthenticated/captcha.rb +0 -27
- data/lib/redd/client/unauthenticated/links_comments.rb +0 -60
- data/lib/redd/client/unauthenticated/listing.rb +0 -65
- data/lib/redd/client/unauthenticated/live.rb +0 -9
- data/lib/redd/client/unauthenticated/moderation.rb +0 -26
- data/lib/redd/client/unauthenticated/subreddits.rb +0 -49
- data/lib/redd/client/unauthenticated/users.rb +0 -67
- data/lib/redd/client/unauthenticated/utilities.rb +0 -109
- data/lib/redd/client/unauthenticated/wiki.rb +0 -33
- data/lib/redd/oauth2_access.rb +0 -70
- data/lib/redd/object/comment.rb +0 -74
- data/lib/redd/object/listing.rb +0 -29
- data/lib/redd/object/more_comments.rb +0 -14
- data/lib/redd/object/private_message.rb +0 -35
- data/lib/redd/object/submission.rb +0 -94
- data/lib/redd/object/subreddit.rb +0 -74
- data/lib/redd/object/user.rb +0 -34
- data/lib/redd/object/wiki_page.rb +0 -27
- data/lib/redd/thing.rb +0 -27
- data/lib/redd/thing/commentable.rb +0 -27
- data/lib/redd/thing/editable.rb +0 -16
- data/lib/redd/thing/hideable.rb +0 -16
- data/lib/redd/thing/inboxable.rb +0 -20
- data/lib/redd/thing/messageable.rb +0 -12
- data/lib/redd/thing/moderatable.rb +0 -32
- data/lib/redd/thing/reportable.rb +0 -12
- data/lib/redd/thing/saveable.rb +0 -16
- data/lib/redd/thing/voteable.rb +0 -22
- data/spec/README.md +0 -18
- data/spec/redd/base_spec.rb +0 -36
- data/spec/redd/client/authenticated/account_spec.rb +0 -5
- data/spec/redd/client/authenticated/apps_spec.rb +0 -2
- data/spec/redd/client/authenticated/flair_spec.rb +0 -26
- data/spec/redd/client/authenticated/gold_spec.rb +0 -2
- data/spec/redd/client/authenticated/links_comments_spec.rb +0 -231
- data/spec/redd/client/authenticated/live_spec.rb +0 -2
- data/spec/redd/client/unauthenticated/account_spec.rb +0 -15
- data/spec/redd/client/unauthenticated/captcha_spec.rb +0 -23
- data/spec/redd/client/unauthenticated/links_comments_spec.rb +0 -28
- data/spec/redd/client/unauthenticated/listing_spec.rb +0 -23
- data/spec/redd/client/unauthenticated/live_spec.rb +0 -2
- data/spec/redd/client/unauthenticated/moderation_spec.rb +0 -14
- data/spec/redd/client/unauthenticated/subreddits_spec.rb +0 -35
- data/spec/redd/client/unauthenticated/users_spec.rb +0 -34
- data/spec/redd/client/unauthenticated/wiki_spec.rb +0 -18
- data/spec/redd/oauth2_access_spec.rb +0 -83
- data/spec/redd/thing_spec.rb +0 -22
metadata
CHANGED
@@ -1,101 +1,101 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: redd
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.7.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Avinash Dwarapu
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2015-02-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "
|
17
|
+
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version:
|
19
|
+
version: 1.8.1
|
20
20
|
type: :development
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- - "
|
24
|
+
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version:
|
26
|
+
version: 1.8.1
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rake
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- - "
|
31
|
+
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version:
|
33
|
+
version: 10.4.2
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- - "
|
38
|
+
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version:
|
40
|
+
version: 10.4.2
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: rspec
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- - "
|
45
|
+
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version:
|
47
|
+
version: 3.2.0
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- - "
|
52
|
+
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version:
|
54
|
+
version: 3.2.0
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: vcr
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
|
-
- - "
|
59
|
+
- - "~>"
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version:
|
61
|
+
version: 2.9.3
|
62
62
|
type: :development
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
|
-
- - "
|
66
|
+
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version:
|
68
|
+
version: 2.9.3
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: webmock
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
|
-
- - "
|
73
|
+
- - "~>"
|
74
74
|
- !ruby/object:Gem::Version
|
75
|
-
version:
|
75
|
+
version: 1.20.4
|
76
76
|
type: :development
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
|
-
- - "
|
80
|
+
- - "~>"
|
81
81
|
- !ruby/object:Gem::Version
|
82
|
-
version:
|
82
|
+
version: 1.20.4
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
|
-
name:
|
84
|
+
name: hashie
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
86
86
|
requirements:
|
87
87
|
- - "~>"
|
88
88
|
- !ruby/object:Gem::Version
|
89
|
-
version:
|
89
|
+
version: 3.4.0
|
90
90
|
type: :runtime
|
91
91
|
prerelease: false
|
92
92
|
version_requirements: !ruby/object:Gem::Requirement
|
93
93
|
requirements:
|
94
94
|
- - "~>"
|
95
95
|
- !ruby/object:Gem::Version
|
96
|
-
version:
|
96
|
+
version: 3.4.0
|
97
97
|
- !ruby/object:Gem::Dependency
|
98
|
-
name:
|
98
|
+
name: faraday
|
99
99
|
requirement: !ruby/object:Gem::Requirement
|
100
100
|
requirements:
|
101
101
|
- - "~>"
|
@@ -114,31 +114,17 @@ dependencies:
|
|
114
114
|
requirements:
|
115
115
|
- - "~>"
|
116
116
|
- !ruby/object:Gem::Version
|
117
|
-
version:
|
117
|
+
version: 1.10.1
|
118
118
|
type: :runtime
|
119
119
|
prerelease: false
|
120
120
|
version_requirements: !ruby/object:Gem::Requirement
|
121
121
|
requirements:
|
122
122
|
- - "~>"
|
123
123
|
- !ruby/object:Gem::Version
|
124
|
-
version:
|
125
|
-
|
126
|
-
name: memoizable
|
127
|
-
requirement: !ruby/object:Gem::Requirement
|
128
|
-
requirements:
|
129
|
-
- - ">="
|
130
|
-
- !ruby/object:Gem::Version
|
131
|
-
version: '0'
|
132
|
-
type: :runtime
|
133
|
-
prerelease: false
|
134
|
-
version_requirements: !ruby/object:Gem::Requirement
|
135
|
-
requirements:
|
136
|
-
- - ">="
|
137
|
-
- !ruby/object:Gem::Version
|
138
|
-
version: '0'
|
139
|
-
description: A Reddit API Wrapper for Ruby.
|
124
|
+
version: 1.10.1
|
125
|
+
description:
|
140
126
|
email:
|
141
|
-
-
|
127
|
+
- avinash@dwarapu.me
|
142
128
|
executables: []
|
143
129
|
extensions: []
|
144
130
|
extra_rdoc_files: []
|
@@ -147,91 +133,58 @@ files:
|
|
147
133
|
- ".rspec"
|
148
134
|
- ".rubocop.yml"
|
149
135
|
- ".travis.yml"
|
150
|
-
- ".yardopts"
|
151
136
|
- Gemfile
|
152
|
-
- LICENSE.
|
137
|
+
- LICENSE.txt
|
153
138
|
- README.md
|
154
139
|
- Rakefile
|
155
|
-
- RedditKit.LICENSE.
|
140
|
+
- RedditKit.LICENSE.txt
|
156
141
|
- lib/redd.rb
|
157
|
-
- lib/redd/
|
158
|
-
- lib/redd/
|
159
|
-
- lib/redd/
|
160
|
-
- lib/redd/
|
161
|
-
- lib/redd/
|
162
|
-
- lib/redd/
|
163
|
-
- lib/redd/
|
164
|
-
- lib/redd/
|
165
|
-
- lib/redd/
|
166
|
-
- lib/redd/
|
167
|
-
- lib/redd/
|
168
|
-
- lib/redd/
|
169
|
-
- lib/redd/
|
170
|
-
- lib/redd/
|
171
|
-
- lib/redd/
|
172
|
-
- lib/redd/client/oauth2/authorization.rb
|
173
|
-
- lib/redd/client/oauth2/identity.rb
|
174
|
-
- lib/redd/client/oauth2_script.rb
|
175
|
-
- lib/redd/client/oauth2_script/authorization.rb
|
176
|
-
- lib/redd/client/unauthenticated.rb
|
177
|
-
- lib/redd/client/unauthenticated/account.rb
|
178
|
-
- lib/redd/client/unauthenticated/captcha.rb
|
179
|
-
- lib/redd/client/unauthenticated/links_comments.rb
|
180
|
-
- lib/redd/client/unauthenticated/listing.rb
|
181
|
-
- lib/redd/client/unauthenticated/live.rb
|
182
|
-
- lib/redd/client/unauthenticated/moderation.rb
|
183
|
-
- lib/redd/client/unauthenticated/subreddits.rb
|
184
|
-
- lib/redd/client/unauthenticated/users.rb
|
185
|
-
- lib/redd/client/unauthenticated/utilities.rb
|
186
|
-
- lib/redd/client/unauthenticated/wiki.rb
|
142
|
+
- lib/redd/access.rb
|
143
|
+
- lib/redd/clients/base.rb
|
144
|
+
- lib/redd/clients/base/account.rb
|
145
|
+
- lib/redd/clients/base/identity.rb
|
146
|
+
- lib/redd/clients/base/none.rb
|
147
|
+
- lib/redd/clients/base/privatemessages.rb
|
148
|
+
- lib/redd/clients/base/read.rb
|
149
|
+
- lib/redd/clients/base/stream.rb
|
150
|
+
- lib/redd/clients/base/submit.rb
|
151
|
+
- lib/redd/clients/base/utilities.rb
|
152
|
+
- lib/redd/clients/base/wikiread.rb
|
153
|
+
- lib/redd/clients/installed.rb
|
154
|
+
- lib/redd/clients/script.rb
|
155
|
+
- lib/redd/clients/userless.rb
|
156
|
+
- lib/redd/clients/web.rb
|
187
157
|
- lib/redd/error.rb
|
188
|
-
- lib/redd/
|
189
|
-
- lib/redd/
|
190
|
-
- lib/redd/
|
191
|
-
- lib/redd/
|
192
|
-
- lib/redd/
|
193
|
-
- lib/redd/
|
194
|
-
- lib/redd/
|
195
|
-
- lib/redd/
|
196
|
-
- lib/redd/
|
158
|
+
- lib/redd/objects/base.rb
|
159
|
+
- lib/redd/objects/comment.rb
|
160
|
+
- lib/redd/objects/listing.rb
|
161
|
+
- lib/redd/objects/more_comments.rb
|
162
|
+
- lib/redd/objects/private_message.rb
|
163
|
+
- lib/redd/objects/submission.rb
|
164
|
+
- lib/redd/objects/subreddit.rb
|
165
|
+
- lib/redd/objects/thing.rb
|
166
|
+
- lib/redd/objects/thing/editable.rb
|
167
|
+
- lib/redd/objects/thing/hideable.rb
|
168
|
+
- lib/redd/objects/thing/inboxable.rb
|
169
|
+
- lib/redd/objects/thing/messageable.rb
|
170
|
+
- lib/redd/objects/thing/moderatable.rb
|
171
|
+
- lib/redd/objects/thing/refreshable.rb
|
172
|
+
- lib/redd/objects/thing/saveable.rb
|
173
|
+
- lib/redd/objects/thing/votable.rb
|
174
|
+
- lib/redd/objects/user.rb
|
175
|
+
- lib/redd/objects/wiki_page.rb
|
197
176
|
- lib/redd/rate_limit.rb
|
198
177
|
- lib/redd/response/parse_json.rb
|
199
178
|
- lib/redd/response/raise_error.rb
|
200
|
-
- lib/redd/thing.rb
|
201
|
-
- lib/redd/thing/commentable.rb
|
202
|
-
- lib/redd/thing/editable.rb
|
203
|
-
- lib/redd/thing/hideable.rb
|
204
|
-
- lib/redd/thing/inboxable.rb
|
205
|
-
- lib/redd/thing/messageable.rb
|
206
|
-
- lib/redd/thing/moderatable.rb
|
207
|
-
- lib/redd/thing/reportable.rb
|
208
|
-
- lib/redd/thing/saveable.rb
|
209
|
-
- lib/redd/thing/voteable.rb
|
210
179
|
- lib/redd/version.rb
|
211
180
|
- redd.gemspec
|
212
|
-
- spec/
|
213
|
-
- spec/redd/base_spec.rb
|
214
|
-
- spec/redd/client/authenticated/account_spec.rb
|
215
|
-
- spec/redd/client/authenticated/apps_spec.rb
|
216
|
-
- spec/redd/client/authenticated/flair_spec.rb
|
217
|
-
- spec/redd/client/authenticated/gold_spec.rb
|
218
|
-
- spec/redd/client/authenticated/links_comments_spec.rb
|
219
|
-
- spec/redd/client/authenticated/live_spec.rb
|
220
|
-
- spec/redd/client/unauthenticated/account_spec.rb
|
221
|
-
- spec/redd/client/unauthenticated/captcha_spec.rb
|
222
|
-
- spec/redd/client/unauthenticated/links_comments_spec.rb
|
223
|
-
- spec/redd/client/unauthenticated/listing_spec.rb
|
224
|
-
- spec/redd/client/unauthenticated/live_spec.rb
|
225
|
-
- spec/redd/client/unauthenticated/moderation_spec.rb
|
226
|
-
- spec/redd/client/unauthenticated/subreddits_spec.rb
|
227
|
-
- spec/redd/client/unauthenticated/users_spec.rb
|
228
|
-
- spec/redd/client/unauthenticated/wiki_spec.rb
|
229
|
-
- spec/redd/oauth2_access_spec.rb
|
181
|
+
- spec/redd/objects/base_spec.rb
|
230
182
|
- spec/redd/rate_limit_spec.rb
|
231
|
-
- spec/redd/
|
183
|
+
- spec/redd/response/parse_json_spec.rb
|
184
|
+
- spec/redd/response/raise_error_spec.rb
|
232
185
|
- spec/redd_spec.rb
|
233
186
|
- spec/spec_helper.rb
|
234
|
-
homepage:
|
187
|
+
homepage: https://github.com/avidw/redd
|
235
188
|
licenses:
|
236
189
|
- MIT
|
237
190
|
metadata: {}
|
@@ -243,7 +196,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
243
196
|
requirements:
|
244
197
|
- - ">="
|
245
198
|
- !ruby/object:Gem::Version
|
246
|
-
version:
|
199
|
+
version: 2.1.0
|
247
200
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
248
201
|
requirements:
|
249
202
|
- - ">="
|
@@ -256,26 +209,10 @@ signing_key:
|
|
256
209
|
specification_version: 4
|
257
210
|
summary: A Reddit API Wrapper for Ruby.
|
258
211
|
test_files:
|
259
|
-
- spec/
|
260
|
-
- spec/redd/base_spec.rb
|
261
|
-
- spec/redd/client/authenticated/account_spec.rb
|
262
|
-
- spec/redd/client/authenticated/apps_spec.rb
|
263
|
-
- spec/redd/client/authenticated/flair_spec.rb
|
264
|
-
- spec/redd/client/authenticated/gold_spec.rb
|
265
|
-
- spec/redd/client/authenticated/links_comments_spec.rb
|
266
|
-
- spec/redd/client/authenticated/live_spec.rb
|
267
|
-
- spec/redd/client/unauthenticated/account_spec.rb
|
268
|
-
- spec/redd/client/unauthenticated/captcha_spec.rb
|
269
|
-
- spec/redd/client/unauthenticated/links_comments_spec.rb
|
270
|
-
- spec/redd/client/unauthenticated/listing_spec.rb
|
271
|
-
- spec/redd/client/unauthenticated/live_spec.rb
|
272
|
-
- spec/redd/client/unauthenticated/moderation_spec.rb
|
273
|
-
- spec/redd/client/unauthenticated/subreddits_spec.rb
|
274
|
-
- spec/redd/client/unauthenticated/users_spec.rb
|
275
|
-
- spec/redd/client/unauthenticated/wiki_spec.rb
|
276
|
-
- spec/redd/oauth2_access_spec.rb
|
212
|
+
- spec/redd/objects/base_spec.rb
|
277
213
|
- spec/redd/rate_limit_spec.rb
|
278
|
-
- spec/redd/
|
214
|
+
- spec/redd/response/parse_json_spec.rb
|
215
|
+
- spec/redd/response/raise_error_spec.rb
|
279
216
|
- spec/redd_spec.rb
|
280
217
|
- spec/spec_helper.rb
|
281
218
|
has_rdoc:
|
data/.yardopts
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
--private
|
data/lib/redd/base.rb
DELETED
@@ -1,56 +0,0 @@
|
|
1
|
-
require "memoizable"
|
2
|
-
|
3
|
-
module Redd
|
4
|
-
# A container for various models with attributes and a client.
|
5
|
-
class Base
|
6
|
-
include Memoizable
|
7
|
-
|
8
|
-
# @!attribute [r] attributes
|
9
|
-
# @return [Hash] A list of attributes returned by reddit for this object.
|
10
|
-
attr_reader :attributes
|
11
|
-
alias_method :to_h, :attributes
|
12
|
-
|
13
|
-
# @!attribute [r] client
|
14
|
-
# @return The client instance used to make requests with this object.
|
15
|
-
attr_reader :client
|
16
|
-
|
17
|
-
# Define and memoize the method that returns a key from the attributes
|
18
|
-
# hash.
|
19
|
-
#
|
20
|
-
# @param [Symbol, String] attr The attribute to construct a method out of.
|
21
|
-
def self.attr_reader(attr)
|
22
|
-
define_attribute_method(attr)
|
23
|
-
define_predicate_method(attr)
|
24
|
-
end
|
25
|
-
|
26
|
-
# @param method [#to_sym] An attribute of the class
|
27
|
-
# @return The attribute requested
|
28
|
-
def [](method)
|
29
|
-
send(method.to_sym)
|
30
|
-
rescue NoMethodError
|
31
|
-
nil
|
32
|
-
end
|
33
|
-
|
34
|
-
# @param client The client to use when making requests with this object.
|
35
|
-
# This is similar to reddit_session in praw.
|
36
|
-
# @param [Hash] attributes
|
37
|
-
def initialize(client, attributes)
|
38
|
-
@client = client
|
39
|
-
@attributes = attributes[:data]
|
40
|
-
@attributes[:kind] = attributes[:kind]
|
41
|
-
end
|
42
|
-
|
43
|
-
# Create a new method with the given name that accesses the @attributes.
|
44
|
-
def self.define_attribute_method(method)
|
45
|
-
define_method(method) { @attributes[method] }
|
46
|
-
memoize method
|
47
|
-
end
|
48
|
-
|
49
|
-
# Create a new method with the given name that accesses the @attributes.
|
50
|
-
# @return [Boolean]
|
51
|
-
def self.define_predicate_method(method)
|
52
|
-
define_method(:"#{method}?") { !!@attributes[method] }
|
53
|
-
memoize :"#{method}?"
|
54
|
-
end
|
55
|
-
end
|
56
|
-
end
|
@@ -1,83 +0,0 @@
|
|
1
|
-
require "redd/client/unauthenticated"
|
2
|
-
|
3
|
-
module Redd
|
4
|
-
module Client
|
5
|
-
# The class that handles requests when authenticated using a username and
|
6
|
-
# password.
|
7
|
-
class Authenticated < Redd::Client::Unauthenticated
|
8
|
-
require "redd/client/authenticated/account"
|
9
|
-
require "redd/client/authenticated/apps"
|
10
|
-
require "redd/client/authenticated/flair"
|
11
|
-
require "redd/client/authenticated/gold"
|
12
|
-
require "redd/client/authenticated/links_comments"
|
13
|
-
require "redd/client/authenticated/live"
|
14
|
-
require "redd/client/authenticated/moderation"
|
15
|
-
require "redd/client/authenticated/multis"
|
16
|
-
require "redd/client/authenticated/private_messages"
|
17
|
-
require "redd/client/authenticated/subreddits"
|
18
|
-
require "redd/client/authenticated/users"
|
19
|
-
require "redd/client/authenticated/wiki"
|
20
|
-
|
21
|
-
include Redd::Client::Authenticated::Account
|
22
|
-
include Redd::Client::Authenticated::Apps
|
23
|
-
include Redd::Client::Authenticated::Flair
|
24
|
-
include Redd::Client::Authenticated::Gold
|
25
|
-
include Redd::Client::Authenticated::LinksComments
|
26
|
-
include Redd::Client::Authenticated::Live
|
27
|
-
include Redd::Client::Authenticated::Moderation
|
28
|
-
include Redd::Client::Authenticated::Multis
|
29
|
-
include Redd::Client::Authenticated::PrivateMessages
|
30
|
-
include Redd::Client::Authenticated::Subreddits
|
31
|
-
include Redd::Client::Authenticated::Users
|
32
|
-
include Redd::Client::Authenticated::Wiki
|
33
|
-
|
34
|
-
# @!attribute [r] username
|
35
|
-
# @return [String] The username of the logged-in user.
|
36
|
-
attr_reader :username
|
37
|
-
|
38
|
-
# @!attribute [r] cookie
|
39
|
-
# @return [String] The cookie used to store the current session.
|
40
|
-
attr_reader :cookie
|
41
|
-
|
42
|
-
# @!attribute [r] modhash
|
43
|
-
# @return [String] The returned modhash used when making requests.
|
44
|
-
attr_reader :modhash
|
45
|
-
|
46
|
-
def self.new_from_credentials(username, password, options = {})
|
47
|
-
@username = username
|
48
|
-
Redd::Client::Unauthenticated.new.login(username, password, options)
|
49
|
-
end
|
50
|
-
|
51
|
-
# Set up an authenticated connection to reddit.
|
52
|
-
#
|
53
|
-
# @param [String] cookie The cookie to use when sending a request.
|
54
|
-
# @param [String] modhash The modhash to use when sending a request.
|
55
|
-
# @param [Hash] options A hash of options to connect using.
|
56
|
-
# @option options [String] :user_agent The User-Agent string to use in the
|
57
|
-
# header of every request.
|
58
|
-
# @option options [String] :api_endpoint The main domain to connect to, in
|
59
|
-
# this case, the URL for reddit.
|
60
|
-
# @option options [String] :auth_endpoint The domain to login with, in
|
61
|
-
# this case, the ssl subdomain using https.
|
62
|
-
def initialize(cookie, modhash, options = {})
|
63
|
-
@cookie = cookie
|
64
|
-
@modhash = modhash
|
65
|
-
|
66
|
-
@rate_limit = options[:rate_limit] || Redd::RateLimit.new
|
67
|
-
@user_agent = options[:user_agent] || "Redd/Ruby, v#{Redd::VERSION}"
|
68
|
-
@api_endpoint = options[:api_endpoint] || "https://www.reddit.com/"
|
69
|
-
end
|
70
|
-
|
71
|
-
private
|
72
|
-
|
73
|
-
# @return [Hash] The headers that are sent with every request.
|
74
|
-
def headers
|
75
|
-
@headers ||= {
|
76
|
-
"User-Agent" => @user_agent,
|
77
|
-
"Cookie" => "reddit_session=#{@cookie}",
|
78
|
-
"X-Modhash" => @modhash
|
79
|
-
}
|
80
|
-
end
|
81
|
-
end
|
82
|
-
end
|
83
|
-
end
|