chronopost_fuel_adjustment_coefficients 0.2.1 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +0 -0
- data/.rubocop.yml +12 -1
- data/CHANGELOG.md +20 -0
- data/Gemfile.lock +1 -10
- data/chronopost_fuel_adjustment_coefficients.gemspec +7 -13
- data/lib/chronopost_fuel_adjustment_coefficients.rb +24 -17
- metadata +3 -17
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: af263a1e2c77dcbb83f0620f19ec996774b6738ec010171a3ba30bc85fa0b8bf
|
4
|
+
data.tar.gz: 0d80c679e23e88d20287891e3ff097161bb2cd9d5585814e64d454d28a9d77e3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ff27cc4b0a8753a0c4c8e9b023418d989b334fb1f55a22677624c5d133760d77f41ccc8073a4cb1dc06d48e24dc04b81d054f2c462cd7400079ec77cc94a144e
|
7
|
+
data.tar.gz: f1eeba4c765f5b1452e5301201f01919014a8799c5f085d481357a7dad348f547e786bd2d7e60904e06809999ded9e16bb00ebf6ee67ecdab63791b5551a1217
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data.tar.gz.sig
CHANGED
Binary file
|
data/.rubocop.yml
CHANGED
@@ -7,7 +7,7 @@ Style/StringLiterals:
|
|
7
7
|
Style/GuardClause:
|
8
8
|
Exclude:
|
9
9
|
- './*.gemspec'
|
10
|
-
|
10
|
+
|
11
11
|
Metrics/BlockLength:
|
12
12
|
Exclude:
|
13
13
|
- './*.gemspec'
|
@@ -16,3 +16,14 @@ Metrics/LineLength:
|
|
16
16
|
Exclude:
|
17
17
|
- './*.gemspec'
|
18
18
|
|
19
|
+
Lint/AssignmentInCondition:
|
20
|
+
Enabled: false
|
21
|
+
|
22
|
+
Metrics/MethodLength:
|
23
|
+
Exclude:
|
24
|
+
- 'lib/chronopost_fuel_adjustment_coefficients.rb'
|
25
|
+
|
26
|
+
Metrics/AbcSize:
|
27
|
+
Exclude:
|
28
|
+
- 'lib/chronopost_fuel_adjustment_coefficients.rb'
|
29
|
+
- 'test/chronopost_fuel_adjustment_coefficients_test.rb'
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,25 @@
|
|
1
1
|
# Change Log
|
2
2
|
|
3
|
+
## [v0.3.0](https://github.com/levups/chronopost_fuel_adjustment_coefficients/tree/v0.3.0) (2018-11-27)
|
4
|
+
[Full Changelog](https://github.com/levups/chronopost_fuel_adjustment_coefficients/compare/v0.2.1...v0.3.0)
|
5
|
+
|
6
|
+
**Closed issues:**
|
7
|
+
|
8
|
+
- Replace Oga usage with plain standard REXML parsing? [\#18](https://github.com/levups/chronopost_fuel_adjustment_coefficients/issues/18)
|
9
|
+
|
10
|
+
**Merged pull requests:**
|
11
|
+
|
12
|
+
- Replace oga with plain string parsing [\#19](https://github.com/levups/chronopost_fuel_adjustment_coefficients/pull/19) ([bobmaerten](https://github.com/bobmaerten))
|
13
|
+
- Prepare for official gem release [\#17](https://github.com/levups/chronopost_fuel_adjustment_coefficients/pull/17) ([bobmaerten](https://github.com/bobmaerten))
|
14
|
+
|
15
|
+
## [v0.2.1](https://github.com/levups/chronopost_fuel_adjustment_coefficients/tree/v0.2.1) (2018-11-16)
|
16
|
+
[Full Changelog](https://github.com/levups/chronopost_fuel_adjustment_coefficients/compare/v0.2.0...v0.2.1)
|
17
|
+
|
18
|
+
**Closed issues:**
|
19
|
+
|
20
|
+
- Sign gem before publishing it [\#16](https://github.com/levups/chronopost_fuel_adjustment_coefficients/issues/16)
|
21
|
+
- Comply to `bundle gem` defaults [\#15](https://github.com/levups/chronopost_fuel_adjustment_coefficients/issues/15)
|
22
|
+
|
3
23
|
## [v0.2.0](https://github.com/levups/chronopost_fuel_adjustment_coefficients/tree/v0.2.0) (2018-11-14)
|
4
24
|
[Full Changelog](https://github.com/levups/chronopost_fuel_adjustment_coefficients/compare/v0.1.1...v0.2.0)
|
5
25
|
|
data/Gemfile.lock
CHANGED
@@ -1,17 +1,14 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
chronopost_fuel_adjustment_coefficients (0.
|
4
|
+
chronopost_fuel_adjustment_coefficients (0.3.0)
|
5
5
|
http (~> 4.0)
|
6
|
-
oga (~> 2.10)
|
7
6
|
|
8
7
|
GEM
|
9
8
|
remote: https://rubygems.org/
|
10
9
|
specs:
|
11
10
|
addressable (2.5.2)
|
12
11
|
public_suffix (>= 2.0.2, < 4.0)
|
13
|
-
ansi (1.5.0)
|
14
|
-
ast (2.4.0)
|
15
12
|
domain_name (0.5.20180417)
|
16
13
|
unf (>= 0.0.5, < 1.0.0)
|
17
14
|
http (4.0.0)
|
@@ -25,14 +22,8 @@ GEM
|
|
25
22
|
http_parser.rb (0.6.0)
|
26
23
|
minitest (5.11.3)
|
27
24
|
minitest-stub_any_instance (1.0.2)
|
28
|
-
oga (2.15)
|
29
|
-
ast
|
30
|
-
ruby-ll (~> 2.1)
|
31
25
|
public_suffix (3.0.3)
|
32
26
|
rake (12.3.1)
|
33
|
-
ruby-ll (2.1.2)
|
34
|
-
ansi
|
35
|
-
ast
|
36
27
|
unf (0.1.4)
|
37
28
|
unf_ext
|
38
29
|
unf_ext (0.0.7.5)
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
s.name = "chronopost_fuel_adjustment_coefficients"
|
3
|
-
s.version = "0.
|
3
|
+
s.version = "0.3.0"
|
4
4
|
s.authors = ["Bob Maerten", "Clément Joubert"]
|
5
5
|
s.email = ["bob@levups.com", "clement@levups.com"]
|
6
6
|
|
@@ -10,17 +10,12 @@ Gem::Specification.new do |s|
|
|
10
10
|
s.homepage = "https://rubygems.org/gems/chronopost_fuel_adjustment_coefficients"
|
11
11
|
s.license = "MIT"
|
12
12
|
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
s.metadata["source_code_uri"] = "https://github.com/levups/chronopost_fuel_adjustment_coefficients"
|
20
|
-
s.metadata["changelog_uri"] = "https://github.com/levups/chronopost_fuel_adjustment_coefficients/blob/master/CHANGELOG.md"
|
21
|
-
else
|
22
|
-
raise "RubyGems 2.0 or newer is required to protect against public gem pushes."
|
23
|
-
end
|
13
|
+
s.metadata = {
|
14
|
+
"bug_tracker_uri" => "https://github.com/levups/chronopost_fuel_adjustment_coefficients/issues",
|
15
|
+
"changelog_uri" => "https://github.com/levups/chronopost_fuel_adjustment_coefficients/blob/master/CHANGELOG.md",
|
16
|
+
"homepage_uri" => "https://rubygems.org/gems/chronopost_fuel_adjustment_coefficients",
|
17
|
+
"source_code_uri" => "https://github.com/levups/chronopost_fuel_adjustment_coefficients"
|
18
|
+
}
|
24
19
|
|
25
20
|
s.bindir = "exe"
|
26
21
|
s.executables = "chronopost_fuel_adjustment_coefficients"
|
@@ -36,7 +31,6 @@ Gem::Specification.new do |s|
|
|
36
31
|
s.signing_key = File.expand_path("~/.ssh/bob_levups-gem-private_key.pem") if $PROGRAM_NAME.end_with?("gem")
|
37
32
|
|
38
33
|
s.add_dependency "http", "~> 4.0"
|
39
|
-
s.add_dependency "oga", "~> 2.10"
|
40
34
|
|
41
35
|
s.add_development_dependency "bundler", "~> 1.17"
|
42
36
|
s.add_development_dependency "minitest", "~> 5.1"
|
@@ -2,32 +2,20 @@
|
|
2
2
|
|
3
3
|
require 'bigdecimal'
|
4
4
|
require 'http'
|
5
|
-
require 'oga'
|
6
5
|
|
7
6
|
class ChronopostFuelAdjustmentCoefficients
|
8
|
-
|
9
|
-
@document = ::Oga.parse_html response.to_s
|
10
|
-
end
|
11
|
-
|
12
|
-
def time_period
|
13
|
-
el = @document.at_css('table.ch-table thead tr th:last-child')
|
14
|
-
return unless el
|
7
|
+
attr_reader :time_period
|
15
8
|
|
16
|
-
|
9
|
+
def initialize
|
10
|
+
@time_period, @routier, @aerien = extracted_content
|
17
11
|
end
|
18
12
|
|
19
13
|
def air_multiplier
|
20
|
-
|
21
|
-
return unless el
|
22
|
-
|
23
|
-
format_multiplier el.text
|
14
|
+
format_multiplier @aerien
|
24
15
|
end
|
25
16
|
|
26
17
|
def road_multiplier
|
27
|
-
|
28
|
-
return unless el
|
29
|
-
|
30
|
-
format_multiplier el.text
|
18
|
+
format_multiplier @routier
|
31
19
|
end
|
32
20
|
|
33
21
|
def url
|
@@ -42,7 +30,26 @@ class ChronopostFuelAdjustmentCoefficients
|
|
42
30
|
''
|
43
31
|
end
|
44
32
|
|
33
|
+
def extracted_content
|
34
|
+
html = response.to_s.delete("\n").gsub(/\s+/, " ")
|
35
|
+
|
36
|
+
return [] unless tables = html.split("<table ")[1]
|
37
|
+
return [] unless table = tables.split("<h2>Principe</h2>").first
|
38
|
+
return [] unless head = table.scan(%r{<thead>.*</thead>}).first
|
39
|
+
return [] unless period = head.match(%r{<p>(?<content>.*)</p>})
|
40
|
+
return [] unless body = table.scan(%r{<tbody><tr>.*</tr></tbody>}).first
|
41
|
+
|
42
|
+
time_period = period[:content].sub("<br />", "")
|
43
|
+
adjustements = body.split("</tr><tr>").map do |line|
|
44
|
+
line.to_s.rpartition("</td>").first.rpartition(">").last
|
45
|
+
end
|
46
|
+
|
47
|
+
[time_period, adjustements[0], adjustements[1]]
|
48
|
+
end
|
49
|
+
|
45
50
|
def format_multiplier(string)
|
51
|
+
return unless string
|
52
|
+
|
46
53
|
number = (string.to_f / 100 + 1).round(4)
|
47
54
|
BigDecimal(number.to_s)
|
48
55
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: chronopost_fuel_adjustment_coefficients
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Bob Maerten
|
@@ -51,20 +51,6 @@ dependencies:
|
|
51
51
|
- - "~>"
|
52
52
|
- !ruby/object:Gem::Version
|
53
53
|
version: '4.0'
|
54
|
-
- !ruby/object:Gem::Dependency
|
55
|
-
name: oga
|
56
|
-
requirement: !ruby/object:Gem::Requirement
|
57
|
-
requirements:
|
58
|
-
- - "~>"
|
59
|
-
- !ruby/object:Gem::Version
|
60
|
-
version: '2.10'
|
61
|
-
type: :runtime
|
62
|
-
prerelease: false
|
63
|
-
version_requirements: !ruby/object:Gem::Requirement
|
64
|
-
requirements:
|
65
|
-
- - "~>"
|
66
|
-
- !ruby/object:Gem::Version
|
67
|
-
version: '2.10'
|
68
54
|
- !ruby/object:Gem::Dependency
|
69
55
|
name: bundler
|
70
56
|
requirement: !ruby/object:Gem::Requirement
|
@@ -148,10 +134,10 @@ homepage: https://rubygems.org/gems/chronopost_fuel_adjustment_coefficients
|
|
148
134
|
licenses:
|
149
135
|
- MIT
|
150
136
|
metadata:
|
151
|
-
|
137
|
+
bug_tracker_uri: https://github.com/levups/chronopost_fuel_adjustment_coefficients/issues
|
138
|
+
changelog_uri: https://github.com/levups/chronopost_fuel_adjustment_coefficients/blob/master/CHANGELOG.md
|
152
139
|
homepage_uri: https://rubygems.org/gems/chronopost_fuel_adjustment_coefficients
|
153
140
|
source_code_uri: https://github.com/levups/chronopost_fuel_adjustment_coefficients
|
154
|
-
changelog_uri: https://github.com/levups/chronopost_fuel_adjustment_coefficients/blob/master/CHANGELOG.md
|
155
141
|
post_install_message:
|
156
142
|
rdoc_options: []
|
157
143
|
require_paths:
|
metadata.gz.sig
CHANGED
Binary file
|