redd 0.6.5 → 0.7.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (125) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +34 -33
  3. data/.rspec +3 -4
  4. data/.rubocop.yml +5 -5
  5. data/.travis.yml +9 -7
  6. data/{LICENSE.md → LICENSE.txt} +22 -22
  7. data/README.md +126 -241
  8. data/Rakefile +5 -6
  9. data/{RedditKit.LICENSE.md → RedditKit.LICENSE.txt} +13 -13
  10. data/lib/redd.rb +50 -4
  11. data/lib/redd/access.rb +76 -0
  12. data/lib/redd/clients/base.rb +178 -0
  13. data/lib/redd/clients/base/account.rb +20 -0
  14. data/lib/redd/clients/base/identity.rb +22 -0
  15. data/lib/redd/clients/base/none.rb +27 -0
  16. data/lib/redd/clients/base/privatemessages.rb +28 -0
  17. data/lib/redd/clients/base/read.rb +66 -0
  18. data/lib/redd/clients/base/stream.rb +74 -0
  19. data/lib/redd/clients/base/submit.rb +54 -0
  20. data/lib/redd/clients/base/utilities.rb +80 -0
  21. data/lib/redd/clients/base/wikiread.rb +33 -0
  22. data/lib/redd/clients/installed.rb +55 -0
  23. data/lib/redd/clients/script.rb +37 -0
  24. data/lib/redd/clients/userless.rb +31 -0
  25. data/lib/redd/clients/web.rb +57 -0
  26. data/lib/redd/error.rb +138 -153
  27. data/lib/redd/objects/base.rb +36 -0
  28. data/lib/redd/objects/comment.rb +22 -0
  29. data/lib/redd/objects/listing.rb +29 -0
  30. data/lib/redd/objects/more_comments.rb +10 -0
  31. data/lib/redd/objects/private_message.rb +18 -0
  32. data/lib/redd/objects/submission.rb +72 -0
  33. data/lib/redd/objects/subreddit.rb +152 -0
  34. data/lib/redd/objects/thing.rb +33 -0
  35. data/lib/redd/objects/thing/editable.rb +22 -0
  36. data/lib/redd/objects/thing/hideable.rb +18 -0
  37. data/lib/redd/objects/thing/inboxable.rb +25 -0
  38. data/lib/redd/objects/thing/messageable.rb +34 -0
  39. data/lib/redd/objects/thing/moderatable.rb +43 -0
  40. data/lib/redd/objects/thing/refreshable.rb +14 -0
  41. data/lib/redd/objects/thing/saveable.rb +21 -0
  42. data/lib/redd/objects/thing/votable.rb +33 -0
  43. data/lib/redd/objects/user.rb +52 -0
  44. data/lib/redd/objects/wiki_page.rb +15 -0
  45. data/lib/redd/rate_limit.rb +50 -49
  46. data/lib/redd/response/parse_json.rb +17 -33
  47. data/lib/redd/response/raise_error.rb +16 -25
  48. data/lib/redd/version.rb +4 -5
  49. data/redd.gemspec +30 -31
  50. data/spec/redd/objects/base_spec.rb +1 -0
  51. data/spec/redd/rate_limit_spec.rb +29 -29
  52. data/spec/redd/response/parse_json_spec.rb +12 -0
  53. data/spec/redd/response/raise_error_spec.rb +11 -0
  54. data/spec/redd_spec.rb +7 -5
  55. data/spec/spec_helper.rb +69 -50
  56. metadata +73 -136
  57. data/.yardopts +0 -1
  58. data/lib/redd/base.rb +0 -56
  59. data/lib/redd/client/authenticated.rb +0 -83
  60. data/lib/redd/client/authenticated/account.rb +0 -13
  61. data/lib/redd/client/authenticated/apps.rb +0 -13
  62. data/lib/redd/client/authenticated/flair.rb +0 -71
  63. data/lib/redd/client/authenticated/gold.rb +0 -13
  64. data/lib/redd/client/authenticated/links_comments.rb +0 -189
  65. data/lib/redd/client/authenticated/live.rb +0 -13
  66. data/lib/redd/client/authenticated/moderation.rb +0 -126
  67. data/lib/redd/client/authenticated/multis.rb +0 -9
  68. data/lib/redd/client/authenticated/private_messages.rb +0 -73
  69. data/lib/redd/client/authenticated/subreddits.rb +0 -172
  70. data/lib/redd/client/authenticated/users.rb +0 -9
  71. data/lib/redd/client/authenticated/wiki.rb +0 -9
  72. data/lib/redd/client/oauth2.rb +0 -71
  73. data/lib/redd/client/oauth2/authorization.rb +0 -108
  74. data/lib/redd/client/oauth2/identity.rb +0 -16
  75. data/lib/redd/client/oauth2_script.rb +0 -24
  76. data/lib/redd/client/oauth2_script/authorization.rb +0 -21
  77. data/lib/redd/client/unauthenticated.rb +0 -118
  78. data/lib/redd/client/unauthenticated/account.rb +0 -30
  79. data/lib/redd/client/unauthenticated/captcha.rb +0 -27
  80. data/lib/redd/client/unauthenticated/links_comments.rb +0 -60
  81. data/lib/redd/client/unauthenticated/listing.rb +0 -65
  82. data/lib/redd/client/unauthenticated/live.rb +0 -9
  83. data/lib/redd/client/unauthenticated/moderation.rb +0 -26
  84. data/lib/redd/client/unauthenticated/subreddits.rb +0 -49
  85. data/lib/redd/client/unauthenticated/users.rb +0 -67
  86. data/lib/redd/client/unauthenticated/utilities.rb +0 -109
  87. data/lib/redd/client/unauthenticated/wiki.rb +0 -33
  88. data/lib/redd/oauth2_access.rb +0 -70
  89. data/lib/redd/object/comment.rb +0 -74
  90. data/lib/redd/object/listing.rb +0 -29
  91. data/lib/redd/object/more_comments.rb +0 -14
  92. data/lib/redd/object/private_message.rb +0 -35
  93. data/lib/redd/object/submission.rb +0 -94
  94. data/lib/redd/object/subreddit.rb +0 -74
  95. data/lib/redd/object/user.rb +0 -34
  96. data/lib/redd/object/wiki_page.rb +0 -27
  97. data/lib/redd/thing.rb +0 -27
  98. data/lib/redd/thing/commentable.rb +0 -27
  99. data/lib/redd/thing/editable.rb +0 -16
  100. data/lib/redd/thing/hideable.rb +0 -16
  101. data/lib/redd/thing/inboxable.rb +0 -20
  102. data/lib/redd/thing/messageable.rb +0 -12
  103. data/lib/redd/thing/moderatable.rb +0 -32
  104. data/lib/redd/thing/reportable.rb +0 -12
  105. data/lib/redd/thing/saveable.rb +0 -16
  106. data/lib/redd/thing/voteable.rb +0 -22
  107. data/spec/README.md +0 -18
  108. data/spec/redd/base_spec.rb +0 -36
  109. data/spec/redd/client/authenticated/account_spec.rb +0 -5
  110. data/spec/redd/client/authenticated/apps_spec.rb +0 -2
  111. data/spec/redd/client/authenticated/flair_spec.rb +0 -26
  112. data/spec/redd/client/authenticated/gold_spec.rb +0 -2
  113. data/spec/redd/client/authenticated/links_comments_spec.rb +0 -231
  114. data/spec/redd/client/authenticated/live_spec.rb +0 -2
  115. data/spec/redd/client/unauthenticated/account_spec.rb +0 -15
  116. data/spec/redd/client/unauthenticated/captcha_spec.rb +0 -23
  117. data/spec/redd/client/unauthenticated/links_comments_spec.rb +0 -28
  118. data/spec/redd/client/unauthenticated/listing_spec.rb +0 -23
  119. data/spec/redd/client/unauthenticated/live_spec.rb +0 -2
  120. data/spec/redd/client/unauthenticated/moderation_spec.rb +0 -14
  121. data/spec/redd/client/unauthenticated/subreddits_spec.rb +0 -35
  122. data/spec/redd/client/unauthenticated/users_spec.rb +0 -34
  123. data/spec/redd/client/unauthenticated/wiki_spec.rb +0 -18
  124. data/spec/redd/oauth2_access_spec.rb +0 -83
  125. data/spec/redd/thing_spec.rb +0 -22
