fuel_surcharge 1.2.0 → 1.2.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 69aed266b7e88f7c91f9e89208cc7ec34d837acf6674f602c19a466ce9b2b995
4
- data.tar.gz: 1053ad24d7dab572cba924c78ddfbbf678d27b8174fbc57fb3830a0bfa0a09a0
3
+ metadata.gz: f68cb01ef88675ef0ca5094c6ea5712cb669b111d4ec25c902fe6a2a4eaffc1d
4
+ data.tar.gz: 5fa8a822c054f84fa35b3180b9d8b439d953a7f87f3a24d4f38b3c49ac593945
5
5
  SHA512:
6
- metadata.gz: ec61592c3cf6e60cd2bde7db257012f266d7f02e5e7690d964e255c22edc0e610e79ee8724c4806f93e65d39791517acd78cb033abc49d483c914172a0296df8
7
- data.tar.gz: c72c8e1380fc086d439bb965a31fc9286cb62eebd39c4cf817fe386d91e445d5fb90585cb9f2207726953f33743ac3b6047e76a1dc2c67ef68959041532ade78
6
+ metadata.gz: ea6cc3b909404bd3020fd6bea0e7c9f06988ee3beee2c6ea39a547d9571e19e84ba1cc1879bd1efb6e8f5922535eec01ad6c814a62a599768520f67aea9b1272
7
+ data.tar.gz: e295ab64de727767269256b972f4ba5d627734c4f9a5f479b4c8eedf6bb94330ea26803dc77018978d5cbb9dfda14eb8eea2cf577f953e39cd8d9b466d8646d4
data/.circleci/config.yml CHANGED
@@ -40,7 +40,7 @@ jobs:
40
40
  - <<: *unit
41
41
  "jruby":
42
42
  docker:
43
- - image: circleci/jruby:latest
43
+ - image: circleci/jruby:9.2.6
44
44
  steps:
45
45
  - checkout
46
46
  - <<: *restore
@@ -1 +1 @@
1
- future-release=1.2.0
1
+ future-release=1.2.1
data/CHANGELOG.md CHANGED
@@ -1,8 +1,23 @@
1
1
  # Change Log
2
2
 
