hacker_news_search 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.autotest +1 -0
- data/.gemtest +0 -0
- data/.gitignore +41 -0
- data/.rspec +3 -0
- data/.yardopts +3 -0
- data/Gemfile +4 -0
- data/LICENSE.md +20 -0
- data/README.md +69 -0
- data/Rakefile +18 -0
- data/hacker_news_search.gemspec +30 -0
- data/lib/hacker_news_search.rb +20 -0
- data/lib/hacker_news_search/client.rb +16 -0
- data/lib/hacker_news_search/client/connection.rb +19 -0
- data/lib/hacker_news_search/client/items.rb +19 -0
- data/lib/hacker_news_search/client/request.rb +18 -0
- data/lib/hacker_news_search/client/search.rb +30 -0
- data/lib/hacker_news_search/client/users.rb +18 -0
- data/lib/hacker_news_search/version.rb +3 -0
- data/spec/faraday/response_spec.rb +34 -0
- data/spec/fixtures/hotness.json +1 -0
- data/spec/fixtures/items.json +1 -0
- data/spec/fixtures/items_search.json +1 -0
- data/spec/fixtures/users.json +1 -0
- data/spec/fixtures/users_search.json +1 -0
- data/spec/hacker_news_search/client_spec.rb +4 -0
- data/spec/hacker_news_search/items_spec.rb +22 -0
- data/spec/hacker_news_search/search_spec.rb +36 -0
- data/spec/hacker_news_search/users_spec.rb +22 -0
- data/spec/hacker_news_search_spec.rb +9 -0
- data/spec/helper.rb +47 -0
- metadata +218 -0
data/.autotest
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require 'autotest/bundler'
|
data/.gemtest
ADDED
File without changes
|
data/.gitignore
ADDED
@@ -0,0 +1,41 @@
|
|
1
|
+
!.gitignore
|
2
|
+
*.gem
|
3
|
+
*.rbc
|
4
|
+
*.sw[a-p]
|
5
|
+
*.tmproj
|
6
|
+
*.tmproject
|
7
|
+
*.un~
|
8
|
+
*~
|
9
|
+
.DS_Store
|
10
|
+
.Spotlight-V100
|
11
|
+
.Trashes
|
12
|
+
._*
|
13
|
+
.bundle
|
14
|
+
.config
|
15
|
+
.directory
|
16
|
+
.elc
|
17
|
+
.redcar
|
18
|
+
.yardoc
|
19
|
+
/.emacs.desktop
|
20
|
+
/.emacs.desktop.lock
|
21
|
+
Desktop.ini
|
22
|
+
Gemfile.lock
|
23
|
+
Icon?
|
24
|
+
InstalledFiles
|
25
|
+
Session.vim
|
26
|
+
Thumbs.db
|
27
|
+
\#*\#
|
28
|
+
_yardoc
|
29
|
+
auto-save-list
|
30
|
+
coverage
|
31
|
+
doc/
|
32
|
+
lib/bundler/man
|
33
|
+
pkg
|
34
|
+
pkg/*
|
35
|
+
rdoc
|
36
|
+
spec/reports
|
37
|
+
test/tmp
|
38
|
+
test/version_tmp
|
39
|
+
tmp
|
40
|
+
tmtags
|
41
|
+
tramp
|
data/.rspec
ADDED
data/.yardopts
ADDED
data/Gemfile
ADDED
data/LICENSE.md
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2011 Ryan Resella
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,69 @@
|
|
1
|
+
# Hacker News Search
|
2
|
+
|
3
|
+
Ruby wrapper for the Hacker News Search API
|
4
|
+
|
5
|
+
Installation
|
6
|
+
------------
|
7
|
+
gem install hacker_news_search
|
8
|
+
|
9
|
+
Usage Examples
|
10
|
+
--------------
|
11
|
+
require 'hacker_news_search'
|
12
|
+
|
13
|
+
@client = HackerNewsSearch.new
|
14
|
+
@client.users("ryanatwork") # Return the user
|
15
|
+
@client.username # => "ryanatwork"
|
16
|
+
@client.search("users", {q: => "jobs"}) # Return search results for jobs
|
17
|
+
|
18
|
+
Contributing
|
19
|
+
------------
|
20
|
+
In the spirit of [free software](http://www.fsf.org/licensing/essays/free-sw.html), **everyone** is encouraged to help improve this project.
|
21
|
+
|
22
|
+
Here are some ways *you* can contribute:
|
23
|
+
|
24
|
+
* by using alpha, beta, and prerelease versions
|
25
|
+
* by reporting bugs
|
26
|
+
* by suggesting new features
|
27
|
+
* by writing or editing documentation
|
28
|
+
* by writing specifications
|
29
|
+
* by writing code (**no patch is too small**: fix typos, add comments, clean up inconsistent whitespace)
|
30
|
+
* by refactoring code
|
31
|
+
* by resolving [issues](https://github.com/ryanatwork/hacker_news_search/issues)
|
32
|
+
* by reviewing patches
|
33
|
+
|
34
|
+
|
35
|
+
Submitting an Issue
|
36
|
+
-------------------
|
37
|
+
We use the [GitHub issue tracker](https://github.com/ryanatwork/hacker_news_search/issues)
|
38
|
+
to track bugs and features. Before submitting a bug report or feature request,
|
39
|
+
check to make sure it hasn't already been submitted. You can indicate support
|
40
|
+
for an existing issuse by voting it up. When submitting a bug report, please
|
41
|
+
include a [Gist](https://gist.github.com/) that includes a stack trace and any
|
42
|
+
details that may be necessary to reproduce the bug, including your gem version,
|
43
|
+
Ruby version, and operating system. Ideally, a bug report should include a pull
|
44
|
+
request with failing specs.
|
45
|
+
|
46
|
+
Submitting a Pull Request
|
47
|
+
-------------------------
|
48
|
+
1. Fork the project.
|
49
|
+
2. Create a topic branch.
|
50
|
+
3. Implement your feature or bug fix.
|
51
|
+
4. Add documentation for your feature or bug fix.
|
52
|
+
5. Run <tt>bundle exec rake doc:yard</tt>. If your changes are not 100% documented, go back to step 4.
|
53
|
+
6. Add specs for your feature or bug fix.
|
54
|
+
7. Run <tt>bundle exec rake spec</tt>. If your changes are not 100% covered, go back to step 6.
|
55
|
+
8. Commit and push your changes.
|
56
|
+
9. Submit a pull request. Please do not include changes to the gemspec, version, or history file. (If you want to create your own version for some reason, please do so in a separate commit.)
|
57
|
+
|
58
|
+
Credits
|
59
|
+
-------
|
60
|
+
[Hacker News Search API](http://www.hnsearch.com/api) and [ThriftDB REST API](http://www.thriftdb.com/documentation/rest-api/search-api)
|
61
|
+
|
62
|
+
Inspiration
|
63
|
+
-----------
|
64
|
+
Hacker News Search was heavily inspired by the [https://github.com/codeforamerica/gem_template](Code for America Gem Template)
|
65
|
+
|
66
|
+
Copyright
|
67
|
+
---------
|
68
|
+
Copyright (c) 2011 Ryan Resella
|
69
|
+
See [LICENSE](https://github.com/ryanatwork/hacker_news_search/blob/master/LICENSE) for details.
|
data/Rakefile
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
#!/usr/bin/env rake
|
2
|
+
|
3
|
+
require 'bundler'
|
4
|
+
Bundler::GemHelper.install_tasks
|
5
|
+
|
6
|
+
require 'rspec/core/rake_task'
|
7
|
+
RSpec::Core::RakeTask.new(:spec)
|
8
|
+
|
9
|
+
task :default => :spec
|
10
|
+
task :test => :spec
|
11
|
+
|
12
|
+
require 'yard'
|
13
|
+
namespace :doc do
|
14
|
+
YARD::Rake::YardocTask.new do |task|
|
15
|
+
task.files = ['LICENSE.md', 'lib/**/*.rb']
|
16
|
+
task.options = ['--markup', 'markdown']
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
require File.expand_path('../lib/hacker_news_search/version', __FILE__)
|
3
|
+
|
4
|
+
Gem::Specification.new do |gem|
|
5
|
+
gem.name = 'hacker_news_search'
|
6
|
+
gem.version = HackerNewsSearch::VERSION
|
7
|
+
gem.author = "Ryan Resella"
|
8
|
+
gem.email = 'ryan@codeforamerica.org'
|
9
|
+
gem.homepage = 'https://github.com/ryanatwork/hacker_news_search'
|
10
|
+
gem.summary = %q{Wrapper for the Hacker News Search API}
|
11
|
+
gem.description = %q{Simple Ruby wrapper for the Hacker News Search API}
|
12
|
+
|
13
|
+
gem.files = `git ls-files`.split("\n")
|
14
|
+
gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
15
|
+
gem.executables = `git ls-files -- bin/*`.split("\n").map{|f| File.basename(f)}
|
16
|
+
gem.require_paths = ['lib']
|
17
|
+
|
18
|
+
gem.add_development_dependency 'ZenTest', '~> 4.5'
|
19
|
+
gem.add_development_dependency 'maruku', '~> 0.6'
|
20
|
+
gem.add_development_dependency 'rake', '~> 0.9'
|
21
|
+
gem.add_development_dependency 'rspec', '~> 2.6'
|
22
|
+
gem.add_development_dependency 'simplecov', '~> 0.4'
|
23
|
+
gem.add_development_dependency 'webmock', '~> 1.6'
|
24
|
+
gem.add_development_dependency 'yard', '~> 0.7'
|
25
|
+
gem.add_runtime_dependency 'faraday', '~> 0.6.1'
|
26
|
+
gem.add_runtime_dependency 'faraday_middleware', '~> 0.6.3'
|
27
|
+
gem.add_runtime_dependency 'hashie', '~> 1.0.0'
|
28
|
+
gem.add_runtime_dependency 'multi_json', '~> 1.0.2'
|
29
|
+
gem.add_runtime_dependency 'rash', '~> 0.3.0'
|
30
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
require 'hacker_news_search/client'
|
2
|
+
|
3
|
+
module HackerNewsSearch
|
4
|
+
# Alias for HackerNewsSearch::Client.new
|
5
|
+
#
|
6
|
+
# @return [HackerNewsSearch::Client]
|
7
|
+
def self.new
|
8
|
+
HackerNewsSearch::Client.new
|
9
|
+
end
|
10
|
+
|
11
|
+
# Delegate to HackerNewsSearch::Client
|
12
|
+
def self.method_missing(method, *args, &block)
|
13
|
+
return super unless new.respond_to?(method)
|
14
|
+
new.send(method, *args, &block)
|
15
|
+
end
|
16
|
+
|
17
|
+
def self.respond_to?(method, include_private=false)
|
18
|
+
new.respond_to?(method, include_private) || super(method, include_private)
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
require 'hacker_news_search/client/connection'
|
2
|
+
require 'hacker_news_search/client/request'
|
3
|
+
require 'hacker_news_search/client/items'
|
4
|
+
require 'hacker_news_search/client/users'
|
5
|
+
require 'hacker_news_search/client/search'
|
6
|
+
|
7
|
+
module HackerNewsSearch
|
8
|
+
class Client
|
9
|
+
include HackerNewsSearch::Client::Connection
|
10
|
+
include HackerNewsSearch::Client::Request
|
11
|
+
|
12
|
+
include HackerNewsSearch::Client::Items
|
13
|
+
include HackerNewsSearch::Client::Search
|
14
|
+
include HackerNewsSearch::Client::Users
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require 'faraday_middleware'
|
2
|
+
|
3
|
+
module HackerNewsSearch
|
4
|
+
class Client
|
5
|
+
module Connection
|
6
|
+
private
|
7
|
+
|
8
|
+
def connection
|
9
|
+
Faraday.new(:url => 'http://api.thriftdb.com/api.hnsearch.com/') do |connection|
|
10
|
+
connection.use Faraday::Request::UrlEncoded
|
11
|
+
connection.use Faraday::Response::RaiseError
|
12
|
+
connection.use Faraday::Response::Rashify
|
13
|
+
connection.use Faraday::Response::ParseJson
|
14
|
+
connection.adapter(Faraday.default_adapter)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module HackerNewsSearch
|
2
|
+
class Client
|
3
|
+
module Items
|
4
|
+
|
5
|
+
# Returns the information of the item from Hacker News Search
|
6
|
+
#
|
7
|
+
# @param item_id [String] The hacker news item plus the thriftdb_id - must know the thriftDB id
|
8
|
+
# @param options [Hash] A customizable set of options.
|
9
|
+
# @return {Hash}
|
10
|
+
# @see http://www.hnsearch.com/api
|
11
|
+
# @example
|
12
|
+
# HackerNewsSearch.item("2619846-a30f9")
|
13
|
+
def item(item_id, options={})
|
14
|
+
get("items/#{item_id}", options)
|
15
|
+
end
|
16
|
+
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
module HackerNewsSearch
|
2
|
+
class Client
|
3
|
+
module Request
|
4
|
+
def get(path, options={})
|
5
|
+
request(:get, path, options)
|
6
|
+
end
|
7
|
+
|
8
|
+
private
|
9
|
+
|
10
|
+
def request(method, path, options)
|
11
|
+
response = connection.send(method) do |request|
|
12
|
+
request.url(path, options)
|
13
|
+
end
|
14
|
+
response.body
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
module HackerNewsSearch
|
2
|
+
class Client
|
3
|
+
module Search
|
4
|
+
|
5
|
+
# Returns the information based on the search criteria
|
6
|
+
#
|
7
|
+
# @param collection [String] collection is either - users or items
|
8
|
+
# @param options [Hash] A customizable set of options.
|
9
|
+
# @return {Hash}
|
10
|
+
# @see http://www.hnsearch.com/api
|
11
|
+
# @see http://www.thriftdb.com/documentation/rest-api/search-api
|
12
|
+
# @example
|
13
|
+
# HackerNewsSearch.search("users" {:q => "sferik"})
|
14
|
+
def search(collection, options={})
|
15
|
+
get("#{collection}/_search", options)
|
16
|
+
end
|
17
|
+
|
18
|
+
# Returns the top 30 hot stories based on the Hacker News Search algorithm
|
19
|
+
#
|
20
|
+
# @param options [Hash] A customizable set of options.
|
21
|
+
# @return {Hash}
|
22
|
+
# @see http://www.hnsearch.com/api
|
23
|
+
# @example
|
24
|
+
# HackerNewsSearch.hotness
|
25
|
+
def hotness(options={})
|
26
|
+
get("items/_search?limit=30&sortby=product(points,pow(2,div(div(ms(create_ts,NOW),3600000),72)))%20desc", options)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
module HackerNewsSearch
|
2
|
+
class Client
|
3
|
+
module Users
|
4
|
+
|
5
|
+
# Returns the information about a user
|
6
|
+
#
|
7
|
+
# @param user_name [String] user name from Hacker News
|
8
|
+
# @param options [Hash] A customizable set of options.
|
9
|
+
# @return {Hash}
|
10
|
+
# @see http://www.hnsearch.com/api
|
11
|
+
# @example
|
12
|
+
# HackerNewsSearch.users("sferik")
|
13
|
+
def users(user_name, options={})
|
14
|
+
get("users/#{user_name}", options)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
require 'helper'
|
3
|
+
|
4
|
+
describe Faraday::Response do
|
5
|
+
before do
|
6
|
+
@client = HackerNewsSearch::Client.new
|
7
|
+
end
|
8
|
+
|
9
|
+
{
|
10
|
+
400 => Faraday::Error::ClientError,
|
11
|
+
401 => Faraday::Error::ClientError,
|
12
|
+
403 => Faraday::Error::ClientError,
|
13
|
+
404 => Faraday::Error::ResourceNotFound,
|
14
|
+
406 => Faraday::Error::ClientError,
|
15
|
+
500 => Faraday::Error::ClientError,
|
16
|
+
501 => Faraday::Error::ClientError,
|
17
|
+
502 => Faraday::Error::ClientError,
|
18
|
+
503 => Faraday::Error::ClientError,
|
19
|
+
}.each do |status, exception|
|
20
|
+
context "when HTTP status is #{status}" do
|
21
|
+
|
22
|
+
before do
|
23
|
+
stub_get('users/abc1234').
|
24
|
+
to_return(:status => status)
|
25
|
+
end
|
26
|
+
|
27
|
+
it "should raise #{exception.name} error" do
|
28
|
+
lambda do
|
29
|
+
@client.users('abc1234')
|
30
|
+
end.should raise_error(exception)
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
{"hits": 2428061, "facet_results": {"fields": {}, "queries": {}}, "warnings": [], "request": {"facet": {"fields": {}, "queries": []}, "q": "", "start": 0, "limit": 30, "sortby": "product(points,pow(2,div(div(ms(create_ts,NOW),3600000),72))) desc", "highlight": {"include_matches": false, "fragments": {"maxchars": 100, "include": false, "markup_text": false}, "markup_items": false}, "weights": {"username": 1.0, "domain": 1.0, "title": 1.0, "url": 1.0, "text": 1.0, "type": 1.0}, "filter": {"fields": {}, "queries": []}, "boosts": {"fields": {}, "functions": {}, "filters": {}}}, "results": [{"item": {"username": "ssclafani", "domain": "avc.com", "title": "Enough Is Enough", "url": "http://www.avc.com/a_vc/2011/06/enough-is-enough.html", "text": null, "discussion": null, "parent_id": null, "points": null, "create_ts": "2011-06-01T10:44:12Z", "num_comments": 154, "cache_ts": "2011-06-01T20:55:01Z", "_id": "2606727-6a410", "type": "submission", "id": 2606727}, "score": 1.0}, {"item": {"username": "pg", "domain": "ycombinator.com", "title": "Hacker News Search", "url": "http://ycombinator.com/newsnews.html#4jun11", "text": null, "discussion": null, "parent_id": null, "points": null, "create_ts": "2011-06-04T16:20:00Z", "num_comments": 126, "cache_ts": "2011-06-05T17:14:28Z", "_id": "2619736-586ae", "type": "submission", "id": 2619736}, "score": 1.0}, {"item": {"username": "baha_man", "domain": "badscience.net", "title": "Kids who spot bullshit, and the adults who get upset about it", "url": "http://www.badscience.net/2011/06/kids-who-spot-bullshit-and-the-adults-who-get-upset-about-it/", "text": null, "discussion": null, "parent_id": null, "points": null, "create_ts": "2011-06-04T14:37:17Z", "num_comments": 123, "cache_ts": "2011-06-05T17:14:28Z", "_id": "2619563-a2746", "type": "submission", "id": 2619563}, "score": 1.0}, {"item": {"username": "jagira", "domain": "shortlogic.tumblr.com", "title": "Try to digest the Groupon story", "url": "http://shortlogic.tumblr.com/post/6142108636/groupon-ipo-pass-on-this-deal", "text": null, "discussion": null, "parent_id": null, "points": null, "create_ts": "2011-06-03T14:20:58Z", "num_comments": 156, "cache_ts": "2011-06-04T10:02:55Z", "_id": "2616412-684aa", "type": "submission", "id": 2616412}, "score": 1.0}, {"item": {"username": "Umalu", "domain": "theatlantic.com", "title": "How I Failed, Failed, and Finally Succeeded at Learning How to Code", "url": "http://www.theatlantic.com/technology/print/2011/06/how-i-failed-failed-and-finally-succeeded-at-learning-how-to-code/239855/", "text": null, "discussion": null, "parent_id": null, "points": null, "create_ts": "2011-06-03T23:07:03Z", "num_comments": 48, "cache_ts": "2011-06-04T20:41:20Z", "_id": "2618316-48163", "type": "submission", "id": 2618316}, "score": 1.0}, {"item": {"username": "pg", "domain": "ycombinator.com", "title": "Y Combinator Numbers", "url": "http://ycombinator.com/nums.html", "text": null, "discussion": null, "parent_id": null, "points": null, "create_ts": "2011-06-01T17:55:17Z", "num_comments": 108, "cache_ts": "2011-06-02T09:14:50Z", "_id": "2608440-e3ce3", "type": "submission", "id": 2608440}, "score": 1.0}, {"item": {"username": "bkaid", "domain": "thisguyhasmymacbook.tumblr.com", "title": "This Guy Has My MacBook", "url": "http://thisguyhasmymacbook.tumblr.com/", "text": null, "discussion": null, "parent_id": null, "points": 543, "create_ts": "2011-05-31T19:15:10Z", "num_comments": 356, "cache_ts": "2011-06-01T06:52:15Z", "_id": "2604013-adccc", "type": "submission", "id": 2604013}, "score": 1.0}, {"item": {"username": "jbk", "domain": "skype-open-source.blogspot.com", "title": "Skype protocol reverse engineered, source available", "url": "http://skype-open-source.blogspot.com/", "text": null, "discussion": null, "parent_id": null, "points": null, "create_ts": "2011-06-02T09:51:12Z", "num_comments": 108, "cache_ts": "2011-06-02T22:32:01Z", "_id": "2611299-34084", "type": "submission", "id": 2611299}, "score": 1.0}, {"item": {"username": "brudgers", "domain": "hackerfactor.com", "title": "How Perceptual Hashes Work", "url": "http://www.hackerfactor.com/blog/index.php?/archives/432-Looks-Like-It.html", "text": null, "discussion": null, "parent_id": null, "points": null, "create_ts": "2011-06-03T01:26:28Z", "num_comments": 66, "cache_ts": "2011-06-03T17:44:26Z", "_id": "2614797-26160", "type": "submission", "id": 2614797}, "score": 1.0}, {"item": {"username": "sivers", "domain": "sivers.org", "title": "I moved to Singapore", "url": "http://sivers.org/singapore", "text": null, "discussion": null, "parent_id": null, "points": null, "create_ts": "2011-06-05T05:20:49Z", "num_comments": 166, "cache_ts": "2011-06-05T19:18:39Z", "_id": "2621371-91c01", "type": "submission", "id": 2621371}, "score": 1.0}, {"item": {"username": "ssclafani", "domain": "pastebin.com", "title": "SonyPictures.com hacked, personal information and passwords compromised", "url": "http://pastebin.com/Y38gCS82", "text": null, "discussion": null, "parent_id": null, "points": null, "create_ts": "2011-06-02T20:20:10Z", "num_comments": 153, "cache_ts": "2011-06-03T13:41:24Z", "_id": "2613774-78517", "type": "submission", "id": 2613774}, "score": 1.0}, {"item": {"username": "kyleslattery", "domain": "slate.com", "title": "Amazon: Ponzi Scheme or Wal-Mart of the Web? (2000)", "url": "http://www.slate.com/id/1004565/", "text": null, "discussion": null, "parent_id": null, "points": null, "create_ts": "2011-06-03T22:48:54Z", "num_comments": 83, "cache_ts": "2011-06-04T20:41:20Z", "_id": "2618270-eb64c", "type": "submission", "id": 2618270}, "score": 1.0}, {"item": {"username": "desigooner", "domain": "microsoft.com", "title": "Previewing Windows 8 (Video)", "url": "http://www.microsoft.com/presspass/features/2011/jun11/06-01corporatenews.aspx", "text": null, "discussion": null, "parent_id": null, "points": null, "create_ts": "2011-06-01T23:46:28Z", "num_comments": 194, "cache_ts": "2011-06-02T14:59:21Z", "_id": "2609910-55eae", "type": "submission", "id": 2609910}, "score": 1.0}, {"item": {"username": "cabinguy", "domain": "davegooden.com", "title": "How AirBnB Became a Billion Dollar Company", "url": "http://davegooden.com/2011/05/how-airbnb-became-a-billion-dollar-company/", "text": null, "discussion": null, "parent_id": null, "points": 419, "create_ts": "2011-05-31T18:34:46Z", "num_comments": 147, "cache_ts": "2011-06-01T06:52:15Z", "_id": "2603844-d1469", "type": "submission", "id": 2603844}, "score": 1.0}, {"item": {"username": "hornokplease", "domain": "pastebin.com", "title": "LulzSec versus FBI (We Challenge You, NATO)", "url": "http://pastebin.com/MQG0a130", "text": null, "discussion": null, "parent_id": null, "points": null, "create_ts": "2011-06-04T00:50:09Z", "num_comments": 67, "cache_ts": "2011-06-05T05:33:37Z", "_id": "2618562-f713d", "type": "submission", "id": 2618562}, "score": 1.0}, {"item": {"username": "fogus", "domain": "neopythonic.blogspot.com", "title": "The depth and breadth of Python", "url": "http://neopythonic.blogspot.com/2011/06/depth-and-breadth-of-python.html", "text": null, "discussion": null, "parent_id": null, "points": null, "create_ts": "2011-06-03T18:15:32Z", "num_comments": 41, "cache_ts": "2011-06-04T20:41:20Z", "_id": "2617402-c5c07", "type": "submission", "id": 2617402}, "score": 1.0}, {"item": {"username": "thefox", "domain": "sourceforge.net", "title": "GitHub, Collaboration, and Haters", "url": "http://sourceforge.net/blog/github-collaboration-and-haters/", "text": null, "discussion": null, "parent_id": null, "points": null, "create_ts": "2011-06-03T20:11:58Z", "num_comments": 49, "cache_ts": "2011-06-04T20:41:20Z", "_id": "2617807-f9c62", "type": "submission", "id": 2617807}, "score": 1.0}, {"item": {"username": "blumentopf", "domain": "noop.nl", "title": "How a 3 week business trip to the US got reduced to 3 hours", "url": "http://www.noop.nl/2011/06/american-learning-experience.html", "text": null, "discussion": null, "parent_id": null, "points": null, "create_ts": "2011-06-04T16:22:08Z", "num_comments": 96, "cache_ts": "2011-06-05T17:14:28Z", "_id": "2619740-f0d54", "type": "submission", "id": 2619740}, "score": 1.0}, {"item": {"username": "DanielRibeiro", "domain": "allthingsd.com", "title": "Andrew Mason\u2019s \"I'm not answering that\" technique", "url": "http://allthingsd.com/20110601/see-andrew-masons-amazing-death-stare/", "text": null, "discussion": null, "parent_id": null, "points": null, "create_ts": "2011-06-05T02:37:03Z", "num_comments": 32, "cache_ts": "2011-06-05T19:18:39Z", "_id": "2621132-95288", "type": "submission", "id": 2621132}, "score": 1.0}, {"item": {"username": "mixmax", "domain": "raketvenner.dk", "title": "Copenhagen Suborbitals open-source private spacerocket will launch in an hour", "url": "http://raketvenner.dk/launch/", "text": null, "discussion": null, "parent_id": null, "points": null, "create_ts": "2011-06-03T12:25:57Z", "num_comments": 55, "cache_ts": "2011-06-03T22:38:33Z", "_id": "2616050-04ee4", "type": "submission", "id": 2616050}, "score": 1.0}, {"item": {"username": "colinprince", "domain": "m.minyanville.com", "title": "Groupon is Effectively Insolvent", "url": "http://m.minyanville.com/?guid=34936&catid=4", "text": null, "discussion": null, "parent_id": null, "points": null, "create_ts": "2011-06-03T15:38:10Z", "num_comments": 101, "cache_ts": "2011-06-04T10:02:55Z", "_id": "2616750-0fbd2", "type": "submission", "id": 2616750}, "score": 1.0}, {"item": {"username": "DanielRibeiro", "domain": "37signals.com", "title": "Fire the workaholics (2008)", "url": "http://37signals.com/svn/posts/902-fire-the-workaholics", "text": null, "discussion": null, "parent_id": null, "points": null, "create_ts": "2011-06-04T16:30:05Z", "num_comments": 73, "cache_ts": "2011-06-05T17:14:28Z", "_id": "2619760-1fafc", "type": "submission", "id": 2619760}, "score": 1.0}, {"item": {"username": "44Aman", "domain": "blogs.wsj.com", "title": "Groupon files for IPO", "url": "http://blogs.wsj.com/deals/2011/06/02/groupon-ipo-its-here/", "text": null, "discussion": null, "parent_id": null, "points": null, "create_ts": "2011-06-02T19:02:11Z", "num_comments": 162, "cache_ts": "2011-06-03T13:41:24Z", "_id": "2613407-db426", "type": "submission", "id": 2613407}, "score": 1.0}, {"item": {"username": "tptacek", "domain": null, "title": null, "url": null, "text": "I like hnsearch a lot, but I'd like us to take a second to thank whoever was running SearchYC, which for the past couple years has been practically indispensable in keeping up with this community.", "discussion": {"id": 2619736, "title": "Hacker News Search"}, "parent_id": 2619736, "points": null, "create_ts": "2011-06-04T16:52:58Z", "num_comments": 22, "cache_ts": "2011-06-05T17:14:28Z", "_id": "2619811-02e34", "type": "comment", "id": 2619811}, "score": 1.0}, {"item": {"username": "guynamedloren", "domain": "lorenburton.com", "title": "Loren wants to work at Airbnb", "url": "http://www.lorenburton.com", "text": null, "discussion": null, "parent_id": null, "points": 399, "create_ts": "2011-05-30T20:00:40Z", "num_comments": 103, "cache_ts": "2011-05-31T16:43:07Z", "_id": "2600264-8a520", "type": "submission", "id": 2600264}, "score": 1.0}, {"item": {"username": "sucuri2", "domain": "blog.sucuri.net", "title": "Sony Music Brazil hacked", "url": "http://blog.sucuri.net/2011/06/sony-music-brazil-hacked.html", "text": null, "discussion": null, "parent_id": null, "points": null, "create_ts": "2011-06-05T11:54:41Z", "num_comments": 43, "cache_ts": "2011-06-05T19:07:24Z", "_id": "2621844-af5a2", "type": "submission", "id": 2621844}, "score": 1.0}, {"item": {"username": "andreasklinger", "domain": "b.qr.ae", "title": "The Quora post that killed Bitcoins. Please discuss if his arguments are valid.", "url": "http://b.qr.ae/jRRsvb ", "text": null, "discussion": null, "parent_id": null, "points": null, "create_ts": "2011-06-02T09:36:28Z", "num_comments": 277, "cache_ts": "2011-06-02T22:32:01Z", "_id": "2611281-60177", "type": "submission", "id": 2611281}, "score": 1.0}, {"item": {"username": "zmoazeni", "domain": "blog.postrank.com", "title": "Google acquires Postrank.com", "url": "http://blog.postrank.com/2011/06/postrank-has-been-acquired-by-google/", "text": null, "discussion": null, "parent_id": null, "points": null, "create_ts": "2011-06-03T18:04:15Z", "num_comments": 47, "cache_ts": "2011-06-04T12:23:47Z", "_id": "2617347-76464", "type": "submission", "id": 2617347}, "score": 1.0}, {"item": {"username": "sgallant", "domain": "jqapi.com", "title": "Alternative jQuery Documentation", "url": "http://jqapi.com/", "text": null, "discussion": null, "parent_id": null, "points": null, "create_ts": "2011-06-02T13:03:09Z", "num_comments": 43, "cache_ts": "2011-06-02T22:32:01Z", "_id": "2611767-76ebe", "type": "submission", "id": 2611767}, "score": 1.0}, {"item": {"username": "rryan", "domain": "googlecode.blogspot.com", "title": "Google to offer for-pay Translate API", "url": "http://googlecode.blogspot.com/2011/05/spring-cleaning-for-some-of-our-apis.html?foolio", "text": null, "discussion": null, "parent_id": null, "points": null, "create_ts": "2011-06-03T22:15:54Z", "num_comments": 42, "cache_ts": "2011-06-04T20:41:20Z", "_id": "2618181-088d2", "type": "submission", "id": 2618181}, "score": 1.0}], "time": 0.95732784271240234}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"username": "pg", "domain": null, "title": null, "url": null, "text": "I should add that HNSearch has an API<p><a href=\"http://www.hnsearch.com/api\" rel=\"nofollow\">http://www.hnsearch.com/api</a><p>which should be a lot faster than crawling HN itself to get the same data.", "discussion": {"id": 2619736, "title": "Hacker News Search"}, "parent_id": 2619736, "points": 31, "create_ts": "2011-06-04T17:03:15Z", "num_comments": 19, "cache_ts": "2011-06-05T17:14:28Z", "_id": "2619846-a30f9", "type": "comment", "id": 2619846}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"hits": 13, "facet_results": {"fields": {}, "queries": {}}, "warnings": [], "request": {"facet": {"fields": {}, "queries": []}, "q": "sferik", "start": 0, "limit": 10, "sortby": "score desc", "highlight": {"include_matches": false, "fragments": {"maxchars": 100, "include": false, "markup_text": false}, "markup_items": false}, "weights": {"username": 1.0, "domain": 1.0, "title": 1.0, "url": 1.0, "text": 1.0, "type": 1.0}, "filter": {"fields": {}, "queries": []}, "boosts": {"fields": {}, "functions": {}, "filters": {}}}, "results": [{"item": {"username": "sferik", "domain": null, "title": null, "url": null, "text": "Thank you for pointing this out. Before I started the project, I requested permission from Wilson Miner to use the stylesheets and javascripts from Django and added his name to the acknowledgments, but I neglected to add the BSD license.<p>This error has been corrected in: <a href=\"https://github.com/sferik/merb-admin/commit/b5462f4b73d444477cc411fd7b226cd81dde1dd1\" rel=\"nofollow\">https://github.com/sferik/merb-admin/commit/b5462f4b73d44447...</a>", "discussion": {"id": 2011674, "title": "RailsAdmin: Rails3 easy-to-use interface for managing your data"}, "parent_id": 2012044, "points": 1, "create_ts": "2010-12-16T22:01:11Z", "num_comments": 0, "cache_ts": "2011-01-04T17:40:35Z", "_id": "2013945-51445", "type": "comment", "id": 2013945}, "score": 11.014941}, {"item": {"username": "sferik", "domain": null, "title": null, "url": null, "text": "I've been holding out to read Rework until I can get it on iPad. This was just the dose I needed to get me through.", "discussion": {"id": 1225483, "title": "Points I took from Rework"}, "parent_id": 1225483, "points": 1, "create_ts": "2010-03-29T00:40:50Z", "num_comments": 0, "cache_ts": "2011-01-04T17:38:46Z", "_id": "1225523-43bca", "type": "comment", "id": 1225523}, "score": 10.990933}, {"item": {"username": "sferik", "domain": null, "title": null, "url": null, "text": "I've always believed the biggest single moment of destruction of future programmers is when Microsoft stopped shipping BASIC (plus the full source code of the games GORILLA.BAS and NIBBLES.BAS) with DOS/Windows.", "discussion": {"id": 1243516, "title": "Is Apple destroying a generation of tech whizzes?"}, "parent_id": 1243516, "points": 10, "create_ts": "2010-04-06T01:46:19Z", "num_comments": 6, "cache_ts": "2011-01-04T17:38:46Z", "_id": "1243601-edfd5", "type": "comment", "id": 1243601}, "score": 10.990933}, {"item": {"username": "sferik", "domain": null, "title": null, "url": null, "text": "This totally solves the problem I asked about a month ago. Thanks! <a href=\"http://news.ycombinator.com/item?id=1453143\" rel=\"nofollow\">http://news.ycombinator.com/item?id=1453143</a>", "discussion": {"id": 1528652, "title": "Twitter feed of Hacker News stories as soon as they reach 20 points"}, "parent_id": 1528652, "points": 2, "create_ts": "2010-07-19T22:43:47Z", "num_comments": 0, "cache_ts": "2011-01-04T17:38:55Z", "_id": "1530467-af1c8", "type": "comment", "id": 1530467}, "score": 10.990933}, {"item": {"username": "sferik", "domain": null, "title": null, "url": null, "text": "Given your response, you might be surprised at the number of angel (or even Series A) investments made almost exclusively on the basis of the individuals involved, sans any tangible product or traction.<p>The thing that holds Kickstarter projects together is putting one's own credibility on the line. The people who pledge, understand that it would not be worth me publicly destroying my reputation for $2000. And since I haven't solicited pledges above $64, I would argue that I'm taking on a much greater risk than any individual contributor.<p>I view Kickstarter primarily as a tool for customer discovery, to gauge whether a project is worth my time. It has the added benefit of building momentum behind the project by creating a small army of people who are, quite literally, invested in it.<p>There are probably other names for this process, but I like to call it IDD: icon-driven development.", "discussion": {"id": 1967915, "title": "Hubcap: A GitHub client for Mac OS X"}, "parent_id": 1968141, "points": 1, "create_ts": "2010-12-04T02:41:40Z", "num_comments": 1, "cache_ts": "2011-01-04T17:40:17Z", "_id": "1968279-147c7", "type": "comment", "id": 1968279}, "score": 10.990933}, {"item": {"username": "sferik", "domain": null, "title": null, "url": null, "text": "LOL! Any designers out there?", "discussion": {"id": 1985853, "title": "Kickstarting Hubcap: a Socially Aware GitHub Mac App"}, "parent_id": 1985967, "points": 1, "create_ts": "2010-12-09T04:19:05Z", "num_comments": 1, "cache_ts": "2011-01-04T17:40:22Z", "_id": "1986005-c3e7a", "type": "comment", "id": 1986005}, "score": 10.990933}, {"item": {"username": "sferik", "domain": "fluther.com", "title": "Why do airplanes float in water? A better answer from Fluther.", "url": "http://www.fluther.com/disc/32715/why-do-airplanes-float-in-water/", "text": null, "discussion": null, "parent_id": null, "points": 1, "create_ts": "2009-01-20T18:34:35Z", "num_comments": 1, "cache_ts": "2011-01-04T17:42:46Z", "_id": "442031-d01bf", "type": "submission", "id": 442031}, "score": 10.990933}, {"item": {"username": "sferik", "domain": null, "title": "Ask HN: How do you filter Hacker News?", "url": null, "text": "I just glanced at my RSS Reader stats and was a bit horrified to see that I am sent over 100 items per day from Hacker News. Many of those items are duplicate or dead stories that still make it into the RSS feed. I would love a lightweight version of the Hacker News feed that only shows items above a certain threshold (say, 20 points).<p>I can't believe everyone here does this filtering manually. What do you do to separate the wheat from the chaff?", "discussion": null, "parent_id": null, "points": 8, "create_ts": "2010-06-22T20:53:06Z", "num_comments": 12, "cache_ts": "2011-01-04T17:38:51Z", "_id": "1453143-05276", "type": "submission", "id": 1453143}, "score": 10.990933}, {"item": {"username": "sferik", "domain": "adweek.blogs.com", "title": "Reality: Old Spice sales are actually up 107% in the last month", "url": "http://adweek.blogs.com/adfreak/2010/07/hey-old-spice-haters-sales-are-up-107.html", "text": null, "discussion": null, "parent_id": null, "points": 159, "create_ts": "2010-07-27T17:37:19Z", "num_comments": 61, "cache_ts": "2011-01-04T17:38:56Z", "_id": "1551990-148e8", "type": "submission", "id": 1551990}, "score": 10.990933}, {"item": {"username": "sferik", "domain": "twitter.com", "title": "Paul Graham is now tweeting", "url": "http://twitter.com/paulg", "text": null, "discussion": null, "parent_id": null, "points": 201, "create_ts": "2010-08-27T22:38:05Z", "num_comments": 130, "cache_ts": "2011-01-04T17:39:00Z", "_id": "1640530-eb3ab", "type": "submission", "id": 1640530}, "score": 10.990933}], "time": 0.020479917526245117}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"username": "sferik", "about": null, "karma": 455, "cache_ts": "2011-01-04T17:45:04Z", "_id": "sferik", "create_ts": "2007-12-20T22:06:11Z"}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"hits": 70623, "facet_results": {"fields": {}, "queries": {}}, "warnings": [], "request": {"facet": {"fields": {}, "queries": []}, "q": "", "start": 0, "limit": 10, "sortby": "score desc", "highlight": {"include_matches": false, "fragments": {"maxchars": 100, "include": false, "markup_text": false}, "markup_items": false}, "weights": {"username": 1.0, "about": 1.0}, "filter": {"fields": {}, "queries": []}, "boosts": {"fields": {}, "functions": {}, "filters": {}}}, "results": [{"item": {"username": "markessien", "about": "Follow on twitter: http://www.twitter.com/markessien", "karma": 2053, "cache_ts": "2011-02-03T13:41:32Z", "_id": "markessien", "create_ts": "2007-03-28T06:55:27Z"}, "score": 1.0}, {"item": {"username": "davidmurphy", "about": "Working on the next big thing.<p>Previous startups: co-founder of Hotline Communications, Ltd; and Friendgiftr, Inc; etc.<p>Also done a number of nonprofit efforts, including Building LA's Future.", "karma": 399, "cache_ts": "2011-04-22T03:36:50Z", "_id": "davidmurphy", "create_ts": "2007-09-18T04:51:47Z"}, "score": 1.0}, {"item": {"username": "inerte", "about": "My blog: http://www.inerciasensorial.com.br<p>\"inerte\" is also my gmail username.<p>http://www.hackernewsers.com/users/inerte.html", "karma": 899, "cache_ts": "2011-04-22T04:24:06Z", "_id": "inerte", "create_ts": "2008-03-13T17:51:56Z"}, "score": 1.0}, {"item": {"username": "alrex021", "about": "Hacker, painter, husband, father and (lisp 'enthusiast)", "karma": 3827, "cache_ts": "2011-03-23T12:51:55Z", "_id": "alrex021", "create_ts": "2008-10-14T09:54:00Z"}, "score": 1.0}, {"item": {"username": "Specstacular", "about": null, "karma": 123, "cache_ts": "2011-02-11T06:15:24Z", "_id": "Specstacular", "create_ts": "2009-09-17T06:12:08Z"}, "score": 1.0}, {"item": {"username": "nearestneighbor", "about": "machine learning", "karma": 543, "cache_ts": "2011-01-04T17:44:44Z", "_id": "nearestneighbor", "create_ts": "2009-09-07T06:02:12Z"}, "score": 1.0}, {"item": {"username": "minus1", "about": null, "karma": 197, "cache_ts": "2011-03-24T00:57:59Z", "_id": "minus1", "create_ts": "2007-08-23T04:27:27Z"}, "score": 1.0}, {"item": {"username": "lloydP", "about": null, "karma": 4, "cache_ts": "2011-01-04T17:44:32Z", "_id": "lloydP", "create_ts": "2009-12-17T22:51:28Z"}, "score": 1.0}, {"item": {"username": "pierrefar", "about": "Currently freelancing my way to a startup in online education.<p>My projects, past and present:<p>OpenCourseWare search engine: http://www.ocwsearch.com/<p>SEO geek: http://ekstreme.com<p>Science blogger: http://blogsci.com<p>Built and sold Cligs ( http://cli.gs/ ), a URL shortener with analytics for professional marketers.<p>Personal/umbrella website: http://www.pierrefar.com/<p>Twitter: http://twitter.com/pierrefar .<p>Email: \"hackernews\" at my username dotcom.<p>My top color is #FFDC7A.", "karma": 5117, "cache_ts": "2011-03-23T20:41:47Z", "_id": "pierrefar", "create_ts": "2007-11-13T12:42:43Z"}, "score": 1.0}, {"item": {"username": "rationalthug", "about": null, "karma": 1, "cache_ts": "2011-01-04T17:44:56Z", "_id": "rationalthug", "create_ts": "2009-09-10T20:02:15Z"}, "score": 1.0}], "time": 0.012382984161376953}
|
@@ -0,0 +1,22 @@
|
|
1
|
+
require 'helper'
|
2
|
+
|
3
|
+
describe HackerNewsSearch::Client::Items do
|
4
|
+
|
5
|
+
before do
|
6
|
+
@client = HackerNewsSearch::Client.new
|
7
|
+
end
|
8
|
+
|
9
|
+
describe ".items" do
|
10
|
+
before do
|
11
|
+
stub_get("items/2619846-a30f9").
|
12
|
+
to_return(:status => 200, :body => fixture("items.json"))
|
13
|
+
end
|
14
|
+
|
15
|
+
it "should return the correct item" do
|
16
|
+
item = @client.item("2619846-a30f9")
|
17
|
+
a_get("items/2619846-a30f9").should have_been_made
|
18
|
+
item.id.should == 2619846
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
require 'helper'
|
2
|
+
|
3
|
+
describe HackerNewsSearch::Client::Search do
|
4
|
+
|
5
|
+
before do
|
6
|
+
@client = HackerNewsSearch::Client.new
|
7
|
+
end
|
8
|
+
|
9
|
+
describe ".search" do
|
10
|
+
context "with item search" do
|
11
|
+
before do
|
12
|
+
stub_get("items/_search?q=sferik").
|
13
|
+
to_return(:status => 200, :body => fixture("items_search.json"))
|
14
|
+
end
|
15
|
+
|
16
|
+
it "should fetch all items matching the search criteria" do
|
17
|
+
search = @client.search("items", {:q => "sferik"})
|
18
|
+
a_get("items/_search?q=sferik").should have_been_made
|
19
|
+
search.hits.should == 13
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
describe ".hotness" do
|
25
|
+
before do
|
26
|
+
stub_get("items/_search?limit=30&sortby=product(points,pow(2,div(div(ms(create_ts,NOW),3600000),72)))%20desc").
|
27
|
+
to_return(:status => 200, :body => fixture("hotness.json"))
|
28
|
+
end
|
29
|
+
|
30
|
+
it "should return the current hot stories on hacker news" do
|
31
|
+
hot = @client.hotness
|
32
|
+
a_get("items/_search?limit=30&sortby=product(points,pow(2,div(div(ms(create_ts,NOW),3600000),72)))%20desc").should have_been_made
|
33
|
+
hot.hits == 2428061
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
require 'helper'
|
2
|
+
|
3
|
+
describe HackerNewsSearch::Client::Users do
|
4
|
+
|
5
|
+
before do
|
6
|
+
@client = HackerNewsSearch::Client.new
|
7
|
+
end
|
8
|
+
|
9
|
+
describe ".users" do
|
10
|
+
before do
|
11
|
+
stub_get("users/sferik").
|
12
|
+
to_return(:status => 200, :body => fixture("users.json"))
|
13
|
+
end
|
14
|
+
|
15
|
+
it "should return one user" do
|
16
|
+
user = @client.users("sferik")
|
17
|
+
a_get("users/sferik").should have_been_made
|
18
|
+
user.username.should == "sferik"
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
end
|
data/spec/helper.rb
ADDED
@@ -0,0 +1,47 @@
|
|
1
|
+
$:.unshift File.expand_path('..', __FILE__)
|
2
|
+
$:.unshift File.expand_path('../../lib', __FILE__)
|
3
|
+
require 'simplecov'
|
4
|
+
SimpleCov.start
|
5
|
+
require 'hacker_news_search'
|
6
|
+
require 'rspec'
|
7
|
+
require 'webmock/rspec'
|
8
|
+
|
9
|
+
def a_delete(path)
|
10
|
+
a_request(:delete, 'http://api.thriftdb.com/api.hnsearch.com/' + path)
|
11
|
+
end
|
12
|
+
|
13
|
+
def a_get(path)
|
14
|
+
a_request(:get, 'http://api.thriftdb.com/api.hnsearch.com/' + path)
|
15
|
+
end
|
16
|
+
|
17
|
+
def a_post(path)
|
18
|
+
a_request(:post, 'http://api.thriftdb.com/api.hnsearch.com/' + path)
|
19
|
+
end
|
20
|
+
|
21
|
+
def a_put(path)
|
22
|
+
a_request(:put, 'http://api.thriftdb.com/api.hnsearch.com/' + path)
|
23
|
+
end
|
24
|
+
|
25
|
+
def stub_delete(path)
|
26
|
+
stub_request(:delete, 'http://api.thriftdb.com/api.hnsearch.com/' + path)
|
27
|
+
end
|
28
|
+
|
29
|
+
def stub_get(path)
|
30
|
+
stub_request(:get, 'http://api.thriftdb.com/api.hnsearch.com/' + path)
|
31
|
+
end
|
32
|
+
|
33
|
+
def stub_post(path)
|
34
|
+
stub_request(:post, 'http://api.thriftdb.com/api.hnsearch.com/' + path)
|
35
|
+
end
|
36
|
+
|
37
|
+
def stub_put(path)
|
38
|
+
stub_request(:put, 'http://api.thriftdb.com/api.hnsearch.com/' + path)
|
39
|
+
end
|
40
|
+
|
41
|
+
def fixture_path
|
42
|
+
File.expand_path('../fixtures', __FILE__)
|
43
|
+
end
|
44
|
+
|
45
|
+
def fixture(file)
|
46
|
+
File.new(fixture_path + '/' + file)
|
47
|
+
end
|
metadata
ADDED
@@ -0,0 +1,218 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: hacker_news_search
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Ryan Resella
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2011-06-05 00:00:00.000000000Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: ZenTest
|
16
|
+
requirement: &2157080500 !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ~>
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '4.5'
|
22
|
+
type: :development
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: *2157080500
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: maruku
|
27
|
+
requirement: &2157080000 !ruby/object:Gem::Requirement
|
28
|
+
none: false
|
29
|
+
requirements:
|
30
|
+
- - ~>
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '0.6'
|
33
|
+
type: :development
|
34
|
+
prerelease: false
|
35
|
+
version_requirements: *2157080000
|
36
|
+
- !ruby/object:Gem::Dependency
|
37
|
+
name: rake
|
38
|
+
requirement: &2157079540 !ruby/object:Gem::Requirement
|
39
|
+
none: false
|
40
|
+
requirements:
|
41
|
+
- - ~>
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: '0.9'
|
44
|
+
type: :development
|
45
|
+
prerelease: false
|
46
|
+
version_requirements: *2157079540
|
47
|
+
- !ruby/object:Gem::Dependency
|
48
|
+
name: rspec
|
49
|
+
requirement: &2157079080 !ruby/object:Gem::Requirement
|
50
|
+
none: false
|
51
|
+
requirements:
|
52
|
+
- - ~>
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '2.6'
|
55
|
+
type: :development
|
56
|
+
prerelease: false
|
57
|
+
version_requirements: *2157079080
|
58
|
+
- !ruby/object:Gem::Dependency
|
59
|
+
name: simplecov
|
60
|
+
requirement: &2157078620 !ruby/object:Gem::Requirement
|
61
|
+
none: false
|
62
|
+
requirements:
|
63
|
+
- - ~>
|
64
|
+
- !ruby/object:Gem::Version
|
65
|
+
version: '0.4'
|
66
|
+
type: :development
|
67
|
+
prerelease: false
|
68
|
+
version_requirements: *2157078620
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: webmock
|
71
|
+
requirement: &2157078160 !ruby/object:Gem::Requirement
|
72
|
+
none: false
|
73
|
+
requirements:
|
74
|
+
- - ~>
|
75
|
+
- !ruby/object:Gem::Version
|
76
|
+
version: '1.6'
|
77
|
+
type: :development
|
78
|
+
prerelease: false
|
79
|
+
version_requirements: *2157078160
|
80
|
+
- !ruby/object:Gem::Dependency
|
81
|
+
name: yard
|
82
|
+
requirement: &2157077700 !ruby/object:Gem::Requirement
|
83
|
+
none: false
|
84
|
+
requirements:
|
85
|
+
- - ~>
|
86
|
+
- !ruby/object:Gem::Version
|
87
|
+
version: '0.7'
|
88
|
+
type: :development
|
89
|
+
prerelease: false
|
90
|
+
version_requirements: *2157077700
|
91
|
+
- !ruby/object:Gem::Dependency
|
92
|
+
name: faraday
|
93
|
+
requirement: &2157077240 !ruby/object:Gem::Requirement
|
94
|
+
none: false
|
95
|
+
requirements:
|
96
|
+
- - ~>
|
97
|
+
- !ruby/object:Gem::Version
|
98
|
+
version: 0.6.1
|
99
|
+
type: :runtime
|
100
|
+
prerelease: false
|
101
|
+
version_requirements: *2157077240
|
102
|
+
- !ruby/object:Gem::Dependency
|
103
|
+
name: faraday_middleware
|
104
|
+
requirement: &2157076780 !ruby/object:Gem::Requirement
|
105
|
+
none: false
|
106
|
+
requirements:
|
107
|
+
- - ~>
|
108
|
+
- !ruby/object:Gem::Version
|
109
|
+
version: 0.6.3
|
110
|
+
type: :runtime
|
111
|
+
prerelease: false
|
112
|
+
version_requirements: *2157076780
|
113
|
+
- !ruby/object:Gem::Dependency
|
114
|
+
name: hashie
|
115
|
+
requirement: &2157076320 !ruby/object:Gem::Requirement
|
116
|
+
none: false
|
117
|
+
requirements:
|
118
|
+
- - ~>
|
119
|
+
- !ruby/object:Gem::Version
|
120
|
+
version: 1.0.0
|
121
|
+
type: :runtime
|
122
|
+
prerelease: false
|
123
|
+
version_requirements: *2157076320
|
124
|
+
- !ruby/object:Gem::Dependency
|
125
|
+
name: multi_json
|
126
|
+
requirement: &2157075860 !ruby/object:Gem::Requirement
|
127
|
+
none: false
|
128
|
+
requirements:
|
129
|
+
- - ~>
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: 1.0.2
|
132
|
+
type: :runtime
|
133
|
+
prerelease: false
|
134
|
+
version_requirements: *2157075860
|
135
|
+
- !ruby/object:Gem::Dependency
|
136
|
+
name: rash
|
137
|
+
requirement: &2157075400 !ruby/object:Gem::Requirement
|
138
|
+
none: false
|
139
|
+
requirements:
|
140
|
+
- - ~>
|
141
|
+
- !ruby/object:Gem::Version
|
142
|
+
version: 0.3.0
|
143
|
+
type: :runtime
|
144
|
+
prerelease: false
|
145
|
+
version_requirements: *2157075400
|
146
|
+
description: Simple Ruby wrapper for the Hacker News Search API
|
147
|
+
email: ryan@codeforamerica.org
|
148
|
+
executables: []
|
149
|
+
extensions: []
|
150
|
+
extra_rdoc_files: []
|
151
|
+
files:
|
152
|
+
- .autotest
|
153
|
+
- .gemtest
|
154
|
+
- .gitignore
|
155
|
+
- .rspec
|
156
|
+
- .yardopts
|
157
|
+
- Gemfile
|
158
|
+
- LICENSE.md
|
159
|
+
- README.md
|
160
|
+
- Rakefile
|
161
|
+
- hacker_news_search.gemspec
|
162
|
+
- lib/hacker_news_search.rb
|
163
|
+
- lib/hacker_news_search/client.rb
|
164
|
+
- lib/hacker_news_search/client/connection.rb
|
165
|
+
- lib/hacker_news_search/client/items.rb
|
166
|
+
- lib/hacker_news_search/client/request.rb
|
167
|
+
- lib/hacker_news_search/client/search.rb
|
168
|
+
- lib/hacker_news_search/client/users.rb
|
169
|
+
- lib/hacker_news_search/version.rb
|
170
|
+
- spec/faraday/response_spec.rb
|
171
|
+
- spec/fixtures/hotness.json
|
172
|
+
- spec/fixtures/items.json
|
173
|
+
- spec/fixtures/items_search.json
|
174
|
+
- spec/fixtures/users.json
|
175
|
+
- spec/fixtures/users_search.json
|
176
|
+
- spec/hacker_news_search/client_spec.rb
|
177
|
+
- spec/hacker_news_search/items_spec.rb
|
178
|
+
- spec/hacker_news_search/search_spec.rb
|
179
|
+
- spec/hacker_news_search/users_spec.rb
|
180
|
+
- spec/hacker_news_search_spec.rb
|
181
|
+
- spec/helper.rb
|
182
|
+
homepage: https://github.com/ryanatwork/hacker_news_search
|
183
|
+
licenses: []
|
184
|
+
post_install_message:
|
185
|
+
rdoc_options: []
|
186
|
+
require_paths:
|
187
|
+
- lib
|
188
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
189
|
+
none: false
|
190
|
+
requirements:
|
191
|
+
- - ! '>='
|
192
|
+
- !ruby/object:Gem::Version
|
193
|
+
version: '0'
|
194
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
195
|
+
none: false
|
196
|
+
requirements:
|
197
|
+
- - ! '>='
|
198
|
+
- !ruby/object:Gem::Version
|
199
|
+
version: '0'
|
200
|
+
requirements: []
|
201
|
+
rubyforge_project:
|
202
|
+
rubygems_version: 1.8.5
|
203
|
+
signing_key:
|
204
|
+
specification_version: 3
|
205
|
+
summary: Wrapper for the Hacker News Search API
|
206
|
+
test_files:
|
207
|
+
- spec/faraday/response_spec.rb
|
208
|
+
- spec/fixtures/hotness.json
|
209
|
+
- spec/fixtures/items.json
|
210
|
+
- spec/fixtures/items_search.json
|
211
|
+
- spec/fixtures/users.json
|
212
|
+
- spec/fixtures/users_search.json
|
213
|
+
- spec/hacker_news_search/client_spec.rb
|
214
|
+
- spec/hacker_news_search/items_spec.rb
|
215
|
+
- spec/hacker_news_search/search_spec.rb
|
216
|
+
- spec/hacker_news_search/users_spec.rb
|
217
|
+
- spec/hacker_news_search_spec.rb
|
218
|
+
- spec/helper.rb
|