@@ -1,2 +0,0 @@
1
- describe Redd::Client::Authenticated::Gold do
2
- end
@@ -1,231 +0,0 @@
1
- describe Redd::Client::Authenticated::LinksComments do
2
- describe "#submit" do
3
- before do
4
- # create the posts
5
- end
6
-
7
- it "submits a text post correctly"
8
- it "submits a link post correctly"
9
-
10
- after do
11
- # delete the posts?
12
- end
13
- end
14
-
15
- describe "#add_comment" do
16
- context "when commenting on a link" do
17
- it "posts the comment correctly"
18
- end
19
-
20
- context "when replying to a comment" do
21
- it "posts the reply correctly"
22
- end
23
-
24
- context "when replying to a message" do
25
- it "replies to the message correctly"
26
- end
27
-
28
- after do
29
- # delete the reply and the comment?
30
- # we can't do anything for messages
31
- end
32
- end
33
-
34
- describe "#delete" do
35
- context "when deleting a comment" do
36
- before do
37
- # create a comment
38
- end
39
-
40
- it "deletes a comment successfully"
41
- end
42
-
43
- context "when deleting a link" do
44
- before do
45
- # create a link
46
- end
47
-
48
- it "deletes a link successfully"
49
- end
50
- end
51
-
52
- describe "#edit" do
53
- context "when editing a comment" do
54
- before do
55
- # create a comment
56
- end
57
-
58
- it "edits a comment successfully"
59
-
60
- after do
61
- # delete the comment
62
- end
63
- end
64
-
65
- context "when editing a link" do
66
- before do
67
- # create a link
68
- end
69
-
70
- it "edits a link successfully"
71
-
72
- after do
73
- # delete the link
74
- end
75
- end
76
- end
77
-
78
- describe "#hide" do
79
- before do
80
- # create a link
81
- end
82
-
83
- it "hides a link successfully"
84
-
85
- after do
86
- # delete the link
87
- end
88
- end
89
-
90
- describe "#unhide" do
91
- before do
92
- # create a link
93
- end
94
-
95
- it "unhides a link successfully"
96
-
97
- after do
98
- # delete the link
99
- end
100
- end
101
-
102
- describe "#mark_as_nsfw" do
103
- before do
104
- # create a link
105
- end
106
-
107
- it "marks a link as NSFW successfully"
108
-
109
- after do
110
- # delete the link
111
- end
112
- end
113
-
114
- describe "#unmark_as_nsfw" do
115
- before do
116
- # create a link
117
- end
118
-
119
- it "removes the NSFW mark from a link successfully"
120
-
121
- after do
122
- # delete the link
123
- end
124
- end
125
-
126
- # Nobody's going to give my testing suite gold, are they?
127
- describe "#save" do
128
- before do
129
- # create a link
130
- end
131
-
132
- it "saves the link successfully"
133
-
134
- after do
135
- # delete the link
136
- end
137
- end
138
-
139
- describe "#unsave" do
140
- before do
141
- # create a link
142
- end
143
-
144
- it "unsaves the link successfully"
145
-
146
- after do
147
- # delete the link
148
- end
149
- end
150
-
151
- describe "#upvote" do
152
- context "when upvoting a comment" do
153
- before do
154
- # create a comment
155
- end
156
-
157
- # We can't always count on the score increasing
158
- it "adds the comment to the user's liked list"
159
-
160
- after do
161
- # delete the comment
162
- end
163
- end
164
-
165
- context "when upvoting a link" do
166
- before do
167
- # create a link
168
- end
169
-
170
- it "adds the link to the user's liked list"
171
-
172
- after do
173
- # delete the link
174
- end
175
- end
176
- end
177
-
178
- describe "#downvote" do
179
- context "when downvoting a comment" do
180
- before do
181
- # create a comment
182
- end
183
-
184
- # We can't always count on the score increasing
185
- it "adds the comment to the user's disliked list"
186
-
187
- after do
188
- # delete the comment
189
- end
190
- end
191
-
192
- context "when downvoting a link" do
193
- before do
194
- # create a link
195
- end
196
-
197
- it "adds the link to the user's disliked list"
198
-
199
- after do
200
- # delete the link
201
- end
202
- end
203
- end
204
-
205
- describe "#unvote" do
206
- context "when unvoting a comment" do
207
- before do
208
- # create a comment and like it
209
- end
210
-
211
- # We can't always count on the score increasing
212
- it "removes the comment from the user's liked list"
213
-
214
- after do
215
- # delete the comment
216
- end
217
- end
218
-
219
- context "when unvoting a link" do
220
- before do
221
- # create a link
222
- end
223
-
224
- it "removes the link from the user's liked list"
225
-
226
- after do
227
- # delete the link
228
- end
229
- end
230
- end
231
- end
@@ -1,2 +0,0 @@
1
- describe Redd::Client::Authenticated::Live do
2
- end
@@ -1,15 +0,0 @@
1
- describe Redd::Client::Unauthenticated::Account do
2
- describe "#login" do
3
- let(:logged_in_client) do
4
- unauthenticated_client.login(test_username, test_password)
5
- end
6
-
7
- it "returns an Authenticated client" do
8
- expect(logged_in_client).to be_a(Redd::Client::Authenticated)
9
- end
10
-
11
- it "can be used to make requests" do
12
- expect(logged_in_client.me[:name]).to match(/#{test_username}/i)
13
- end
14
- end
15
- end
@@ -1,23 +0,0 @@
1
- require "uri"
2
-
3
- describe Redd::Client::Unauthenticated::Captcha do
4
- describe "#needs_captcha?" do
5
- it "returns a boolean" do
6
- expect(unauthenticated_client.needs_captcha?).to be(true).or be(false)
7
- end
8
- end
9
-
10
- describe "#new_captcha" do
11
- it "returns a string" do
12
- expect(unauthenticated_client.new_captcha).to be_a(String)
13
- end
14
- end
15
-
16
- describe "#captcha_url" do
17
- it "returns a valid url" do
18
- new_captcha = unauthenticated_client.new_captcha
19
- captcha_url = unauthenticated_client.captcha_url(new_captcha)
20
- expect(captcha_url).to match(URI::ABS_URI)
21
- end
22
- end
23
- end
@@ -1,28 +0,0 @@
1
- describe Redd::Client::Unauthenticated::LinksComments do
2
- describe "#get_info" do
3
- let(:response) { unauthenticated_client.get_info(id: test_link_id) }
4
-
5
- it "returns a listing" do
6
- expect(response).to be_a(Redd::Object::Listing)
7
- end
8
-
9
- it "returns the correct objects" do
10
- link = response.things.first
11
- expect(link).to be_a(Redd::Object::Submission)
12
- expect(link.fullname).to eq(test_link_id)
13
- end
14
- end
15
-
16
- describe "#submission_comments" do
17
- it "returns a listing of comments and morecomments only"
18
- end
19
-
20
- describe "#get_replies" do
21
- it "returns a listing of comments and morecomments only"
22
- end
23
-
24
- describe "expand_morecomments" do
25
- it "returns a listing of comments only"
26
- it "returns the same number of comments as it indicated"
27
- end
28
- end
@@ -1,23 +0,0 @@
1
- describe Redd::Client::Unauthenticated::Listing do
2
- describe "#by_id" do
3
- let(:response) { unauthenticated_client.by_id(test_link_id) }
4
-
5
- it "returns a listing" do
6
- expect(response).to be_a(Redd::Object::Listing)
7
- end
8
-
9
- it "returns the correct object" do
10
- link = response.things.first
11
- expect(link).to be_a(Redd::Object::Submission)
12
- expect(link.fullname).to eq(test_link_id)
13
- end
14
- end
15
-
16
- describe "#get_hot, #get_new, #get_op, #get_controversial" do
17
- it "returns a listing of submissions only"
18
- end
19
-
20
- describe "#get_comments" do
21
- it "returns a listing of comments only"
22
- end
23
- end
@@ -1,2 +0,0 @@
1
- describe Redd::Client::Unauthenticated::Live do
2
- end
@@ -1,14 +0,0 @@
1
- require "uri"
2
-
3
- describe Redd::Client::Unauthenticated::Moderation do
4
- describe "#stylesheet_url" do
5
- it "returns a valid url" do
6
- url = unauthenticated_client.stylesheet_url(test_subreddit)
7
- expect(url).to match(URI::ABS_URI)
8
- end
9
- end
10
-
11
- describe "#stylesheet" do
12
- it "returns valid CSS" # Yeah, nope.
13
- end
14
- end
@@ -1,35 +0,0 @@
1
- describe Redd::Client::Unauthenticated::Subreddits do
2
- describe "#subreddit" do
3
- let(:subreddit) { unauthenticated_client.subreddit(test_subreddit) }
4
-
5
- it "returns a subreddit object" do
6
- expect(subreddit).to be_a(Redd::Object::Subreddit)
7
- end
8
-
9
- it "returns the correct subreddit" do
10
- expect(subreddit.display_name).to eq(test_subreddit)
11
- end
12
- end
13
-
14
- describe "#get_subreddits" do
15
- let(:subreddits) { unauthenticated_client.get_subreddits }
16
-
17
- it "returns a listing" do
18
- expect(subreddits).to be_a(Redd::Object::Listing)
19
- end
20
-
21
- it "returns a listing of subreddits"
22
- end
23
-
24
- describe "#search_subreddits" do
25
- let(:search) { unauthenticated_client.search_subreddits(test_subreddit) }
26
-
27
- it "returns a listing" do
28
- expect(search).to be_a(Redd::Object::Listing)
29
- end
30
-
31
- it "returns a listing of subreddits"
32
-
33
- it "includes the subreddit searched for"
34
- end
35
- end
@@ -1,34 +0,0 @@
1
- describe Redd::Client::Unauthenticated::Users do
2
- describe "#user" do
3
- let(:user) { unauthenticated_client.user(test_username) }
4
-
5
- it "returns a user" do
6
- expect(user).to be_a(Redd::Object::User)
7
- end
8
-
9
- it "returns the user requested" do
10
- expect(user.name).to match(/#{test_username}/i)
11
- end
12
- end
13
-
14
- describe "#get_user_overview" do
15
- it "returns a listing"
16
- it "contains content only created by the user"
17
- end
18
-
19
- describe "#get_user_submitted" do
20
- it "returns a listing"
21
- it "contains only submissions"
22
- it "contains submissions only created by the user"
23
- end
24
-
25
- describe "#get_user_comments" do
26
- it "returns a listing"
27
- it "contains only comments"
28
- it "contains comments only created by the user"
29
- end
30
-
31
- describe "#get_user_liked, #get_user_disliked, #get_user_hidden, #get_user_saved, #get_user_gilded" do
32
- it "returns a listing"
33
- end
34
- end
@@ -1,18 +0,0 @@
1
- describe Redd::Client::Unauthenticated::Wiki do
2
- describe "#get_wikipages" do
3
- let(:pages) { unauthenticated_client.get_wikipages(test_subreddit) }
4
-
5
- it "returns an array of pages in the wiki" do
6
- expect(pages).to be_an(Array)
7
- expect(pages).to include(test_wikipage)
8
- end
9
- end
10
-
11
- describe "#wikipage" do
12
- let(:page) { unauthenticated_client.wikipage(test_wikipage, test_subreddit) }
13
-
14
- it "returns a wikipage" do
15
- expect(page).to be_a(Redd::Object::WikiPage)
16
- end
17
- end
18
- end