takuhai_status 1.6.0 → 1.7.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
- SHA1:
3
- metadata.gz: 2c630d804caccce7d61bcc24dacec718ab4f1227
4
- data.tar.gz: 12a793692ca21e6029277ccf4e4af8de94d37b17
2
+ SHA256:
3
+ metadata.gz: 94819f602a3689e653e35416adc771c0f4af070edac50ab4656a2f87352ca575
4
+ data.tar.gz: 2d285e5b188cbc32c3fd8791d7d7ccc111329d35ed4dd260a3d9bd45e81a3af5
5
5
  SHA512:
6
- metadata.gz: ee46e621ff631421b75a7248357b5aea4be4b284944b18523a757360f3c6a0792aaa52969113b3e9eb3d7160231752378f5dadbcaf3fb5e1b46736ba617f277f
7
- data.tar.gz: ce833d64e553e4e2baf3521663e62bcb8f752775104fb752e5b2b9a8f625c87ea25c089d4e28a5c1972e3b25dcad0df260b1154f7ee46836bc91176850c19fd2
6
+ metadata.gz: 49e18a982e1ae00d8d08e25029eed7d6fbb828fc989e7beb0ec909e67d42bfc557de8a64092797d54bdc71bc4f54320fe817ff195b311d02063f35a0fa1bd9f0
7
+ data.tar.gz: e45694dd0bd3cf5ed03b9f9b989e41f888dee830b29bfdc4066a1231ad4e463e9abff6150a455ee25ca9b62e10f3b0d8a50734ab8a41aefc08c1b2ba24b711a8
@@ -6,6 +6,9 @@ require "takuhai_status/tmg_cargo"
6
6
  require "takuhai_status/ups"
7
7
  require "takuhai_status/fedex"
8
8
 
9
+ require "logger"
10
+ require "timeout"
11
+
9
12
  module TakuhaiStatus
10
13
  class NotFound < StandardError; end
11
14
  class NotMyKey < StandardError; end
@@ -17,11 +20,21 @@ module TakuhaiStatus
17
20
  end
18
21
  end
19
22
 
20
- def self.scan(key)
23
+ def self.scan(key, timeout: 10, logger: Logger.new(nil))
21
24
  services = []
22
25
  [].tap{|threads|
23
26
  [Sagawa, JapanPost, KuronekoYamato, TMGCargo, UPS, FedEx].each do |service|
24
- threads.push(Thread.new{service.new(key)})
27
+ threads.push(Thread.new{
28
+ name = service.to_s.sub(/^.*::/, '')
29
+ begin
30
+ Timeout.timeout(timeout, Timeout::Error, "Timeout in #{name}(#{key})") do
31
+ service.new(key)
32
+ end
33
+ rescue Timeout::Error, Faraday::TimeoutError => e
34
+ logger.error e.message
35
+ raise NotMyKey.new(e.message)
36
+ end
37
+ })
25
38
  end
26
39
  }.each{|thread|
27
40
  begin
@@ -1,3 +1,3 @@
1
1
  module TakuhaiStatus
2
- VERSION = "1.6.0"
2
+ VERSION = "1.7.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.6.0
4
+ version: 1.7.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-09-14 00:00:00.000000000 Z
11
+ date: 2017-11-02 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.13
157
+ rubygems_version: 2.6.14
158
158
  signing_key:
159
159
  specification_version: 4
160
160
  summary: get delivery status of Takuhai-bin in Japan