usaidwat 1.4.0 → 1.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/features/log.feature +3 -3
- data/features/posts.feature +33 -0
- data/lib/usaidwat/application.rb +1 -1
- data/lib/usaidwat/ext/string.rb +4 -0
- data/lib/usaidwat/formatter.rb +4 -3
- data/lib/usaidwat/service.rb +2 -1
- data/lib/usaidwat/version.rb +1 -1
- data/spec/usaidwat/formatter_spec.rb +53 -4
- data/spec/usaidwat/string_spec.rb +17 -0
- metadata +5 -5
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 109f7714eb054decf6d7c307f071c5590af3a0e1
|
|
4
|
+
data.tar.gz: dd67a99e77fee4b8c931d0c0e37090be2e165711
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 8b415cfb6cb5b8be767bcf0bed60f72448681512356ad3964310cb95e2d88d2169da679f0d5fcc79ae0d9ee1e86d5601701cfb7712a028102d68c506c6dbed09
|
|
7
|
+
data.tar.gz: 74378fa1d498786439eb61cc9100bb5f8552761ab14fcc9e0c9eefe02baac235017ee902c432bd831bdde60fe5449032c1d00cf60677377d8ecabe0162788140
|
data/features/log.feature
CHANGED
|
@@ -154,7 +154,7 @@ Feature: Browse comments
|
|
|
154
154
|
"""
|
|
155
155
|
Games
|
|
156
156
|
http://www.reddit.com/r/Games/comments/13xc2o/z/c784qj8
|
|
157
|
-
The True Story of Battlefield 3, the Battlefield Franchise, Its Community, &
|
|
157
|
+
The True Story of Battlefield 3, the Battlefield Franchise, Its Community, & EA/
|
|
158
158
|
over 2 years ago • +2
|
|
159
159
|
|
|
160
160
|
That's exactly how I feel. There are times when I have a ton of fun playing BF3…but it always feels like it has so much more potential to be an awesome game.
|
|
@@ -194,7 +194,7 @@ Feature: Browse comments
|
|
|
194
194
|
"""
|
|
195
195
|
Games
|
|
196
196
|
http://www.reddit.com/r/Games/comments/13xc2o/z/c784qj8
|
|
197
|
-
The True Story of Battlefield 3, the Battlefield Franchise, Its Community, &
|
|
197
|
+
The True Story of Battlefield 3, the Battlefield Franchise, Its Community, & EA/
|
|
198
198
|
over 2 years ago • +2
|
|
199
199
|
|
|
200
200
|
That's exactly how I feel. There are times when I have a ton of fun playing BF3…but it always feels like it has so much more potential to be an awesome game.
|
|
@@ -234,7 +234,7 @@ Feature: Browse comments
|
|
|
234
234
|
"""
|
|
235
235
|
Games
|
|
236
236
|
http://www.reddit.com/r/Games/comments/13xc2o/z/c784qj8
|
|
237
|
-
The True Story of Battlefield 3, the Battlefield Franchise, Its Community, &
|
|
237
|
+
The True Story of Battlefield 3, the Battlefield Franchise, Its Community, & EA/
|
|
238
238
|
over 2 years ago • +2
|
|
239
239
|
|
|
240
240
|
That's exactly how I feel. There are times when I have a ton of fun playing BF3…but it always feels like it has so much more potential to be an awesome game.
|
data/features/posts.feature
CHANGED
|
@@ -14,132 +14,154 @@ Feature: Show posts
|
|
|
14
14
|
https://www.reddit.com/r/short/comments/3pj7rx
|
|
15
15
|
Science Says Being Short Makes You Depressed
|
|
16
16
|
about 4 weeks ago
|
|
17
|
+
http://www.vice.com/read/it-sucks-to-be-a-short-guy-511
|
|
17
18
|
|
|
18
19
|
|
|
19
20
|
Games
|
|
20
21
|
https://www.reddit.com/r/Games/comments/3ovldc
|
|
21
22
|
The Xbox One Is Garbage And The Future Is Bullshit
|
|
22
23
|
about 1 month ago
|
|
24
|
+
http://adequateman.deadspin.com/the-xbox-one-is-garbage-and-the-future-is-bullshit-1736054579
|
|
23
25
|
|
|
24
26
|
|
|
25
27
|
technology
|
|
26
28
|
https://www.reddit.com/r/technology/comments/3o0vrh
|
|
27
29
|
Mozilla lays out a proposed set of rules for content blockers
|
|
28
30
|
about 1 month ago
|
|
31
|
+
https://blog.mozilla.org/blog/2015/10/07/proposed-principles-for-content-blocking/
|
|
29
32
|
|
|
30
33
|
|
|
31
34
|
apple
|
|
32
35
|
https://www.reddit.com/r/apple/comments/3o0vp9
|
|
33
36
|
Mozilla lays out a set of proposed rules for content blocking
|
|
34
37
|
about 1 month ago
|
|
38
|
+
https://blog.mozilla.org/blog/2015/10/07/proposed-principles-for-content-blocking/
|
|
35
39
|
|
|
36
40
|
|
|
37
41
|
vim
|
|
38
42
|
https://www.reddit.com/r/vim/comments/3m83kp
|
|
39
43
|
Vim setup for Markdown
|
|
40
44
|
about 2 months ago
|
|
45
|
+
http://www.swamphogg.com/2015/vim-setup/
|
|
41
46
|
|
|
42
47
|
|
|
43
48
|
django
|
|
44
49
|
https://www.reddit.com/r/django/comments/35rzlx
|
|
45
50
|
Deploy Django projects using git push
|
|
46
51
|
about 6 months ago
|
|
52
|
+
http://blog.mathieu-leplatre.info/deploy-django-projects-using-git-push.html
|
|
47
53
|
|
|
48
54
|
|
|
49
55
|
webdev
|
|
50
56
|
https://www.reddit.com/r/webdev/comments/35rtkx
|
|
51
57
|
The Future of Web Design is Hidden in the History of Architecture
|
|
52
58
|
about 6 months ago
|
|
59
|
+
https://medium.com/@sall/the-future-of-web-design-is-hidden-in-the-history-of-architecture-1cc93ea854d0
|
|
53
60
|
|
|
54
61
|
|
|
55
62
|
swift
|
|
56
63
|
https://www.reddit.com/r/swift/comments/33kjrn
|
|
57
64
|
Does Swift make native app development easier?
|
|
58
65
|
about 7 months ago
|
|
66
|
+
http://monkey-robot.com/2015/04/swift-makes-programming-easy/?utm_source=reddit&utm_medium=social&utm_campaign=Post%3A%2022%20Apr%202015
|
|
59
67
|
|
|
60
68
|
|
|
61
69
|
webdev
|
|
62
70
|
https://www.reddit.com/r/webdev/comments/32y92q
|
|
63
71
|
Microservices in Clojure
|
|
64
72
|
about 7 months ago
|
|
73
|
+
https://speakerdeck.com/kachayev/microservices-in-clojure
|
|
65
74
|
|
|
66
75
|
|
|
67
76
|
movies
|
|
68
77
|
https://www.reddit.com/r/movies/comments/2vt5h0
|
|
69
78
|
Interstellar's true black hole would have been too confusing for audiences
|
|
70
79
|
about 9 months ago
|
|
80
|
+
http://www.newscientist.com/article/dn26966-interstellars-true-black-hole-too-confusing.html#.VN3dJ_msXPo
|
|
71
81
|
|
|
72
82
|
|
|
73
83
|
webdev
|
|
74
84
|
https://www.reddit.com/r/webdev/comments/2vo5zs
|
|
75
85
|
Major security alert as 40,000 MongoDB databases left unsecured on the internet
|
|
76
86
|
about 9 months ago
|
|
87
|
+
http://news.hitb.org/content/major-security-alert-40000-mongodb-databases-left-unsecured-internet
|
|
77
88
|
|
|
78
89
|
|
|
79
90
|
vim
|
|
80
91
|
https://www.reddit.com/r/vim/comments/2tvq8u
|
|
81
92
|
Why does my shell prompt disappear when I install and use vim 7.4 (on CentOS 6)?
|
|
82
93
|
about 10 months ago
|
|
94
|
+
http://stackoverflow.com/q/28179589/28804
|
|
83
95
|
|
|
84
96
|
|
|
85
97
|
swift
|
|
86
98
|
https://www.reddit.com/r/swift/comments/2t55vj
|
|
87
99
|
Swift for CLI tools
|
|
88
100
|
about 10 months ago
|
|
101
|
+
https://speakerdeck.com/supermarin/swift-for-cli-tools
|
|
89
102
|
|
|
90
103
|
|
|
91
104
|
Games
|
|
92
105
|
https://www.reddit.com/r/Games/comments/2expgr
|
|
93
106
|
Chief Executive of Rovio, Maker of Angry Birds Game, to Step Down
|
|
94
107
|
about a year ago
|
|
108
|
+
http://www.nytimes.com/2014/08/30/technology/mikael-hed-chief-executive-of-angry-birds-maker-to-step-down.html
|
|
95
109
|
|
|
96
110
|
|
|
97
111
|
webdev
|
|
98
112
|
https://www.reddit.com/r/webdev/comments/2ejsyv
|
|
99
113
|
You have ruined HTML
|
|
100
114
|
about a year ago
|
|
115
|
+
http://blog.dantup.com/2014/08/you-have-ruined-html/
|
|
101
116
|
|
|
102
117
|
|
|
103
118
|
swift
|
|
104
119
|
https://www.reddit.com/r/swift/comments/2au1ki
|
|
105
120
|
A few thoughts on Swift
|
|
106
121
|
about a year ago
|
|
122
|
+
http://monkey-robot.com/2014/07/thoughts-on-swift/?utm_source=reddit&utm_medium=social&utm_campaign=Post%3A%2015%20July%202014
|
|
107
123
|
|
|
108
124
|
|
|
109
125
|
webdev
|
|
110
126
|
https://www.reddit.com/r/webdev/comments/29og3m
|
|
111
127
|
Sick of Ruby, dynamic typing, side effects, and basically object-oriented progra
|
|
112
128
|
about a year ago
|
|
129
|
+
https://blog.abevoelker.com/sick-of-ruby-dynamic-typing-side-effects-object-oriented-programming/
|
|
113
130
|
|
|
114
131
|
|
|
115
132
|
webdev
|
|
116
133
|
https://www.reddit.com/r/webdev/comments/28ziwz
|
|
117
134
|
Vim for people who think things like Vim are weird and hard
|
|
118
135
|
about a year ago
|
|
136
|
+
http://csswizardry.com/2014/06/vim-for-people-who-think-things-like-vim-are-weird-and-hard/
|
|
119
137
|
|
|
120
138
|
|
|
121
139
|
webdev
|
|
122
140
|
https://www.reddit.com/r/webdev/comments/27h6za
|
|
123
141
|
The emperor’s new clothes were built with Node.js
|
|
124
142
|
about a year ago
|
|
143
|
+
http://notes.ericjiang.com/posts/751
|
|
125
144
|
|
|
126
145
|
|
|
127
146
|
webdev
|
|
128
147
|
https://www.reddit.com/r/webdev/comments/26hm0m
|
|
129
148
|
Clojure, or how to put the spark back into your relationship with programming
|
|
130
149
|
about a year ago
|
|
150
|
+
http://monkey-robot.com/2014/05/clojure-a-retrospective/?utm_source=reddit&utm_medium=social&utm_campaign=Post%3A%2025%20May%202014
|
|
131
151
|
|
|
132
152
|
|
|
133
153
|
Clojure
|
|
134
154
|
https://www.reddit.com/r/Clojure/comments/26hlxb
|
|
135
155
|
Clojure: A Retrospective
|
|
136
156
|
about a year ago
|
|
157
|
+
http://monkey-robot.com/2014/05/clojure-a-retrospective/?utm_source=reddit&utm_medium=social&utm_campaign=Post%3A%2025%20May%202014
|
|
137
158
|
|
|
138
159
|
|
|
139
160
|
programming
|
|
140
161
|
https://www.reddit.com/r/programming/comments/26hlvt
|
|
141
162
|
Fresh perspectives: Learning new languages after you know (quite) a few
|
|
142
163
|
about a year ago
|
|
164
|
+
http://monkey-robot.com/2014/05/clojure-a-retrospective/?utm_source=reddit&utm_medium=social&utm_campaign=Post%3A%2025%20May%202014
|
|
143
165
|
|
|
144
166
|
|
|
145
167
|
webdev
|
|
@@ -152,12 +174,14 @@ Feature: Show posts
|
|
|
152
174
|
https://www.reddit.com/r/programming/comments/26562t
|
|
153
175
|
Erlang and code style: Musings on mostly defensive programming styles
|
|
154
176
|
about a year ago
|
|
177
|
+
https://medium.com/p/b5936dceb5e4
|
|
155
178
|
|
|
156
179
|
|
|
157
180
|
webdev
|
|
158
181
|
https://www.reddit.com/r/webdev/comments/25p2d8
|
|
159
182
|
Facebook: MVC Does Not Scale, Use Flux Instead
|
|
160
183
|
about a year ago
|
|
184
|
+
http://www.infoq.com/news/2014/05/facebook-mvc-flux
|
|
161
185
|
"""
|
|
162
186
|
|
|
163
187
|
Scenario: List posts when user has no submissions
|
|
@@ -179,48 +203,56 @@ Feature: Show posts
|
|
|
179
203
|
https://www.reddit.com/r/webdev/comments/35rtkx
|
|
180
204
|
The Future of Web Design is Hidden in the History of Architecture
|
|
181
205
|
about 6 months ago
|
|
206
|
+
https://medium.com/@sall/the-future-of-web-design-is-hidden-in-the-history-of-architecture-1cc93ea854d0
|
|
182
207
|
|
|
183
208
|
|
|
184
209
|
webdev
|
|
185
210
|
https://www.reddit.com/r/webdev/comments/32y92q
|
|
186
211
|
Microservices in Clojure
|
|
187
212
|
about 7 months ago
|
|
213
|
+
https://speakerdeck.com/kachayev/microservices-in-clojure
|
|
188
214
|
|
|
189
215
|
|
|
190
216
|
webdev
|
|
191
217
|
https://www.reddit.com/r/webdev/comments/2vo5zs
|
|
192
218
|
Major security alert as 40,000 MongoDB databases left unsecured on the internet
|
|
193
219
|
about 9 months ago
|
|
220
|
+
http://news.hitb.org/content/major-security-alert-40000-mongodb-databases-left-unsecured-internet
|
|
194
221
|
|
|
195
222
|
|
|
196
223
|
webdev
|
|
197
224
|
https://www.reddit.com/r/webdev/comments/2ejsyv
|
|
198
225
|
You have ruined HTML
|
|
199
226
|
about a year ago
|
|
227
|
+
http://blog.dantup.com/2014/08/you-have-ruined-html/
|
|
200
228
|
|
|
201
229
|
|
|
202
230
|
webdev
|
|
203
231
|
https://www.reddit.com/r/webdev/comments/29og3m
|
|
204
232
|
Sick of Ruby, dynamic typing, side effects, and basically object-oriented progra
|
|
205
233
|
about a year ago
|
|
234
|
+
https://blog.abevoelker.com/sick-of-ruby-dynamic-typing-side-effects-object-oriented-programming/
|
|
206
235
|
|
|
207
236
|
|
|
208
237
|
webdev
|
|
209
238
|
https://www.reddit.com/r/webdev/comments/28ziwz
|
|
210
239
|
Vim for people who think things like Vim are weird and hard
|
|
211
240
|
about a year ago
|
|
241
|
+
http://csswizardry.com/2014/06/vim-for-people-who-think-things-like-vim-are-weird-and-hard/
|
|
212
242
|
|
|
213
243
|
|
|
214
244
|
webdev
|
|
215
245
|
https://www.reddit.com/r/webdev/comments/27h6za
|
|
216
246
|
The emperor’s new clothes were built with Node.js
|
|
217
247
|
about a year ago
|
|
248
|
+
http://notes.ericjiang.com/posts/751
|
|
218
249
|
|
|
219
250
|
|
|
220
251
|
webdev
|
|
221
252
|
https://www.reddit.com/r/webdev/comments/26hm0m
|
|
222
253
|
Clojure, or how to put the spark back into your relationship with programming
|
|
223
254
|
about a year ago
|
|
255
|
+
http://monkey-robot.com/2014/05/clojure-a-retrospective/?utm_source=reddit&utm_medium=social&utm_campaign=Post%3A%2025%20May%202014
|
|
224
256
|
|
|
225
257
|
|
|
226
258
|
webdev
|
|
@@ -233,6 +265,7 @@ Feature: Show posts
|
|
|
233
265
|
https://www.reddit.com/r/webdev/comments/25p2d8
|
|
234
266
|
Facebook: MVC Does Not Scale, Use Flux Instead
|
|
235
267
|
about a year ago
|
|
268
|
+
http://www.infoq.com/news/2014/05/facebook-mvc-flux
|
|
236
269
|
"""
|
|
237
270
|
|
|
238
271
|
Scenario: Filter posts by subreddit when user has no submissions to that subreddit
|
data/lib/usaidwat/application.rb
CHANGED
|
@@ -81,7 +81,7 @@ module USaidWat
|
|
|
81
81
|
c.alias :l
|
|
82
82
|
c.option 'date', '--date FORMAT', 'Show dates in "absolute" or "relative" format'
|
|
83
83
|
c.option 'grep', '--grep STRING', 'Show only comments matching STRING'
|
|
84
|
-
c.option 'limit', '-n LIMIT', 'Only show n comments'
|
|
84
|
+
c.option 'limit', '--limit LIMIT', '-n LIMIT', 'Only show n comments'
|
|
85
85
|
c.option 'oneline', '--oneline', 'Output log in a more compact form'
|
|
86
86
|
c.option 'raw', '--raw', 'Print raw comment bodies'
|
|
87
87
|
|
data/lib/usaidwat/ext/string.rb
CHANGED
data/lib/usaidwat/formatter.rb
CHANGED
|
@@ -48,8 +48,9 @@ module USaidWat
|
|
|
48
48
|
out.write("\n\n\n") unless @count == 0
|
|
49
49
|
out.write("#{post.subreddit}\n".color(:green))
|
|
50
50
|
out.write("#{post_link(post)}\n".color(:yellow))
|
|
51
|
-
out.write("#{post.title.strip.truncate(cols)}\n".color(:magenta))
|
|
51
|
+
out.write("#{post.title.strip.transform_html_entities.truncate(cols)}\n".color(:magenta))
|
|
52
52
|
out.write("#{post_date(post)}".color(:blue))
|
|
53
|
+
out.write("\n#{post.url}") unless post.url.end_with?(post.permalink)
|
|
53
54
|
@count += 1
|
|
54
55
|
out.rewind
|
|
55
56
|
out.read
|
|
@@ -73,7 +74,7 @@ module USaidWat
|
|
|
73
74
|
out.write("\n\n") unless @count == 0
|
|
74
75
|
out.write("#{comment.subreddit}\n".color(:green))
|
|
75
76
|
out.write("#{comment_link(comment)}\n".color(:yellow))
|
|
76
|
-
out.write("#{comment.link_title.strip.truncate(cols)}\n".color(:magenta))
|
|
77
|
+
out.write("#{comment.link_title.strip.transform_html_entities.truncate(cols)}\n".color(:magenta))
|
|
77
78
|
out.write("#{comment_date(comment)}".color(:blue))
|
|
78
79
|
out.write(" \u2022 ".color(:cyan))
|
|
79
80
|
out.write(sprintf("%+d\n", comment_karma(comment)).color(:blue))
|
|
@@ -128,7 +129,7 @@ module USaidWat
|
|
|
128
129
|
out = StringIO.new
|
|
129
130
|
subreddit = comment.subreddit
|
|
130
131
|
cols -= subreddit.length + 1
|
|
131
|
-
title = comment.link_title.strip.truncate(cols)
|
|
132
|
+
title = comment.link_title.strip.transform_html_entities.truncate(cols)
|
|
132
133
|
key = "#{subreddit} #{title}"
|
|
133
134
|
if !seen?(key)
|
|
134
135
|
out.write("#{subreddit}".color(:green))
|
data/lib/usaidwat/service.rb
CHANGED
|
@@ -17,7 +17,7 @@ module USaidWat
|
|
|
17
17
|
end
|
|
18
18
|
|
|
19
19
|
class MockSubmission
|
|
20
|
-
attr_reader :subreddit, :title, :created_utc, :permalink
|
|
20
|
+
attr_reader :subreddit, :title, :created_utc, :permalink, :url
|
|
21
21
|
|
|
22
22
|
def initialize(dict)
|
|
23
23
|
data = dict['data']
|
|
@@ -25,6 +25,7 @@ module USaidWat
|
|
|
25
25
|
@title = data['title']
|
|
26
26
|
@created_utc = data['created_utc']
|
|
27
27
|
@permalink = data['permalink']
|
|
28
|
+
@url = data['url']
|
|
28
29
|
end
|
|
29
30
|
end
|
|
30
31
|
|
data/lib/usaidwat/version.rb
CHANGED
|
@@ -103,9 +103,30 @@ module USaidWat
|
|
|
103
103
|
it "should return a string containing the formatted post" do
|
|
104
104
|
post = double("post")
|
|
105
105
|
expect(post).to receive(:subreddit).and_return("Games")
|
|
106
|
-
expect(post).to receive(:permalink).and_return("/r/Games/comments/3ovldc/the_xbox_one_is_garbage_and_the_future_is_bullshit/")
|
|
106
|
+
expect(post).to receive(:permalink).twice.and_return("/r/Games/comments/3ovldc/the_xbox_one_is_garbage_and_the_future_is_bullshit/")
|
|
107
107
|
expect(post).to receive(:title).and_return("The Xbox One Is Garbage And The Future Is Bullshit")
|
|
108
108
|
expect(post).to receive(:created_utc).and_return(1444928064)
|
|
109
|
+
expect(post).to receive(:url).twice.and_return("http://adequateman.deadspin.com/the-xbox-one-is-garbage-and-the-future-is-bullshit-1736054579")
|
|
110
|
+
expected = <<-EXPECTED
|
|
111
|
+
Games
|
|
112
|
+
https://www.reddit.com/r/Games/comments/3ovldc
|
|
113
|
+
The Xbox One Is Garbage And The Future Is Bullshit
|
|
114
|
+
about 1 month ago
|
|
115
|
+
http://adequateman.deadspin.com/the-xbox-one-is-garbage-and-the-future-is-bullshit-1736054579
|
|
116
|
+
EXPECTED
|
|
117
|
+
expected = expected.strip
|
|
118
|
+
actual = formatter.format(post).delete_ansi_color_codes
|
|
119
|
+
expect(actual).to eq(expected)
|
|
120
|
+
end
|
|
121
|
+
|
|
122
|
+
it "should not include the URL if it is the same as the permalink" do
|
|
123
|
+
permalink = "/r/Games/comments/3ovldc/the_xbox_one_is_garbage_and_the_future_is_bullshit/"
|
|
124
|
+
post = double("post")
|
|
125
|
+
expect(post).to receive(:subreddit).and_return("Games")
|
|
126
|
+
expect(post).to receive(:permalink).twice.and_return(permalink)
|
|
127
|
+
expect(post).to receive(:title).and_return("The Xbox One Is Garbage And The Future Is Bullshit")
|
|
128
|
+
expect(post).to receive(:created_utc).and_return(1444928064)
|
|
129
|
+
expect(post).to receive(:url).and_return("https://www.reddit.com#{permalink}")
|
|
109
130
|
expected = <<-EXPECTED
|
|
110
131
|
Games
|
|
111
132
|
https://www.reddit.com/r/Games/comments/3ovldc
|
|
@@ -120,14 +141,16 @@ EXPECTED
|
|
|
120
141
|
it "should print two spaces between posts" do
|
|
121
142
|
post1 = double("first post")
|
|
122
143
|
expect(post1).to receive(:subreddit).and_return("Games")
|
|
123
|
-
expect(post1).to receive(:permalink).and_return("/r/Games/comments/3ovldc/the_xbox_one_is_garbage_and_the_future_is_bullshit/")
|
|
144
|
+
expect(post1).to receive(:permalink).twice.and_return("/r/Games/comments/3ovldc/the_xbox_one_is_garbage_and_the_future_is_bullshit/")
|
|
124
145
|
expect(post1).to receive(:title).and_return("The Xbox One Is Garbage And The Future Is Bullshit")
|
|
125
146
|
expect(post1).to receive(:created_utc).and_return(1444928064)
|
|
147
|
+
expect(post1).to receive(:url).twice.and_return("http://adequateman.deadspin.com/the-xbox-one-is-garbage-and-the-future-is-bullshit-1736054579")
|
|
126
148
|
post2 = double("second post")
|
|
127
149
|
expect(post2).to receive(:subreddit).and_return("technology")
|
|
128
|
-
expect(post2).to receive(:permalink).and_return("/r/technology/comments/3o0vrh/mozilla_lays_out_a_proposed_set_of_rules_for/")
|
|
150
|
+
expect(post2).to receive(:permalink).twice.and_return("/r/technology/comments/3o0vrh/mozilla_lays_out_a_proposed_set_of_rules_for/")
|
|
129
151
|
expect(post2).to receive(:title).and_return("Mozilla lays out a proposed set of rules for content blockers")
|
|
130
152
|
expect(post2).to receive(:created_utc).and_return(1444340278)
|
|
153
|
+
expect(post2).to receive(:url).twice.and_return("https://blog.mozilla.org/blog/2015/10/07/proposed-principles-for-content-blocking/")
|
|
131
154
|
s = formatter.format(post1)
|
|
132
155
|
s = formatter.format(post2)
|
|
133
156
|
lines = s.split("\n")
|
|
@@ -140,14 +163,16 @@ EXPECTED
|
|
|
140
163
|
it "should truncate titles to 80 characters" do
|
|
141
164
|
post = double("post")
|
|
142
165
|
expect(post).to receive(:subreddit).and_return("webdev")
|
|
143
|
-
expect(post).to receive(:permalink).and_return("/r/webdev/comments/29og3m/sick_of_ruby_dynamic_typing_side_effects_and/")
|
|
166
|
+
expect(post).to receive(:permalink).twice.and_return("/r/webdev/comments/29og3m/sick_of_ruby_dynamic_typing_side_effects_and/")
|
|
144
167
|
expect(post).to receive(:title).and_return("Sick of Ruby, dynamic typing, side effects, and basically object-oriented programming")
|
|
145
168
|
expect(post).to receive(:created_utc).and_return(1404331670)
|
|
169
|
+
expect(post).to receive(:url).twice.and_return("https://blog.abevoelker.com/sick-of-ruby-dynamic-typing-side-effects-object-oriented-programming/")
|
|
146
170
|
expected = <<-EXPECTED
|
|
147
171
|
webdev
|
|
148
172
|
https://www.reddit.com/r/webdev/comments/29og3m
|
|
149
173
|
Sick of Ruby, dynamic typing, side effects, and basically object-oriented progra
|
|
150
174
|
about a year ago
|
|
175
|
+
https://blog.abevoelker.com/sick-of-ruby-dynamic-typing-side-effects-object-oriented-programming/
|
|
151
176
|
EXPECTED
|
|
152
177
|
expected = expected.strip
|
|
153
178
|
actual = formatter.format(post).delete_ansi_color_codes
|
|
@@ -231,6 +256,21 @@ EXPECTED
|
|
|
231
256
|
lines = s.split("\n")
|
|
232
257
|
expect(lines[-1]).to eq("It has two lines.")
|
|
233
258
|
end
|
|
259
|
+
|
|
260
|
+
it "should format HTML entities in post titles" do
|
|
261
|
+
comment = double("first comment")
|
|
262
|
+
expect(comment).to receive(:subreddit).twice.and_return("guitars")
|
|
263
|
+
expect(comment).to receive(:link_id).and_return("t3_13f783")
|
|
264
|
+
expect(comment).to receive(:id).and_return("c73qhxi")
|
|
265
|
+
expect(comment).to receive(:created_utc).and_return(1433378314.0)
|
|
266
|
+
expect(comment).to receive(:ups).and_return(12)
|
|
267
|
+
expect(comment).to receive(:downs).and_return(1)
|
|
268
|
+
expect(comment).to receive(:link_title).and_return("[GEAR] My 06 Fender EJ Strat, an R&D prototype sold at NAMM")
|
|
269
|
+
expect(comment).to receive(:body).and_return("Lorem ipsum")
|
|
270
|
+
s = formatter.format(comment).delete_ansi_color_codes
|
|
271
|
+
lines = s.split("\n")
|
|
272
|
+
expect(lines[2]).to eq("[GEAR] My 06 Fender EJ Strat, an R&D prototype sold at NAMM")
|
|
273
|
+
end
|
|
234
274
|
end
|
|
235
275
|
end
|
|
236
276
|
|
|
@@ -255,6 +295,15 @@ EXPECTED
|
|
|
255
295
|
expect(actual).to eq(expected)
|
|
256
296
|
end
|
|
257
297
|
|
|
298
|
+
it "should format HTML entities in titles" do
|
|
299
|
+
comment = double("comment")
|
|
300
|
+
expect(comment).to receive(:subreddit).and_return("guitars")
|
|
301
|
+
expect(comment).to receive(:link_title).and_return("[GEAR] My 06 Fender EJ Strat, an R&D prototype sold at NAMM")
|
|
302
|
+
expected = "guitars [GEAR] My 06 Fender EJ Strat, an R&D prototype sold at NAMM\n"
|
|
303
|
+
actual = formatter.format(comment).delete_ansi_color_codes
|
|
304
|
+
expect(actual).to eq(expected)
|
|
305
|
+
end
|
|
306
|
+
|
|
258
307
|
it "should return an empty string if a comment has already been printed" do
|
|
259
308
|
comment1 = double("comment")
|
|
260
309
|
comment2 = double("comment")
|
|
@@ -19,6 +19,23 @@ module USaidWat
|
|
|
19
19
|
end
|
|
20
20
|
end
|
|
21
21
|
|
|
22
|
+
describe "#transform_html_entities" do
|
|
23
|
+
it "transforms & to &" do
|
|
24
|
+
s = "this & that"
|
|
25
|
+
expect(s.transform_html_entities).to eq("this & that")
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
it "transform < to <" do
|
|
29
|
+
s = "chocolate < vanilla"
|
|
30
|
+
expect(s.transform_html_entities).to eq("chocolate < vanilla")
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
it "transforms > to >" do
|
|
34
|
+
s = "cats > dogs"
|
|
35
|
+
expect(s.transform_html_entities).to eq("cats > dogs")
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
|
|
22
39
|
describe "#pluralize" do
|
|
23
40
|
it "should not append an 's' to a singular noun" do
|
|
24
41
|
s = "dog"
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: usaidwat
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.4.
|
|
4
|
+
version: 1.4.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Michael Dippery
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2016-
|
|
11
|
+
date: 2016-02-18 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: downterm
|
|
@@ -226,9 +226,9 @@ homepage: https://github.com/mdippery/usaidwat
|
|
|
226
226
|
licenses:
|
|
227
227
|
- MIT
|
|
228
228
|
metadata:
|
|
229
|
-
build_date: 2016-
|
|
230
|
-
commit: v1.4.
|
|
231
|
-
commit_hash:
|
|
229
|
+
build_date: 2016-02-17 21:16:59 PST
|
|
230
|
+
commit: v1.4.1
|
|
231
|
+
commit_hash: 0dc8b829187f42a68619a70fbca57b2130f8099f
|
|
232
232
|
post_install_message:
|
|
233
233
|
rdoc_options: []
|
|
234
234
|
require_paths:
|