commissioner-guy 0.1.0 → 0.1.2

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: f6067d96597146d7a831da0b17b7ddd5b1c2a3f33b41763d5ba093fd42e60021
4
- data.tar.gz: 5db9d89fd1598f2d2a281164634c38f4d91b9c7f3fe8ff0f3caf0eaee737a3d0
3
+ metadata.gz: fe7e70de62af11761a16e9f9a1375aa837abc96e7a9c6d5ae7054a502036c69f
4
+ data.tar.gz: 7f75bd17875adc6aefa876d59e99d12c84ced25f775fade72873b128b3a954ae
5
5
  SHA512:
6
- metadata.gz: 339d2995163a048e22bc76fc7e17128011eba644cb98f9eafbc0a63cf8be0e1eef060782d36615769747117a427e1e67d9a4c94162012b1174abe2170de6bb77
7
- data.tar.gz: 5cc1573af34d93762a262534980b26b6141474b403eeaa3b306a32152cb0ab7d765293699398d3d7d93c40fe0a83a33eb9fbf3223c4f146ad4aac89a4926a460
6
+ metadata.gz: d7a2d80c717ac710a51863745b69cb54d6c0c077a7c4d7c68167b4d42988ef530482396b38abf659a1375690694d42674dbadfc7b9a312f04d031b1c7cd1a9cb
7
+ data.tar.gz: a6286246d68e4a1860c808d5e8566ede9490a63ac5333b18ca1b5d4cbdea772c7fa189b124f8c5341207512aaac11bd559ccc5b44034d9e5036298a2137a46c2
data/.gitignore CHANGED
@@ -9,3 +9,4 @@
9
9
 
10
10
  # rspec failure tracking
11
11
  .rspec_status
12
+ .irbrc
@@ -4,4 +4,7 @@ language: ruby
4
4
  cache: bundler
5
5
  rvm:
6
6
  - 2.6.3
7
- before_install: gem install bundler -v 1.17.2
7
+ before_install: gem install bundler -v 1.17.3
8
+
9
+ script:
10
+ - bundle exec rspec
@@ -1,9 +1,9 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- commissioner (0.1.0)
4
+ commissioner-guy (0.1.1)
5
5
  dry-auto_inject (~> 0.6)
6
- dry-configurable
6
+ dry-configurable (~> 0.11)
7
7
  money (~> 6.13.8)
8
8
 
9
9
  GEM
@@ -47,7 +47,7 @@ PLATFORMS
47
47
 
48
48
  DEPENDENCIES
49
49
  bundler (~> 1.17)
50
- commissioner!
50
+ commissioner-guy!
51
51
  rake (~> 10.0)
52
52
  rspec (~> 3.0)
53
53
 
data/README.md CHANGED
@@ -1,12 +1,15 @@
1
- # Commissioner
1
+ # Commissioner Guy
2
2
 
3
+ [![Build Status](https://travis-ci.org/mrexox/commissioner.svg?branch=main)](https://travis-ci.org/mrexox/commissioner)
4
+
5
+ Calculates charged and received amounts base on provided one. Can call your exchanger if needed. Applies commissions in the right order.
3
6
 
4
7
  ## Installation
5
8
 
6
9
  Add this line to your application's Gemfile:
7
10
 
8
11
  ```ruby
9
- gem 'commissioner'
12
+ gem 'commissioner-guy', require: 'commissioner'
10
13
  ```
11
14
 
12
15
  And then execute:
@@ -15,13 +18,15 @@ And then execute:
15
18
 
16
19
  Or install it yourself as:
17
20
 
18
- $ gem install easy_commissioner
21
+ $ gem install commissioner-guy
19
22
 
20
23
  ## Usage
21
24
 
22
25
  ### First, configure the gem
23
26
 
24
27
  ```ruby
28
+ require 'commissioner'
29
+
25
30
  Commissioner.configure do |config|
26
31
  # If you exchange money provider the lambda that receives
27
32
  # from - string
@@ -6,16 +6,9 @@ module Commissioner
6
6
  CommissionerArityInvalid = Class.new(StandardError)
7
7
 
8
8
  HELP_MESSAGE = 'You must provider either charged_amount (with charged_currency) or received_amount (with received_currency). If none or both are non-zero, the service cannot know how to handle this.'.freeze
9
- DEFAULT_ORDER = [
10
- :reduce_commission,
11
- :exchange,
12
- :reduce_exchange_commission
13
- ].freeze
14
-
15
9
  private_constant :HELP_MESSAGE
16
10
 
17
-
18
- def initialize(params, config:, order: DEFAULT_ORDER)
11
+ def initialize(params, config:)
19
12
  @charged_amount = guess_amount(params[:charged_amount], params[:charged_currency])
20
13
  @received_amount = guess_amount(params[:received_amount], params[:received_currency])
21
14
 
@@ -38,7 +31,6 @@ module Commissioner
38
31
  else
39
32
  BigDecimal::ROUND_HALF_UP
40
33
  end
41
- @order = order
42
34
  end
43
35
 
44
36
  def calculate
@@ -10,7 +10,7 @@ module Commissioner
10
10
  # ]
11
11
 
12
12
  def calculate(params)
13
- Calculator.new(params, config: Commissioner.config, order: @@order).calculate
13
+ Calculator.new(params, config: Commissioner.config).calculate
14
14
  end
15
15
  end
16
16
  end
@@ -1,3 +1,3 @@
1
1
  module Commissioner
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.2"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: commissioner-guy
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Valentine Kiselev
@@ -102,7 +102,6 @@ extensions: []
102
102
  extra_rdoc_files: []
103
103
  files:
104
104
  - ".gitignore"
105
- - ".irbrc"
106
105
  - ".rspec"
107
106
  - ".ruby-version"
108
107
  - ".travis.yml"
data/.irbrc DELETED
@@ -1,4 +0,0 @@
1
- lib = File.expand_path('../lib', __FILE__)
2
- $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
- require 'commissioner'
4
- Commissioner.configure {|c| c.exchanger = ->(from, to, amount) { [Money.from_amount(amount.to_f, to), 1] } }