ruboty-amazon_wishlist 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.
- checksums.yaml +7 -0
- data/.gitignore +5 -0
- data/Gemfile +3 -0
- data/LICENSE +22 -0
- data/README.md +26 -0
- data/Rakefile +2 -0
- data/lib/ruboty/amazon_wishlist/version.rb +5 -0
- data/lib/ruboty/amazon_wishlist.rb +11 -0
- data/lib/ruboty/handlers/amazon_wishlist.rb +98 -0
- data/rakuten-rental.gemspec +25 -0
- metadata +111 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: bf44c5778f3a8a05a5ab2531ac9109fc7cbb9302
|
4
|
+
data.tar.gz: 008e62ddfe40aa80be1a360c2f030a45e9dcf46d
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 31953319977675075295ee9ed8c6f17c9cd550bb29f82213c4de443239733bcc99925f091ae0e4af9b52e68b25e908eb116ebbafe480415fcb37f1313d95d7b2
|
7
|
+
data.tar.gz: 316ac5cd865b683ce246cd24c3f8f5a5d2befa748031c29e85e0db3eaee73a216305e1d29ef0745eb05e393ce05141eb939979efb4222686a8c28fc7ae824f71
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2015 haccht
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
+
SOFTWARE.
|
22
|
+
|
data/README.md
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
# Ruboty::Amazon_wishlist
|
2
|
+
|
3
|
+
Ruboty handler to check whether the prices of items in your Amazon wishlist
|
4
|
+
has changed. http://www.amazon.co.jp/
|
5
|
+
|
6
|
+
## Installation
|
7
|
+
|
8
|
+
```ruby
|
9
|
+
gem 'ruboty-amazon_wishlist' :github => 'haccht/ruboty-amazon_wishlist'
|
10
|
+
```
|
11
|
+
|
12
|
+
## Usage
|
13
|
+
|
14
|
+
```
|
15
|
+
> @ruboty list amazon_wishlist
|
16
|
+
> @ruboty list amazon_wishlist updated
|
17
|
+
```
|
18
|
+
|
19
|
+
## Env
|
20
|
+
|
21
|
+
Requires the Amazon wishlist ID from your wishlist url.
|
22
|
+
http://www.amazon.co.jp/gp/registry/wishlist/*************/
|
23
|
+
|
24
|
+
```
|
25
|
+
export AMAZON_WISHLIST_ID=*************
|
26
|
+
```
|
data/Rakefile
ADDED
@@ -0,0 +1,98 @@
|
|
1
|
+
require 'mechanize'
|
2
|
+
require 'stringio'
|
3
|
+
|
4
|
+
module Ruboty
|
5
|
+
module Handlers
|
6
|
+
class Amazon_wishlist < Base
|
7
|
+
on(/list amazon_wishlist(?<verbose> -v)?\z/,
|
8
|
+
name: 'list',
|
9
|
+
description: 'List Amazon wishlist items.')
|
10
|
+
|
11
|
+
on(/list amazon_wishlist updated(?<verbose> -v)?\z/,
|
12
|
+
name: 'list_updated',
|
13
|
+
description: 'List Amazon wishlist items which price has updated.')
|
14
|
+
|
15
|
+
def initialize(*args)
|
16
|
+
super
|
17
|
+
@agent = Mechanize.new
|
18
|
+
end
|
19
|
+
|
20
|
+
def list(message)
|
21
|
+
items = []
|
22
|
+
list_items.each do |id, item|
|
23
|
+
items << "#{item[:title]} (#{item[:price]})"
|
24
|
+
cache[id] = item[:price]
|
25
|
+
end
|
26
|
+
|
27
|
+
text = StringIO.new
|
28
|
+
if items.empty?
|
29
|
+
text.puts "Amazonほしい物リストに登録されているタイトルがないですね"
|
30
|
+
message.reply(text.string) if message[:verbose]
|
31
|
+
else
|
32
|
+
text.puts "Amazonほしい物リストに次のタイトルが登録されていますね"
|
33
|
+
text.puts endpoint
|
34
|
+
text.puts
|
35
|
+
items.each { |item| text.puts item }
|
36
|
+
message.reply(text.string)
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
def list_updated(message)
|
41
|
+
items = []
|
42
|
+
list_items.each do |id, item|
|
43
|
+
last_price = cache[id].to_s.force_encoding('utf-8')
|
44
|
+
if item[:price] != last_price
|
45
|
+
last_price = 'null' if last_price.empty?
|
46
|
+
items << "#{item[:title]} (from:#{last_price} to:#{item[:price]})"
|
47
|
+
end
|
48
|
+
|
49
|
+
cache[id] = item[:price]
|
50
|
+
end
|
51
|
+
|
52
|
+
text = StringIO.new
|
53
|
+
if items.empty?
|
54
|
+
text.puts "Amazonほしい物リストで価格変動はありませんでした"
|
55
|
+
message.reply(text.string) if message[:verbose]
|
56
|
+
else
|
57
|
+
text.puts "Amazonほしい物リストで次のタイトルに価格変動があったようですよ"
|
58
|
+
text.puts endpoint
|
59
|
+
text.puts
|
60
|
+
items.each { |item| text.puts item }
|
61
|
+
message.reply(text.string)
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
def list_items
|
66
|
+
items = {}
|
67
|
+
|
68
|
+
page = @agent.get(endpoint)
|
69
|
+
body = page.at("//body")
|
70
|
+
|
71
|
+
page_size = body.css("div#wishlistPagination ul.a-pagination li[data-action]").size
|
72
|
+
page_size.times do |index|
|
73
|
+
page = @agent.get(endpoint(index + 1))
|
74
|
+
body = page.at("//body")
|
75
|
+
|
76
|
+
body.css("div[id^='item_']").each do |div|
|
77
|
+
item = Hash.new
|
78
|
+
item[:title] = div.css("a[id^='itemName_']").text.strip
|
79
|
+
item[:price] = div.css("span[id^='itemPrice_']").text.strip.gsub('¥ ', '¥')
|
80
|
+
|
81
|
+
id = div.get_attribute('id')
|
82
|
+
items[id] = item
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
items
|
87
|
+
end
|
88
|
+
|
89
|
+
def endpoint(page = 1)
|
90
|
+
"#{Ruboty::Amazon_wishlist::WISHLIST_URL}/#{Ruboty::Amazon_wishlist::WISHLIST_ID}/ref=?page=#{page}"
|
91
|
+
end
|
92
|
+
|
93
|
+
def cache
|
94
|
+
robot.brain.data[Ruboty::Amazon_wishlist::NAMESPACE] ||= {}
|
95
|
+
end
|
96
|
+
end
|
97
|
+
end
|
98
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
$LOAD_PATH << File.expand_path('../lib', __FILE__)
|
3
|
+
require 'ruboty/amazon_wishlist/version'
|
4
|
+
|
5
|
+
Gem::Specification.new do |spec|
|
6
|
+
spec.name = 'ruboty-amazon_wishlist'
|
7
|
+
spec.version = Ruboty::Amazon_wishlist::VERSION
|
8
|
+
spec.authors = ['haccht']
|
9
|
+
spec.email = ['haccht00@gmail.com']
|
10
|
+
spec.summary = "Ruboty handler to check whether the prices of items in your Amazon wishlist has changed."
|
11
|
+
spec.description = spec.summary
|
12
|
+
spec.homepage = 'https://github.com/haccht/ruboty-amazon_wishlist'
|
13
|
+
spec.license = 'MIT'
|
14
|
+
|
15
|
+
spec.files = `git ls-files -z`.split("\x0")
|
16
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
17
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
18
|
+
spec.require_paths = ['lib']
|
19
|
+
|
20
|
+
spec.add_runtime_dependency 'ruboty'
|
21
|
+
spec.add_runtime_dependency 'mechanize'
|
22
|
+
|
23
|
+
spec.add_development_dependency 'bundler'
|
24
|
+
spec.add_development_dependency 'rake'
|
25
|
+
end
|
metadata
ADDED
@@ -0,0 +1,111 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: ruboty-amazon_wishlist
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- haccht
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-10-26 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: ruboty
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: mechanize
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: bundler
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rake
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
description: Ruboty handler to check whether the prices of items in your Amazon wishlist
|
70
|
+
has changed.
|
71
|
+
email:
|
72
|
+
- haccht00@gmail.com
|
73
|
+
executables: []
|
74
|
+
extensions: []
|
75
|
+
extra_rdoc_files: []
|
76
|
+
files:
|
77
|
+
- ".gitignore"
|
78
|
+
- Gemfile
|
79
|
+
- LICENSE
|
80
|
+
- README.md
|
81
|
+
- Rakefile
|
82
|
+
- lib/ruboty/amazon_wishlist.rb
|
83
|
+
- lib/ruboty/amazon_wishlist/version.rb
|
84
|
+
- lib/ruboty/handlers/amazon_wishlist.rb
|
85
|
+
- rakuten-rental.gemspec
|
86
|
+
homepage: https://github.com/haccht/ruboty-amazon_wishlist
|
87
|
+
licenses:
|
88
|
+
- MIT
|
89
|
+
metadata: {}
|
90
|
+
post_install_message:
|
91
|
+
rdoc_options: []
|
92
|
+
require_paths:
|
93
|
+
- lib
|
94
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
95
|
+
requirements:
|
96
|
+
- - ">="
|
97
|
+
- !ruby/object:Gem::Version
|
98
|
+
version: '0'
|
99
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ">="
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
requirements: []
|
105
|
+
rubyforge_project:
|
106
|
+
rubygems_version: 2.4.8
|
107
|
+
signing_key:
|
108
|
+
specification_version: 4
|
109
|
+
summary: Ruboty handler to check whether the prices of items in your Amazon wishlist
|
110
|
+
has changed.
|
111
|
+
test_files: []
|