takuhai_status 1.5.2 → 1.5.3

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: f6444e75ae0646f3346bf5f4beb4c7c14ecd9ad1
4
- data.tar.gz: 246c5e5ff61b0c66c79959d27fe73f2d80c3bb9d
3
+ metadata.gz: bf89da20e44e0e1a6bb3bd04a7ebb3a62262ad70
4
+ data.tar.gz: 395dfb1a24414c4314641277b8e1c24cf03f4c6f
5
5
  SHA512:
6
- metadata.gz: 299c6f3e61ba8821c24d603533c8e966f6e44a329318a59b156bb612a464ca24bbb82b6a9e9a08621a4eef7815aed8feebb9a0617b45f9b3e6fa35f956c836bb
7
- data.tar.gz: d5f7199d2de6a1cb4e011c9eba719ddfa125e27c7fbc0d7004c0d36705ccd21bc7ca129767c4d93a1a132d588ac5c9f83651d4fff4adeaf25676703318dc9cee
6
+ metadata.gz: 9fadbc62d29de2b0706f31f5d19ff37f6c733c2b82b89308c6921498dd26f8a29fa728e30b7566dea8dbb1980b7418211b22de6ded730dfb5c4626f86e950adb
7
+ data.tar.gz: 99c99ef0b39a47403646d4a5beb75bc1e63b44a131d48abbb7f761d46715d283e9eadea62df3d093e433856ba7ea16b914419b597bfa541faaad4dbbb99f17e8
@@ -6,12 +6,12 @@ module TakuhaiStatus
6
6
  attr_reader :key, :time, :state
7
7
 
8
8
  def initialize(key)
9
- @key = key.gsub(/[^0-9]/, '')
9
+ @key = key
10
10
  @time, @state = check
11
11
  end
12
12
 
13
13
  def finish?
14
- return !!(@state =~ /認可済み業者に委託/)
14
+ return !!(@state =~ /認可済み業者に委託|配達完了/)
15
15
  end
16
16
 
17
17
  private
@@ -43,29 +43,23 @@ module TakuhaiStatus
43
43
  version: '1',
44
44
  format: 'json'
45
45
  })
46
- begin
47
- data = JSON.parse(res.body)
48
- raise unless data["TrackPackagesResponse"]["successful"]
49
46
 
50
- package = data["TrackPackagesResponse"]["packageList"].first
51
- current = package["scanEventList"].first
47
+ package = JSON.parse(res.body)["TrackPackagesResponse"]
48
+ unless package["successful"]
49
+ raise NotMyKey.new(package["errorList"].first["message"])
50
+ end
52
51
 
53
- begin
54
- time = Time.parse("#{current['date']} #{current['time']}#{current['+09:00']}")
55
- rescue ArgumentError
56
- raise NotMyKey.new('no time status in the package');
57
- end
52
+ current = package["packageList"].first["scanEventList"].first
58
53
 
59
- state = "#{current['status']}"
60
- state = "#{state}(#{current['scanDetails']})" if current['scanDetails'].size > 0
61
- state = "#{state} - #{current['scanLocation']}" if current['scanLocation'].size > 0
54
+ t_str = "#{current['date']} #{current['time']}"
55
+ raise NotMyKey.new('no time status in the package') if t_str.size == 1
56
+ time = Time.parse("#{t_str}+09:00")
62
57
 
63
- return time, state
64
- rescue NotMyKey
65
- raise
66
- rescue
67
- return (@time || Time.now), (@state || '')
68
- end
58
+ state = "#{current['status']}"
59
+ state = "#{state}(#{current['scanDetails']})" if current['scanDetails'].size > 0
60
+ state = "#{state} - #{current['scanLocation']}" if current['scanLocation'].size > 0
61
+
62
+ return time, state
69
63
  end
70
64
  end
71
65
  end
@@ -1,3 +1,3 @@
1
1
  module TakuhaiStatus
2
- VERSION = "1.5.2"
2
+ VERSION = "1.5.3"
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.2
4
+ version: 1.5.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - TADA Tadashi
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-06-29 00:00:00.000000000 Z
11
+ date: 2016-06-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday