chronopost_fuel_multiplier 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: f09c6dc42a3d41cf8418478efca8afe60bcac9c8
4
+ data.tar.gz: 38b178547a90290617d8f18950dcbfb8ba300ba6
5
+ SHA512:
6
+ metadata.gz: 8fa13cf61550f13b648dad9ed99309f403d4a20cd7ea7058a22e4bcbe9cf26491c57e82fe0b3986af5a2a9167dd3545d74ded284995fb9a646d8158fe545aef7
7
+ data.tar.gz: f2e8f97776b2872eef8e138a835cb5cc1203599d29270232a67aad6e6a676ce59f8e6959f3aa4f3ab40c2e96fb7692bf948710bc69fe163e0e9e30f2ea7a46ec
@@ -0,0 +1,30 @@
1
+ # frozen_string_literal: true
2
+ require "addressable/uri"
3
+ require "httparty"
4
+ require "nokogiri"
5
+ require "plain_http_client"
6
+
7
+ class ChronopostFuelMultiplier
8
+ URL = 'http://www.chronopost.fr/fr/surcharge-carburant'
9
+
10
+ def initialize
11
+ response = PlainHttpClient.get(url, limit: 3, timeout: 10)
12
+ @page = Nokogiri::HTML response.body
13
+ end
14
+
15
+ def time_period
16
+ @page.at_css("table.ch-table thead tr th:last-child").text
17
+ end
18
+
19
+ def air_multiplier
20
+ "%.4f" % (@page.at_css("table.ch-table tbody tr:last-child td:last-child").text.to_f / 100 + 1)
21
+ end
22
+
23
+ def road_multiplier
24
+ "%.4f" % (@page.at_css("table.ch-table tbody tr td:last-child").text.to_f / 100 + 1)
25
+ end
26
+
27
+ def url
28
+ URL
29
+ end
30
+ end
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ # The HTTParty documentation advise to create new classes to parameter behavior
4
+ class PlainHttpClient
5
+ include HTTParty
6
+
7
+ uri_adapter Addressable::URI
8
+ end
metadata ADDED
@@ -0,0 +1,46 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: chronopost_fuel_multiplier
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Bob Maerten
8
+ - Clément Joubert
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2017-02-24 00:00:00.000000000 Z
13
+ dependencies: []
14
+ description: A simple gem to ease/automate getting this data every month
15
+ email: bob.maerten@gmail.com
16
+ executables: []
17
+ extensions: []
18
+ extra_rdoc_files: []
19
+ files:
20
+ - lib/chronopost_fuel_multiplier.rb
21
+ - lib/plain_http_client.rb
22
+ homepage: https://rubygems.org/gems/chronopost_fuel_multiplier
23
+ licenses:
24
+ - MIT
25
+ metadata: {}
26
+ post_install_message:
27
+ rdoc_options: []
28
+ require_paths:
29
+ - lib
30
+ required_ruby_version: !ruby/object:Gem::Requirement
31
+ requirements:
32
+ - - ">="
33
+ - !ruby/object:Gem::Version
34
+ version: '0'
35
+ required_rubygems_version: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - ">="
38
+ - !ruby/object:Gem::Version
39
+ version: '0'
40
+ requirements: []
41
+ rubyforge_project:
42
+ rubygems_version: 2.6.10
43
+ signing_key:
44
+ specification_version: 4
45
+ summary: Retrieve current month's Chronopost's fuel surcharges
46
+ test_files: []