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 +4 -4
- data/lib/takuhai_status.rb +31 -3
- data/lib/takuhai_status/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e21851b811b553ec9b53945835235fafa7566f4a
|
4
|
+
data.tar.gz: 30a04950d36086f59bd829a0d5ea8ba2c544fbda
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 592d46f00c7447c2a002c5fe2d6feec5efccafcbf989efd0bacd0a789f74ce19fd45a44b9f612dde2b9ff83cf1035862dd126ce67ab4af309b87e6e2814cb2b5
|
7
|
+
data.tar.gz: 1512a22f0d1b6ec9a05057c2ee7e46fbb0f6e41f2b05493eee9faa798c1de79316efa3ee32fb4b1413d1ac74d38eb007927991f972462ba851a7288a6e414d39
|
data/lib/takuhai_status.rb
CHANGED
@@ -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
|
-
|
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
|
-
|
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
|
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.
|
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-
|
11
|
+
date: 2016-01-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|