prezzo 0.3.1 → 0.4.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e55520457e5b44bddcadbd3f1398b1ae77dde501
4
- data.tar.gz: f725b317c35cf7d64cf08e3c5f81b3d1ebfd2670
3
+ metadata.gz: e68e4778b29b3cf78670d0096790d55914beb14f
4
+ data.tar.gz: 3d0694e12d2e317356e7eae95483eb07fea11003
5
5
  SHA512:
6
- metadata.gz: f99c37f37e85a8498e476a7073dd415de73949b8f459bc78e0db9d8786f94ee3062521cc192835603749fbf84e34be14bed86feea99c6061a233113e55eb0a0b
7
- data.tar.gz: 74a88efd109d6a0a5d8d7fa7c689c43c7811ac1d04f5a6cb4d9e9a8395def25b6ba5a9fbaf4fa951c00e84d3f4099d3177fc6c7737401ed5680106c7354a5c79
6
+ metadata.gz: 1a20557bd58a6a26268c159986e775220f8864a601e97186fe10f9ac4b9e89672d22d27dfb3c9525a1db96740bedf5834edb62c21afc1149e1120dc6edc05cbe
7
+ data.tar.gz: e32f05204cfc04690f6d1e657438fbc6e516ae4f9db5511a70c6e4b2c09338d720485d7b4e339cb0090cdb53d87af782e8e9464d60fdc5cf7c47fb14b94315e0
data/.gitignore CHANGED
@@ -8,3 +8,4 @@
8
8
  /spec/reports/
9
9
  /tmp/
10
10
  .byebug_history
11
+ .ruby-version
data/README.md CHANGED
@@ -150,7 +150,7 @@ end
150
150
 
151
151
  context = Uber::Context.new(distance: 10.0)
152
152
  Uber::RidePriceCalculator.new(context).explain
153
- #=> { base_fare: 4.3, price_per_distance: 21.3 }
153
+ #=> { total: 25.6, components: { base_fare: 4.3, price_per_distance: 21.3 } }
154
154
  ```
155
155
 
156
156
  Check the full [Uber pricing](/spec/integration/uber_pricing_spec.rb) for more complete example with many calculators and factors.
@@ -7,11 +7,19 @@ module Prezzo
7
7
  end
8
8
 
9
9
  module ClassMethods
10
- def explain_with(*options)
10
+ def explain_with(*methods)
11
11
  define_method(:explain) do
12
- options.each_with_object({}) do |method, explanation|
13
- explanation[method] = send(method)
12
+ explanation = {
13
+ total: calculate,
14
+ }
15
+
16
+ components = methods.each_with_object({}) do |method, acc|
17
+ acc[method] = send(method)
14
18
  end
19
+
20
+ explanation[:components] = components unless components.empty?
21
+
22
+ explanation
15
23
  end
16
24
  end
17
25
  end
@@ -1,3 +1,3 @@
1
1
  module Prezzo
2
- VERSION = "0.3.1".freeze
2
+ VERSION = "0.4.0".freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: prezzo
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.1
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Marcelo Boeira
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-06-06 00:00:00.000000000 Z
11
+ date: 2017-06-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: hanami-validations