diffbot_api 0.0.1 → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,38 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: http://api.diffbot.com/v2/article?token=a61adc28baecf45aae26966288f2db19&url=/example.com
6
+ body:
7
+ encoding: US-ASCII
8
+ string: ''
9
+ headers:
10
+ User-Agent:
11
+ - Faraday v0.8.8
12
+ Accept-Encoding:
13
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
14
+ Accept:
15
+ - "*/*"
16
+ response:
17
+ status:
18
+ code: 500
19
+ message: Internal Server Error
20
+ headers:
21
+ Server:
22
+ - nginx/1.3.4
23
+ Date:
24
+ - Wed, 08 Jan 2014 21:34:41 GMT
25
+ Content-Type:
26
+ - application/json;charset=UTF-8
27
+ Transfer-Encoding:
28
+ - chunked
29
+ Connection:
30
+ - keep-alive
31
+ Vary:
32
+ - Accept-Encoding
33
+ body:
34
+ encoding: UTF-8
35
+ string: "{\"error\":\"Error.\",\"errorCode\":500}"
36
+ http_version:
37
+ recorded_at: Wed, 08 Jan 2014 21:31:19 GMT
38
+ recorded_with: VCR 2.8.0
@@ -0,0 +1,35 @@
1
+ require 'spec_helper'
2
+
3
+ describe Diffbot::Article do
4
+ before do
5
+ Diffbot.configure do |c|
6
+ c.token = DIFFBOT_TEST_TOKEN
7
+ end
8
+ end
9
+
10
+ describe "validations" do
11
+ it "validates token existance" do
12
+ Diffbot.stub(:token).and_return(nil)
13
+
14
+ expect { Diffbot::Article.new("example.com") }.to raise_error Diffbot::TokenNotFound
15
+ end
16
+ end
17
+
18
+ describe "extracts xconomy article", :vcr do
19
+ XCONOMY = "http://www.xconomy.com/san-francisco/2012/07/25/diffbot-is-using-computer-vision-to-reinvent-the-semantic-web/"
20
+ let(:article) { Diffbot::Article.new(XCONOMY) }
21
+
22
+ it "fetches article title" do
23
+ expect(article['title']).to eq "Diffbot Is Using Computer Vision to Reinvent the Semantic Web"
24
+ end
25
+
26
+ it "fetches article author" do
27
+ expect(article['author']).to eq "Wade Roush"
28
+ end
29
+
30
+ it "fetches article date" do
31
+ expect(article['date']).to match /Wed, 25 Jul 2012/
32
+ end
33
+
34
+ end
35
+ end
@@ -0,0 +1,26 @@
1
+ require 'spec_helper'
2
+
3
+ describe Diffbot::Client do
4
+
5
+ before do
6
+ Diffbot.configure do |c|
7
+ c.token = DIFFBOT_TEST_TOKEN
8
+ end
9
+ end
10
+
11
+ describe ".article", :vcr do
12
+ let(:client) { Diffbot::Client.new }
13
+
14
+ it "build an article from his url" do
15
+ expect(client.article("example.com")).to be_a Diffbot::Article
16
+ end
17
+ end
18
+
19
+ describe "validations" do
20
+ it "validates token existance" do
21
+ Diffbot.stub(:token).and_return(nil)
22
+
23
+ expect { Diffbot::Client.new }.to raise_exception Diffbot::TokenNotFound
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,19 @@
1
+ require 'spec_helper'
2
+
3
+ describe Diffbot::Configurable do
4
+
5
+ before do
6
+ Diffbot.configure do |config|
7
+ config.token = DIFFBOT_TEST_TOKEN
8
+ end
9
+ end
10
+
11
+ it "loads default configuration" do
12
+ expect(Diffbot.api_endpoint).to eq "http://api.diffbot.com"
13
+ expect(Diffbot.api_version).to eq "v2"
14
+ end
15
+
16
+ it "overrides module configuration" do
17
+ expect(Diffbot.token).to eq DIFFBOT_TEST_TOKEN
18
+ end
19
+ end
@@ -0,0 +1,16 @@
1
+ require 'diffbot_api'
2
+ require 'rspec'
3
+ require 'vcr'
4
+
5
+ DIFFBOT_TEST_TOKEN = "a61adc28baecf45aae26966288f2db19"
6
+
7
+ RSpec.configure do |c|
8
+ # in RSpec 3 this will no longer be necessary
9
+ c.treat_symbols_as_metadata_keys_with_true_values = true
10
+ end
11
+
12
+ VCR.configure do |c|
13
+ c.cassette_library_dir = 'spec/cassettes'
14
+ c.hook_into :webmock
15
+ c.configure_rspec_metadata!
16
+ end
metadata CHANGED
@@ -1,43 +1,43 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: diffbot_api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Oscar Rendon
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-01-05 00:00:00.000000000 Z
11
+ date: 2014-01-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: bundler
14
+ name: faraday
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '1.5'
20
- type: :development
19
+ version: 0.8.8
20
+ type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '1.5'
26
+ version: 0.8.8
27
27
  - !ruby/object:Gem::Dependency
28
- name: rake
28
+ name: bundler
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - ">="
31
+ - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '0'
33
+ version: '1.5'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - ">="
38
+ - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: '0'
40
+ version: '1.5'
41
41
  description: Ruby wraper for the Diffbot API, follows Ruby conventions and idioms.
42
42
  email:
43
43
  - orendon@gmail.com
@@ -45,14 +45,32 @@ executables: []
45
45
  extensions: []
46
46
  extra_rdoc_files: []
47
47
  files:
48
+ - ".gitignore"
49
+ - ".rspec"
50
+ - ".travis.yml"
48
51
  - Gemfile
52
+ - Gemfile.lock
49
53
  - LICENSE
50
54
  - LICENSE.txt
51
55
  - README.md
52
56
  - Rakefile
53
57
  - diffbot_api.gemspec
54
58
  - lib/diffbot_api.rb
59
+ - lib/diffbot_api/article.rb
60
+ - lib/diffbot_api/base.rb
61
+ - lib/diffbot_api/client.rb
62
+ - lib/diffbot_api/configurable.rb
55
63
  - lib/diffbot_api/version.rb
64
+ - spec/cassettes/Diffbot_Article/extracts_xconomy_article/fetches_article_author.yml
65
+ - spec/cassettes/Diffbot_Article/extracts_xconomy_article/fetches_article_date.yml
66
+ - spec/cassettes/Diffbot_Article/extracts_xconomy_article/fetches_article_title.yml
67
+ - spec/cassettes/Diffbot_Article/extracts_xconomy_article/raises_an_error_with_unknown_fields.yml
68
+ - spec/cassettes/Diffbot_Article/extracts_xconomy_article/raises_an_error_with_unknown_keys.yml
69
+ - spec/cassettes/Diffbot_Client/_article/build_an_article_from_his_url.yml
70
+ - spec/diffbot_api/article_spec.rb
71
+ - spec/diffbot_api/client_spec.rb
72
+ - spec/diffbot_api/configurable_spec.rb
73
+ - spec/spec_helper.rb
56
74
  homepage: https://github.com/orendon/diffbot.rb
57
75
  licenses:
58
76
  - MIT
@@ -77,4 +95,15 @@ rubygems_version: 2.2.0
77
95
  signing_key:
78
96
  specification_version: 4
79
97
  summary: Ruby client for Diffbot API.
80
- test_files: []
98
+ test_files:
99
+ - spec/cassettes/Diffbot_Article/extracts_xconomy_article/fetches_article_author.yml
100
+ - spec/cassettes/Diffbot_Article/extracts_xconomy_article/fetches_article_date.yml
101
+ - spec/cassettes/Diffbot_Article/extracts_xconomy_article/fetches_article_title.yml
102
+ - spec/cassettes/Diffbot_Article/extracts_xconomy_article/raises_an_error_with_unknown_fields.yml
103
+ - spec/cassettes/Diffbot_Article/extracts_xconomy_article/raises_an_error_with_unknown_keys.yml
104
+ - spec/cassettes/Diffbot_Client/_article/build_an_article_from_his_url.yml
105
+ - spec/diffbot_api/article_spec.rb
106
+ - spec/diffbot_api/client_spec.rb
107
+ - spec/diffbot_api/configurable_spec.rb
108
+ - spec/spec_helper.rb
109
+ has_rdoc: