takuhai_status 1.2.0 → 1.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: 473252d7c70aa15e6532dc81cddc276cb46c87a6
4
- data.tar.gz: f86a202b6778ccce2858cd220fa9b94b1129f8b8
3
+ metadata.gz: 41c1c118ffc27f4ee1d7d49d814d1c32bd1b8918
4
+ data.tar.gz: 5e0cb11bb1733ef54ea1bb49705d185f1ad45011
5
5
  SHA512:
6
- metadata.gz: c0da30d82d4806c36bd3e43c2b81363c50f63b75e0218cc01187ece57ece4d6a574a01bc5de861279f566123793407add16e3a26a7273723f482dc93824a223c
7
- data.tar.gz: 974bd36f497878136fbd3eee89c5450baf9a0d6de7af644100e6c6720a5d09e7b17cc709928ba5c273aa08811b95642c1c48eafbd9a4deb8ece1d18383d2c20c
6
+ metadata.gz: 1bc7dc093158478be889ce62bad9a50d401521376a47c87893382b9200d3eca907dcffa6d83c870fe73e236b24930fd2e64e97f64c1dd4909d1ad148bc4dee9b
7
+ data.tar.gz: da5240397fc3f8833e58abb7358b06b0eb0c633dae14600b0bdec90543f6705565288f6a8284e96e0cc2494ac9ed76f2dbb2c3ba34812425d6c8a1a24e560752
@@ -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
@@ -21,28 +21,21 @@ module TakuhaiStatus
21
21
  doc = Nokogiri(res.body)
22
22
 
23
23
  begin
24
- table = doc.css('#detail-1 table').first
25
- state_line = table.css('tr td')[7].children.map(&:text).first
26
- if state_line == 'お問い合わせNo.をお確かめ下さい。'
27
- raise NotMyKey.new('invalid key')
28
- end
29
- if state_line == 'お問い合わせのデータは登録されておりません。'
30
- raise NotMyKey.new('not entry yet')
31
- end
32
-
33
- state = state_line.split(/[ \u{a0}]+/).last
34
-
35
- begin
36
- s = state_line.sub(/^[^0-9]+/, '')
37
- s = state_line if s.empty?
38
- time = Time.parse(s.gsub(/[^0-9 :]/, '-'))
39
- rescue ArgumentError
40
- ship = table.css('tr td')[1].text.strip.gsub(/[^0-9]/, '-')
41
- time = Time.parse(ship) rescue Time.now
42
- end
24
+ cells = doc.css('.table_okurijo_detail2').css('tr').last.css('td')
25
+ state = "#{cells[0].text.strip} [#{cells[2].text.strip}]".sub(/^./, '')
26
+ time = Time.parse(cells[1].text.strip)
43
27
  return time, state
44
28
  rescue NoMethodError
45
- raise NotMyKey.new('invalid response')
29
+ begin
30
+ time = Time.now
31
+ state = doc.css('.table_okurijo_detail').first.css('tr').last.css('td').text.strip
32
+ if state == '恐れ入りますが、お問い合せ送り状NOをお確かめください。'
33
+ raise NotMyKey.new('invalid key')
34
+ end
35
+ return time, state
36
+ rescue NoMethodError
37
+ raise NotMyKey.new('invalid response')
38
+ end
46
39
  rescue ArgumentError
47
40
  return Time.now, ''
48
41
  end
@@ -1,3 +1,3 @@
1
1
  module TakuhaiStatus
2
- VERSION = "1.2.0"
2
+ VERSION = "1.3.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.2.0
4
+ version: 1.3.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: 2015-11-18 00:00:00.000000000 Z
11
+ date: 2015-11-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday