lita-onewheel-amazon-product 0.0.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: fa6d18fe862294c39ae2df5efc32ef7c60446e41
4
+ data.tar.gz: fe23bd2f833a2d50957900d07900b784dec799c5
5
+ SHA512:
6
+ metadata.gz: 9394f66ee5377142cd990651ca9f62159125f078e5bcee63eb6e1147bff197a734e23aebc5ff844babab4bd22f6c5b020b3725d1269ad82eca712f4bc2b1b1ee
7
+ data.tar.gz: 2f741ddf2776755c14fa4660c87b3813b17e6644134cd881ca6c96802d726cd8984635ecb7609621d2c2b9bfb55fcde6b4b85d783189185aee324df4c7fcd69c
@@ -0,0 +1,19 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
18
+ lita_config.rb
19
+ .idea
@@ -0,0 +1,9 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.2.4
4
+ - 2.3.0
5
+ script: bundle exec rake
6
+ before_install:
7
+ - gem update --system
8
+ services:
9
+ - redis-server
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec
@@ -0,0 +1,15 @@
1
+ # lita-onewheel-amazon-product
2
+
3
+ [![Build Status](https://travis-ci.org/onewheelskyward/lita-onewheel-amazon-product.png?branch=master)](https://travis-ci.org/onewheelskyward/lita-onewheel-amazon-product)
4
+ [![Coverage Status](https://coveralls.io/repos/onewheelskyward/lita-onewheel-amazon-product/badge.png)](https://coveralls.io/r/onewheelskyward/lita-onewheel-amazon-product)
5
+
6
+ Display Amazon product links when product pages are posted.
7
+
8
+ ## Installation
9
+
10
+ Add lita-onewheel-amazon-product to your Lita instance's Gemfile:
11
+
12
+ ``` ruby
13
+ gem 'lita-onewheel-amazon-product'
14
+ ```
15
+
@@ -0,0 +1,6 @@
1
+ require 'bundler/gem_tasks'
2
+ require 'rspec/core/rake_task'
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task default: :spec
@@ -0,0 +1,12 @@
1
+ require 'lita'
2
+
3
+ Lita.load_locales Dir[File.expand_path(
4
+ File.join('..', '..', 'locales', '*.yml'), __FILE__
5
+ )]
6
+
7
+ require 'lita/handlers/onewheel_amazon_product'
8
+
9
+ Lita::Handlers::OnewheelAmazonProduct.template_root File.expand_path(
10
+ File.join('..', '..', 'templates'),
11
+ __FILE__
12
+ )
@@ -0,0 +1,33 @@
1
+ require 'nokogiri'
2
+ require 'rest-client'
3
+
4
+ module Lita
5
+ module Handlers
6
+ class OnewheelAmazonProduct < Handler
7
+ route /(http.*amazon.com\/.*\/dp\/.*)\?*/i, :get_amazon_product
8
+
9
+ def get_amazon_product(response)
10
+ description = ''
11
+ price = 0
12
+ uri = response.matches[0][0]
13
+ doc = RestClient.get uri
14
+
15
+ noko_doc = Nokogiri::HTML doc
16
+ noko_doc.xpath('//meta').each do |meta|
17
+ attrs = meta.attributes
18
+ if attrs['name'].to_s == 'description'
19
+ description = attrs['content'].to_s
20
+ end
21
+ end
22
+
23
+ price_node = noko_doc.css('span#priceblock_ourprice').first.content
24
+
25
+ unless description.empty?
26
+ response.reply price_node.to_s + ' ' + description.to_s
27
+ end
28
+ end
29
+
30
+ Lita.register_handler(self)
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,28 @@
1
+ Gem::Specification.new do |spec|
2
+ spec.name = 'lita-onewheel-amazon-product'
3
+ spec.version = '0.0.0'
4
+ spec.authors = ['Andrew Kreps']
5
+ spec.email = ['andrew.kreps@gmail.com']
6
+ spec.description = %q{Lita interface to post information about amazon products.}
7
+ spec.summary = %q{See above.}
8
+ spec.homepage = 'https://github.com/onewheelskyward/lita-onewheel-amazon-product'
9
+ spec.license = 'MIT'
10
+ spec.metadata = { 'lita_plugin_type' => 'handler'}
11
+
12
+ spec.files = `git ls-files`.split($/)
13
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
14
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
15
+ spec.require_paths = ['lib']
16
+
17
+ spec.add_runtime_dependency 'lita', '~> 4.7'
18
+ spec.add_runtime_dependency 'rest-client', '~> 1.8'
19
+ spec.add_runtime_dependency 'nokogiri', '~> 1.6'
20
+
21
+ spec.add_development_dependency 'bundler', '~> 1.3'
22
+ # spec.add_development_dependency 'pry-byebug', '~> 3.1'
23
+ spec.add_development_dependency 'rake', '~> 10.4'
24
+ spec.add_development_dependency 'rack-test', '~> 0.6'
25
+ spec.add_development_dependency 'rspec', '~> 3.0'
26
+ spec.add_development_dependency 'simplecov', '~> 0.10'
27
+ spec.add_development_dependency 'coveralls', '~> 0.8'
28
+ end
@@ -0,0 +1,30 @@
1
+
2
+ <!doctype html><!--[if lt IE 7]><html class="a-no-js a-lt-ie10 a-lt-ie9 a-lt-ie8 a-lt-ie7 a-ie6" data-19ax5a9jf="dingo"><![endif]--><!--[if IE 7]><html class="a-no-js a-lt-ie10 a-lt-ie9 a-lt-ie8 a-ie7" data-19ax5a9jf="dingo"><![endif]--><!--[if IE 8]><html class="a-no-js a-lt-ie10 a-lt-ie9 a-ie8" data-19ax5a9jf="dingo"><![endif]--><!--[if IE 9]><html class="a-no-js a-lt-ie10 a-ie9" data-19ax5a9jf="dingo"><![endif]--><!--[if !IE]><!--><html class="a-no-js" data-19ax5a9jf="dingo"><!--<![endif]-->
3
+ <head>
4
+ <meta http-equiv="content-type" content="text/html; charset=iso-8859-1" />
5
+
6
+
7
+
8
+
9
+ <link rel="canonical" href="http://www.amazon.com/Plugable-Micro-B-Ethernet-Raspberry-AX88772A/dp/B00RM3KXAU" />
10
+ <meta name="description" content="Amazon.com: Plugable USB 2.0 OTG Micro-B to 10/100 Fast Ethernet Adapter for Windows Tablets &amp; Raspberry Pi Zero (ASIX AX88772A chipset): Computers &amp; Accessories" />
11
+ <meta name="title" content="Amazon.com: Plugable USB 2.0 OTG Micro-B to 10/100 Fast Ethernet Adapter for Windows Tablets &amp; Raspberry Pi Zero (ASIX AX88772A chipset): Computers &amp; Accessories" />
12
+
13
+ <meta name="keywords" content="Plugable USB 2.0 OTG Micro-B to 10/100 Fast Ethernet Adapter for Windows Tablets &amp; Raspberry Pi Zero (ASIX AX88772A chipset),Plugable Technologies,USB2-OTGE100" />
14
+ <title>Amazon.com: Plugable USB 2.0 OTG Micro-B to 10/100 Fast Ethernet Adapter for Windows Tablets &amp; Raspberry Pi Zero (ASIX AX88772A chipset): Computers &amp; Accessories</title>
15
+ </head>
16
+
17
+
18
+ <body id="dp" class="pc en_US a-auix_ux_57388-t1 a-aui_49697-c a-aui_51744-c a-aui_57326-c a-aui_58736-c a-aui_accessibility_49860-c a-aui_attr_validations_1_51371-c a-aui_bolt_62845-c a-aui_ux_47524-t1 a-aui_ux_49594-c a-aui_ux_52290-c a-aui_ux_56217-c a-aui_ux_59374-c a-aui_ux_59797-c a-aui_ux_60000-c">
19
+ <table>
20
+ <tr id="priceblock_ourprice_row">
21
+ <td id="priceblock_ourprice_lbl" class="a-color-secondary a-size-base a-text-right a-nowrap">Price:</td>
22
+ <td class="a-span12">
23
+ <span id="priceblock_ourprice" class="a-size-medium a-color-price">$13.95</span>
24
+ </td>
25
+ </tr>
26
+ </table>
27
+
28
+ </body>
29
+
30
+ </html>
@@ -0,0 +1,14 @@
1
+ require 'spec_helper'
2
+
3
+ def mock_fixture(fixture)
4
+ mock = File.open("spec/fixtures/#{fixture}.html").read
5
+ allow(RestClient).to receive(:get) { mock }
6
+ end
7
+
8
+ describe Lita::Handlers::OnewheelAmazonProduct, lita_handler: true do
9
+ it 'puts the amazon product info on the response' do
10
+ mock_fixture('sample')
11
+ send_message ('http://www.amazon.com/Plugable-Micro-B-Ethernet-Raspberry-AX88772A/dp/B00RM3KXAU/')
12
+ expect(replies.last).to eq('$13.95 Amazon.com: Plugable USB 2.0 OTG Micro-B to 10/100 Fast Ethernet Adapter for Windows Tablets & Raspberry Pi Zero (ASIX AX88772A chipset): Computers & Accessories')
13
+ end
14
+ end
@@ -0,0 +1,14 @@
1
+ require 'simplecov'
2
+ require 'coveralls'
3
+ SimpleCov.formatters = [
4
+ SimpleCov::Formatter::HTMLFormatter,
5
+ Coveralls::SimpleCov::Formatter
6
+ ]
7
+ SimpleCov.start { add_filter '/spec/' }
8
+
9
+ require 'lita-onewheel-amazon-product'
10
+ require 'lita/rspec'
11
+
12
+ # A compatibility mode is provided for older plugins upgrading from Lita 3. Since this plugin
13
+ # was generated with Lita 4, the compatibility mode should be left disabled.
14
+ Lita.version_3_compatibility_mode = false
metadata ADDED
@@ -0,0 +1,185 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: lita-onewheel-amazon-product
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Andrew Kreps
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2016-02-04 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: lita
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '4.7'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '4.7'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rest-client
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '1.8'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1.8'
41
+ - !ruby/object:Gem::Dependency
42
+ name: nokogiri
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '1.6'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '1.6'
55
+ - !ruby/object:Gem::Dependency
56
+ name: bundler
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '1.3'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '1.3'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rake
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '10.4'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '10.4'
83
+ - !ruby/object:Gem::Dependency
84
+ name: rack-test
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '0.6'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: '0.6'
97
+ - !ruby/object:Gem::Dependency
98
+ name: rspec
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - "~>"
102
+ - !ruby/object:Gem::Version
103
+ version: '3.0'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - "~>"
109
+ - !ruby/object:Gem::Version
110
+ version: '3.0'
111
+ - !ruby/object:Gem::Dependency
112
+ name: simplecov
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - "~>"
116
+ - !ruby/object:Gem::Version
117
+ version: '0.10'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - "~>"
123
+ - !ruby/object:Gem::Version
124
+ version: '0.10'
125
+ - !ruby/object:Gem::Dependency
126
+ name: coveralls
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - "~>"
130
+ - !ruby/object:Gem::Version
131
+ version: '0.8'
132
+ type: :development
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - "~>"
137
+ - !ruby/object:Gem::Version
138
+ version: '0.8'
139
+ description: Lita interface to post information about amazon products.
140
+ email:
141
+ - andrew.kreps@gmail.com
142
+ executables: []
143
+ extensions: []
144
+ extra_rdoc_files: []
145
+ files:
146
+ - ".gitignore"
147
+ - ".travis.yml"
148
+ - Gemfile
149
+ - README.md
150
+ - Rakefile
151
+ - lib/lita-onewheel-amazon-product.rb
152
+ - lib/lita/handlers/onewheel_amazon_product.rb
153
+ - lita-onewheel-amazon-product.gemspec
154
+ - spec/fixtures/sample.html
155
+ - spec/lita/handlers/onewheel_amazon_product_spec.rb
156
+ - spec/spec_helper.rb
157
+ homepage: https://github.com/onewheelskyward/lita-onewheel-amazon-product
158
+ licenses:
159
+ - MIT
160
+ metadata:
161
+ lita_plugin_type: handler
162
+ post_install_message:
163
+ rdoc_options: []
164
+ require_paths:
165
+ - lib
166
+ required_ruby_version: !ruby/object:Gem::Requirement
167
+ requirements:
168
+ - - ">="
169
+ - !ruby/object:Gem::Version
170
+ version: '0'
171
+ required_rubygems_version: !ruby/object:Gem::Requirement
172
+ requirements:
173
+ - - ">="
174
+ - !ruby/object:Gem::Version
175
+ version: '0'
176
+ requirements: []
177
+ rubyforge_project:
178
+ rubygems_version: 2.5.1
179
+ signing_key:
180
+ specification_version: 4
181
+ summary: See above.
182
+ test_files:
183
+ - spec/fixtures/sample.html
184
+ - spec/lita/handlers/onewheel_amazon_product_spec.rb
185
+ - spec/spec_helper.rb