3
- ## [1.2.0](https://github.com/levups/fuel_surcharge/tree/1.2.0) (2019-04-23)
3
+ ## [1.2.1](https://github.com/levups/fuel_surcharge/tree/1.2.1) (2019-07-22)
4
+ [Full Changelog](https://github.com/levups/fuel_surcharge/compare/v1.2.0...1.2.1)
4
5
 
5
- [Full Changelog](https://github.com/levups/fuel_surcharge/compare/v1.1.0...1.2.0)
6
+ **Fixed bugs:**
7
+
8
+ - Website changes for TNT and Chronopost fuel surcharge infos [\#55](https://github.com/levups/fuel_surcharge/issues/55)
9
+
10
+ **Merged pull requests:**
11
+
12
+ - Adapt to TNT / Chronopost website structure changes [\#56](https://github.com/levups/fuel_surcharge/pull/56) ([bobmaerten](https://github.com/bobmaerten))
13
+ - 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
+ - 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))
15
+ - Bump standard from 0.0.40 to 0.0.41 [\#52](https://github.com/levups/fuel_surcharge/pull/52) ([dependabot-preview[bot]](https://github.com/apps/dependabot-preview))
16
+ - Bump standard from 0.0.39 to 0.0.40 [\#51](https://github.com/levups/fuel_surcharge/pull/51) ([dependabot-preview[bot]](https://github.com/apps/dependabot-preview))
17
+ - Add gem release how-to [\#50](https://github.com/levups/fuel_surcharge/pull/50) ([czj](https://github.com/czj))
18
+
19
+ ## [v1.2.0](https://github.com/levups/fuel_surcharge/tree/v1.2.0) (2019-04-23)
20
+ [Full Changelog](https://github.com/levups/fuel_surcharge/compare/v1.1.0...v1.2.0)
6
21
 
7
22
  **Fixed bugs:**
8
23
 
@@ -10,15 +25,25 @@
10
25
 
11
26
  **Merged pull requests:**
12
27
 
13
- - Correct github workflow for gem push [\#33](https://github.com/levups/fuel_surcharge/pull/33) ([bobmaerten](https://github.com/bobmaerten))
14
- - Fix versions for rubocop and standard gem in Sider [\#44](https://github.com/levups/fuel_surcharge/pull/44) ([bobmaerten](https://github.com/bobmaerten))
28
+ - Release 1.2.0 [\#49](https://github.com/levups/fuel_surcharge/pull/49) ([czj](https://github.com/czj))
29
+ - Rewrite TNT class to stabilize it at any time of the month [\#48](https://github.com/levups/fuel_surcharge/pull/48) ([czj](https://github.com/czj))
15
30
  - Move out of Travis CI into Circle CI [\#47](https://github.com/levups/fuel_surcharge/pull/47) ([czj](https://github.com/czj))
31
+ - Bump standard from 0.0.38 to 0.0.39 [\#46](https://github.com/levups/fuel_surcharge/pull/46) ([dependabot-preview[bot]](https://github.com/apps/dependabot-preview))
32
+ - Bump standard from 0.0.37 to 0.0.38 [\#45](https://github.com/levups/fuel_surcharge/pull/45) ([dependabot-preview[bot]](https://github.com/apps/dependabot-preview))
33
+ - Fix versions for rubocop and standard gem in Sider [\#44](https://github.com/levups/fuel_surcharge/pull/44) ([bobmaerten](https://github.com/bobmaerten))
34
+ - Bump standard from 0.0.36 to 0.0.37 [\#43](https://github.com/levups/fuel_surcharge/pull/43) ([dependabot-preview[bot]](https://github.com/apps/dependabot-preview))
16
35
  - Optimize chronopost scrapping [\#42](https://github.com/levups/fuel_surcharge/pull/42) ([bobmaerten](https://github.com/bobmaerten))
17
36
  - Replace Rubocop with standard.rb [\#41](https://github.com/levups/fuel_surcharge/pull/41) ([bobmaerten](https://github.com/bobmaerten))
18
- - Rewrite TNT class to stabilize it at any time of the month [\#48](https://github.com/levups/fuel_surcharge/pull/48) ([czj](https://github.com/czj))
37
+ - Bump rubocop from 0.65.0 to 0.66.0 [\#40](https://github.com/levups/fuel_surcharge/pull/40) ([dependabot-preview[bot]](https://github.com/apps/dependabot-preview))
38
+ - Bump http from 4.1.0 to 4.1.1 [\#39](https://github.com/levups/fuel_surcharge/pull/39) ([dependabot-preview[bot]](https://github.com/apps/dependabot-preview))
39
+ - Bump http from 4.0.5 to 4.1.0 [\#38](https://github.com/levups/fuel_surcharge/pull/38) ([dependabot-preview[bot]](https://github.com/apps/dependabot-preview))
40
+ - Bump rubocop from 0.64.0 to 0.65.0 [\#37](https://github.com/levups/fuel_surcharge/pull/37) ([dependabot-preview[bot]](https://github.com/apps/dependabot-preview))
41
+ - Bump http from 4.0.4 to 4.0.5 [\#36](https://github.com/levups/fuel_surcharge/pull/36) ([dependabot-preview[bot]](https://github.com/apps/dependabot-preview))
42
+ - Bump http from 4.0.3 to 4.0.4 [\#35](https://github.com/levups/fuel_surcharge/pull/35) ([dependabot-preview[bot]](https://github.com/apps/dependabot-preview))
43
+ - Bump rubocop from 0.63.1 to 0.64.0 [\#34](https://github.com/levups/fuel_surcharge/pull/34) ([dependabot-preview[bot]](https://github.com/apps/dependabot-preview))
44
+ - Correct github workflow for gem push [\#33](https://github.com/levups/fuel_surcharge/pull/33) ([bobmaerten](https://github.com/bobmaerten))
19
45
 
20
46
  ## [v1.1.0](https://github.com/levups/fuel_surcharge/tree/v1.1.0) (2019-02-08)
21
-
22
47
  [Full Changelog](https://github.com/levups/fuel_surcharge/compare/v1.0.0...v1.1.0)
23
48
 
24
49
  **Implemented enhancements:**
@@ -36,9 +61,13 @@
36
61
  - Check workflow agains git ref before running other actions [\#29](https://github.com/levups/fuel_surcharge/pull/29) ([bobmaerten](https://github.com/bobmaerten))
37
62
  - Github action auto publish [\#28](https://github.com/levups/fuel_surcharge/pull/28) ([bobmaerten](https://github.com/bobmaerten))
38
63
  - Fix chronopost time period extract [\#27](https://github.com/levups/fuel_surcharge/pull/27) ([bobmaerten](https://github.com/bobmaerten))
64
+ - Bump rubocop from 0.63.0 to 0.63.1 [\#24](https://github.com/levups/fuel_surcharge/pull/24) ([dependabot-preview[bot]](https://github.com/apps/dependabot-preview))
65
+ - Bump http from 4.0.2 to 4.0.3 [\#23](https://github.com/levups/fuel_surcharge/pull/23) ([dependabot-preview[bot]](https://github.com/apps/dependabot-preview))
66
+ - Bump rubocop from 0.62.0 to 0.63.0 [\#22](https://github.com/levups/fuel_surcharge/pull/22) ([dependabot-preview[bot]](https://github.com/apps/dependabot-preview))
67
+ - Bump http from 4.0.1 to 4.0.2 [\#21](https://github.com/levups/fuel_surcharge/pull/21) ([dependabot-preview[bot]](https://github.com/apps/dependabot-preview))
68
+ - Bump http from 4.0.0 to 4.0.1 [\#20](https://github.com/levups/fuel_surcharge/pull/20) ([dependabot-preview[bot]](https://github.com/apps/dependabot-preview))
39
69
 
40
70
  ## [v1.0.0](https://github.com/levups/fuel_surcharge/tree/v1.0.0) (2019-01-04)
41
-
42
71
  [Full Changelog](https://github.com/levups/fuel_surcharge/compare/v0.2.0...v1.0.0)
43
72
 
44
73
  **Merged pull requests:**
@@ -49,11 +78,12 @@
49
78
  - Bump to v1.0.0 [\#16](https://github.com/levups/fuel_surcharge/pull/16) ([czj](https://github.com/czj))
50
79
  - Include and comply to relaxed Rubocop style [\#15](https://github.com/levups/fuel_surcharge/pull/15) ([czj](https://github.com/czj))
51
80
  - Add BigDecimal compatibility for ruby 2.6 [\#13](https://github.com/levups/fuel_surcharge/pull/13) ([bobmaerten](https://github.com/bobmaerten))
81
+ - Bump rake from 12.3.1 to 12.3.2 [\#12](https://github.com/levups/fuel_surcharge/pull/12) ([dependabot-preview[bot]](https://github.com/apps/dependabot-preview))
82
+ - Update rake requirement from ~\> 10.0 to ~\> 12.3 [\#11](https://github.com/levups/fuel_surcharge/pull/11) ([dependabot-preview[bot]](https://github.com/apps/dependabot-preview))
52
83
  - Fix and unify time period tests [\#9](https://github.com/levups/fuel_surcharge/pull/9) ([bobmaerten](https://github.com/bobmaerten))
53
84
  - Fix fuel surcharge binary [\#8](https://github.com/levups/fuel_surcharge/pull/8) ([bobmaerten](https://github.com/bobmaerten))
54
85
 
55
86
  ## [v0.2.0](https://github.com/levups/fuel_surcharge/tree/v0.2.0) (2018-11-28)
56
-
57
87
  [Full Changelog](https://github.com/levups/fuel_surcharge/compare/v0.1.0...v0.2.0)
58
88
 
59
89
  **Implemented enhancements:**
@@ -71,11 +101,10 @@
71
101
  - Upgrade Travis CI dist to Xenial [\#2](https://github.com/levups/fuel_surcharge/pull/2) ([czj](https://github.com/czj))
72
102
 
73
103
  ## [v0.1.0](https://github.com/levups/fuel_surcharge/tree/v0.1.0) (2018-11-25)
74
-
75
104
  **Merged pull requests:**
76
105
 
77
106
  - Prepare for initial release [\#1](https://github.com/levups/fuel_surcharge/pull/1) ([bobmaerten](https://github.com/bobmaerten))
78
107
 
79
108
 
80
109
 
81
- \* *This Change Log was automatically generated by [github_changelog_generator](https://github.com/skywinder/Github-Changelog-Generator)*
110
+ \* *This Change Log was automatically generated by [github_changelog_generator](https://github.com/skywinder/Github-Changelog-Generator)*
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- fuel_surcharge (1.2.0)
4
+ fuel_surcharge (1.2.1)
5
5
  http (~> 4.0)
6
6
 
7
7
  GEM
@@ -16,7 +16,7 @@ GEM
16
16
  public_suffix (>= 2.0.2, < 4.0)
17
17
  ast (2.4.0)
18
18
  concurrent-ruby (1.1.5)
19
- domain_name (0.5.20180417)
19
+ domain_name (0.5.20190701)
20
20
  unf (>= 0.0.5, < 1.0.0)
21
21
  faraday (0.15.4)
22
22
  multipart-post (>= 1.2, < 3)
@@ -41,7 +41,7 @@ GEM
41
41
  http_parser.rb (0.6.0)
42
42
  i18n (1.6.0)
43
43
  concurrent-ruby (~> 1.0)
44
- jaro_winkler (1.5.2)
44
+ jaro_winkler (1.5.3)
45
45
  minitest (5.11.3)
46
46
  minitest-stub_any_instance (1.0.2)
47
47
  multi_json (1.13.1)
@@ -49,34 +49,35 @@ GEM
49
49
  octokit (4.14.0)
50
50
  sawyer (~> 0.8.0, >= 0.5.3)
51
51
  parallel (1.17.0)
52
- parser (2.6.2.1)
52
+ parser (2.6.3.0)
53
53
  ast (~> 2.4.0)
54
- psych (3.1.0)
55
54
  public_suffix (3.0.3)
56
55
  rainbow (3.0.0)
57
- rake (12.3.2)
56
+ rake (12.3.3)
58
57
  retriable (2.1.0)
59
- rubocop (0.67.2)
58
+ rubocop (0.72.0)
60
59
  jaro_winkler (~> 1.5.1)
61
60
  parallel (~> 1.10)
62
- parser (>= 2.5, != 2.5.1.1)
63
- psych (>= 3.1.0)
61
+ parser (>= 2.6)
64
62
  rainbow (>= 2.2.2, < 4.0)
65
63
  ruby-progressbar (~> 1.7)
66
- unicode-display_width (>= 1.4.0, < 1.6)
67
- ruby-progressbar (1.10.0)
64
+ unicode-display_width (>= 1.4.0, < 1.7)
65
+ rubocop-performance (1.4.0)
66
+ rubocop (>= 0.71.0)
67
+ ruby-progressbar (1.10.1)
68
68
  sawyer (0.8.1)
69
69
  addressable (>= 2.3.5, < 2.6)
70
70
  faraday (~> 0.8, < 1.0)
71
- standard (0.0.39)
72
- rubocop (~> 0.67.1)
71
+ standard (0.1.0)
72
+ rubocop (~> 0.72.0)
73
+ rubocop-performance (~> 1.4.0)
73
74
  thread_safe (0.3.6)
74
75
  tzinfo (1.2.5)
75
76
  thread_safe (~> 0.1)
76
77
  unf (0.1.4)
77
78
  unf_ext
78
79
  unf_ext (0.0.7.6)
79
- unicode-display_width (1.5.0)
80
+ unicode-display_width (1.6.0)
80
81
 
81
82
  PLATFORMS
82
83
  ruby
@@ -88,7 +89,7 @@ DEPENDENCIES
88
89
  minitest (~> 5.0)
89
90
  minitest-stub_any_instance (~> 1.0)
90
91
  rake (~> 12.3)
91
- standard (~> 0.0.39)
92
+ standard (~> 0.1.0)
92
93
 
93
94
  BUNDLED WITH
94
- 2.0.1
95
+ 2.0.2
data/README.md CHANGED
@@ -57,3 +57,12 @@ Or use it in your app:
57
57
  tnt = FuelSurcharge::TNT.new
58
58
  tnt.road_multiplier # 0.1121e1
59
59
  tnt.air_multiplier # 0.1185e1
60
+
61
+ ## Releasing a new version of this gem
62
+
63
+ - bump version in `lib/fuel_surcharge/version.rb` and `.github_changelog_generator`
64
+ - run `git fetch --all --prune --tag` to ensure having latest tags
65
+ - update CHANGELOG.md file by running `github_changelog_generator`
66
+ - commit, push, merge PR for this release
67
+ - draft and validate a new release on https://github.com/levups/fuel_surcharge/releases/new
68
+ - GitHub action publishes new relase on rubygems automatically
@@ -42,5 +42,5 @@ Gem::Specification.new do |spec|
42
42
  spec.add_development_dependency "minitest", "~> 5.0"
43
43
  spec.add_development_dependency "minitest-stub_any_instance", "~> 1.0"
44
44
  spec.add_development_dependency "rake", "~> 12.3"
45
- spec.add_development_dependency "standard", "~> 0.0.39"
45
+ spec.add_development_dependency "standard", "~> 0.1.0"
46
46
  end
@@ -9,7 +9,7 @@ module FuelSurcharge
9
9
  using StringFormatter
10
10
 
11
11
  def time_period
12
- periods.last
12
+ periods[1]
13
13
  end
14
14
 
15
15
  def air_multiplier
@@ -21,11 +21,17 @@ module FuelSurcharge
21
21
  end
22
22
 
23
23
  def air_percentage
24
- @air_percentage ||= HTMLScanner.new(air_content).all("td")&.last
24
+ @air_percentage ||= begin
25
+ table_row = HTMLScanner.new(air_content).all("td")
26
+ table_row[1]
27
+ end
25
28
  end
26
29
 
27
30
  def road_percentage
28
- @road_percentage ||= HTMLScanner.new(road_content).all("td")&.last
31
+ @road_percentage ||= begin
32
+ table_row = HTMLScanner.new(road_content).all("td")
33
+ table_row[1]
34
+ end
29
35
  end
30
36
 
31
37
  def url
@@ -34,8 +40,12 @@ module FuelSurcharge
34
40
 
35
41
  private
36
42
 
43
+ # In JRuby HTMLScanner is somehow loaded before this class and all String
44
+ # returned do not use StringFormatter refinement. Mapping HTMLScanner output
45
+ # with `to_s` method ensures those strings are using the StringFormatter
46
+ # refinement.
37
47
  def periods
38
- @periods ||= HTMLScanner.new(thead).all("th").map(&:strip_html).map(&:squish)
48
+ @periods ||= HTMLScanner.new(thead).all("th").map { |e| e.to_s.strip_html.squish }
39
49
  end
40
50
 
41
51
  def air_content
@@ -7,12 +7,6 @@ module FuelSurcharge
7
7
  class TNT
8
8
  using StringFormatter
9
9
 
10
- attr_accessor :current_month
11
-
12
- def initialize(current_month: Date.today.month)
13
- @current_month = current_month
14
- end
15
-
16
10
  def time_period
17
11
  road_value&.first&.to_s
18
12
  end
@@ -33,37 +27,25 @@ module FuelSurcharge
33
27
  air_percentage&.to_multiplier
34
28
  end
35
29
 
36
- private
37
-
38
- VALUES_REGEX = /Surcharge d[e\' ]+(.*) : (.*%)</.freeze
39
- # Sample obtained structure :
40
- # [
41
- # [" novembre 2018 ", "12,10%"],
42
- # ["octobre 2018 ", "11,95%"],
43
- # [" septembre 2018 ", "11,95%"],
44
- # [" novembre 2018 ", "18,50%"],
45
- # ["octobre 2018 ", "17,50%"],
46
- # [" septembre 2018 ", "17,50%"]
47
- # ]
48
- def extracted_values
49
- response.to_s.scan(VALUES_REGEX)
30
+ def url
31
+ "https://www.tnt.com/express/fr_fr/site/comment/facturation/comprendre-votre-facture/baremes-et-historiques.html"
50
32
  end
51
33
 
52
- def current_month_values
53
- extracted_values.select { |month, value| month.include? current_month_name }
54
- end
34
+ private
35
+
36
+ ROAD_VALUES_REGEX = /Surcharge d[e\' ]+ (\w+ \d{4}) : (.+%)</.freeze
37
+ AIR_VALUES_REGEX = /Surcharge du \d+ au \d+ (\w+ \d{4}) : (.*%)</.freeze
55
38
 
56
39
  def air_value
57
- current_month_values.last
40
+ response.to_s.scan(AIR_VALUES_REGEX).first
58
41
  end
59
42
 
60
43
  def road_value
61
- current_month_values.first
44
+ response.to_s.scan(ROAD_VALUES_REGEX).first
62
45
  end
63
46
 
64
- URL = "https://www.tnt.com/express/fr_fr/site/home/comment-expedier/facturation/surcharges/baremes-et-historiques.html"
65
47
  def response
66
- @response ||= HTTPRequest.new(URL).response
48
+ @response ||= HTTPRequest.new(url).response
67
49
  end
68
50
 
69
51
  FRENCH_MONTHS_NAMES = %w[
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module FuelSurcharge
4
- VERSION = "1.2.0"
4
+ VERSION = "1.2.1"
5
5
  end
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.0
4
+ version: 1.2.1
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-04-23 00:00:00.000000000 Z
12
+ date: 2019-07-22 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: http
@@ -101,14 +101,14 @@ dependencies:
101
101
  requirements:
102
102
  - - "~>"
103
103
  - !ruby/object:Gem::Version
104
- version: 0.0.39
104
+ version: 0.1.0
105
105
  type: :development
106
106
  prerelease: false
107
107
  version_requirements: !ruby/object:Gem::Requirement
108
108
  requirements:
109
109
  - - "~>"
110
110
  - !ruby/object:Gem::Version
111
- version: 0.0.39
111
+ version: 0.1.0
112
112
  description: A simple gem to fetch transporters data every month.
113
113
  email:
114
114
  - bob@levups.com