biffbot 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/biffbot.gemspec +3 -1
- data/lib/biffbot/base.rb +17 -0
- data/lib/biffbot/version.rb +1 -1
- data/spec/biffbot_spec.rb +7 -0
- data/spec/spec_helper.rb +1 -0
- metadata +43 -6
data/biffbot.gemspec
CHANGED
@@ -7,7 +7,7 @@ Gem::Specification.new do |gem|
|
|
7
7
|
gem.name = "biffbot"
|
8
8
|
gem.version = Biffbot::VERSION
|
9
9
|
gem.authors = ["Anurag Mohanty"]
|
10
|
-
gem.email = ["
|
10
|
+
gem.email = ["tevren@gmail.com"]
|
11
11
|
gem.description = "Ruby gem to connect to diffbot's article api"
|
12
12
|
gem.summary = "Given a url, pulls article content using diffbot's article extractor"
|
13
13
|
gem.homepage = "https://github.com/tevren/biffbot"
|
@@ -17,4 +17,6 @@ Gem::Specification.new do |gem|
|
|
17
17
|
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
18
18
|
gem.require_paths = ["lib"]
|
19
19
|
gem.add_dependency("httparty")
|
20
|
+
gem.add_dependency("json", "~> 1.7.7")
|
21
|
+
gem.add_development_dependency("rspec")
|
20
22
|
end
|
data/lib/biffbot/base.rb
CHANGED
@@ -1,4 +1,6 @@
|
|
1
1
|
require 'httparty'
|
2
|
+
require 'json'
|
3
|
+
|
2
4
|
module Biffbot
|
3
5
|
class Base
|
4
6
|
def initialize(token)
|
@@ -19,5 +21,20 @@ module Biffbot
|
|
19
21
|
end
|
20
22
|
return output
|
21
23
|
end
|
24
|
+
def batch(urls=[],options={})
|
25
|
+
output = []
|
26
|
+
request = "http://www.diffbot.com/api/batch"
|
27
|
+
batch = urls.map do |url|
|
28
|
+
{ :method => "GET", :relative_url => "/api/article?token=#{@token}&url=#{url}" }
|
29
|
+
end
|
30
|
+
options = { :body => {:token => @token, :batch => batch.to_json }, :basic_auth => @auth }
|
31
|
+
response = HTTParty.post(request, options)
|
32
|
+
|
33
|
+
JSON.parse(response.parsed_response).each do |response_dict|
|
34
|
+
puts response_dict.inspect
|
35
|
+
output << JSON.parse(response_dict["body"])
|
36
|
+
end
|
37
|
+
return output
|
38
|
+
end
|
22
39
|
end
|
23
40
|
end
|
data/lib/biffbot/version.rb
CHANGED
data/spec/biffbot_spec.rb
CHANGED
@@ -11,4 +11,11 @@ describe Biffbot do
|
|
11
11
|
@biffbot.parse("http://www.huffingtonpost.ca/2012/10/11/amanda-todd-teen-bullying-suicide-youtube_n_1959668.html").size.should_not be_nil
|
12
12
|
end
|
13
13
|
end
|
14
|
+
|
15
|
+
describe "#batch" do
|
16
|
+
it "not nil" do
|
17
|
+
articles = ["http://www.huffingtonpost.ca/2012/10/11/amanda-todd-teen-bullying-suicide-youtube_n_1959668.html", "http://www.nytimes.com/2013/02/08/business/asset-sales-help-quarterly-profit-at-times-company.html"]
|
18
|
+
@biffbot.batch(articles).size.should == 2
|
19
|
+
end
|
20
|
+
end
|
14
21
|
end
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: biffbot
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2013-05-12 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: httparty
|
16
|
-
requirement:
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,10 +21,47 @@ dependencies:
|
|
21
21
|
version: '0'
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements:
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ! '>='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '0'
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: json
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - ~>
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: 1.7.7
|
38
|
+
type: :runtime
|
39
|
+
prerelease: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ~>
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: 1.7.7
|
46
|
+
- !ruby/object:Gem::Dependency
|
47
|
+
name: rspec
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
50
|
+
requirements:
|
51
|
+
- - ! '>='
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '0'
|
54
|
+
type: :development
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ! '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
25
62
|
description: Ruby gem to connect to diffbot's article api
|
26
63
|
email:
|
27
|
-
-
|
64
|
+
- tevren@gmail.com
|
28
65
|
executables: []
|
29
66
|
extensions: []
|
30
67
|
extra_rdoc_files: []
|
@@ -60,7 +97,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
60
97
|
version: '0'
|
61
98
|
requirements: []
|
62
99
|
rubyforge_project:
|
63
|
-
rubygems_version: 1.8.
|
100
|
+
rubygems_version: 1.8.24
|
64
101
|
signing_key:
|
65
102
|
specification_version: 3
|
66
103
|
summary: Given a url, pulls article content using diffbot's article extractor
|