takuhai_status 1.5.5 → 1.6.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: 9be075febbf69c7a73c761d80ccf7d8589315d2c
4
- data.tar.gz: f40577194d5dcff9daea8ae4b656904161d8205c
3
+ metadata.gz: 2c630d804caccce7d61bcc24dacec718ab4f1227
4
+ data.tar.gz: 12a793692ca21e6029277ccf4e4af8de94d37b17
5
5
  SHA512:
6
- metadata.gz: ebcc0043195c97a5311a047b32f20620c1336dc330d606ad372e9c8652542d1421fb715dfc44a63e2627f4ed847f5d36db84dc97efa3cc20f131e37a53f49cc3
7
- data.tar.gz: d372dca2d79255b2ec66ecf9e521cff2c655924e8219e2f3ac2842c7c533c50afe02ffbad0b12862d814a3fa6c7bed69d049e674b486d9dbdb9483cb13e2cd42
6
+ metadata.gz: ee46e621ff631421b75a7248357b5aea4be4b284944b18523a757360f3c6a0792aaa52969113b3e9eb3d7160231752378f5dadbcaf3fb5e1b46736ba617f277f
7
+ data.tar.gz: ce833d64e553e4e2baf3521663e62bcb8f752775104fb752e5b2b9a8f625c87ea25c089d4e28a5c1972e3b25dcad0df260b1154f7ee46836bc91176850c19fd2
@@ -11,7 +11,7 @@ module TakuhaiStatus
11
11
  end
12
12
 
13
13
  def finish?
14
- return !!(@state =~ /^(お客様引渡|配達|投函)完了|返品|国内到着/)
14
+ return !!(@state =~ /^(お客様引渡|配達|投函)完了|返品/)
15
15
  end
16
16
 
17
17
  private
@@ -27,6 +27,14 @@ module TakuhaiStatus
27
27
  stime = tr.css('td')[3].text
28
28
  time = Time.parse("#{sday} #{stime}")
29
29
 
30
+ if state == '国内到着'
31
+ begin
32
+ time, state = global_state(doc)
33
+ rescue
34
+ $stderr.puts "error in yamato global, about #{key}"
35
+ end
36
+ end
37
+
30
38
  return time, state
31
39
  rescue NoMethodError
32
40
  raise NotMyKey
@@ -34,5 +42,22 @@ module TakuhaiStatus
34
42
  return Time.now, state || ''
35
43
  end
36
44
  end
45
+
46
+ def global_state(doc)
47
+ form = doc.css('form[method=POST]')
48
+ values = form.css('input[type=hidden]').map{|x| [x[:name], x[:value]]}.flatten
49
+ params = Hash[*values]
50
+
51
+ res = Faraday.new.post(
52
+ 'http://globaltoi.kuronekoyamato.co.jp/Global/outside',
53
+ params
54
+ )
55
+ html = res.body.force_encoding('Shift_JIS').encode('UTF-8')
56
+ tr = Nokogiri(html).css('table.detail tr')
57
+ state = tr[tr.size-1].css('td')[1].text
58
+ loc = tr[tr.size-1].css('td')[4].text.strip.chop.chop
59
+ stime = "#{tr[tr.size-1].css('td')[2].text} #{tr[tr.size-1].css('td')[3].text}"
60
+ return Time.parse(stime), "#{state}[#{loc}]"
61
+ end
37
62
  end
38
63
  end
@@ -1,3 +1,3 @@
1
1
  module TakuhaiStatus
2
- VERSION = "1.5.5"
2
+ VERSION = "1.6.0"
3
3
  end
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.5.5
4
+ version: 1.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - TADA Tadashi
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-07-10 00:00:00.000000000 Z
11
+ date: 2017-09-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday
@@ -154,7 +154,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
154
154
  version: '0'
155
155
  requirements: []
156
156
  rubyforge_project:
157
- rubygems_version: 2.6.11
157
+ rubygems_version: 2.6.13
158
158
  signing_key:
159
159
  specification_version: 4
160
160
  summary: get delivery status of Takuhai-bin in Japan