hackernews_ruby 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 6a1ff18b2fa16aff66a6e9bf6e6cec674779b083
4
- data.tar.gz: 5c74bda0a04dac382d2a9112dd9f0ffbd5e76dc1
3
+ metadata.gz: e7a6ce6c4ed75ca0e664a8e2b61d7611bf9032f4
4
+ data.tar.gz: 46426e649c903e0db544d803c5c9cc9f8b41432c
5
5
  SHA512:
6
- metadata.gz: c0d36fe983b0f0764c6806152ad1ae31483308d1da82d7607102c690f732bd594d8894400b758535ce34a69e4fd4c8cfc33f24c2b1ce520169023d4c04af0b59
7
- data.tar.gz: 71245b78c981bf2999b9c5c898d26daf1cb0f0680b0cc914162dc3fb04fb4372f4bf9113e64124be058a6719ca74575cbbb29408710defe564755bfc2e0bcd1f
6
+ metadata.gz: 44b3901881c8e62efe709f7f43eaaa6a56c66a1d25495844402c946a65067c6eb2f9e238f64d8f08cd0e010533668e89f8d6b11dfe7901cbf2833980f1e8a200
7
+ data.tar.gz: ba7e5f702cdb3a4f18e72cd3050589571f5a6e5d2e1f822d137a7f456efce35c0d719413984cdc7da45629a69665d17d996211dd4ff0127a2377751207700c56
data/.gitignore CHANGED
@@ -12,3 +12,4 @@
12
12
  *.o
13
13
  *.a
14
14
  mkmf.log
15
+ .coveralls.yml
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --color
2
+ --require spec_helper
data/.travis.yml ADDED
@@ -0,0 +1,9 @@
1
+ language: ruby
2
+ cache: bundler
3
+ rvm:
4
+ - 2.1.2
5
+
6
+ script: 'bundle exec rake'
7
+
8
+ notifications:
9
+ email: false
data/README.md CHANGED
@@ -1,5 +1,7 @@
1
1
  # HackernewsRuby
2
2
 
3
+ [![Coverage Status](https://coveralls.io/repos/allcentury/hackernews_ruby/badge.png?branch=master)](https://coveralls.io/r/allcentury/hackernews_ruby?branch=master)
4
+
3
5
  A wrapper for the new Hacker News API.
4
6
 
5
7
  ## Installation
@@ -20,7 +22,91 @@ Or install it yourself as:
20
22
 
21
23
  ## Usage
22
24
 
23
- TODO: Write usage instructions here
25
+ Instantiate a client like so:
26
+
27
+ ```ruby
28
+ client = HackernewsRuby::Client.new
29
+ ```
30
+
31
+ ## Items
32
+
33
+ Items have the following fields:
34
+
35
+ [Outlined here form HN](https://github.com/HackerNews/API/blob/master/README.md#items)
36
+
37
+ Field | Description
38
+ ------|------------
39
+ id | The item's unique id. Required.
40
+ deleted | `true` if the item is deleted.
41
+ type | The type of item. One of "job", "story", "comment", "poll", or "pollopt".
42
+ by | The username of the item's author.
43
+ time | Creation date of the item, in [Unix Time](http://en.wikipedia.org/wiki/Unix_time).
44
+ text | The comment, Ask HN, or poll text. HTML.
45
+ dead | `true` if the item is dead.
46
+ parent | The item's parent. For comments, either another comment or the relevant story. For pollopts, the relevant poll.
47
+ kids | The ids of the item's comments, in ranked display order.
48
+ url | The URL of the story.
49
+ score | The story's score, or the votes for a pollopt.
50
+ title | The title of the story or poll.
51
+ parts | A list of related pollopts, in display order.
52
+
53
+ To get an item simply do:
54
+
55
+ ```ruby
56
+ client.get_item(834129)
57
+ ```
58
+ This will get any item available on the API by ID such as stories, comments, polls and jobs.
59
+
60
+ Say you wanted the **title** of a story:
61
+
62
+ ```ruby
63
+ story = client.get_item(8863) #story_id
64
+ story.title
65
+ => "My YC app: Dropbox - Throw away your USB drive"
66
+ ```
67
+
68
+ ## Users
69
+
70
+ Users have the following fields:
71
+
72
+ [Outlined here from HN](https://github.com/HackerNews/API/blob/master/README.md#user://github.com/HackerNews/API/blob/master/README.md#users)
73
+
74
+ Field | Description
75
+ ------|------------
76
+ id | The user's unique username. Case-sensitive. Required.
77
+ delay | Delay in minutes between a comment's creation and its visibility to other users.
78
+ created | Creation date of the user, in [Unix Time](http://en.wikipedia.org/wiki/Unix_time).
79
+ karma | The user's karma.
80
+ about | The user's optional self-description. HTML.
81
+ submitted | List of the user's stories, polls and comments.
82
+
83
+ Say you wanted to fetch a particular **user**:
84
+
85
+ ```ruby
86
+ user = client.get_user('jl') #userid is case sensitive
87
+ user.about
88
+ => "This is a test"
89
+ ```
90
+
91
+ ## Live Data
92
+
93
+ To fetch the top 100 stories:
94
+
95
+ ```ruby
96
+ stories = client.top_stories
97
+ ```
98
+
99
+ This will return an array of ID's. To get each story after that, just use the get_item method like this:
100
+
101
+ ```ruby
102
+ stories = client.top_stories
103
+ stories.each do |story|
104
+ puts story.title
105
+ puts story.score
106
+ puts story.url
107
+ end
108
+ ```
109
+
24
110
 
25
111
  ## Contributing
26
112
 
data/Rakefile CHANGED
@@ -1,2 +1,7 @@
1
1
  require "bundler/gem_tasks"
2
+ require 'rspec/core/rake_task'
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task default: :spec
2
7
 
@@ -18,6 +18,17 @@ Gem::Specification.new do |spec|
18
18
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
19
  spec.require_paths = ["lib"]
20
20
 
21
- spec.add_development_dependency "bundler", "~> 1.7"
21
+ spec.add_dependency 'faraday_middleware'
22
+ spec.add_dependency 'multi_json'
23
+ spec.add_dependency 'activesupport'
24
+ spec.add_dependency 'hashie'
25
+
26
+ spec.add_development_dependency "bundler"
22
27
  spec.add_development_dependency "rake", "~> 10.0"
28
+ spec.add_development_dependency "rspec"
29
+ spec.add_development_dependency "pry"
30
+ spec.add_development_dependency "vcr"
31
+ spec.add_development_dependency "shoulda"
32
+ spec.add_development_dependency "webmock"
33
+ spec.add_development_dependency "coveralls"
23
34
  end
@@ -0,0 +1,62 @@
1
+ require 'forwardable'
2
+ require 'hackernews_ruby/request'
3
+
4
+ module HackernewsRuby
5
+ class Client
6
+ extend Forwardable
7
+
8
+ include Request
9
+ attr_accessor :api_url, :api_version
10
+
11
+
12
+ def initialize(options={})
13
+ @api_url = options[:api_url].nil? ? HackernewsRuby.api_url : options[:api_url]
14
+ @api_version = options[:api_version].nil? ? HackernewsRuby.api_version : options[:api_version]
15
+
16
+ reload_config
17
+ end
18
+
19
+ def connection
20
+ params = {}
21
+ @connection = Faraday.new(url: @api_url, params: params,
22
+ headers: default_headers,
23
+ ssl: { verify: true } ) do |faraday|
24
+ faraday.use FaradayMiddleware::Mashify
25
+ faraday.use FaradayMiddleware::ParseJson, content_type: /\bjson$/
26
+ faraday.use FaradayMiddleware::FollowRedirects
27
+ faraday.adapter Faraday.default_adapter
28
+ end
29
+ end
30
+
31
+ def get_item(id, params={})
32
+ url = "/#{HackernewsRuby.api_version}/item/#{id}.json"
33
+ get(url, params)
34
+ end
35
+
36
+ def get_user(id, params={})
37
+ url = "/#{HackernewsRuby.api_version}/user/#{id}.json"
38
+ get(url, params)
39
+ end
40
+
41
+ def top_stories(params={})
42
+ url ="/#{HackernewsRuby.api_version}/topstories.json?"
43
+ get(url, params)
44
+ end
45
+
46
+
47
+ private
48
+
49
+ def default_headers
50
+ {
51
+ accept: 'application/json',
52
+ content_type: 'application/json',
53
+ user_agent: "Ruby Gem vy HackerNews_Ruby #{HackernewsRuby::VERSION}"
54
+ }
55
+ end
56
+
57
+ def reload_config
58
+ HackernewsRuby.api_url = api_url
59
+ HackernewsRuby.api_version = api_version
60
+ end
61
+ end
62
+ end
@@ -0,0 +1,22 @@
1
+ require 'active_support/core_ext'
2
+ require 'multi_json'
3
+
4
+ module HackernewsRuby
5
+ module Request
6
+
7
+ def get(path, options)
8
+ request(:get, path, options)
9
+ end
10
+
11
+ def request(method, path, options)
12
+ response = connection.send(method) do |request|
13
+ case method
14
+ when :get
15
+ request.url(path, options)
16
+ end
17
+ end
18
+
19
+ response.body
20
+ end
21
+ end
22
+ end
@@ -1,3 +1,3 @@
1
1
  module HackernewsRuby
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
@@ -1,5 +1,28 @@
1
1
  require "hackernews_ruby/version"
2
+ require "faraday"
3
+ require "faraday_middleware"
4
+ require "hackernews_ruby/client"
5
+ require "hackernews_ruby/version"
6
+
7
+ directory = File.expand_path(File.dirname(__FILE__))
2
8
 
3
9
  module HackernewsRuby
4
- # Your code goes here...
10
+ class << self
11
+ attr_accessor :api_url, :api_version
12
+
13
+ ## configure default
14
+ def configure
15
+ load_defaults
16
+ yield self
17
+ true
18
+ end
19
+
20
+ private
21
+
22
+ def load_defaults
23
+ self.api_url ||= 'https://hacker-news.firebaseio.com'
24
+ self.api_version ||= 'v0'
25
+ end
26
+
27
+ end
5
28
  end
@@ -0,0 +1,68 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: https://hacker-news.firebaseio.com/v0/item/2921983.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.1
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
+ - '291'
25
+ Content-Type:
26
+ - application/json; charset=utf-8
27
+ Cache-Control:
28
+ - no-cache
29
+ body:
30
+ encoding: UTF-8
31
+ string: '{"by":"norvig","id":2921983,"kids":[2922097,2922429,2924562,2922709,2922573,2922140,2922141],"parent":2921506,"text":"Aw
32
+ shucks, guys ... you make me blush with your compliments.<p>Tell you what,
33
+ Ill make a deal: I''ll keep writing if you keep reading. K?","time":1314211127,"type":"comment"}'
34
+ http_version:
35
+ recorded_at: Wed, 08 Oct 2014 14:57:04 GMT
36
+ - request:
37
+ method: get
38
+ uri: https://hacker-news.firebaseio.com/v0/item/126809.json
39
+ body:
40
+ encoding: US-ASCII
41
+ string: ''
42
+ headers:
43
+ Accept:
44
+ - application/json
45
+ Content-Type:
46
+ - application/json
47
+ User-Agent:
48
+ - Ruby Gem vy HackerNews_Ruby 0.0.1
49
+ Accept-Encoding:
50
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
51
+ response:
52
+ status:
53
+ code: 200
54
+ message: OK
55
+ headers:
56
+ Content-Length:
57
+ - '368'
58
+ Content-Type:
59
+ - application/json; charset=utf-8
60
+ Cache-Control:
61
+ - no-cache
62
+ body:
63
+ encoding: UTF-8
64
+ string: '{"by":"pg","id":126809,"kids":[126822,126823,126993,126824,126934,127411,126888,127681,126818,126816,126854,127095,126861,127313,127299,126859,126852,126882,126832,127072,127217,126889,127535,126917,126875],"parts":[126810,126811,126812],"score":46,"text":"","time":1204403652,"title":"Poll:
65
+ What would happen if News.YC had explicit support for polls?","type":"poll"}'
66
+ http_version:
67
+ recorded_at: Wed, 08 Oct 2014 15:02:11 GMT
68
+ recorded_with: VCR 2.8.0
@@ -0,0 +1,35 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: https://hacker-news.firebaseio.com/v0/item/8863.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.1
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
+ - '358'
25
+ Content-Type:
26
+ - application/json; charset=utf-8
27
+ Cache-Control:
28
+ - no-cache
29
+ body:
30
+ encoding: UTF-8
31
+ string: '{"by":"dhouston","id":8863,"kids":[8952,9224,8917,8884,8887,8943,8869,8958,9005,9671,8940,9067,8908,9055,8865,8881,8872,8873,8955,10403,8903,8928,9125,8998,8901,8902,8907,8894,8878,8870,8980,8934,8876],"score":111,"time":1175714200,"title":"My
32
+ YC app: Dropbox - Throw away your USB drive","type":"story","url":"http://www.getdropbox.com/u/2/screencast.html"}'
33
+ http_version:
34
+ recorded_at: Wed, 08 Oct 2014 14:27:41 GMT
35
+ recorded_with: VCR 2.8.0
@@ -0,0 +1,65 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: https://hacker-news.firebaseio.com/v0/item/jl.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.1
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
+ - '4'
25
+ Content-Type:
26
+ - application/json; charset=utf-8
27
+ Cache-Control:
28
+ - no-cache
29
+ body:
30
+ encoding: UTF-8
31
+ string: 'null'
32
+ http_version:
33
+ recorded_at: Wed, 08 Oct 2014 17:58:09 GMT
34
+ - request:
35
+ method: get
36
+ uri: https://hacker-news.firebaseio.com/v0/user/jl.json
37
+ body:
38
+ encoding: US-ASCII
39
+ string: ''
40
+ headers:
41
+ Accept:
42
+ - application/json
43
+ Content-Type:
44
+ - application/json
45
+ User-Agent:
46
+ - Ruby Gem vy HackerNews_Ruby 0.0.1
47
+ Accept-Encoding:
48
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
49
+ response:
50
+ status:
51
+ code: 200
52
+ message: OK
53
+ headers:
54
+ Content-Length:
55
+ - '1926'
56
+ Content-Type:
57
+ - application/json; charset=utf-8
58
+ Cache-Control:
59
+ - no-cache
60
+ body:
61
+ encoding: UTF-8
62
+ string: '{"about":"This is a test","created":1173923446,"delay":0,"id":"jl","karma":2937,"submitted":[8265435,8168423,8090946,8090326,7699907,7637962,7596179,7596163,7594569,7562135,7562111,7494708,7494171,7488093,7444860,7327817,7280290,7278694,7097557,7097546,7097254,7052857,7039484,6987273,6649999,6649706,6629560,6609127,6327951,6225810,6111999,5580079,5112008,4907948,4901821,4700469,4678919,3779193,3711380,3701405,3627981,3473004,3473000,3457006,3422158,3136701,2943046,2794646,2482737,2425640,2411925,2408077,2407992,2407940,2278689,2220295,2144918,2144852,1875323,1875295,1857397,1839737,1809010,1788048,1780681,1721745,1676227,1654023,1651449,1641019,1631985,1618759,1522978,1499641,1441290,1440993,1436440,1430510,1430208,1385525,1384917,1370453,1346118,1309968,1305415,1305037,1276771,1270981,1233287,1211456,1210688,1210682,1194189,1193914,1191653,1190766,1190319,1189925,1188455,1188177,1185884,1165649,1164314,1160048,1159156,1158865,1150900,1115326,933897,924482,923918,922804,922280,922168,920332,919803,917871,912867,910426,902506,891171,807902,806254,796618,786286,764412,764325,642566,642564,587821,575744,547504,532055,521067,492164,491979,383935,383933,383930,383927,375462,263479,258389,250751,245140,243472,237445,229393,226797,225536,225483,225426,221084,213940,213342,211238,210099,210007,209913,209908,209904,209903,170904,165850,161566,158388,158305,158294,156235,151097,148566,146948,136968,134656,133455,129765,126740,122101,122100,120867,120492,115999,114492,114304,111730,110980,110451,108420,107165,105150,104735,103188,103187,99902,99282,99122,98972,98417,98416,98231,96007,96005,95623,95487,95475,95471,95467,95326,95322,94952,94681,94679,94678,94420,94419,94393,94149,94008,93490,93489,92944,92247,91713,90162,90091,89844,89678,89498,86953,86109,85244,85195,85194,85193,85192,84955,84629,83902,82918,76393,68677,61565,60542,47745,47744,41098,39153,38678,37741,33469,12897,6746,5252,4752,4586,4289]}'
63
+ http_version:
64
+ recorded_at: Wed, 08 Oct 2014 17:58:40 GMT
65
+ recorded_with: VCR 2.8.0
@@ -0,0 +1,68 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: https://hacker-news.firebaseio.com/v0/top_stories.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.1
16
+ Accept-Encoding:
17
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
18
+ response:
19
+ status:
20
+ code: 401
21
+ message: Unauthorized
22
+ headers:
23
+ Content-Length:
24
+ - '36'
25
+ Content-Type:
26
+ - application/json; charset=utf-8
27
+ Cache-Control:
28
+ - no-cache
29
+ body:
30
+ encoding: UTF-8
31
+ string: |
32
+ {
33
+ "error" : "Permission denied"
34
+ }
35
+ http_version:
36
+ recorded_at: Wed, 08 Oct 2014 18:32:49 GMT
37
+ - request:
38
+ method: get
39
+ uri: https://hacker-news.firebaseio.com/v0/topstories.json
40
+ body:
41
+ encoding: US-ASCII
42
+ string: ''
43
+ headers:
44
+ Accept:
45
+ - application/json
46
+ Content-Type:
47
+ - application/json
48
+ User-Agent:
49
+ - Ruby Gem vy HackerNews_Ruby 0.0.1
50
+ Accept-Encoding:
51
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
52
+ response:
53
+ status:
54
+ code: 200
55
+ message: OK
56
+ headers:
57
+ Content-Length:
58
+ - '801'
59
+ Content-Type:
60
+ - application/json; charset=utf-8
61
+ Cache-Control:
62
+ - no-cache
63
+ body:
64
+ encoding: UTF-8
65
+ string: "[8427086,8426984,8427468,8427757,8426148,8428007,8427484,8428182,8428418,8422599,8427174,8427676,8428231,8426349,8428159,8426561,8427036,8424696,8426558,8422087,8426411,8427924,8426764,8422928,8425246,8426104,8426803,8425575,8422581,8425209,8423825,8424502,8427114,8420274,8426937,8427903,8424165,8425799,8425501,8428067,8422051,8428446,8424391,8425463,8426617,8425797,8422408,8426548,8428149,8420902,8428257,8427843,8426232,8422546,8424333,8427186,8416393,8428078,8427944,8423633,8421656,8428488,8426300,8427483,8419658,8421594,8417062,8420309,8423936,8428289,8424907,8428261,8419222,8416693,8422695,8428163,8427577,8426816,8424320,8425663,8427192,8427401,8427764,8426900,8426985,8426365,8423007,8421866,8426809,8425385,8427873,8427633,8421518,8424438,8410519,8400778,8415595,8424264,8418464,8418085]"
66
+ http_version:
67
+ recorded_at: Wed, 08 Oct 2014 18:35:07 GMT
68
+ recorded_with: VCR 2.8.0
@@ -0,0 +1,60 @@
1
+ require 'spec_helper'
2
+
3
+ describe HackernewsRuby::Client do
4
+ let(:client) { HackernewsRuby::Client.new }
5
+
6
+ it 'creates a Faraday::Connection' do
7
+ expect(client.connection).to be_kind_of Faraday::Connection
8
+ end
9
+ it '#get_item story' do
10
+ VCR.use_cassette('get_story') do
11
+ story = client.get_item(8863)
12
+
13
+ expect(story).to_not be_nil
14
+ expect(story.id).to eq 8863
15
+ expect(story.type).to eq "story"
16
+ expect(story.kids).to be_kind_of Array
17
+ end
18
+ end
19
+
20
+ it '#get_item comment' do
21
+ VCR.use_cassette('get_comment') do
22
+ comment = client.get_item(2921983)
23
+
24
+ expect(comment).to_not be_nil
25
+ expect(comment.id).to eq 2921983
26
+ expect(comment.type).to eq "comment"
27
+ end
28
+ end
29
+
30
+ it '#get_item poll' do
31
+
32
+ VCR.use_cassette('get_comment') do
33
+ poll = client.get_item(126809)
34
+
35
+ expect(poll).to_not be_nil
36
+ expect(poll.id).to eq 126809
37
+ expect(poll.type).to eq "poll"
38
+ expect(poll.score).to_not be_nil
39
+ expect(poll.parts).to be_kind_of Array
40
+ end
41
+ end
42
+
43
+ it '#get_user' do
44
+ VCR.use_cassette('get_user') do
45
+ user = client.get_user('jl')
46
+
47
+ expect(user.about).to eq "This is a test"
48
+ expect(user.created).to eq 1173923446
49
+ end
50
+ end
51
+
52
+ it "#top_storeis" do
53
+ VCR.use_cassette('top_stories') do
54
+ tstories = client.top_stories
55
+
56
+ expect(tstories).to be_kind_of Array
57
+ expect(tstories.all? { |id| id.is_a? Fixnum} ).to eq true
58
+ end
59
+ end
60
+ end
@@ -0,0 +1,31 @@
1
+ require 'spec_helper'
2
+
3
+ describe HackernewsRuby do
4
+ let(:client) { HackernewsRuby::Client.new }
5
+
6
+ context 'configure defaults' do
7
+ it 'uses default API URL' do
8
+ expect(client.api_url).to eq "https://hacker-news.firebaseio.com"
9
+ end
10
+
11
+ it 'uses default API version' do
12
+ expect(client.api_version).to eq "v0"
13
+ end
14
+ end
15
+
16
+ context 'custom configuration' do
17
+ let(:custom_client) do
18
+ HackernewsRuby::Client.new(api_url: "https://hackernews.ycomb.com",
19
+ api_version: "v1")
20
+ end
21
+
22
+ it "::Client API_URL config" do
23
+ expect(custom_client.api_url).to eq "https://hackernews.ycomb.com"
24
+ end
25
+
26
+ it "::Client API_VERSION config" do
27
+ expect(custom_client.api_version).to eq "v1"
28
+ end
29
+
30
+ end
31
+ end
@@ -0,0 +1,28 @@
1
+ require 'bundler/setup'
2
+ Bundler.setup
3
+ require 'coveralls'
4
+ Coveralls.wear!
5
+
6
+ require 'vcr'
7
+ require 'pry'
8
+ require 'hackernews_ruby'
9
+
10
+ VCR.configure do |c|
11
+ c.cassette_library_dir = 'spec/cassettes'
12
+ c.hook_into :webmock
13
+ c.allow_http_connections_when_no_cassette = true
14
+ c.ignore_localhost = true
15
+ c.default_cassette_options = {
16
+ record: :new_episodes,
17
+ re_record_interval: 7.days
18
+ }
19
+ end
20
+
21
+ RSpec.configure do |c|
22
+
23
+ HackernewsRuby.configure do |config|
24
+ config.api_url = "https://hacker-news.firebaseio.com"
25
+ config.api_version = "v0"
26
+ end
27
+
28
+ 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.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Anthony Ross
@@ -10,20 +10,76 @@ bindir: bin
10
10
  cert_chain: []
11
11
  date: 2014-10-08 00:00:00.000000000 Z
12
12
  dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: faraday_middleware
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: multi_json
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: activesupport
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: hashie
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
13
69
  - !ruby/object:Gem::Dependency
14
70
  name: bundler
15
71
  requirement: !ruby/object:Gem::Requirement
16
72
  requirements:
17
- - - "~>"
73
+ - - ">="
18
74
  - !ruby/object:Gem::Version
19
- version: '1.7'
75
+ version: '0'
20
76
  type: :development
21
77
  prerelease: false
22
78
  version_requirements: !ruby/object:Gem::Requirement
23
79
  requirements:
24
- - - "~>"
80
+ - - ">="
25
81
  - !ruby/object:Gem::Version
26
- version: '1.7'
82
+ version: '0'
27
83
  - !ruby/object:Gem::Dependency
28
84
  name: rake
29
85
  requirement: !ruby/object:Gem::Requirement
@@ -38,6 +94,90 @@ dependencies:
38
94
  - - "~>"
39
95
  - !ruby/object:Gem::Version
40
96
  version: '10.0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: rspec
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
+ - !ruby/object:Gem::Dependency
112
+ name: pry
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - ">="
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - ">="
123
+ - !ruby/object:Gem::Version
124
+ version: '0'
125
+ - !ruby/object:Gem::Dependency
126
+ name: vcr
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - ">="
130
+ - !ruby/object:Gem::Version
131
+ version: '0'
132
+ type: :development
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - ">="
137
+ - !ruby/object:Gem::Version
138
+ version: '0'
139
+ - !ruby/object:Gem::Dependency
140
+ name: shoulda
141
+ requirement: !ruby/object:Gem::Requirement
142
+ requirements:
143
+ - - ">="
144
+ - !ruby/object:Gem::Version
145
+ version: '0'
146
+ type: :development
147
+ prerelease: false
148
+ version_requirements: !ruby/object:Gem::Requirement
149
+ requirements:
150
+ - - ">="
151
+ - !ruby/object:Gem::Version
152
+ version: '0'
153
+ - !ruby/object:Gem::Dependency
154
+ name: webmock
155
+ requirement: !ruby/object:Gem::Requirement
156
+ requirements:
157
+ - - ">="
158
+ - !ruby/object:Gem::Version
159
+ version: '0'
160
+ type: :development
161
+ prerelease: false
162
+ version_requirements: !ruby/object:Gem::Requirement
163
+ requirements:
164
+ - - ">="
165
+ - !ruby/object:Gem::Version
166
+ version: '0'
167
+ - !ruby/object:Gem::Dependency
168
+ name: coveralls
169
+ requirement: !ruby/object:Gem::Requirement
170
+ requirements:
171
+ - - ">="
172
+ - !ruby/object:Gem::Version
173
+ version: '0'
174
+ type: :development
175
+ prerelease: false
176
+ version_requirements: !ruby/object:Gem::Requirement
177
+ requirements:
178
+ - - ">="
179
+ - !ruby/object:Gem::Version
180
+ version: '0'
41
181
  description: A ruby wrapper for the new Hacker News API
42
182
  email:
43
183
  - anthony.s.ross@gmail.com
@@ -46,13 +186,24 @@ extensions: []
46
186
  extra_rdoc_files: []
47
187
  files:
48
188
  - ".gitignore"
189
+ - ".rspec"
190
+ - ".travis.yml"
49
191
  - Gemfile
50
192
  - LICENSE.txt
51
193
  - README.md
52
194
  - Rakefile
53
195
  - hackernews_ruby.gemspec
54
196
  - lib/hackernews_ruby.rb
197
+ - lib/hackernews_ruby/client.rb
198
+ - lib/hackernews_ruby/request.rb
55
199
  - lib/hackernews_ruby/version.rb
200
+ - spec/cassettes/get_comment.yml
201
+ - spec/cassettes/get_story.yml
202
+ - spec/cassettes/get_user.yml
203
+ - spec/cassettes/top_stories.yml
204
+ - spec/hackernews_ruby/client_spec.rb
205
+ - spec/hackernews_ruby_spec.rb
206
+ - spec/spec_helper.rb
56
207
  homepage: ''
57
208
  licenses:
58
209
  - MIT
@@ -77,4 +228,11 @@ rubygems_version: 2.2.2
77
228
  signing_key:
78
229
  specification_version: 4
79
230
  summary: A wrapper for the Hacker News API
80
- test_files: []
231
+ test_files:
232
+ - spec/cassettes/get_comment.yml
233
+ - spec/cassettes/get_story.yml
234
+ - spec/cassettes/get_user.yml
235
+ - spec/cassettes/top_stories.yml
236
+ - spec/hackernews_ruby/client_spec.rb
237
+ - spec/hackernews_ruby_spec.rb
238
+ - spec/spec_helper.rb