fuel_surcharge 1.2.1 → 1.2.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github_changelog_generator +1 -1
- data/CHANGELOG.md +14 -2
- data/Gemfile.lock +1 -1
- data/lib/fuel_surcharge/html_scanner.rb +4 -4
- data/lib/fuel_surcharge/tnt.rb +16 -6
- data/lib/fuel_surcharge/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a6db529ef07a052e6406c2cc32c414bfd6a8cca577ab239c78bb3622cb326a93
|
4
|
+
data.tar.gz: 29f736220eb3c8c7ef87a02ae2c02a9812f280cf4c0a9590adaffb76df02a26b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9775e48cea5cf6b9aa79fb078e75480d8545a9716ec7a8daa3865468ddcf1a7410043da62249baa43dd2cfe0423e5591a6c1d54e28879d9621684cd2f062cfa2
|
7
|
+
data.tar.gz: 2bb3b0601f7331ba9b27ca87b2bdc0c2119cee206729e79119248ec070ca132622ca7ac09cb9e7ae365dfa9e4dc4a650b9f1aa7f62ecc9e0e13298a790cc4a93
|
data/.github_changelog_generator
CHANGED
@@ -1 +1 @@
|
|
1
|
-
future-release=1.2.
|
1
|
+
future-release=1.2.2
|
data/CHANGELOG.md
CHANGED
@@ -1,7 +1,18 @@
|
|
1
1
|
# Change Log
|
2
2
|
|
3
|
-
## [1.2.
|
4
|
-
[Full Changelog](https://github.com/levups/fuel_surcharge/compare/v1.2.
|
3
|
+
## [1.2.2](https://github.com/levups/fuel_surcharge/tree/1.2.2) (2019-08-01)
|
4
|
+
[Full Changelog](https://github.com/levups/fuel_surcharge/compare/v1.2.1...1.2.2)
|
5
|
+
|
6
|
+
**Fixed bugs:**
|
7
|
+
|
8
|
+
- TNT website change, again… [\#58](https://github.com/levups/fuel_surcharge/issues/58)
|
9
|
+
|
10
|
+
**Merged pull requests:**
|
11
|
+
|
12
|
+
- Correct TNT website parsing [\#59](https://github.com/levups/fuel_surcharge/pull/59) ([bobmaerten](https://github.com/bobmaerten))
|
13
|
+
|
14
|
+
## [v1.2.1](https://github.com/levups/fuel_surcharge/tree/v1.2.1) (2019-07-22)
|
15
|
+
[Full Changelog](https://github.com/levups/fuel_surcharge/compare/v1.2.0...v1.2.1)
|
5
16
|
|
6
17
|
**Fixed bugs:**
|
7
18
|
|
@@ -9,6 +20,7 @@
|
|
9
20
|
|
10
21
|
**Merged pull requests:**
|
11
22
|
|
23
|
+
- Release v1.2.1 [\#57](https://github.com/levups/fuel_surcharge/pull/57) ([bobmaerten](https://github.com/bobmaerten))
|
12
24
|
- Adapt to TNT / Chronopost website structure changes [\#56](https://github.com/levups/fuel_surcharge/pull/56) ([bobmaerten](https://github.com/bobmaerten))
|
13
25
|
- Bump rake from 12.3.2 to 12.3.3 [\#54](https://github.com/levups/fuel_surcharge/pull/54) ([dependabot-preview[bot]](https://github.com/apps/dependabot-preview))
|
14
26
|
- Update standard requirement from ~\> 0.0.39 to ~\> 0.1.0 [\#53](https://github.com/levups/fuel_surcharge/pull/53) ([dependabot-preview[bot]](https://github.com/apps/dependabot-preview))
|
data/Gemfile.lock
CHANGED
@@ -8,10 +8,10 @@ module FuelSurcharge
|
|
8
8
|
@scanner = StringScanner.new(source.to_s)
|
9
9
|
end
|
10
10
|
|
11
|
-
def upcoming(tag)
|
11
|
+
def upcoming(tag, attribute = nil)
|
12
12
|
return if @scanner.eos?
|
13
13
|
|
14
|
-
opening = "<#{tag}[^>]*>"
|
14
|
+
opening = attribute ? "<#{tag}\s[^>]*#{attribute}[^>]*>" : "<#{tag}[^>]*>"
|
15
15
|
closing = "</#{tag}>"
|
16
16
|
return unless @scanner.exist?(/#{opening}/) && @scanner.exist?(/#{closing}/)
|
17
17
|
|
@@ -22,11 +22,11 @@ module FuelSurcharge
|
|
22
22
|
chunk[0...chunk.size - closing.size].strip
|
23
23
|
end
|
24
24
|
|
25
|
-
def all(tag)
|
25
|
+
def all(tag, attribute = nil)
|
26
26
|
chunks = []
|
27
27
|
return chunks if @scanner.eos?
|
28
28
|
|
29
|
-
while (chunk = upcoming(tag))
|
29
|
+
while (chunk = upcoming(tag, attribute))
|
30
30
|
chunks << chunk
|
31
31
|
end
|
32
32
|
chunks
|
data/lib/fuel_surcharge/tnt.rb
CHANGED
@@ -16,7 +16,9 @@ module FuelSurcharge
|
|
16
16
|
end
|
17
17
|
|
18
18
|
def air_percentage
|
19
|
-
air_value&.
|
19
|
+
if (value = air_value&.dig("list", 0, "surcharge"))
|
20
|
+
value.tr(".", ",") << "%"
|
21
|
+
end
|
20
22
|
end
|
21
23
|
|
22
24
|
def road_multiplier
|
@@ -33,21 +35,29 @@ module FuelSurcharge
|
|
33
35
|
|
34
36
|
private
|
35
37
|
|
36
|
-
|
37
|
-
|
38
|
+
def json_air_url
|
39
|
+
"https://www.tnt.com/express/getDynamicData.europe.json"
|
40
|
+
end
|
38
41
|
|
39
42
|
def air_value
|
40
|
-
|
43
|
+
return if (json = air_response.to_s).empty?
|
44
|
+
|
45
|
+
JSON.parse(json)
|
41
46
|
end
|
42
47
|
|
48
|
+
ROAD_VALUES_REGEX = /Surcharge d[e\' ]+ (\w+ \d{4}) : (.+%)</.freeze
|
43
49
|
def road_value
|
44
|
-
|
50
|
+
road_response.to_s.scan(ROAD_VALUES_REGEX).first
|
45
51
|
end
|
46
52
|
|
47
|
-
def
|
53
|
+
def road_response
|
48
54
|
@response ||= HTTPRequest.new(url).response
|
49
55
|
end
|
50
56
|
|
57
|
+
def air_response
|
58
|
+
@air_response ||= HTTPRequest.new(json_air_url).response
|
59
|
+
end
|
60
|
+
|
51
61
|
FRENCH_MONTHS_NAMES = %w[
|
52
62
|
janvier
|
53
63
|
février
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fuel_surcharge
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.2.
|
4
|
+
version: 1.2.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Bob Maerten
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: exe
|
11
11
|
cert_chain: []
|
12
|
-
date: 2019-
|
12
|
+
date: 2019-08-01 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: http
|