commissioner-guy 0.1.0 → 0.1.2
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
- data/.gitignore +1 -0
- data/.travis.yml +4 -1
- data/Gemfile.lock +3 -3
- data/README.md +8 -3
- data/lib/commissioner/calculator.rb +1 -9
- data/lib/commissioner/mixin.rb +1 -1
- data/lib/commissioner/version.rb +1 -1
- metadata +1 -2
- data/.irbrc +0 -4
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: fe7e70de62af11761a16e9f9a1375aa837abc96e7a9c6d5ae7054a502036c69f
|
|
4
|
+
data.tar.gz: 7f75bd17875adc6aefa876d59e99d12c84ced25f775fade72873b128b3a954ae
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: d7a2d80c717ac710a51863745b69cb54d6c0c077a7c4d7c68167b4d42988ef530482396b38abf659a1375690694d42674dbadfc7b9a312f04d031b1c7cd1a9cb
|
|
7
|
+
data.tar.gz: a6286246d68e4a1860c808d5e8566ede9490a63ac5333b18ca1b5d4cbdea772c7fa189b124f8c5341207512aaac11bd559ccc5b44034d9e5036298a2137a46c2
|
data/.gitignore
CHANGED
data/.travis.yml
CHANGED
data/Gemfile.lock
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
PATH
|
|
2
2
|
remote: .
|
|
3
3
|
specs:
|
|
4
|
-
commissioner (0.1.
|
|
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
|
+
[](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
|
|
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
|
data/lib/commissioner/mixin.rb
CHANGED
data/lib/commissioner/version.rb
CHANGED
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.
|
|
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