usaidwat 1.4.5 → 1.5.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -12,8 +12,8 @@ module USaidWat
12
12
  end
13
13
  end
14
14
 
15
- describe MockUser do
16
- let (:user) { MockUser.new("mipadi") }
15
+ describe USaidWat::Thing::User do
16
+ let (:user) { MockService.new.user("mipadi") }
17
17
 
18
18
  describe "#comments" do
19
19
  it "should return an array of comments" do
@@ -26,8 +26,8 @@ module USaidWat
26
26
  end
27
27
  end
28
28
 
29
- describe MockComment do
30
- let (:comment) { MockUser.new("mipadi").comments(100).first }
29
+ describe USaidWat::Thing::Comment do
30
+ let (:comment) { MockService.new.user("mipadi").comments(100).first }
31
31
 
32
32
  describe "#subreddit" do
33
33
  it "should return a string denoting what subreddit it belongs to" do
@@ -0,0 +1,139 @@
1
+ require 'spec_helper'
2
+ require 'json'
3
+
4
+ module USaidWat
5
+ module Thing
6
+ describe User do
7
+ let(:user_data) { JSON.parse(IO.read('features/fixtures/user_mipadi.json')) }
8
+ let(:comment_data) { JSON.parse(IO.read('features/fixtures/mipadi.json')) }
9
+ let(:post_data) { JSON.parse(IO.read('features/fixtures/submissions_mipadi.json')) }
10
+ let(:user) { User.new('mipadi', user_data, comment_data, post_data) }
11
+
12
+ describe '#about' do
13
+ it "should return an object detailing the user's info" do
14
+ expect(user.about).to be_kind_of(About)
15
+ end
16
+ end
17
+
18
+ describe '#comments' do
19
+ it 'returns 100 comments' do
20
+ expect(user.comments(100).count).to eq(100)
21
+ end
22
+ end
23
+
24
+ describe '#posts' do
25
+ it 'returns 25 posts' do
26
+ expect(user.posts.count).to eq(25)
27
+ end
28
+ end
29
+ end
30
+
31
+ describe About do
32
+ let(:data) { JSON.parse(IO.read('features/fixtures/user_mipadi.json')) }
33
+ let(:about) { About.new(data) }
34
+
35
+ it "should return the user's creation date" do
36
+ expected = Time.new(2008, 3, 31, 15, 55, 26, '-07:00')
37
+ expect(about.created_utc).to eq(expected)
38
+ end
39
+
40
+ it "should return the user's link karma" do
41
+ expect(about.link_karma).to eq(4892)
42
+ end
43
+
44
+ it "should return the user's comment karma" do
45
+ expect(about.comment_karma).to eq(33440)
46
+ end
47
+ end
48
+
49
+ describe Comment do
50
+ let(:data) { JSON.parse(IO.read('features/fixtures/mipadi.json'))['data']['children'][0] }
51
+ let(:comment) { Comment.new(data) }
52
+
53
+ describe '#subreddit' do
54
+ it 'should return the name of the subreddit to which the comment belongs' do
55
+ expect(comment.subreddit).to eq('wikipedia')
56
+ end
57
+ end
58
+
59
+ describe '#body' do
60
+ it "should return the comment's body" do
61
+ expect(comment.body).to eq('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).')
62
+ end
63
+ end
64
+
65
+ describe '#id' do
66
+ it "should return the comment's ID" do
67
+ expect(comment.id).to eq('c79peed')
68
+ end
69
+ end
70
+
71
+ describe '#link_id' do
72
+ it "should return the comment's link ID" do
73
+ expect(comment.link_id).to eq('t3_142t4w')
74
+ end
75
+ end
76
+
77
+ describe '#link_title' do
78
+ it "should return the title of the link to which the comment belongs" do
79
+ expect(comment.link_title).to eq('Heisenbug: a software bug that seems to disappear or alter its behavior when one attempts to study it')
80
+ end
81
+ end
82
+
83
+ describe '#ups' do
84
+ it "should return the number of upvotes" do
85
+ expect(comment.ups).to eq(1)
86
+ end
87
+ end
88
+
89
+ describe '#downs' do
90
+ it "should return the number of downvotes" do
91
+ expect(comment.downs).to eq(0)
92
+ end
93
+ end
94
+
95
+ describe '#created_utc' do
96
+ it "should return the date the comment was written" do
97
+ expected = Time.new(2012, 12, 1, 12, 14, 28, '-08:00')
98
+ expect(comment.created_utc).to eq(expected)
99
+ end
100
+ end
101
+ end
102
+
103
+ describe Submission do
104
+ let(:data) { JSON.parse(IO.read('features/fixtures/submissions_mipadi.json'))['data']['children'][0] }
105
+ let(:post) { Submission.new(data) }
106
+
107
+ describe '#subreddit' do
108
+ it "should return the post's subreddit" do
109
+ expect(post.subreddit).to eq('short')
110
+ end
111
+ end
112
+
113
+ describe '#title' do
114
+ it "should return the post's title" do
115
+ expect(post.title).to eq('Science Says Being Short Makes You Depressed')
116
+ end
117
+ end
118
+
119
+ describe '#permalink' do
120
+ it "should return the post's permalink" do
121
+ expect(post.permalink).to eq('/r/short/comments/3pj7rx/science_says_being_short_makes_you_depressed/')
122
+ end
123
+ end
124
+
125
+ describe '#url' do
126
+ it "should return the post's URL" do
127
+ expect(post.url).to eq('http://www.vice.com/read/it-sucks-to-be-a-short-guy-511')
128
+ end
129
+ end
130
+
131
+ describe '#created_utc' do
132
+ it "should return the time the post was created" do
133
+ expected = Time.new(2015, 10, 20, 12, 36, 37, '-07:00')
134
+ expect(post.created_utc).to eq(expected)
135
+ end
136
+ end
137
+ end
138
+ end
139
+ end
@@ -0,0 +1,16 @@
1
+ require 'spec_helper'
2
+
3
+ module USaidWat
4
+ describe 'commit_hash' do
5
+ let (:metadata) {{'commit' => 'v1.4.4-4-g11624e0',
6
+ 'commit_hash' => '11624e069842b18860352db00de17e4880315477',
7
+ 'build_date' => Time.new(2016, 9, 27, 11, 15, 5, '-07:00')}}
8
+
9
+ it 'should return the first seven characters of the current commit' do
10
+ expected = '11624e0'
11
+ allow_any_instance_of(Gem::Specification).to receive(:metadata).and_return(metadata)
12
+ actual = USaidWat::commit_hash
13
+ expect(actual).to eq(expected)
14
+ end
15
+ end
16
+ end
data/usaidwat.gemspec CHANGED
@@ -30,9 +30,8 @@ Gem::Specification.new do |gem|
30
30
 
31
31
  gem.add_runtime_dependency('downterm', '~> 0.1.5')
32
32
  gem.add_runtime_dependency('mercenary', '~> 0.3.5', '!= 0.3.6')
33
- gem.add_runtime_dependency('net-http-persistent', '~> 2.5')
34
33
  gem.add_runtime_dependency('rainbow', '~> 2.0')
35
- gem.add_runtime_dependency('snooby', '~> 0.1.5')
34
+ gem.add_runtime_dependency('requests', '~> 1.0')
36
35
  gem.add_runtime_dependency('sysexits', '~> 1.2')
37
36
  gem.add_runtime_dependency('ttycaca', '~> 1.0')
38
37
 
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.5
4
+ version: 1.5.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: 2016-10-12 00:00:00.000000000 Z
11
+ date: 2016-11-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: downterm
@@ -44,20 +44,6 @@ dependencies:
44
44
  - - "!="
45
45
  - !ruby/object:Gem::Version
46
46
  version: 0.3.6
47
- - !ruby/object:Gem::Dependency
48
- name: net-http-persistent
49
- requirement: !ruby/object:Gem::Requirement
50
- requirements:
51
- - - "~>"
52
- - !ruby/object:Gem::Version
53
- version: '2.5'
54
- type: :runtime
55
- prerelease: false
56
- version_requirements: !ruby/object:Gem::Requirement
57
- requirements:
58
- - - "~>"
59
- - !ruby/object:Gem::Version
60
- version: '2.5'
61
47
  - !ruby/object:Gem::Dependency
62
48
  name: rainbow
63
49
  requirement: !ruby/object:Gem::Requirement
@@ -73,19 +59,19 @@ dependencies:
73
59
  - !ruby/object:Gem::Version
74
60
  version: '2.0'
75
61
  - !ruby/object:Gem::Dependency
76
- name: snooby
62
+ name: requests
77
63
  requirement: !ruby/object:Gem::Requirement
78
64
  requirements:
79
65
  - - "~>"
80
66
  - !ruby/object:Gem::Version
81
- version: 0.1.5
67
+ version: '1.0'
82
68
  type: :runtime
83
69
  prerelease: false
84
70
  version_requirements: !ruby/object:Gem::Requirement
85
71
  requirements:
86
72
  - - "~>"
87
73
  - !ruby/object:Gem::Version
88
- version: 0.1.5
74
+ version: '1.0'
89
75
  - !ruby/object:Gem::Dependency
90
76
  name: sysexits
91
77
  requirement: !ruby/object:Gem::Requirement
@@ -214,6 +200,7 @@ files:
214
200
  - features/step_definitions/time_steps.rb
215
201
  - features/support/aruba.rb
216
202
  - features/tally.feature
203
+ - features/timeline.feature
217
204
  - features/user.feature
218
205
  - lib/usaidwat.rb
219
206
  - lib/usaidwat/algo.rb
@@ -223,17 +210,23 @@ files:
223
210
  - lib/usaidwat/commands/log.rb
224
211
  - lib/usaidwat/commands/posts.rb
225
212
  - lib/usaidwat/commands/tally.rb
213
+ - lib/usaidwat/commands/timeline.rb
226
214
  - lib/usaidwat/count.rb
227
215
  - lib/usaidwat/either.rb
228
216
  - lib/usaidwat/ext/array.rb
229
217
  - lib/usaidwat/ext/mercenary.rb
230
- - lib/usaidwat/ext/snooby.rb
231
218
  - lib/usaidwat/ext/string.rb
232
219
  - lib/usaidwat/ext/time.rb
233
220
  - lib/usaidwat/filter.rb
234
221
  - lib/usaidwat/formatter.rb
222
+ - lib/usaidwat/formatter/base.rb
223
+ - lib/usaidwat/formatter/comment.rb
224
+ - lib/usaidwat/formatter/count.rb
225
+ - lib/usaidwat/formatter/post.rb
226
+ - lib/usaidwat/formatter/timeline.rb
235
227
  - lib/usaidwat/pager.rb
236
228
  - lib/usaidwat/service.rb
229
+ - lib/usaidwat/thing.rb
237
230
  - lib/usaidwat/version.rb
238
231
  - spec/spec_helper.rb
239
232
  - spec/usaidwat/algo_spec.rb
@@ -245,15 +238,17 @@ files:
245
238
  - spec/usaidwat/formatter_spec.rb
246
239
  - spec/usaidwat/service_spec.rb
247
240
  - spec/usaidwat/string_spec.rb
241
+ - spec/usaidwat/thing_spec.rb
248
242
  - spec/usaidwat/time_spec.rb
243
+ - spec/usaidwat/version_spec.rb
249
244
  - usaidwat.gemspec
250
245
  homepage: https://github.com/mdippery/usaidwat
251
246
  licenses:
252
247
  - MIT
253
248
  metadata:
254
- build_date: 2016-10-11 19:26:37 PDT
255
- commit: v1.4.5
256
- commit_hash: 4147214e593d4d46c96cfa9fc0fec5132dfa5d99
249
+ build_date: 2016-11-02 08:04:29 PDT
250
+ commit: v1.5.0
251
+ commit_hash: a3055f2b9c02ef9780c6235ce45c1e4887e7e51a
257
252
  post_install_message:
258
253
  rdoc_options: []
259
254
  require_paths:
@@ -290,6 +285,7 @@ test_files:
290
285
  - features/step_definitions/time_steps.rb
291
286
  - features/support/aruba.rb
292
287
  - features/tally.feature
288
+ - features/timeline.feature
293
289
  - features/user.feature
294
290
  - spec/spec_helper.rb
295
291
  - spec/usaidwat/algo_spec.rb
@@ -301,4 +297,6 @@ test_files:
301
297
  - spec/usaidwat/formatter_spec.rb
302
298
  - spec/usaidwat/service_spec.rb
303
299
  - spec/usaidwat/string_spec.rb
300
+ - spec/usaidwat/thing_spec.rb
304
301
  - spec/usaidwat/time_spec.rb
302
+ - spec/usaidwat/version_spec.rb
@@ -1,32 +0,0 @@
1
- require 'snooby'
2
-
3
- module Snooby
4
- # Copied from snooby gem so we can fix Paths constant to use Reddit's
5
- # https URLs. Ugly solution, but it'll work until snooby is fixed.
6
- remove_const(:Paths)
7
- paths = {
8
- :comment => 'api/comment',
9
- :compose => 'api/compose',
10
- :delete => 'api/del',
11
- :disliked => 'user/%s/disliked.json',
12
- :friend => 'api/friend',
13
- :hidden => 'user/%s/hidden.json',
14
- :liked => 'user/%s/liked.json',
15
- :login => 'api/login/%s',
16
- :me => 'api/me.json',
17
- :post_comments => 'comments/%s.json',
18
- :reddit => '.json',
19
- :saved => 'saved.json',
20
- :subreddit_about => 'r/%s/about.json',
21
- :subreddit_comments => 'r/%s/comments.json',
22
- :subreddit_posts => 'r/%s.json',
23
- :subscribe => 'api/subscribe',
24
- :unfriend => 'api/unfriend',
25
- :user => 'user/%s',
26
- :user_about => 'user/%s/about.json',
27
- :user_comments => 'user/%s/comments.json',
28
- :user_posts => 'user/%s/submitted.json',
29
- :vote => 'api/vote'
30
- }
31
- Paths = paths.merge(paths) { |k, v| "https://www.reddit.com/#{v}" }
32
- end