usaidwat 1.2.0 → 1.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/features/log.feature +81 -0
- data/lib/usaidwat/formatter.rb +32 -14
- data/lib/usaidwat/terminal.rb +19 -0
- data/lib/usaidwat/version.rb +1 -1
- data/lib/usaidwat.rb +1 -0
- data/spec/usaidwat/formatter_spec.rb +12 -0
- data/spec/usaidwat/terminal_spec.rb +21 -0
- data/usaidwat.gemspec +3 -3
- metadata +27 -24
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a8e0d58a8806f6f9f2de8668e04b5e6deddee9b2
|
4
|
+
data.tar.gz: f2d2e61621eb9997243031e12ee78c087569fa04
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d98a2134b5857f5b6e1e2e725ae5b0e00f371564828b33ad99ed8a35ef0c28ad548c784cf5aafd4c15acad00468a0639a6d6d0f7082953801d825662d86ecf12
|
7
|
+
data.tar.gz: a74bbb9e8aaef91c4d07a9a8c933e31d3bbf6c68ad17307d5216b495d52950994b08598ccdba462f1e9bcefe77502af45a5654fcaaa452f4ceeac208ff4f8fd7
|
data/features/log.feature
CHANGED
@@ -287,6 +287,87 @@ Feature: Browse comments
|
|
287
287
|
nyc NYC taxi roof lights get overhaul - A light simply will mean the cab is ava
|
288
288
|
"""
|
289
289
|
|
290
|
+
Scenario: One-line comments should be collapsed into unique titles
|
291
|
+
Given the Reddit service returns comments for the user "mipadi"
|
292
|
+
And time is frozen at Jun 24, 2015 11:05 AM
|
293
|
+
When I run `usaidwat log --oneline mipadi`
|
294
|
+
Then it should pass with exactly:
|
295
|
+
"""
|
296
|
+
wikipedia Heisenbug: a software bug that seems to disappear or alter its behavio
|
297
|
+
nyc NYC taxi roof lights get overhaul - A light simply will mean the cab is ava
|
298
|
+
worldnews Palestinians win upgraded UN status by wide margin
|
299
|
+
AskReddit Do colleges actually teach students how to think critically? Or even t
|
300
|
+
AskReddit I'm from Tennessee and most of our jokes are geared toward Mississippi
|
301
|
+
AskReddit Today I was going 80mph in a 55 when an unmarked police car pulled up
|
302
|
+
AskReddit Why should I pay for a college degree when all of the information they
|
303
|
+
apple iTunes 11 finally available for download - The Verge
|
304
|
+
Games The True Story of Battlefield 3, the Battlefield Franchise, Its Community,
|
305
|
+
AskReddit Professors/Students of Reddit- What are your feelings towards shit Pro
|
306
|
+
books I was saddened hearing this story on the Takeaway this morning- "Is litera
|
307
|
+
AskReddit My friends give me crap about not watching "good" movies. Such as I've
|
308
|
+
AskReddit Reddit, what is the worst thing about your city?
|
309
|
+
AskReddit What is it like to own a decommissioned police car?
|
310
|
+
AskReddit When Microsoft was found guilty of violating antitrust law by bundling
|
311
|
+
django I need a little help understanding billing and payment
|
312
|
+
programming Why software engineers are vastly undervalued
|
313
|
+
AskReddit Is Germany racist?
|
314
|
+
apple Report: Apple bumps Android from top spot in U.S. smartphone market on str
|
315
|
+
AskReddit I got stood up by a girl for the first date. I have to go to work tomm
|
316
|
+
AskReddit How much does 'life' costs in your country/city/area?
|
317
|
+
programming Apple's proposal for modules in C(++) [PDF slides]
|
318
|
+
AskReddit Half of my facebook newsfeed is of people posting this quoted copyrigh
|
319
|
+
AskReddit I'm lying in my warm bed with my fiance as my jetpack while Redditing
|
320
|
+
AskReddit I found out tonight that my dad's great grandfather was a Civil War PO
|
321
|
+
AskReddit This morning on the way home from walking my dogs I shit myself. What'
|
322
|
+
AskReddit Is it just me or do women have less genuine friendships than men?
|
323
|
+
programming RubyMonk
|
324
|
+
AskReddit How many government officials would have to die in an accident or atta
|
325
|
+
programming The X.Org CodingStyle
|
326
|
+
AskReddit How would you stop people from pushing others into oncoming subways? C
|
327
|
+
worldnews How Israeli Drone Pilots Made Their Life-and-Death Choices Over Gaza -
|
328
|
+
AskReddit This entire semester I thought my TA was a girl named Kayla...it's a b
|
329
|
+
AskReddit Why is it that mathematical "illiteracy" is ok, but being unable to re
|
330
|
+
AskReddit What's your brand of cigarette, and why?
|
331
|
+
AskReddit Accomplished Adults of Reddit: Honestly, is it more important to do wh
|
332
|
+
AskReddit I m a nutritionist. I often over hear people talk about nutrition like
|
333
|
+
personalfinance What's the most expensive mistake you ever made financially?
|
334
|
+
AskReddit I want to quit college and enlist in the Air Force. Am I throwing away
|
335
|
+
AskReddit Reddit, my boyfriend is abroad for a year. I'm trying to subtly work f
|
336
|
+
AskReddit Why is everyone naming Israel as the "aggressor"?? Am I missing someth
|
337
|
+
programming Why Brit Ruby 2013 was cancelled and why this is not ok — Gist
|
338
|
+
battlefield3 Can't argue with those rules..
|
339
|
+
AskReddit Who thinks "Mens Gift Ideas" are always super lame? Men of reddit what
|
340
|
+
redditcasual Submissions for new clan tag...
|
341
|
+
programming How To Package Your Python Code - The Right Way…
|
342
|
+
programming Hounded By Recruiters, Coders Put Themselves Up For Auction - Forbes
|
343
|
+
photography Do you travel? If so, what camera do you use/prefer?
|
344
|
+
AskReddit I want to go to college for music even though it's not the most financ
|
345
|
+
AskReddit Reddit, what popular opinions about films do you think the complete op
|
346
|
+
AskReddit If someone writes "Should of" instead of "Should have", I immediately
|
347
|
+
AskReddit I'm A Mixed Race Teen (Black Dad, White Mum) And I Constantly Get Peop
|
348
|
+
AskReddit Do the James Bond films features occur in any sort of chronological or
|
349
|
+
apple iMessage down?
|
350
|
+
AskReddit Reddit, how old were you when you officially moved out? I'm 24 and fee
|
351
|
+
AskReddit Guys, what do girls wear that you absolutely can't stand?
|
352
|
+
AskReddit Looking into getting Windows 8 (Don't really like the looks of it from
|
353
|
+
AskReddit My stepdaughter is acting (sexually) inappropriately around me - what
|
354
|
+
programming FizzBuzz Still Works
|
355
|
+
AskReddit Reddit, what is your most expensive mistake?
|
356
|
+
AskReddit Were you a part of the Occupy Wall Street movement?
|
357
|
+
AskReddit I'm coming up on my 6th year free from cocaine. Anybody else had or h
|
358
|
+
programming UserManager.isUserAGoat() -- Oh you silly goat
|
359
|
+
AskReddit in regards to choosing a future career, should salary or enjoy-ability
|
360
|
+
AskReddit Guy I like asks me out to have coffee; gives me tips on how to get a b
|
361
|
+
AskReddit Men of Reddit: How much pressure is there for you guys to look good?
|
362
|
+
AskReddit Reddit, what custom ringtone do you use?
|
363
|
+
AskReddit Reddit: A lot of talk happens here about taxing the rich at a higher p
|
364
|
+
AskReddit I'm dropping out of college and joining the workforce for a while, hav
|
365
|
+
AskReddit What ever happened to the cent sign (¢)?
|
366
|
+
AskReddit I ask you this reddit, what is your most prized possession in this wor
|
367
|
+
AskReddit Reddit seems to hate Papa Johns and Chik-Fil-A with a passion. What ar
|
368
|
+
AskReddit Men of Reddit: Do you get turned off when a girl says she is a feminis
|
369
|
+
"""
|
370
|
+
|
290
371
|
Scenario: Search for a specific comment
|
291
372
|
Given the Reddit service returns comments for the user "mipadi"
|
292
373
|
And time is frozen at Jun 24, 2015 11:05 AM
|
data/lib/usaidwat/formatter.rb
CHANGED
@@ -2,8 +2,8 @@ require 'date'
|
|
2
2
|
require 'downterm'
|
3
3
|
require 'rainbow/ext/string'
|
4
4
|
require 'redcarpet'
|
5
|
+
require 'set'
|
5
6
|
require 'stringio'
|
6
|
-
require 'tty-screen'
|
7
7
|
require 'usaidwat/ext/string'
|
8
8
|
require 'usaidwat/ext/time'
|
9
9
|
|
@@ -35,19 +35,12 @@ module USaidWat
|
|
35
35
|
|
36
36
|
protected
|
37
37
|
|
38
|
-
|
39
|
-
|
40
|
-
|
38
|
+
def tty
|
39
|
+
@tty ||= USaidWat::Application::Terminal.new
|
40
|
+
end
|
41
41
|
end
|
42
42
|
|
43
43
|
class CommentFormatter < BaseFormatter
|
44
|
-
def initialize(options = {})
|
45
|
-
@markdown = Redcarpet::Markdown.new(Downterm::Render::Terminal, :autolink => true,
|
46
|
-
:strikethrough => true,
|
47
|
-
:superscript => true)
|
48
|
-
super
|
49
|
-
end
|
50
|
-
|
51
44
|
def format(comment)
|
52
45
|
cols = tty.width
|
53
46
|
out = StringIO.new
|
@@ -66,9 +59,15 @@ module USaidWat
|
|
66
59
|
end
|
67
60
|
|
68
61
|
private
|
62
|
+
def markdown
|
63
|
+
@markdown ||= Redcarpet::Markdown.new(Downterm::Render::Terminal, :autolink => true,
|
64
|
+
:strikethrough => true,
|
65
|
+
:superscript => true)
|
66
|
+
end
|
67
|
+
|
69
68
|
def comment_body(comment)
|
70
69
|
body = comment.body.strip
|
71
|
-
body =
|
70
|
+
body = markdown.render(body) unless raw?
|
72
71
|
if pattern?
|
73
72
|
body.highlight(pattern)
|
74
73
|
else
|
@@ -103,11 +102,30 @@ module USaidWat
|
|
103
102
|
out = StringIO.new
|
104
103
|
subreddit = comment.subreddit
|
105
104
|
cols -= subreddit.length + 1
|
106
|
-
|
107
|
-
|
105
|
+
title = comment.link_title.strip.truncate(cols)
|
106
|
+
key = "#{subreddit} #{title}"
|
107
|
+
if !seen?(key)
|
108
|
+
out.write("#{subreddit}".color(:green))
|
109
|
+
out.write(" #{title}\n")
|
110
|
+
end
|
111
|
+
mark_seen(key)
|
108
112
|
out.rewind
|
109
113
|
out.read
|
110
114
|
end
|
115
|
+
|
116
|
+
private
|
117
|
+
|
118
|
+
def comments
|
119
|
+
@comments ||= Set.new
|
120
|
+
end
|
121
|
+
|
122
|
+
def mark_seen(comment)
|
123
|
+
comments << comment
|
124
|
+
end
|
125
|
+
|
126
|
+
def seen?(comment)
|
127
|
+
comments.include?(comment)
|
128
|
+
end
|
111
129
|
end
|
112
130
|
end
|
113
131
|
end
|
data/lib/usaidwat/version.rb
CHANGED
data/lib/usaidwat.rb
CHANGED
@@ -186,6 +186,18 @@ EXPECTED
|
|
186
186
|
actual = formatter.format(comment).delete_ansi_color_codes
|
187
187
|
expect(actual).to eq(expected)
|
188
188
|
end
|
189
|
+
|
190
|
+
it "should return an empty string if a comment has already been printed" do
|
191
|
+
comment1 = double("comment")
|
192
|
+
comment2 = double("comment")
|
193
|
+
expect(comment1).to receive(:subreddit).and_return("programming")
|
194
|
+
expect(comment1).to receive(:link_title).and_return("Why Brit Ruby 2013 was cancelled and why this is not ok - Gist")
|
195
|
+
_ = formatter.format(comment1).delete_ansi_color_codes
|
196
|
+
expect(comment2).to receive(:subreddit).and_return("programming")
|
197
|
+
expect(comment2).to receive(:link_title).and_return("Why Brit Ruby 2013 was cancelled and why this is not ok - Gist")
|
198
|
+
actual = formatter.format(comment2).delete_ansi_color_codes
|
199
|
+
expect(actual).to eq("")
|
200
|
+
end
|
189
201
|
end
|
190
202
|
end
|
191
203
|
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
module USaidWat
|
4
|
+
module Application
|
5
|
+
describe Terminal do
|
6
|
+
let (:terminal) { Terminal.new }
|
7
|
+
|
8
|
+
describe "#width" do
|
9
|
+
it "should return a positive integer" do
|
10
|
+
expect(terminal.width).to be > 0
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
describe "#height" do
|
15
|
+
it "should return a positive integer" do
|
16
|
+
expect(terminal.height).to be > 0
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
data/usaidwat.gemspec
CHANGED
@@ -28,14 +28,14 @@ Gem::Specification.new do |gem|
|
|
28
28
|
|
29
29
|
gem.required_ruby_version = '>= 1.9.3'
|
30
30
|
|
31
|
-
gem.add_runtime_dependency('downterm', '~> 0.1.
|
31
|
+
gem.add_runtime_dependency('downterm', '~> 0.1.3')
|
32
|
+
gem.add_runtime_dependency('highline', '~> 1.7')
|
32
33
|
gem.add_runtime_dependency('mercenary', '~> 0.3.5')
|
33
34
|
gem.add_runtime_dependency('rainbow', '~> 2.0')
|
34
35
|
gem.add_runtime_dependency('snooby', '~> 0.1.5')
|
35
36
|
gem.add_runtime_dependency('sysexits', '~> 1.2')
|
36
|
-
gem.add_runtime_dependency('tty-screen', '~> 0.4.0')
|
37
37
|
|
38
|
-
gem.add_development_dependency('aruba', '~> 0.9
|
38
|
+
gem.add_development_dependency('aruba', '~> 0.9')
|
39
39
|
gem.add_development_dependency('cucumber', '~> 2.0')
|
40
40
|
gem.add_development_dependency('rspec', '~> 3.2')
|
41
41
|
gem.add_development_dependency('timecop', '~> 0.8.0')
|
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
|
+
version: 1.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Michael Dippery
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-11-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: downterm
|
@@ -16,14 +16,28 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 0.1.
|
19
|
+
version: 0.1.3
|
20
20
|
type: :runtime
|
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: 0.1.
|
26
|
+
version: 0.1.3
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: highline
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1.7'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.7'
|
27
41
|
- !ruby/object:Gem::Dependency
|
28
42
|
name: mercenary
|
29
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -80,34 +94,20 @@ dependencies:
|
|
80
94
|
- - "~>"
|
81
95
|
- !ruby/object:Gem::Version
|
82
96
|
version: '1.2'
|
83
|
-
- !ruby/object:Gem::Dependency
|
84
|
-
name: tty-screen
|
85
|
-
requirement: !ruby/object:Gem::Requirement
|
86
|
-
requirements:
|
87
|
-
- - "~>"
|
88
|
-
- !ruby/object:Gem::Version
|
89
|
-
version: 0.4.0
|
90
|
-
type: :runtime
|
91
|
-
prerelease: false
|
92
|
-
version_requirements: !ruby/object:Gem::Requirement
|
93
|
-
requirements:
|
94
|
-
- - "~>"
|
95
|
-
- !ruby/object:Gem::Version
|
96
|
-
version: 0.4.0
|
97
97
|
- !ruby/object:Gem::Dependency
|
98
98
|
name: aruba
|
99
99
|
requirement: !ruby/object:Gem::Requirement
|
100
100
|
requirements:
|
101
101
|
- - "~>"
|
102
102
|
- !ruby/object:Gem::Version
|
103
|
-
version: 0.9
|
103
|
+
version: '0.9'
|
104
104
|
type: :development
|
105
105
|
prerelease: false
|
106
106
|
version_requirements: !ruby/object:Gem::Requirement
|
107
107
|
requirements:
|
108
108
|
- - "~>"
|
109
109
|
- !ruby/object:Gem::Version
|
110
|
-
version: 0.9
|
110
|
+
version: '0.9'
|
111
111
|
- !ruby/object:Gem::Dependency
|
112
112
|
name: cucumber
|
113
113
|
requirement: !ruby/object:Gem::Requirement
|
@@ -201,6 +201,7 @@ files:
|
|
201
201
|
- lib/usaidwat/formatter.rb
|
202
202
|
- lib/usaidwat/pager.rb
|
203
203
|
- lib/usaidwat/service.rb
|
204
|
+
- lib/usaidwat/terminal.rb
|
204
205
|
- lib/usaidwat/version.rb
|
205
206
|
- spec/spec_helper.rb
|
206
207
|
- spec/usaidwat/algo_spec.rb
|
@@ -209,15 +210,16 @@ files:
|
|
209
210
|
- spec/usaidwat/formatter_spec.rb
|
210
211
|
- spec/usaidwat/service_spec.rb
|
211
212
|
- spec/usaidwat/string_spec.rb
|
213
|
+
- spec/usaidwat/terminal_spec.rb
|
212
214
|
- spec/usaidwat/time_spec.rb
|
213
215
|
- usaidwat.gemspec
|
214
216
|
homepage: https://github.com/mdippery/usaidwat
|
215
217
|
licenses:
|
216
218
|
- MIT
|
217
219
|
metadata:
|
218
|
-
build_date: 2015-
|
219
|
-
commit: v1.
|
220
|
-
commit_hash:
|
220
|
+
build_date: 2015-11-03 19:55:52 PST
|
221
|
+
commit: v1.3.0
|
222
|
+
commit_hash: 2ac920497d08c42b67f40bda4e78496e1b9ad6c4
|
221
223
|
post_install_message:
|
222
224
|
rdoc_options: []
|
223
225
|
require_paths:
|
@@ -234,7 +236,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
234
236
|
version: '0'
|
235
237
|
requirements: []
|
236
238
|
rubyforge_project:
|
237
|
-
rubygems_version: 2.4.5
|
239
|
+
rubygems_version: 2.4.5.1
|
238
240
|
signing_key:
|
239
241
|
specification_version: 4
|
240
242
|
summary: Answers the age-old question, "Where does a Redditor comment the most?"
|
@@ -259,4 +261,5 @@ test_files:
|
|
259
261
|
- spec/usaidwat/formatter_spec.rb
|
260
262
|
- spec/usaidwat/service_spec.rb
|
261
263
|
- spec/usaidwat/string_spec.rb
|
264
|
+
- spec/usaidwat/terminal_spec.rb
|
262
265
|
- spec/usaidwat/time_spec.rb
|