takuhai_status 1.8.7 → 1.9.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +3 -3
- data/lib/takuhai_status.rb +12 -2
- data/lib/takuhai_status/japanpost.rb +1 -1
- data/lib/takuhai_status/sagawa.rb +21 -19
- data/lib/takuhai_status/tmg_cargo.rb +3 -3
- data/lib/takuhai_status/version.rb +1 -1
- data/takuhai_status.gemspec +1 -1
- metadata +5 -7
- data/bin/console +0 -14
- data/bin/setup +0 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 271863577b644e618af2df2a53eef10f98b678210ec6470ebbbf7af9d4ecf95a
|
4
|
+
data.tar.gz: a10652ae8164b17c9b5544eff250de9ae7c4269988d50dacdbf42fd2277d2e4b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 32d23a601473c351ff967f0e135e0afca8b87806ee90b0593f3d29a04e169f13623aa80c9fe1639534e420acff596931cc328b027d2941003f68cc332ad0a91b
|
7
|
+
data.tar.gz: faf1ebfc7389c9584324b679e3ff9a38abe97fa20df0ff88c4ebe8bb139137cfd37c749c0f521f647a2b94f333be9b2a96f9fe557fe7676b2e2cd65c1e2c39e4
|
data/.travis.yml
CHANGED
data/lib/takuhai_status.rb
CHANGED
@@ -14,13 +14,23 @@ module TakuhaiStatus
|
|
14
14
|
|
15
15
|
# loading plugins
|
16
16
|
@@services = []
|
17
|
-
|
18
|
-
|
17
|
+
# service_class as class
|
18
|
+
def self.add_service(service_class)
|
19
|
+
@@services << service_class
|
19
20
|
end
|
20
21
|
Dir.glob("#{File.dirname(__FILE__)}/takuhai_status/*.rb") do |plugin|
|
21
22
|
require plugin
|
22
23
|
end
|
23
24
|
|
25
|
+
# service_name as symbol, cf. :USPS
|
26
|
+
def self.ignore_service(service_name)
|
27
|
+
begin
|
28
|
+
@@services.delete(TakuhaiStatus.const_get(service_name))
|
29
|
+
rescue NameError
|
30
|
+
return nil
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
24
34
|
def self.scan(key, timeout: 10, logger: Logger.new(nil))
|
25
35
|
services = []
|
26
36
|
[].tap{|threads|
|
@@ -1,5 +1,4 @@
|
|
1
|
-
require '
|
2
|
-
require 'nokogiri'
|
1
|
+
require 'mechanize'
|
3
2
|
|
4
3
|
module TakuhaiStatus
|
5
4
|
class Sagawa
|
@@ -13,31 +12,34 @@ module TakuhaiStatus
|
|
13
12
|
end
|
14
13
|
|
15
14
|
def finish?
|
16
|
-
return !!(@state =~
|
15
|
+
return !!(@state =~ /営業所へお問い合わせください。|配達は終了致しました。$|^配達完了|引渡完了/)
|
17
16
|
end
|
18
17
|
|
19
18
|
private
|
20
19
|
def check
|
21
|
-
|
22
|
-
|
23
|
-
|
20
|
+
agent = Mechanize.new
|
21
|
+
page = agent.get('https://k2k.sagawa-exp.co.jp/p/sagawa/web/okurijoinput.jsp')
|
22
|
+
form = page.form_with('main')
|
23
|
+
form['main:no1'] = @key
|
24
|
+
button = form.button_with('main:toiStart')
|
25
|
+
result = agent.submit(form, button)
|
24
26
|
|
25
27
|
begin
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
28
|
+
row = result.css('#detail1 tr')
|
29
|
+
cells = row[row.size - 1].css('td')
|
30
|
+
if cells.size == 3 #has detail
|
31
|
+
state = "#{cells[0].text.strip[1,100]} [#{cells[2].text.strip}]"
|
32
|
+
time = Time.parse(cells[1].text.strip) rescue Time.now
|
33
|
+
else # finished?
|
34
|
+
state = cells[0].text.strip
|
32
35
|
time = Time.now
|
33
|
-
state = doc.css('.table_okurijo_detail').first.css('tr').last.css('td').text.strip
|
34
|
-
if state =~ /恐れ入りますが、お問い合せ送り状NOをお確かめください。|お荷物データが登録されておりません。/
|
35
|
-
raise NotMyKey.new('invalid key')
|
36
|
-
end
|
37
|
-
return time, state
|
38
|
-
rescue NoMethodError
|
39
|
-
raise NotMyKey.new('invalid response')
|
40
36
|
end
|
37
|
+
if state =~ /恐れ入りますが、お問い合せ送り状NOをお確かめください。|お荷物データが登録されておりません。/
|
38
|
+
raise NotMyKey.new('invalid key')
|
39
|
+
end
|
40
|
+
return time, state
|
41
|
+
rescue NoMethodError
|
42
|
+
raise NotMyKey.new('invalid response')
|
41
43
|
rescue ArgumentError
|
42
44
|
return Time.now, ''
|
43
45
|
end
|
@@ -21,8 +21,7 @@ module TakuhaiStatus
|
|
21
21
|
|
22
22
|
private
|
23
23
|
def check
|
24
|
-
@@conn = Faraday.new(url: 'https://track-a.tmg-
|
25
|
-
#@@conn = Faraday.new(url: 'https://track-a.tmg-tms.com'){|builder|
|
24
|
+
@@conn = Faraday.new(url: 'https://track-a.tmg-tms.com'){|builder|
|
26
25
|
builder.use :cookie_jar
|
27
26
|
builder.use FaradayMiddleware::FollowRedirects
|
28
27
|
builder.request :url_encoded
|
@@ -37,9 +36,10 @@ module TakuhaiStatus
|
|
37
36
|
begin
|
38
37
|
state = doc.css('#list tr td')[2].text.strip
|
39
38
|
raise if state =~ /お荷物情報が見つかりません/
|
39
|
+
raise if state == '2' # skip error state occurs sometime
|
40
40
|
return Time.now, state
|
41
41
|
rescue
|
42
|
-
raise NotMyKey
|
42
|
+
raise NotMyKey.new(state)
|
43
43
|
end
|
44
44
|
end
|
45
45
|
end
|
data/takuhai_status.gemspec
CHANGED
@@ -25,7 +25,7 @@ Gem::Specification.new do |spec|
|
|
25
25
|
spec.add_runtime_dependency "faraday_middleware"
|
26
26
|
|
27
27
|
spec.add_development_dependency "bundler"
|
28
|
-
spec.add_development_dependency "rake", "~>
|
28
|
+
spec.add_development_dependency "rake", "~> 12.0"
|
29
29
|
spec.add_development_dependency "rspec"
|
30
30
|
spec.add_development_dependency "pry"
|
31
31
|
spec.add_development_dependency "travis"
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: takuhai_status
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.9.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- TADA Tadashi
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2020-09-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|
@@ -86,14 +86,14 @@ dependencies:
|
|
86
86
|
requirements:
|
87
87
|
- - "~>"
|
88
88
|
- !ruby/object:Gem::Version
|
89
|
-
version: '
|
89
|
+
version: '12.0'
|
90
90
|
type: :development
|
91
91
|
prerelease: false
|
92
92
|
version_requirements: !ruby/object:Gem::Requirement
|
93
93
|
requirements:
|
94
94
|
- - "~>"
|
95
95
|
- !ruby/object:Gem::Version
|
96
|
-
version: '
|
96
|
+
version: '12.0'
|
97
97
|
- !ruby/object:Gem::Dependency
|
98
98
|
name: rspec
|
99
99
|
requirement: !ruby/object:Gem::Requirement
|
@@ -151,8 +151,6 @@ files:
|
|
151
151
|
- LICENSE.txt
|
152
152
|
- README.md
|
153
153
|
- Rakefile
|
154
|
-
- bin/console
|
155
|
-
- bin/setup
|
156
154
|
- lib/takuhai_status.rb
|
157
155
|
- lib/takuhai_status/fedex.rb
|
158
156
|
- lib/takuhai_status/japanpost.rb
|
@@ -182,7 +180,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
182
180
|
- !ruby/object:Gem::Version
|
183
181
|
version: '0'
|
184
182
|
requirements: []
|
185
|
-
rubygems_version: 3.0.
|
183
|
+
rubygems_version: 3.0.8
|
186
184
|
signing_key:
|
187
185
|
specification_version: 4
|
188
186
|
summary: get delivery status of Takuhai-bin in Japan
|
data/bin/console
DELETED
@@ -1,14 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
|
3
|
-
require "bundler/setup"
|
4
|
-
require "takuhai_status"
|
5
|
-
|
6
|
-
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
-
# with your gem easier. You can also use a different console, if you like.
|
8
|
-
|
9
|
-
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
-
# require "pry"
|
11
|
-
# Pry.start
|
12
|
-
|
13
|
-
require "irb"
|
14
|
-
IRB.start
|