takuhai_status 1.3.2 → 1.4.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: e00546f8f48385326d432823a60bb7be085a6689
4
- data.tar.gz: 1b550bcc680908baa39a1fd3bf81dbe245695508
3
+ metadata.gz: e21851b811b553ec9b53945835235fafa7566f4a
4
+ data.tar.gz: 30a04950d36086f59bd829a0d5ea8ba2c544fbda
5
5
  SHA512:
6
- metadata.gz: d5e224e270657cf696f7e8e9ce557f48e40ea0e4df39e793a656e543cff85dec45b5a70b734d7db217e005a9a6772a9bb811a348452d821b5441a963ca92fd96
7
- data.tar.gz: 9264a9db8a8b09feab54a51b92795b908bcf581f5fc2f0468a455b8d2435cafa99a5116bbea3dbaa9bc1c3321500357209a7a5958ea0e59c11eaa1ac0514a0db
6
+ metadata.gz: 592d46f00c7447c2a002c5fe2d6feec5efccafcbf989efd0bacd0a789f74ce19fd45a44b9f612dde2b9ff83cf1035862dd126ce67ab4af309b87e6e2814cb2b5
7
+ data.tar.gz: 1512a22f0d1b6ec9a05057c2ee7e46fbb0f6e41f2b05493eee9faa798c1de79316efa3ee32fb4b1413d1ac74d38eb007927991f972462ba851a7288a6e414d39
@@ -8,14 +8,42 @@ require "takuhai_status/ups"
8
8
  module TakuhaiStatus
9
9
  class NotFound < StandardError; end
10
10
  class NotMyKey < StandardError; end
11
+ class Multiple < StandardError
12
+ attr_reader :services
13
+ def initialize(msg, services)
14
+ super(msg)
15
+ @services = services
16
+ end
17
+ end
11
18
 
12
19
  def self.scan(key)
13
- [JapanPost, KuronekoYamato, Sagawa, TMGCargo, UPS].each do |service|
20
+ services = []
21
+ [].tap{|threads|
22
+ [Sagawa, JapanPost, KuronekoYamato, TMGCargo, UPS].each do |service|
23
+ threads.push(Thread.new{service.new(key)})
24
+ end
25
+ }.each{|thread|
14
26
  begin
15
- return service.new(key)
27
+ services.push(thread.value)
16
28
  rescue NotMyKey
17
29
  end
30
+ }
31
+
32
+ case services.size
33
+ when 0
34
+ raise NotFound
35
+ when 1
36
+ return services.first
37
+ else
38
+ services.delete_if{|service| service.finish?}
39
+ case services.size
40
+ when 0
41
+ raise NotFound
42
+ when 1
43
+ return services.first
44
+ else
45
+ raise Multiple.new('some services found', services)
46
+ end
18
47
  end
19
- raise NotFound
20
48
  end
21
49
  end
@@ -1,3 +1,3 @@
1
1
  module TakuhaiStatus
2
- VERSION = "1.3.2"
2
+ VERSION = "1.4.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.3.2
4
+ version: 1.4.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: 2016-01-19 00:00:00.000000000 Z
11
+ date: 2016-01-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday