hackernews_ruby 0.0.4 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +12 -0
- data/lib/hackernews_ruby/client.rb +18 -1
- data/lib/hackernews_ruby/request.rb +1 -0
- data/lib/hackernews_ruby/version.rb +1 -1
- data/spec/cassettes/changed.yml +34 -0
- data/spec/hackernews_ruby/client_spec.rb +9 -0
- metadata +3 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3df2f1796b5c3ece17ba226d9067d8dd96ad91e3
|
4
|
+
data.tar.gz: 97a85322d8b37507bb24adfdda27dfa891c3df9b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5238c483f86ca906c497abacd1acbcaa12f6cdfc818d4734a2b47d703c363cc2fa8bb0a09db8255eb6b78015a6ac53db1f82b40c95d78294a7cabacc143ef5d9
|
7
|
+
data.tar.gz: 6cc6a454a710886478a879dced4d8d981f59c7cbe466898fb816eeefdf72818ac1d9a5997365f7700d4fff9117aa82d5b2de1171a4886e1db56f57a352ffffd7
|
data/README.md
CHANGED
@@ -109,6 +109,18 @@ stories.each do |story|
|
|
109
109
|
end
|
110
110
|
```
|
111
111
|
|
112
|
+
To get the most updated Profiles & Itemss you can call:
|
113
|
+
|
114
|
+
```ruby
|
115
|
+
updates = client.updated
|
116
|
+
updates.items
|
117
|
+
=> [1212, 1214]
|
118
|
+
updates.profiles
|
119
|
+
=> [5653, 25456]
|
120
|
+
```
|
121
|
+
|
122
|
+
|
123
|
+
|
112
124
|
|
113
125
|
## Contributing
|
114
126
|
|
@@ -30,18 +30,35 @@ module HackernewsRuby
|
|
30
30
|
end
|
31
31
|
end
|
32
32
|
|
33
|
+
#get_item expects an ID
|
34
|
+
#call it like this HackernewsRuby::Client.new.get_item(2324)
|
35
|
+
|
33
36
|
def get_item(id, params={})
|
34
37
|
url = "/#{HackernewsRuby.api_version}/item/#{id}.json"
|
35
38
|
get(url, params)
|
36
39
|
end
|
37
40
|
|
41
|
+
#get_user expects a username
|
42
|
+
#HackernewsRuby::Client.new.get_user('allcentury')
|
43
|
+
|
38
44
|
def get_user(id, params={})
|
39
45
|
url = "/#{HackernewsRuby.api_version}/user/#{id}.json"
|
40
46
|
get(url, params)
|
41
47
|
end
|
42
48
|
|
49
|
+
#top_stories returns an array of the top 100 storeis
|
50
|
+
#HackernewsRuby::Client.new.top_stories
|
51
|
+
|
43
52
|
def top_stories(params={})
|
44
|
-
url ="/#{HackernewsRuby.api_version}/topstories.json
|
53
|
+
url = "/#{HackernewsRuby.api_version}/topstories.json"
|
54
|
+
get(url, params)
|
55
|
+
end
|
56
|
+
|
57
|
+
#changed returns a hash of updates for profiles and items
|
58
|
+
#HackernewsRuby::Client.new.changed
|
59
|
+
|
60
|
+
def changed(params={})
|
61
|
+
url = "/#{HackernewsRuby.api_version}/updates.json"
|
45
62
|
get(url, params)
|
46
63
|
end
|
47
64
|
|
@@ -0,0 +1,34 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: get
|
5
|
+
uri: https://hacker-news.firebaseio.com/v0/updates.json
|
6
|
+
body:
|
7
|
+
encoding: US-ASCII
|
8
|
+
string: ''
|
9
|
+
headers:
|
10
|
+
Accept:
|
11
|
+
- application/json
|
12
|
+
Content-Type:
|
13
|
+
- application/json
|
14
|
+
User-Agent:
|
15
|
+
- Ruby Gem vy HackerNews_Ruby 0.0.4
|
16
|
+
Accept-Encoding:
|
17
|
+
- gzip;q=1.0,deflate;q=0.6,identity;q=0.3
|
18
|
+
response:
|
19
|
+
status:
|
20
|
+
code: 200
|
21
|
+
message: OK
|
22
|
+
headers:
|
23
|
+
Content-Length:
|
24
|
+
- '352'
|
25
|
+
Content-Type:
|
26
|
+
- application/json; charset=utf-8
|
27
|
+
Cache-Control:
|
28
|
+
- no-cache
|
29
|
+
body:
|
30
|
+
encoding: UTF-8
|
31
|
+
string: '{"items":[8434181,8434394,8434393,8432431,8431245,8434016,8425799,8434342,8429607,8419222,8432423,8433789,8434023,8433608,8434344],"profiles":["bluthru","linkeex","antfarm","cryptoz","benesy","rmgraham","r0muald","ComNik","rufugee","akassover","NickCE","fla","mkempe","jonknee","eoi","ark15","mrb","mkup","redtrackker","dnetesn","bribri","spectruman"]}'
|
32
|
+
http_version:
|
33
|
+
recorded_at: Thu, 09 Oct 2014 18:56:05 GMT
|
34
|
+
recorded_with: VCR 2.8.0
|
@@ -57,4 +57,13 @@ describe HackernewsRuby::Client do
|
|
57
57
|
expect(tstories.all? { |id| id.is_a? Fixnum} ).to eq true
|
58
58
|
end
|
59
59
|
end
|
60
|
+
|
61
|
+
it "#changed" do
|
62
|
+
VCR.use_cassette('changed') do
|
63
|
+
changed = client.changed
|
64
|
+
|
65
|
+
expect(changed.items).to be_kind_of Array
|
66
|
+
expect(changed.profiles).to be_kind_of Array
|
67
|
+
end
|
68
|
+
end
|
60
69
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hackernews_ruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Anthony Ross
|
@@ -197,6 +197,7 @@ files:
|
|
197
197
|
- lib/hackernews_ruby/client.rb
|
198
198
|
- lib/hackernews_ruby/request.rb
|
199
199
|
- lib/hackernews_ruby/version.rb
|
200
|
+
- spec/cassettes/changed.yml
|
200
201
|
- spec/cassettes/get_comment.yml
|
201
202
|
- spec/cassettes/get_story.yml
|
202
203
|
- spec/cassettes/get_user.yml
|
@@ -230,6 +231,7 @@ signing_key:
|
|
230
231
|
specification_version: 4
|
231
232
|
summary: A wrapper for the Hacker News API
|
232
233
|
test_files:
|
234
|
+
- spec/cassettes/changed.yml
|
233
235
|
- spec/cassettes/get_comment.yml
|
234
236
|
- spec/cassettes/get_story.yml
|
235
237
|
- spec/cassettes/get_user.yml
|