colissimo_fuel_adjustment_coefficients 0.2.2 → 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 +4 -1
- data/CHANGELOG.md +12 -4
- data/Gemfile.lock +1 -10
- data/colissimo_fuel_adjustment_coefficients.gemspec +1 -2
- data/lib/colissimo_fuel_adjustment_coefficients.rb +28 -21
- metadata +1 -15
- 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: eaabe681fb19bbf0d951eb3af72ce6bf4798779727d8e0a8f8e1f06ed47e9153
|
|
4
|
+
data.tar.gz: eb85387440ca0ce106dd489c12a99b8e7c14c1546055113b649f71f555f4ddef
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 95f980e621b44eba7d358d794c9f29b36b7f338e00e6b343fb9b6de62151b6459000f38685671bc710c92897504b64229bf69d4810320c149a5cbcfe5b7e981e
|
|
7
|
+
data.tar.gz: 1456f7d91c604fd3a9359824fa2148ac9b83c9c2d59edfba3b8d4ab25e45b12c9aeac40f1a66a237a046a4749b3da02907cef82e30912c88a0c83470a6282680
|
checksums.yaml.gz.sig
CHANGED
|
Binary file
|
data.tar.gz.sig
CHANGED
|
Binary file
|
data/.rubocop.yml
CHANGED
|
@@ -10,7 +10,7 @@ Style/StringLiterals:
|
|
|
10
10
|
Style/GuardClause:
|
|
11
11
|
Exclude:
|
|
12
12
|
- './*.gemspec'
|
|
13
|
-
|
|
13
|
+
|
|
14
14
|
Metrics/BlockLength:
|
|
15
15
|
Exclude:
|
|
16
16
|
- './*.gemspec'
|
|
@@ -19,3 +19,6 @@ Metrics/LineLength:
|
|
|
19
19
|
Exclude:
|
|
20
20
|
- './*.gemspec'
|
|
21
21
|
|
|
22
|
+
Metrics/AbcSize:
|
|
23
|
+
Exclude:
|
|
24
|
+
- 'test/colissimo_fuel_adjustment_coefficients_test.rb'
|
data/CHANGELOG.md
CHANGED
|
@@ -1,11 +1,19 @@
|
|
|
1
1
|
# Change Log
|
|
2
2
|
|
|
3
|
+
## [v0.3.0](https://github.com/levups/colissimo_fuel_adjustment_coefficients/tree/v0.3.0) (2018-11-19)
|
|
4
|
+
[Full Changelog](https://github.com/levups/colissimo_fuel_adjustment_coefficients/compare/v0.2.2...v0.3.0)
|
|
5
|
+
|
|
6
|
+
**Closed issues:**
|
|
7
|
+
|
|
8
|
+
- Replace Oga usage with plain standard REXML parsing? [\#13](https://github.com/levups/colissimo_fuel_adjustment_coefficients/issues/13)
|
|
9
|
+
|
|
10
|
+
**Merged pull requests:**
|
|
11
|
+
|
|
12
|
+
- Replace oga with REXML [\#14](https://github.com/levups/colissimo_fuel_adjustment_coefficients/pull/14) ([bobmaerten](https://github.com/bobmaerten))
|
|
13
|
+
|
|
3
14
|
## [v0.2.2](https://github.com/levups/colissimo_fuel_adjustment_coefficients/tree/v0.2.2) (2018-11-16)
|
|
4
15
|
[Full Changelog](https://github.com/levups/colissimo_fuel_adjustment_coefficients/compare/v0.2.1...v0.2.2)
|
|
5
16
|
|
|
6
|
-
- Correct homepage value in gemspec
|
|
7
|
-
- Update README
|
|
8
|
-
|
|
9
17
|
## [v0.2.1](https://github.com/levups/colissimo_fuel_adjustment_coefficients/tree/v0.2.1) (2018-11-16)
|
|
10
18
|
[Full Changelog](https://github.com/levups/colissimo_fuel_adjustment_coefficients/compare/v0.2.0...v0.2.1)
|
|
11
19
|
|
|
@@ -39,4 +47,4 @@
|
|
|
39
47
|
## [v0.1.0](https://github.com/levups/colissimo_fuel_adjustment_coefficients/tree/v0.1.0) (2017-05-23)
|
|
40
48
|
|
|
41
49
|
|
|
42
|
-
\* *This Change Log was automatically generated by [github_changelog_generator](https://github.com/skywinder/Github-Changelog-Generator)*
|
|
50
|
+
\* *This Change Log was automatically generated by [github_changelog_generator](https://github.com/skywinder/Github-Changelog-Generator)*
|
data/Gemfile.lock
CHANGED
|
@@ -1,17 +1,14 @@
|
|
|
1
1
|
PATH
|
|
2
2
|
remote: .
|
|
3
3
|
specs:
|
|
4
|
-
colissimo_fuel_adjustment_coefficients (0.
|
|
4
|
+
colissimo_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 = "colissimo_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
|
|
|
@@ -36,7 +36,6 @@ Gem::Specification.new do |s|
|
|
|
36
36
|
s.signing_key = File.expand_path("~/.ssh/bob_levups-gem-private_key.pem") if $PROGRAM_NAME.end_with?("gem")
|
|
37
37
|
|
|
38
38
|
s.add_dependency "http", "~> 4.0"
|
|
39
|
-
s.add_dependency "oga", "~> 2.10"
|
|
40
39
|
|
|
41
40
|
s.add_development_dependency "bundler", "~> 1.17"
|
|
42
41
|
s.add_development_dependency "minitest", "~> 5.1"
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
require
|
|
4
|
-
require
|
|
5
|
-
require
|
|
3
|
+
require "bigdecimal"
|
|
4
|
+
require "http"
|
|
5
|
+
require "rexml/document"
|
|
6
6
|
|
|
7
7
|
# Excepted XML is like:
|
|
8
8
|
# <indice_gazole>
|
|
@@ -16,29 +16,33 @@ require 'oga'
|
|
|
16
16
|
# </cap>
|
|
17
17
|
# <indice_gazole>
|
|
18
18
|
class ColissimoFuelAdjustmentCoefficients
|
|
19
|
+
include REXML
|
|
20
|
+
|
|
19
21
|
def initialize
|
|
20
|
-
@
|
|
21
|
-
|
|
22
|
-
|
|
22
|
+
@parsed_values = {}
|
|
23
|
+
return unless xml_root
|
|
24
|
+
|
|
25
|
+
caps = xml_root.elements.first
|
|
26
|
+
month = caps.elements.first
|
|
27
|
+
month.elements.each do |element|
|
|
28
|
+
@parsed_values[element.name] = element.text
|
|
29
|
+
end
|
|
23
30
|
end
|
|
24
31
|
|
|
25
32
|
def url
|
|
26
|
-
|
|
33
|
+
"https://www.colissimo.entreprise.laposte.fr/fr/system/files/imagescontent/docs/indice_gazole.xml"
|
|
27
34
|
end
|
|
28
35
|
|
|
29
36
|
def time_period
|
|
30
|
-
|
|
31
|
-
return unless el
|
|
32
|
-
|
|
33
|
-
el.text
|
|
37
|
+
@parsed_values["titre"]
|
|
34
38
|
end
|
|
35
39
|
|
|
36
40
|
def air_multiplier
|
|
37
|
-
format_multiplier
|
|
41
|
+
format_multiplier @parsed_values["aerien"]
|
|
38
42
|
end
|
|
39
43
|
|
|
40
44
|
def road_multiplier
|
|
41
|
-
format_multiplier
|
|
45
|
+
format_multiplier @parsed_values["routier"]
|
|
42
46
|
end
|
|
43
47
|
|
|
44
48
|
private
|
|
@@ -46,18 +50,21 @@ class ColissimoFuelAdjustmentCoefficients
|
|
|
46
50
|
def response
|
|
47
51
|
::HTTP.timeout(10).get(url)
|
|
48
52
|
rescue HTTP::Error
|
|
49
|
-
|
|
53
|
+
""
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
def xml_root
|
|
57
|
+
doc = Document.new response.to_s
|
|
58
|
+
doc.root
|
|
50
59
|
end
|
|
51
60
|
|
|
52
|
-
def format_multiplier(
|
|
53
|
-
|
|
54
|
-
return unless el
|
|
61
|
+
def format_multiplier(value)
|
|
62
|
+
return unless value
|
|
55
63
|
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
multiplier.tr!(',', '.')
|
|
64
|
+
value.tr!("%", "")
|
|
65
|
+
value.tr!(",", ".")
|
|
59
66
|
|
|
60
|
-
number = (
|
|
67
|
+
number = (value.to_f / 100 + 1).round(4)
|
|
61
68
|
BigDecimal(number.to_s)
|
|
62
69
|
end
|
|
63
70
|
end
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: colissimo_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
|
metadata.gz.sig
CHANGED
|
Binary file
|