usaidwat 1.4.1 → 1.4.2
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 +32 -0
- data/lib/usaidwat/application.rb +3 -1
- data/lib/usaidwat/formatter.rb +16 -2
- data/lib/usaidwat/version.rb +1 -1
- data/spec/usaidwat/formatter_spec.rb +15 -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: f60bbafb7dc38ce3ba607557393b5be840110def
|
4
|
+
data.tar.gz: 265fc8c863875b82178991a44f3e11cb040e00e7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0601d41a7aefeda88672eba637015ad703de34618cf41535938d4f8d83e72a077bbebfef0317938be94d88498acc95395ee2f46244d6a91fc301fc5a49d4d0d9
|
7
|
+
data.tar.gz: b20001b8c0a9fee51df926b464d90b51922a244028d9124119f2803e573de2935ba22551c338ffb71e13c177348bd89fb68c2574c688d0e4fb853dfc7dfb8cb7
|
data/features/log.feature
CHANGED
@@ -65,7 +65,7 @@ Feature: Browse comments
|
|
65
65
|
wikipedia
|
66
66
|
http://www.reddit.com/r/wikipedia/comments/142t4w/z/c79peed
|
67
67
|
Heisenbug: a software bug that seems to disappear or alter its behavior when one
|
68
|
-
1 Dec 2012 12:14 PM • +1
|
68
|
+
Sat, 1 Dec 2012, 12:14 PM • +1
|
69
69
|
|
70
70
|
Yep. My first experience with a Heisenbug occurred in a C++ program, and disappeared when I tried to print a variable with printf (only to reappear when that call was removed).
|
71
71
|
|
@@ -73,7 +73,7 @@ Feature: Browse comments
|
|
73
73
|
nyc
|
74
74
|
http://www.reddit.com/r/nyc/comments/141zqc/z/c79dxg6
|
75
75
|
NYC taxi roof lights get overhaul - A light simply will mean the cab is availab
|
76
|
-
30 Nov 2012 4:44 PM • +2
|
76
|
+
Fri, 30 Nov 2012, 4:44 PM • +2
|
77
77
|
|
78
78
|
It has a fare when the lights are off.
|
79
79
|
|
@@ -81,7 +81,7 @@ Feature: Browse comments
|
|
81
81
|
worldnews
|
82
82
|
http://www.reddit.com/r/worldnews/comments/140mra/z/c797jq4
|
83
83
|
Palestinians win upgraded UN status by wide margin
|
84
|
-
30 Nov 2012 10:09 AM • +1
|
84
|
+
Fri, 30 Nov 2012, 10:09 AM • +1
|
85
85
|
|
86
86
|
The Judgment of Solomon Accords.
|
87
87
|
"""
|
data/features/posts.feature
CHANGED
@@ -184,6 +184,38 @@ Feature: Show posts
|
|
184
184
|
http://www.infoq.com/news/2014/05/facebook-mvc-flux
|
185
185
|
"""
|
186
186
|
|
187
|
+
Scenario: List posts in a compact form
|
188
|
+
Given the Reddit service returns posts for the user "mipadi"
|
189
|
+
When I run `usaidwat posts log --oneline mipadi`
|
190
|
+
Then it should pass with:
|
191
|
+
"""
|
192
|
+
short Science Says Being Short Makes You Depressed
|
193
|
+
Games The Xbox One Is Garbage And The Future Is Bullshit
|
194
|
+
technology Mozilla lays out a proposed set of rules for content blockers
|
195
|
+
apple Mozilla lays out a set of proposed rules for content blocking
|
196
|
+
vim Vim setup for Markdown
|
197
|
+
django Deploy Django projects using git push
|
198
|
+
webdev The Future of Web Design is Hidden in the History of Architecture
|
199
|
+
swift Does Swift make native app development easier?
|
200
|
+
webdev Microservices in Clojure
|
201
|
+
movies Interstellar's true black hole would have been too confusing for audience
|
202
|
+
webdev Major security alert as 40,000 MongoDB databases left unsecured on the in
|
203
|
+
vim Why does my shell prompt disappear when I install and use vim 7.4 (on CentOS
|
204
|
+
swift Swift for CLI tools
|
205
|
+
Games Chief Executive of Rovio, Maker of Angry Birds Game, to Step Down
|
206
|
+
webdev You have ruined HTML
|
207
|
+
swift A few thoughts on Swift
|
208
|
+
webdev Sick of Ruby, dynamic typing, side effects, and basically object-oriented
|
209
|
+
webdev Vim for people who think things like Vim are weird and hard
|
210
|
+
webdev The emperor’s new clothes were built with Node.js
|
211
|
+
webdev Clojure, or how to put the spark back into your relationship with program
|
212
|
+
Clojure Clojure: A Retrospective
|
213
|
+
programming Fresh perspectives: Learning new languages after you know (quite) a
|
214
|
+
webdev I created a tool for sampling Reddit users' karma (link and comment)
|
215
|
+
programming Erlang and code style: Musings on mostly defensive programming style
|
216
|
+
webdev Facebook: MVC Does Not Scale, Use Flux Instead
|
217
|
+
"""
|
218
|
+
|
187
219
|
Scenario: List posts when user has no submissions
|
188
220
|
Given the Reddit service returns posts for the user "blank"
|
189
221
|
And time is frozen at Nov 19, 2015 11:22 AM
|
data/lib/usaidwat/application.rb
CHANGED
@@ -140,6 +140,7 @@ module USaidWat
|
|
140
140
|
|
141
141
|
c.command(:log) do |s|
|
142
142
|
s.description "Show a user's submitted posts"
|
143
|
+
s.option 'oneline', '--oneline', 'Output log in a more compact form'
|
143
144
|
s.action do |args, options|
|
144
145
|
process_log(options, args)
|
145
146
|
end
|
@@ -162,6 +163,7 @@ module USaidWat
|
|
162
163
|
|
163
164
|
def process_log(options, args)
|
164
165
|
raise ArgumentError.new('You must specify a username') if args.empty?
|
166
|
+
oneline = !!options['oneline']
|
165
167
|
username = args.shift
|
166
168
|
subreddits = args.subreddits
|
167
169
|
|
@@ -174,7 +176,7 @@ module USaidWat
|
|
174
176
|
quit res.value if res.left?
|
175
177
|
posts = res.value
|
176
178
|
|
177
|
-
formatter = USaidWat::CLI::PostFormatter.new
|
179
|
+
formatter = (oneline ? USaidWat::CLI::CompactPostFormatter : USaidWat::CLI::PostFormatter).new
|
178
180
|
page
|
179
181
|
posts.each { |p| print formatter.format(p) }
|
180
182
|
end
|
data/lib/usaidwat/formatter.rb
CHANGED
@@ -67,6 +67,20 @@ module USaidWat
|
|
67
67
|
end
|
68
68
|
end
|
69
69
|
|
70
|
+
class CompactPostFormatter < BaseFormatter
|
71
|
+
def format(post)
|
72
|
+
cols = tty.width
|
73
|
+
out = StringIO.new
|
74
|
+
subreddit = post.subreddit
|
75
|
+
cols -= subreddit.length + 1
|
76
|
+
title = post.title.strip.transform_html_entities.truncate(cols)
|
77
|
+
out.write(subreddit.color(:green))
|
78
|
+
out.write(" #{title}\n")
|
79
|
+
out.rewind
|
80
|
+
out.read
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
70
84
|
class CommentFormatter < BaseFormatter
|
71
85
|
def format(comment)
|
72
86
|
cols = tty.width
|
@@ -112,9 +126,9 @@ module USaidWat
|
|
112
126
|
if relative_dates?
|
113
127
|
d.ago
|
114
128
|
else
|
115
|
-
d_part = d.strftime("%-d %b %Y")
|
129
|
+
d_part = d.strftime("%a, %-d %b %Y")
|
116
130
|
t_part = d.strftime("%l:%M %p").strip
|
117
|
-
"#{d_part} #{t_part}"
|
131
|
+
"#{d_part}, #{t_part}"
|
118
132
|
end
|
119
133
|
end
|
120
134
|
|
data/lib/usaidwat/version.rb
CHANGED
@@ -318,6 +318,21 @@ EXPECTED
|
|
318
318
|
end
|
319
319
|
end
|
320
320
|
|
321
|
+
describe CompactPostFormatter do
|
322
|
+
let (:formatter) { CompactPostFormatter.new }
|
323
|
+
|
324
|
+
describe '#format' do
|
325
|
+
it 'should return a string containing the formatted comment' do
|
326
|
+
post = double('post')
|
327
|
+
expect(post).to receive(:subreddit).and_return('programming')
|
328
|
+
expect(post).to receive(:title).and_return('Why Brit Ruby 2013 was cancelled and why this is not ok - Gist')
|
329
|
+
expected = "programming Why Brit Ruby 2013 was cancelled and why this is not ok - Gist\n"
|
330
|
+
actual = formatter.format(post).delete_ansi_color_codes
|
331
|
+
expect(actual).to eq(expected)
|
332
|
+
end
|
333
|
+
end
|
334
|
+
end
|
335
|
+
|
321
336
|
describe TallyFormatter do
|
322
337
|
before(:all) do
|
323
338
|
Struct.new('PartitionData', :longest, :counts)
|
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.2
|
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-04-07 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-04-06 19:24:55 PDT
|
230
|
+
commit: v1.4.2
|
231
|
+
commit_hash: babb216c8e4a29a58fa00518a9cf164ab827fc73
|
232
232
|
post_install_message:
|
233
233
|
rdoc_options: []
|
234
234
|
require_paths:
|