lita-onewheel-amazon-product 0.0.1 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/lita/handlers/onewheel_amazon_product.rb +12 -3
- data/lita-onewheel-amazon-product.gemspec +1 -1
- data/spec/fixtures/{sample.html → our_price.html} +0 -0
- data/spec/fixtures/third_party_price.html +15 -0
- data/spec/lita/handlers/onewheel_amazon_product_spec.rb +7 -1
- metadata +5 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1b8b4693d0b58b4757039100d7cef861339936a7
|
4
|
+
data.tar.gz: 93da4351bc30eb1f975b4208af04b54f9d47e6d5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8a1f80939a8cbf487421f0cd7dd5c214345100cd76028c858cecfe08ad952b1621144367b18ae86065314dbd892d67079a1d65cc565e64dd3ad3c467909f2e24
|
7
|
+
data.tar.gz: 29a5763e93bd0c3b821cc0cf1545244bab81644679b6723db0e29b377718317cf5e564b96761de17d4f7b9f72f8d3165cc469171dca61cf8becfe2de5f781a2d
|
@@ -10,20 +10,29 @@ module Lita
|
|
10
10
|
description = ''
|
11
11
|
price = 0
|
12
12
|
uri = response.matches[0][0]
|
13
|
+
Lita.logger.debug "lita-onewheel-amazon-product: Grabbing URI #{uri}"
|
13
14
|
doc = RestClient.get uri
|
14
15
|
|
15
16
|
noko_doc = Nokogiri::HTML doc
|
16
|
-
noko_doc.
|
17
|
+
noko_doc.css('meta').each do |meta|
|
17
18
|
attrs = meta.attributes
|
18
19
|
if attrs['name'].to_s == 'description'
|
19
20
|
description = process_description attrs['content'].to_s
|
20
21
|
end
|
21
22
|
end
|
22
23
|
|
23
|
-
price_node = noko_doc.css('span#priceblock_ourprice')
|
24
|
+
price_node = noko_doc.css('span#priceblock_ourprice')
|
25
|
+
|
26
|
+
if price_node.empty?
|
27
|
+
price_node = noko_doc.css('div#unqualifiedBuyBox .a-color-price')
|
28
|
+
end
|
29
|
+
|
30
|
+
unless price_node.empty?
|
31
|
+
price = price_node.first.content.to_s
|
32
|
+
end
|
24
33
|
|
25
34
|
unless description.empty?
|
26
|
-
response.reply
|
35
|
+
response.reply price.to_s + ' ' + description.to_s
|
27
36
|
end
|
28
37
|
end
|
29
38
|
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Gem::Specification.new do |spec|
|
2
2
|
spec.name = 'lita-onewheel-amazon-product'
|
3
|
-
spec.version = '0.0
|
3
|
+
spec.version = '0.1.0'
|
4
4
|
spec.authors = ['Andrew Kreps']
|
5
5
|
spec.email = ['andrew.kreps@gmail.com']
|
6
6
|
spec.description = %q{Lita interface to post information about amazon products.}
|
File without changes
|
@@ -0,0 +1,15 @@
|
|
1
|
+
<!doctype html>
|
2
|
+
<head>
|
3
|
+
<meta http-equiv="content-type" content="text/html; charset=iso-8859-1" />
|
4
|
+
<link rel="canonical" href="http://www.amazon.com/Digital-Life-Performance-Ethernet-Cables/dp/B001AE8YBW" />
|
5
|
+
<meta name="description" content="Amazon.com: Digital Life High Performance Ethernet Cables - Advanced High Speed - 7 ft. Advanced High Speed Ethernet Cable: Electronics" />
|
6
|
+
<meta name="title" content="Amazon.com: Digital Life High Performance Ethernet Cables - Advanced High Speed - 7 ft. Advanced High Speed Ethernet Cable: Electronics" />
|
7
|
+
|
8
|
+
<meta name="keywords" content="Digital Life High Performance Ethernet Cables - Advanced High Speed - 7 ft. Advanced High Speed Ethernet Cable,Monster,DL NET6 AS-7" />
|
9
|
+
<title>Amazon.com: Digital Life High Performance Ethernet Cables - Advanced High Speed - 7 ft. Advanced High Speed Ethernet Cable: Electronics</title>
|
10
|
+
</head>
|
11
|
+
<body>
|
12
|
+
<div id="unqualifiedBuyBox" class="a-box"><div class="a-box-inner">
|
13
|
+
<div class="a-text-center a-spacing-mini"><a href="/gp/offer-listing/B001AE8YBW/ref=dp_olp_new_mbc?ie=UTF8&condition=new">2 new</a> from <span class='a-color-price'>$67.30</span></div>
|
14
|
+
</body>
|
15
|
+
</html>
|
@@ -7,8 +7,14 @@ end
|
|
7
7
|
|
8
8
|
describe Lita::Handlers::OnewheelAmazonProduct, lita_handler: true do
|
9
9
|
it 'puts the amazon product info on the response' do
|
10
|
-
mock_fixture('
|
10
|
+
mock_fixture('our_price')
|
11
11
|
send_message ('http://www.amazon.com/Plugable-Micro-B-Ethernet-Raspberry-AX88772A/dp/B00RM3KXAU/')
|
12
12
|
expect(replies.last).to eq('$13.95 Plugable USB 2.0 OTG Micro-B to 10/100 Fast Ethernet Adapter for Windows Tablets & Raspberry Pi Zero (ASIX AX88772A chipset)')
|
13
13
|
end
|
14
|
+
|
15
|
+
it 'puts the amazon product info on the response when there is no amazon price' do
|
16
|
+
mock_fixture('third_party_price')
|
17
|
+
send_message ('http://www.amazon.com/Digital-Life-Performance-Ethernet-Cables/dp/B001AE8YBW/')
|
18
|
+
expect(replies.last).to eq('$67.30 Digital Life High Performance Ethernet Cables - Advanced High Speed - 7 ft. Advanced High Speed Ethernet Cable')
|
19
|
+
end
|
14
20
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: lita-onewheel-amazon-product
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andrew Kreps
|
@@ -151,7 +151,8 @@ files:
|
|
151
151
|
- lib/lita-onewheel-amazon-product.rb
|
152
152
|
- lib/lita/handlers/onewheel_amazon_product.rb
|
153
153
|
- lita-onewheel-amazon-product.gemspec
|
154
|
-
- spec/fixtures/
|
154
|
+
- spec/fixtures/our_price.html
|
155
|
+
- spec/fixtures/third_party_price.html
|
155
156
|
- spec/lita/handlers/onewheel_amazon_product_spec.rb
|
156
157
|
- spec/spec_helper.rb
|
157
158
|
homepage: https://github.com/onewheelskyward/lita-onewheel-amazon-product
|
@@ -180,6 +181,7 @@ signing_key:
|
|
180
181
|
specification_version: 4
|
181
182
|
summary: See above.
|
182
183
|
test_files:
|
183
|
-
- spec/fixtures/
|
184
|
+
- spec/fixtures/our_price.html
|
185
|
+
- spec/fixtures/third_party_price.html
|
184
186
|
- spec/lita/handlers/onewheel_amazon_product_spec.rb
|
185
187
|
- spec/spec_helper.rb
|