lita-onewheel-amazon-product 0.2.0 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f98b72ecf3b47998dd6d9e0f679e0f789c8d142a
4
- data.tar.gz: 73adedab333f48bfcb45c74302808866c0f032d0
3
+ metadata.gz: 6899ecfa18f1bb5b95a06b39bd09c0448ad30a23
4
+ data.tar.gz: 9c04098ff39157d2cabd9eba72a23ebf34816572
5
5
  SHA512:
6
- metadata.gz: feab464de042d61b60ef7b9a0069b9cb87757dc70c81168ffd6f5074be38fd066c15ab65b9aa43a16e45ff3be1e21205e659aad8c0fbf1f29bbb4710256d64ab
7
- data.tar.gz: 0ddb056899b1af00670c00d2f100c9309d104ec8318f9886623dc5019136a8787be68091872086eb3fe1794b682f90f9caeb5da076e9171a98a93ef6854c0764
6
+ metadata.gz: 530548e88d7ffc3ef3ccce4c69c348041eb027fac0aef818c3343cd0460692c0970ba27437b94e55f8e3f103ec2fe9dd7adbad707155517c0c892e888b14f6d8
7
+ data.tar.gz: 2d17c457a457add13b13fd9d4a6c666ad2828e3f6c88ec8d4be26a77726782561f1c9a640cf3820cf54afd256082d9ae5d3eb03e4e305320e3a8c47930be4e4b
@@ -26,23 +26,35 @@ module Lita
26
26
  return
27
27
  end
28
28
 
29
+ price = get_price(noko_doc)
30
+
31
+ unless description.empty?
32
+ response.reply price.to_s + ' ' + description.to_s
33
+ end
34
+ end
35
+
36
+ def get_price(noko_doc)
29
37
  price_node = noko_doc.css('span#priceblock_ourprice')
30
38
 
39
+ # Typical product price
31
40
  if price_node.empty?
32
41
  price_node = noko_doc.css('div#unqualifiedBuyBox .a-color-price')
33
42
  end
34
43
 
44
+ # Third-party seller only price
35
45
  if price_node.empty?
36
46
  price_node = noko_doc.css('div#buyNewSection span.a-color-price')
37
47
  end
38
48
 
39
- unless price_node.empty?
40
- price = price_node.first.content.to_s
49
+ # Kindle book price
50
+ if price_node.empty?
51
+ price_node = noko_doc.css('td.dp-price-col span.a-color-price')
41
52
  end
42
53
 
43
- unless description.empty?
44
- response.reply price.to_s + ' ' + description.to_s
54
+ unless price_node.empty?
55
+ price = price_node.first.content.to_s
45
56
  end
57
+ price
46
58
  end
47
59
 
48
60
  def process_description(desc)
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |spec|
2
2
  spec.name = 'lita-onewheel-amazon-product'
3
- spec.version = '0.2.0'
3
+ spec.version = '0.3.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.}
@@ -1,26 +1,28 @@
1
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/Live-Detroit-Without-Being-Jackass/dp/0996836705" />
5
- <meta name="description" content="How To Live In Detroit Without Being A Jackass [Aaron Foley] on Amazon.com. *FREE* shipping on qualifying offers. Are you moving to Detroit because your rent is too high? Did you read somewhere that the only thing you needed to buy a house was the change in your couch cushions? Are you totally terrified about living in one of the most crime-plagued cities in the United States? Welcome to Detroit" />
6
- <meta name="title" content="How To Live In Detroit Without Being A Jackass: Aaron Foley: 9780996836708: Amazon.com: Books" />
7
- <meta name="keywords" content="Aaron Foley,How To Live In Detroit Without Being A Jackass,Belt Publishing,0996836705,Travel / Americas" />
8
- <title>How To Live In Detroit Without Being A Jackass: Aaron Foley: 9780996836708: Amazon.com: Books</title>
9
- <div id="buyNewSection" class="rbbHeader dp-accordion-row">
10
- <h5>
11
- <div class="a-row">
12
- <div class="a-column a-span4 a-text-left a-nowrap">
13
- <span class="a-text-bold">Buy New</span>
14
- </div>
15
- <div class="a-column a-span8 a-text-right a-span-last">
16
- <div class="inlineBlock-display">
17
- <span class="a-letter-space"></span>
18
- <span class="a-size-medium a-color-price offer-price a-text-normal">$15.10</span>
19
- </div>
20
- </div>
21
- </div>
22
- </h5>
23
- </div>
2
+ <html>
3
+ <head>
4
+ <meta http-equiv="content-type" content="text/html; charset=iso-8859-1" />
5
+ <link rel="canonical" href="http://www.amazon.com/Live-Detroit-Without-Being-Jackass/dp/0996836705" />
6
+ <meta name="description" content="How To Live In Detroit Without Being A Jackass [Aaron Foley] on Amazon.com. *FREE* shipping on qualifying offers. Are you moving to Detroit because your rent is too high? Did you read somewhere that the only thing you needed to buy a house was the change in your couch cushions? Are you totally terrified about living in one of the most crime-plagued cities in the United States? Welcome to Detroit" />
7
+ <meta name="title" content="How To Live In Detroit Without Being A Jackass: Aaron Foley: 9780996836708: Amazon.com: Books" />
8
+ <meta name="keywords" content="Aaron Foley,How To Live In Detroit Without Being A Jackass,Belt Publishing,0996836705,Travel / Americas" />
9
+ <title>How To Live In Detroit Without Being A Jackass: Aaron Foley: 9780996836708: Amazon.com: Books</title>
10
+ </head>
11
+ <body>
12
+ <div id="buyNewSection" class="rbbHeader dp-accordion-row">
13
+ <h5>
14
+ <div class="a-row">
15
+ <div class="a-column a-span4 a-text-left a-nowrap">
16
+ <span class="a-text-bold">Buy New</span>
17
+ </div>
18
+ <div class="a-column a-span8 a-text-right a-span-last">
19
+ <div class="inlineBlock-display">
20
+ <span class="a-letter-space"></span>
21
+ <span class="a-size-medium a-color-price offer-price a-text-normal">$15.10</span>
22
+ </div>
23
+ </div>
24
+ </div>
25
+ </h5>
26
+ </div>
24
27
  </body>
