takuhai_status 1.5.4 → 1.5.5
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/ups.rb +17 -7
- data/lib/takuhai_status/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9be075febbf69c7a73c761d80ccf7d8589315d2c
|
4
|
+
data.tar.gz: f40577194d5dcff9daea8ae4b656904161d8205c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ebcc0043195c97a5311a047b32f20620c1336dc330d606ad372e9c8652542d1421fb715dfc44a63e2627f4ed847f5d36db84dc97efa3cc20f131e37a53f49cc3
|
7
|
+
data.tar.gz: d372dca2d79255b2ec66ecf9e521cff2c655924e8219e2f3ac2842c7c533c50afe02ffbad0b12862d814a3fa6c7bed69d049e674b486d9dbdb9483cb13e2cd42
|
data/lib/takuhai_status/ups.rb
CHANGED
@@ -1,9 +1,11 @@
|
|
1
1
|
require 'open-uri'
|
2
|
+
require 'faraday'
|
2
3
|
require 'nokogiri'
|
3
4
|
|
4
5
|
module TakuhaiStatus
|
5
6
|
class UPS
|
6
7
|
attr_reader :key, :time, :state
|
8
|
+
@@conn = nil
|
7
9
|
|
8
10
|
def initialize(key)
|
9
11
|
@key = key.gsub(/[^a-zA-Z0-9]/, '')
|
@@ -16,18 +18,26 @@ module TakuhaiStatus
|
|
16
18
|
|
17
19
|
private
|
18
20
|
def check
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
21
|
+
@@conn = Faraday.new(url: 'https://wwwapps.ups.com/'){|builder|
|
22
|
+
builder.use :cookie_jar
|
23
|
+
builder.request :url_encoded
|
24
|
+
builder.adapter :net_http
|
25
|
+
} unless @@conn
|
26
|
+
@@conn.get('/WebTracking/track?loc=ja_JP') # once access to set cookie
|
27
|
+
res = @@conn.post('/WebTracking/track?loc=ja_JP', {
|
28
|
+
HTMLVersion: '5.0',
|
29
|
+
loc: 'ja',
|
30
|
+
trackNums: @key,
|
31
|
+
'track.x' => 'Track'
|
32
|
+
})
|
33
|
+
doc = Nokogiri::HTML.parse(res.body)
|
24
34
|
|
25
35
|
begin
|
26
36
|
state = doc.css('.newstatus h3')[0].text.strip
|
27
37
|
begin
|
28
|
-
time = "#{doc.css('
|
38
|
+
time = "#{doc.css('#fontControlButtons li li').text.match(/\d{4}\/\d\d\/\d\d \d{1,2}:\d\d/)[0]}+0500)"
|
29
39
|
rescue NoMethodError
|
30
|
-
time = "#{doc.css('
|
40
|
+
time = "#{doc.css('#fontControlButtons li').text.match(/\d{4}\/\d\d\/\d\d/)[0]} 00:00:00+0500)"
|
31
41
|
end
|
32
42
|
return Time.parse(time).localtime, state
|
33
43
|
rescue NoMethodError
|
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.
|
4
|
+
version: 1.5.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- TADA Tadashi
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2017-07-10 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.
|
157
|
+
rubygems_version: 2.6.11
|
158
158
|
signing_key:
|
159
159
|
specification_version: 4
|
160
160
|
summary: get delivery status of Takuhai-bin in Japan
|