diffbot 0.1.14 → 0.1.15
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.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/diffbot.gemspec +1 -1
- data/lib/diffbot/items/product.rb +32 -0
- data/lib/diffbot/product.rb +2 -0
- data/test/fixtures/product.json +1 -0
- data/test/product_test.rb +24 -0
- metadata +4 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: caa4e4b6ca88014e688c7cf370a7cc15cebf63b9
|
|
4
|
+
data.tar.gz: e3760fa56c809acfef7df0dd028c3e5aef77723c
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 9320d5b79937bced704bcc8ea3147da7e6fd6152c37f7a9d0e4e5f8a11e5fab76f7dc415e100860a9b070fd30df3f2b11ed61cc1e875141eb86d4a61048c1389
|
|
7
|
+
data.tar.gz: a8c9b7496cd96410329875548cbb4057471d8f750a3dcb498ab9eb0befee48bad42a63688d81a0155b3b77e610a3a95fbef444aee9056b51a1098a62fb3e0b19
|
data/Gemfile.lock
CHANGED
data/diffbot.gemspec
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Gem::Specification.new do |s|
|
|
2
2
|
s.name = "diffbot"
|
|
3
|
-
s.version = "0.1.
|
|
3
|
+
s.version = "0.1.15"
|
|
4
4
|
s.description = "Diffbot provides a concise API for analyzing and extracting semantic information from web pages using Diffbot (http://www.diffbot.com)."
|
|
5
5
|
s.summary = "Ruby interface to the Diffbot API "
|
|
6
6
|
s.authors = ["Nicolas Sanguinetti", "Roman Greshny"]
|
|
@@ -2,6 +2,11 @@ module Diffbot
|
|
|
2
2
|
module Items
|
|
3
3
|
class Product < Hashie::Trash
|
|
4
4
|
extend CoercibleHash
|
|
5
|
+
include Hashie::Extensions::Coercion
|
|
6
|
+
include Hashie::Extensions::IndifferentAccess
|
|
7
|
+
|
|
8
|
+
# Type of object (always product).
|
|
9
|
+
property :type
|
|
5
10
|
|
|
6
11
|
# Name of the product. Returned by default.
|
|
7
12
|
property :title
|
|
@@ -9,6 +14,9 @@ module Diffbot
|
|
|
9
14
|
# Description, if available, of the product. Returned by default.
|
|
10
15
|
property :description
|
|
11
16
|
|
|
17
|
+
# Item's brand name.
|
|
18
|
+
property :brand
|
|
19
|
+
|
|
12
20
|
# Identified offer or actual/'final' price of the product. Returned by default.
|
|
13
21
|
property :offer_price, from: :offerPrice
|
|
14
22
|
|
|
@@ -23,6 +31,9 @@ module Diffbot
|
|
|
23
31
|
property :availability
|
|
24
32
|
|
|
25
33
|
class Details < Hashie::Trash
|
|
34
|
+
include Hashie::Extensions::Coercion
|
|
35
|
+
include Hashie::Extensions::IndifferentAccess
|
|
36
|
+
|
|
26
37
|
property :amount
|
|
27
38
|
property :text
|
|
28
39
|
property :symbol
|
|
@@ -32,6 +43,9 @@ module Diffbot
|
|
|
32
43
|
coerce_property :offer_price_details, class: Details
|
|
33
44
|
|
|
34
45
|
class Media < Hashie::Trash
|
|
46
|
+
include Hashie::Extensions::Coercion
|
|
47
|
+
include Hashie::Extensions::IndifferentAccess
|
|
48
|
+
|
|
35
49
|
# Only images. Returns "True" if image is identified as primary in terms of size
|
|
36
50
|
# or positioning.
|
|
37
51
|
property :primary
|
|
@@ -53,11 +67,29 @@ module Diffbot
|
|
|
53
67
|
|
|
54
68
|
# Full document Xpath to the media item.
|
|
55
69
|
property :xpath
|
|
70
|
+
|
|
71
|
+
# Raw image height, in pixels.
|
|
72
|
+
property :natural_height, from: :naturalHeight
|
|
73
|
+
|
|
74
|
+
# Raw image width, in pixels.
|
|
75
|
+
property :natural_width, from: :naturalWidth
|
|
76
|
+
|
|
77
|
+
# Internal ID used for indexing.
|
|
78
|
+
property :diffbot_uri, from: :diffbotUri
|
|
56
79
|
end
|
|
57
80
|
|
|
58
81
|
# Array of media items (images or videos) of the product. Returned by default.
|
|
59
82
|
property :media
|
|
60
83
|
coerce_property :media, collection: Media
|
|
84
|
+
|
|
85
|
+
# If a specifications table or similar data is available on the product page,
|
|
86
|
+
# individual specifications will be returned in the specs object as name/value pairs.
|
|
87
|
+
# Names will be normalized to lowercase with spaces replaced by underscores,
|
|
88
|
+
# e.g. display_resolution.
|
|
89
|
+
property :specs
|
|
90
|
+
|
|
91
|
+
# Stock Keeping Unit -- store/vendor inventory number or identifier.
|
|
92
|
+
property :sku
|
|
61
93
|
end
|
|
62
94
|
end
|
|
63
95
|
end
|
data/lib/diffbot/product.rb
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"leafPage":true,"breadcrumb":[{"link":"https://www.amazon.de/baby-babyausstattung-babyartikel/b/ref=dp_bc_1/254-2360146-4073516?ie=UTF8&node=355007011","name":"Baby"},{"link":"https://www.amazon.de/Autositze-Zubeh%C3%B6r/b/ref=dp_bc_2/254-2360146-4073516?ie=UTF8&node=3968832031","name":"Autositze & Zubehör"},{"link":"https://www.amazon.de/Kinderautositze/b/ref=dp_bc_3/254-2360146-4073516?ie=UTF8&node=3968833031","name":"Autositze"}],"url":"https://www.amazon.de/Britax-R%C3%B6mer-Autositz-Kid-Gruppe/dp/B016223T20/ref=sr_1_1?ie=UTF8&qid=1458430097&sr=8-1&keywords=BRITAX+R%C3%96MER+Kid+II","products":[{"offerPriceDetails":{"amount":88.9,"text":"EUR88,90"},"specs":{"modellnummer":"2000022495","model_jahr":"2015","faa-approved_for_use_on_aircraft":"certified frustration-free","artikelgewicht":"5 Kg","empfohlenes_minimales_körpergewicht":"15 Kilogramm","produktabmessungen":"45 x 51 x 68 cm","empfohlenes_maximales_körpergewicht":"36 Kilogramm","is_portable":"Nein","im_angebot_von_amazonde_seit":"2. Oktober 2015","farbe":"Cosmos Black","durchschnittliche_kundenbewertung":"82 Kundenrezensionen","besondere_merkmale":"Leichtgewicht","asin":"B016223T20","dishwasher_safe":"Nein","amazon_bestseller-rang":"Nr. 123 in Baby (Siehe Top 100)\nNr. 5 in Baby > Autositze & Zubehör > Autositze","benötigt_batterien":"Nein","produktgewicht_inkl_verpackung":"8 Kg"},"offerPrice":"EUR88,90","productId":"1458430097","description":"Gruppe 2/3 geeignet von 15 - 36 kg (ca. 4 bis 12 Jahre)\nMade in Germany\nDesign für fehlerfreie Handhabung \u2013 Gurtführung für intuitiv richtiges Anschnallen\nOptimaler Schutz\u2013 hohe, weich gepolsterte Seitenteile & höhenverstellbare Kopfstütze\nLeichtgewicht \u2013 einfacher Wechsel zwischen zwei Fahrzeugen","media":[{"xpath":"/html[1]/body[1]/div[6]/div[1]/div[6]/div[5]/div[1]/div[1]/div[1]/div[1]/div[2]/div[1]/div[1]/ul[1]/li[1]/span[1]/span[1]/div[1]/img[1]","link":"https://images-na.ssl-images-amazon.com/images/I/81qToh6bffL._SX425_.jpg","naturalHeight":425,"width":396,"caption":"Britax Römer Autositz KID II, Gruppe 2/3 (15 - 36 kg), Kollektion 2017, Cosmos Black","naturalWidth":425,"primary":"true","height":396}],"availability":true,"type":"product","title":"Britax Römer Autositz KID II, Gruppe 2/3 (15 - 36 kg), Kollektion 2017, Cosmos Black","sku":"1458430097","brand":"Britax Römer"}]}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
require 'test_helper'
|
|
2
|
+
require 'uri'
|
|
3
|
+
|
|
4
|
+
describe Diffbot::Product do
|
|
5
|
+
describe '.fetch' do
|
|
6
|
+
before do
|
|
7
|
+
path = URI.parse(Diffbot::Product.endpoint).path
|
|
8
|
+
|
|
9
|
+
body = File.read('test/fixtures/product.json')
|
|
10
|
+
|
|
11
|
+
Excon.stub(method: :get, path: path) do |params|
|
|
12
|
+
{ body: body, status: 200 }
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
it 'returns a new Product' do
|
|
17
|
+
product = Diffbot::Product.fetch('https://www.amazon.de/Britax-R%C3%B6mer-Autositz-Kid-Gruppe/dp/B016223T20')
|
|
18
|
+
product_item = product.products[0]
|
|
19
|
+
|
|
20
|
+
product_item.title.must_match(/Britax/)
|
|
21
|
+
product_item.type.must_equal('product')
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
end
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: diffbot
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.1.
|
|
4
|
+
version: 0.1.15
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Nicolas Sanguinetti
|
|
@@ -9,7 +9,7 @@ authors:
|
|
|
9
9
|
autorequire:
|
|
10
10
|
bindir: bin
|
|
11
11
|
cert_chain: []
|
|
12
|
-
date: 2017-02-
|
|
12
|
+
date: 2017-02-23 00:00:00.000000000 Z
|
|
13
13
|
dependencies:
|
|
14
14
|
- !ruby/object:Gem::Dependency
|
|
15
15
|
name: excon
|
|
@@ -137,6 +137,8 @@ files:
|
|
|
137
137
|
- lib/diffbot/request.rb
|
|
138
138
|
- test/article_test.rb
|
|
139
139
|
- test/coercible_hash_test.rb
|
|
140
|
+
- test/fixtures/product.json
|
|
141
|
+
- test/product_test.rb
|
|
140
142
|
- test/request_test.rb
|
|
141
143
|
- test/test_helper.rb
|
|
142
144
|
homepage: http://github.com/greshny/diffbot
|