25
-
26
28
  </html>
@@ -0,0 +1,26 @@
1
+ <!doctype html>
2
+ <html>
3
+ <head>
4
+ <meta http-equiv="content-type" content="text/html; charset=iso-8859-1" />
5
+ <link rel="canonical" href="http://www.amazon.com/Echo-Billionaire-Romance-Bleeding-Hearts-ebook/dp/B01786HTZW" />
6
+ <meta name="description" content="Echo: A Dark Billionaire Romance (Bleeding Hearts Book 1) - Kindle edition by A Zavarelli. Romance Kindle eBooks @ Amazon.com." />
7
+ <meta name="title" content="Echo: A Dark Billionaire Romance (Bleeding Hearts Book 1) - Kindle edition by A Zavarelli. Romance Kindle eBooks @ Amazon.com." />
8
+ <meta name="keywords" content="echo" />
9
+ <title>Echo: A Dark Billionaire Romance (Bleeding Hearts Book 1) - Kindle edition by A Zavarelli. Romance Kindle eBooks @ Amazon.com.</title>
10
+ </head>
11
+ <body>
12
+ <table class="a-normal a-spacing-none">
13
+ <tr>
14
+ <td class="a-text-right dp-price-col">
15
+ <div class="a-fixed-right-grid"><div class="a-fixed-right-grid-inner" style="padding-right:50px">
16
+ <div class="a-fixed-right-grid-col a-col-left" style="padding-right:2.5%;*width:97.1%;float:left;">
17
+ <span class="a-size-small a-color-price">$2.99</span>
18
+ </div>
19
+ <div class="a-fixed-right-grid-col a-col-right" style="width:50px;margin-right:-50px;float:left;">
20
+ </div>
21
+ </div></div>
22
+ </td>
23
+ </tr>
24
+ </table>
25
+ </body>
26
+ </html>
@@ -1,15 +1,15 @@
1
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&amp;condition=new">2&nbsp;new</a>&nbsp;from&nbsp;<span class='a-color-price'>$67.30</span></div>
14
- </body>
2
+ <html>
3
+ <head>
4
+ <meta http-equiv="content-type" content="text/html; charset=iso-8859-1" />
5
+ <link rel="canonical" href="http://www.amazon.com/Digital-Life-Performance-Ethernet-Cables/dp/B001AE8YBW" />
6
+ <meta name="description" content="Amazon.com: Digital Life High Performance Ethernet Cables - Advanced High Speed - 7 ft. Advanced High Speed Ethernet Cable: Electronics" />
7
+ <meta name="title" content="Amazon.com: Digital Life High Performance Ethernet Cables - Advanced High Speed - 7 ft. Advanced High Speed Ethernet Cable: Electronics" />
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&amp;condition=new">2&nbsp;new</a>&nbsp;from&nbsp;<span class='a-color-price'>$67.30</span></div>
14
+ </body>
15
15
  </html>
@@ -23,4 +23,10 @@ describe Lita::Handlers::OnewheelAmazonProduct, lita_handler: true do
23
23
  send_message ('http://www.amazon.com/Live-Detroit-Without-Being-Jackass/dp/0996836705')
24
24
  expect(replies.last).to eq('$15.10 How To Live In Detroit Without Being A Jackass')
25
25
  end
26
+
27
+ it 'puts kindle-only book price' do
28
+ mock_fixture('kindle_book_price')
29
+ send_message ('http://www.amazon.com/Echo-Billionaire-Romance-Bleeding-Hearts-ebook/dp/B01786HTZW')
30
+ expect(replies.last).to eq('$2.99 Echo')
31
+ end
26
32
  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.2.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrew Kreps
@@ -152,6 +152,7 @@ files:
152
152
  - lib/lita/handlers/onewheel_amazon_product.rb
153
153
  - lita-onewheel-amazon-product.gemspec
154
154
  - spec/fixtures/book_price.html
155
+ - spec/fixtures/kindle_book_price.html
155
156
  - spec/fixtures/our_price.html
156
157
  - spec/fixtures/third_party_price.html
157
158
  - spec/lita/handlers/onewheel_amazon_product_spec.rb
@@ -183,6 +184,7 @@ specification_version: 4
183
184
  summary: See above.
184
185
  test_files:
185
186
  - spec/fixtures/book_price.html
187
+ - spec/fixtures/kindle_book_price.html
186
188
  - spec/fixtures/our_price.html
187
189
  - spec/fixtures/third_party_price.html
188
190
  - spec/lita/handlers/onewheel_amazon_product_spec.rb