payment_schedule 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +9 -0
- data/.travis.yml +10 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/Gemfile +7 -0
- data/LICENSE.txt +21 -0
- data/README.md +182 -0
- data/Rakefile +16 -0
- data/bin/console +16 -0
- data/bin/setup +8 -0
- data/lib/payment_schedule/component.rb +26 -0
- data/lib/payment_schedule/core_ext/big_decimal.rb +10 -0
- data/lib/payment_schedule/instruction.rb +29 -0
- data/lib/payment_schedule/output.rb +35 -0
- data/lib/payment_schedule/schedule.rb +103 -0
- data/lib/payment_schedule/version.rb +3 -0
- data/lib/payment_schedule.rb +18 -0
- data/media/screenshot-payment-schedule-example-term.png +0 -0
- data/media/screenshot-payment-schedule-example-xlsx.png +0 -0
- data/payment_schedule.gemspec +34 -0
- metadata +189 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: a3f83ea6697d8246976f5122347a8d22c8302eef
|
4
|
+
data.tar.gz: a1436d9ff840a8ff556e203c86b1feb5342eb527
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: c7680de4928e49cfc00eca2a24294443821adb991f3633df9ea55c4d2150adca6e5e54f4266837120ad9203d7ac814ddf82b895ba287d4994a554078c1973dc5
|
7
|
+
data.tar.gz: 3c43b4afdd05c89c8689754eebf6083e4f381448f56db1fee30b4c105ec4bba0cd8929032038c9e0c438fe6aa3a6d6149175b3f84e9d81a30dee1068507b3af5
|
data/.gitignore
ADDED
data/.travis.yml
ADDED
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,74 @@
|
|
1
|
+
# Contributor Covenant Code of Conduct
|
2
|
+
|
3
|
+
## Our Pledge
|
4
|
+
|
5
|
+
In the interest of fostering an open and welcoming environment, we as
|
6
|
+
contributors and maintainers pledge to making participation in our project and
|
7
|
+
our community a harassment-free experience for everyone, regardless of age, body
|
8
|
+
size, disability, ethnicity, gender identity and expression, level of experience,
|
9
|
+
nationality, personal appearance, race, religion, or sexual identity and
|
10
|
+
orientation.
|
11
|
+
|
12
|
+
## Our Standards
|
13
|
+
|
14
|
+
Examples of behavior that contributes to creating a positive environment
|
15
|
+
include:
|
16
|
+
|
17
|
+
* Using welcoming and inclusive language
|
18
|
+
* Being respectful of differing viewpoints and experiences
|
19
|
+
* Gracefully accepting constructive criticism
|
20
|
+
* Focusing on what is best for the community
|
21
|
+
* Showing empathy towards other community members
|
22
|
+
|
23
|
+
Examples of unacceptable behavior by participants include:
|
24
|
+
|
25
|
+
* The use of sexualized language or imagery and unwelcome sexual attention or
|
26
|
+
advances
|
27
|
+
* Trolling, insulting/derogatory comments, and personal or political attacks
|
28
|
+
* Public or private harassment
|
29
|
+
* Publishing others' private information, such as a physical or electronic
|
30
|
+
address, without explicit permission
|
31
|
+
* Other conduct which could reasonably be considered inappropriate in a
|
32
|
+
professional setting
|
33
|
+
|
34
|
+
## Our Responsibilities
|
35
|
+
|
36
|
+
Project maintainers are responsible for clarifying the standards of acceptable
|
37
|
+
behavior and are expected to take appropriate and fair corrective action in
|
38
|
+
response to any instances of unacceptable behavior.
|
39
|
+
|
40
|
+
Project maintainers have the right and responsibility to remove, edit, or
|
41
|
+
reject comments, commits, code, wiki edits, issues, and other contributions
|
42
|
+
that are not aligned to this Code of Conduct, or to ban temporarily or
|
43
|
+
permanently any contributor for other behaviors that they deem inappropriate,
|
44
|
+
threatening, offensive, or harmful.
|
45
|
+
|
46
|
+
## Scope
|
47
|
+
|
48
|
+
This Code of Conduct applies both within project spaces and in public spaces
|
49
|
+
when an individual is representing the project or its community. Examples of
|
50
|
+
representing a project or community include using an official project e-mail
|
51
|
+
address, posting via an official social media account, or acting as an appointed
|
52
|
+
representative at an online or offline event. Representation of a project may be
|
53
|
+
further defined and clarified by project maintainers.
|
54
|
+
|
55
|
+
## Enforcement
|
56
|
+
|
57
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
58
|
+
reported by contacting the project team at murdho@murdho.com. All
|
59
|
+
complaints will be reviewed and investigated and will result in a response that
|
60
|
+
is deemed necessary and appropriate to the circumstances. The project team is
|
61
|
+
obligated to maintain confidentiality with regard to the reporter of an incident.
|
62
|
+
Further details of specific enforcement policies may be posted separately.
|
63
|
+
|
64
|
+
Project maintainers who do not follow or enforce the Code of Conduct in good
|
65
|
+
faith may face temporary or permanent repercussions as determined by other
|
66
|
+
members of the project's leadership.
|
67
|
+
|
68
|
+
## Attribution
|
69
|
+
|
70
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
|
71
|
+
available at [http://contributor-covenant.org/version/1/4][version]
|
72
|
+
|
73
|
+
[homepage]: http://contributor-covenant.org
|
74
|
+
[version]: http://contributor-covenant.org/version/1/4/
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2017 Murdho
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,182 @@
|
|
1
|
+
# PaymentSchedule
|
2
|
+
|
3
|
+
[![Build Status](https://travis-ci.org/murdho/payment_schedule.svg?branch=master)](https://travis-ci.org/murdho/payment_schedule)
|
4
|
+
[![Code Climate](https://lima.codeclimate.com/github/murdho/payment_schedule/badges/gpa.svg)](https://lima.codeclimate.com/github/murdho/payment_schedule)
|
5
|
+
[![Test Coverage](https://lima.codeclimate.com/github/murdho/payment_schedule/badges/coverage.svg)](https://lima.codeclimate.com/github/murdho/payment_schedule/coverage)
|
6
|
+
|
7
|
+
PaymentSchedule is a Ruby gem for describing and calculating payment schedules. Its goal is to make implementation and modification of payment schedule algorithms fast and easy to understand.
|
8
|
+
|
9
|
+
Requires Ruby 2.4.0 or higher.
|
10
|
+
|
11
|
+
|
12
|
+
|
13
|
+
## Introduction
|
14
|
+
|
15
|
+
#### Easy to use
|
16
|
+
|
17
|
+
Simple to keep the algorithm similar to payment schedule's tabular nature. This enables faster changes in the code when the specification changes. At the same time code is clear and readable, even for a person who hasn't got much experience with such algorithms.
|
18
|
+
|
19
|
+
|
20
|
+
|
21
|
+
#### Fast
|
22
|
+
|
23
|
+
It has good memory and is very lazy — that's why it calculates as little as needed and is very fast.
|
24
|
+
|
25
|
+
|
26
|
+
|
27
|
+
## Example
|
28
|
+
|
29
|
+
Take a look at the example, which demostrates the simplicity of the gem.
|
30
|
+
|
31
|
+
|
32
|
+
|
33
|
+
#### Example specification (spreadsheet)
|
34
|
+
|
35
|
+
Algorithm implemented using a spreadsheet software: [amortization_schedule.xlsx](examples/amortization_schedule.xlsx)
|
36
|
+
|
37
|
+
Screenshot:
|
38
|
+
|
39
|
+
<p align="center">
|
40
|
+
<img src="media/screenshot-payment-schedule-example-xlsx.png" alt="Screenshot of payment schedule example spreadsheet" />
|
41
|
+
</p>
|
42
|
+
|
43
|
+
|
44
|
+
|
45
|
+
#### Example implementation in Ruby
|
46
|
+
|
47
|
+
Algorithm implementation in Ruby, based on the spreadsheet: [amortization_schedule.rb](examples/amortization_schedule.rb)
|
48
|
+
|
49
|
+
Screenshot:
|
50
|
+
|
51
|
+
<p align="center">
|
52
|
+
<img src="media/screenshot-payment-schedule-example-term.png" alt="Screenshot of payment schedule example terminal output" />
|
53
|
+
</p>
|
54
|
+
|
55
|
+
|
56
|
+
## Getting Started
|
57
|
+
|
58
|
+
1. Add this line to your application's Gemfile:
|
59
|
+
|
60
|
+
```ruby
|
61
|
+
gem 'payment_schedule'
|
62
|
+
```
|
63
|
+
|
64
|
+
2. In project directory, execute:
|
65
|
+
|
66
|
+
```shell
|
67
|
+
bundle
|
68
|
+
```
|
69
|
+
|
70
|
+
3. Create a class which describes the algorithm:
|
71
|
+
|
72
|
+
```ruby
|
73
|
+
# Description of My Awesome Payment Schedule algorithm.
|
74
|
+
# References spreadsheet examples/amortization_schedule.xlsx
|
75
|
+
|
76
|
+
MyAwesomeSchedule = PaymentSchedule.new do
|
77
|
+
require_input(
|
78
|
+
:loan_amount, # Cell: C5
|
79
|
+
:loan_term, # Cell: C6
|
80
|
+
:interest_rate_year # Cell: C7
|
81
|
+
)
|
82
|
+
|
83
|
+
# Helper required by algorithm for output and summation
|
84
|
+
helper(:first_row_number) do
|
85
|
+
0
|
86
|
+
end
|
87
|
+
|
88
|
+
# Helper required by algorithm for output and summation
|
89
|
+
helper(:last_row_number) do
|
90
|
+
self[:loan_term]
|
91
|
+
end
|
92
|
+
|
93
|
+
# Cell: C8
|
94
|
+
helper(:interest_rate_month) do
|
95
|
+
(1 + self[:interest_rate_year].to_d) ** (1 / 12.to_d) - 1
|
96
|
+
end
|
97
|
+
|
98
|
+
# Column: G
|
99
|
+
# Note: modified for simplified example
|
100
|
+
component(:balance) do
|
101
|
+
# Cells: G6-G7
|
102
|
+
rows(0..1) { self[:loan_amount] }
|
103
|
+
|
104
|
+
default do |n|
|
105
|
+
self[:balance, n - 1] - n * 5
|
106
|
+
end
|
107
|
+
end
|
108
|
+
|
109
|
+
# Column: I
|
110
|
+
component(:interest) do
|
111
|
+
# Cell: I6
|
112
|
+
row(0) { 0 }
|
113
|
+
|
114
|
+
default do |n|
|
115
|
+
(self[:interest_rate_month] * self[:balance, n]).round(2)
|
116
|
+
end
|
117
|
+
end
|
118
|
+
end
|
119
|
+
```
|
120
|
+
|
121
|
+
4. Try it out in REPL:
|
122
|
+
|
123
|
+
```ruby
|
124
|
+
schedule = MyAwesomeSchedule.new(
|
125
|
+
loan_amount: 1000,
|
126
|
+
loan_term: 12,
|
127
|
+
interest_rate_year: 0.1
|
128
|
+
)
|
129
|
+
|
130
|
+
schedule[:balance, 12]
|
131
|
+
# => 615
|
132
|
+
|
133
|
+
schedule[:interest_rate_month]
|
134
|
+
# => 0.00797414042890374
|
135
|
+
|
136
|
+
puts schedule
|
137
|
+
+----+---------+----------+
|
138
|
+
| MyAwesomeSchedule |
|
139
|
+
+----+---------+----------+
|
140
|
+
| No | Balance | Interest |
|
141
|
+
+----+---------+----------+
|
142
|
+
| 0 | 1000 | 0 |
|
143
|
+
| 1 | 1000 | 7.97 |
|
144
|
+
| 2 | 990 | 7.89 |
|
145
|
+
| 3 | 975 | 7.77 |
|
146
|
+
| 4 | 955 | 7.62 |
|
147
|
+
| 5 | 930 | 7.42 |
|
148
|
+
| 6 | 900 | 7.18 |
|
149
|
+
| 7 | 865 | 6.9 |
|
150
|
+
| 8 | 825 | 6.58 |
|
151
|
+
| 9 | 780 | 6.22 |
|
152
|
+
| 10 | 730 | 5.82 |
|
153
|
+
| 11 | 675 | 5.38 |
|
154
|
+
| 12 | 615 | 4.9 |
|
155
|
+
+----+---------+----------+
|
156
|
+
# => nil
|
157
|
+
```
|
158
|
+
|
159
|
+
5. Plug it in to your app
|
160
|
+
|
161
|
+
6. Share it with customers
|
162
|
+
|
163
|
+
7. Profit! :sunglasses:
|
164
|
+
|
165
|
+
|
166
|
+
|
167
|
+
## Contributing
|
168
|
+
|
169
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/Murdho/payment_schedule. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
|
170
|
+
|
171
|
+
## Wishlist
|
172
|
+
|
173
|
+
Things that would make it even nicer to use.
|
174
|
+
* Add proper documentation (preferably TomDoc) for lowering the barriers of entry
|
175
|
+
* Replace `MyClassName = PaymentSchedule.new(&block)` with `class MyClassName < PaymentSchedule::Schedule` (or similar) to enable inheritance for schedule definitions. Definitely needs modifications to instruction finding as well
|
176
|
+
* Algorithm for generating the schedule Ruby code automatically based on spreadsheet file
|
177
|
+
* Add more commented examples for demonstrating flexibility, readbility and power!
|
178
|
+
|
179
|
+
## License
|
180
|
+
|
181
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
182
|
+
|
data/Rakefile
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
2
|
+
require "rake/testtask"
|
3
|
+
|
4
|
+
Rake::TestTask.new(:test) do |t|
|
5
|
+
t.libs << "examples"
|
6
|
+
t.libs << "test"
|
7
|
+
t.libs << "lib"
|
8
|
+
t.test_files = FileList['test/**/*_test.rb']
|
9
|
+
end
|
10
|
+
|
11
|
+
task :default => :test
|
12
|
+
|
13
|
+
task c: :console
|
14
|
+
task :console do
|
15
|
+
exec './bin/console'
|
16
|
+
end
|
data/bin/console
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "payment_schedule"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
require "pry"
|
11
|
+
require "awesome_print"
|
12
|
+
AwesomePrint.pry!
|
13
|
+
Pry.start
|
14
|
+
|
15
|
+
# require "irb"
|
16
|
+
# IRB.start(__FILE__)
|
data/bin/setup
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
module PaymentSchedule
|
2
|
+
class Component
|
3
|
+
attr_accessor :name, :row_definitions
|
4
|
+
|
5
|
+
def initialize(name)
|
6
|
+
self.name = name
|
7
|
+
self.row_definitions = {}
|
8
|
+
end
|
9
|
+
|
10
|
+
def [](row_no)
|
11
|
+
row_definitions[row_no] || row_definitions[:default]
|
12
|
+
end
|
13
|
+
|
14
|
+
def row(no, &definition)
|
15
|
+
row_definitions[no] = definition
|
16
|
+
end
|
17
|
+
|
18
|
+
def rows(no_range, &definition)
|
19
|
+
no_range.each { |no| row(no, &definition) }
|
20
|
+
end
|
21
|
+
|
22
|
+
def default(&definition)
|
23
|
+
row_definitions[:default] = definition
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
require 'payment_schedule/component'
|
2
|
+
|
3
|
+
module PaymentSchedule
|
4
|
+
class Instruction
|
5
|
+
attr_accessor :required_input
|
6
|
+
attr_accessor :helpers
|
7
|
+
attr_accessor :components
|
8
|
+
|
9
|
+
def initialize
|
10
|
+
self.required_input = []
|
11
|
+
self.helpers = {}
|
12
|
+
self.components = {}
|
13
|
+
end
|
14
|
+
|
15
|
+
def require_input(*keys)
|
16
|
+
self.required_input = keys
|
17
|
+
end
|
18
|
+
|
19
|
+
def helper(name, &definition)
|
20
|
+
helpers[name] = definition
|
21
|
+
end
|
22
|
+
|
23
|
+
def component(name, &definition)
|
24
|
+
component = Component.new(name)
|
25
|
+
component.instance_eval(&definition)
|
26
|
+
components[name] = component
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
require 'terminal-table'
|
2
|
+
|
3
|
+
module PaymentSchedule
|
4
|
+
class Output
|
5
|
+
class << self
|
6
|
+
def to_s(schedule)
|
7
|
+
table = Terminal::Table.new(title: schedule.class) do |t|
|
8
|
+
t << heading(schedule)
|
9
|
+
t << :separator
|
10
|
+
|
11
|
+
schedule.row_numbers.each do |row_no|
|
12
|
+
t << row_contents(schedule, row_no)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
table.to_s
|
17
|
+
end
|
18
|
+
|
19
|
+
private
|
20
|
+
|
21
|
+
def heading(schedule)
|
22
|
+
names = schedule.component_names.map do |name|
|
23
|
+
name.to_s.tr('_', ' ').capitalize
|
24
|
+
end
|
25
|
+
|
26
|
+
['No', names].flatten
|
27
|
+
end
|
28
|
+
|
29
|
+
def row_contents(schedule, row_no)
|
30
|
+
values = schedule.component_names.map { |name| schedule[name, row_no] }
|
31
|
+
[row_no, values].flatten
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,103 @@
|
|
1
|
+
require 'payment_schedule/output'
|
2
|
+
|
3
|
+
module PaymentSchedule
|
4
|
+
class Schedule
|
5
|
+
Error = Class.new(StandardError)
|
6
|
+
|
7
|
+
class << self
|
8
|
+
attr_accessor :instruction
|
9
|
+
end
|
10
|
+
|
11
|
+
attr_accessor :input
|
12
|
+
attr_accessor :helper_memory
|
13
|
+
attr_accessor :component_memory
|
14
|
+
|
15
|
+
def initialize(**input)
|
16
|
+
self.input = input
|
17
|
+
self.helper_memory = {}
|
18
|
+
self.component_memory = {}
|
19
|
+
|
20
|
+
validate_input
|
21
|
+
end
|
22
|
+
|
23
|
+
def [](name, row_no = nil)
|
24
|
+
if row_no
|
25
|
+
component_get(name, row_no)
|
26
|
+
else
|
27
|
+
input[name] || helper_get(name)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
def sum(component_name)
|
32
|
+
row_numbers.sum { |n| self[component_name, n] }
|
33
|
+
end
|
34
|
+
|
35
|
+
def row_numbers
|
36
|
+
first_row_number = self[:first_row_number]
|
37
|
+
last_row_number = self[:last_row_number]
|
38
|
+
|
39
|
+
unless first_row_number && last_row_number
|
40
|
+
raise Error, <<~EOS.tr("\n", ' ')
|
41
|
+
Please define helpers :first_row_number and
|
42
|
+
:last_row_number for using #{self.class}#row_numbers.
|
43
|
+
EOS
|
44
|
+
end
|
45
|
+
|
46
|
+
(first_row_number..last_row_number)
|
47
|
+
end
|
48
|
+
|
49
|
+
def component_names
|
50
|
+
components.keys
|
51
|
+
end
|
52
|
+
|
53
|
+
def to_s
|
54
|
+
Output.to_s(self)
|
55
|
+
end
|
56
|
+
|
57
|
+
private
|
58
|
+
|
59
|
+
def instruction
|
60
|
+
self.class.instruction
|
61
|
+
end
|
62
|
+
|
63
|
+
def components
|
64
|
+
instruction.components
|
65
|
+
end
|
66
|
+
|
67
|
+
def helpers
|
68
|
+
instruction.helpers
|
69
|
+
end
|
70
|
+
|
71
|
+
def component_get(name, row_no)
|
72
|
+
return unless components.key?(name)
|
73
|
+
|
74
|
+
memory_key = [name, row_no].join(':')
|
75
|
+
memoized_value = component_memory[memory_key]
|
76
|
+
return memoized_value if memoized_value
|
77
|
+
|
78
|
+
component_memory[memory_key] = instance_exec(
|
79
|
+
row_no,
|
80
|
+
&components[name][row_no]
|
81
|
+
)
|
82
|
+
end
|
83
|
+
|
84
|
+
def helper_get(name)
|
85
|
+
return unless helpers.key?(name)
|
86
|
+
|
87
|
+
memoized_value = helper_memory[name]
|
88
|
+
return memoized_value if memoized_value
|
89
|
+
|
90
|
+
helper_memory[name] = instance_exec(&helpers[name])
|
91
|
+
end
|
92
|
+
|
93
|
+
def validate_input
|
94
|
+
missing_keys = instruction.required_input.reject do |required_key|
|
95
|
+
input.key?(required_key)
|
96
|
+
end
|
97
|
+
|
98
|
+
return if missing_keys.empty?
|
99
|
+
|
100
|
+
raise Error, "Missing required input key(s) :#{missing_keys.join(', :')}"
|
101
|
+
end
|
102
|
+
end
|
103
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
require 'payment_schedule/core_ext/big_decimal'
|
2
|
+
require 'payment_schedule/instruction'
|
3
|
+
require 'payment_schedule/schedule'
|
4
|
+
require 'payment_schedule/version'
|
5
|
+
|
6
|
+
module PaymentSchedule
|
7
|
+
def self.new(const_name = nil, &block)
|
8
|
+
instruction = Instruction.new
|
9
|
+
instruction.instance_eval(&block)
|
10
|
+
|
11
|
+
schedule_class = Class.new(Schedule)
|
12
|
+
schedule_class.instruction = instruction
|
13
|
+
|
14
|
+
Object.const_set(const_name.to_s, schedule_class) if const_name
|
15
|
+
|
16
|
+
schedule_class
|
17
|
+
end
|
18
|
+
end
|
Binary file
|
Binary file
|
@@ -0,0 +1,34 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'payment_schedule/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "payment_schedule"
|
8
|
+
spec.version = PaymentSchedule::VERSION
|
9
|
+
spec.authors = ["Murdho"]
|
10
|
+
spec.email = ["murdho@murdho.com"]
|
11
|
+
|
12
|
+
spec.summary = %q{Mild toolset for changing payment schedule algorithms to lovely Ruby code.}
|
13
|
+
spec.homepage = "https://github.com/murdho/payment_schedule"
|
14
|
+
spec.license = "MIT"
|
15
|
+
spec.required_ruby_version = '>= 2.4.0'
|
16
|
+
|
17
|
+
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
18
|
+
f.match(%r{^(test|examples)/})
|
19
|
+
end
|
20
|
+
spec.bindir = "exe"
|
21
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
22
|
+
spec.require_paths = ["lib"]
|
23
|
+
|
24
|
+
spec.add_runtime_dependency "terminal-table", "~> 1.7"
|
25
|
+
|
26
|
+
spec.add_development_dependency "bundler", "~> 1.14"
|
27
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
28
|
+
spec.add_development_dependency "minitest", "~> 5.0"
|
29
|
+
spec.add_development_dependency "minitest-reporters", "~> 1.1"
|
30
|
+
spec.add_development_dependency "simplecov", "~> 0.13"
|
31
|
+
spec.add_development_dependency "pry", "~> 0.10"
|
32
|
+
spec.add_development_dependency "awesome_print", "~> 1.7"
|
33
|
+
spec.add_development_dependency "codeclimate-test-reporter", "~> 1.0"
|
34
|
+
end
|
metadata
ADDED
@@ -0,0 +1,189 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: payment_schedule
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Murdho
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2017-07-24 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: terminal-table
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.7'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.7'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: bundler
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1.14'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.14'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rake
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '10.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '10.0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: minitest
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '5.0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '5.0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: minitest-reporters
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '1.1'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '1.1'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: simplecov
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - "~>"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0.13'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - "~>"
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0.13'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: pry
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - "~>"
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0.10'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - "~>"
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0.10'
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: awesome_print
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - "~>"
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '1.7'
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - "~>"
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '1.7'
|
125
|
+
- !ruby/object:Gem::Dependency
|
126
|
+
name: codeclimate-test-reporter
|
127
|
+
requirement: !ruby/object:Gem::Requirement
|
128
|
+
requirements:
|
129
|
+
- - "~>"
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: '1.0'
|
132
|
+
type: :development
|
133
|
+
prerelease: false
|
134
|
+
version_requirements: !ruby/object:Gem::Requirement
|
135
|
+
requirements:
|
136
|
+
- - "~>"
|
137
|
+
- !ruby/object:Gem::Version
|
138
|
+
version: '1.0'
|
139
|
+
description:
|
140
|
+
email:
|
141
|
+
- murdho@murdho.com
|
142
|
+
executables: []
|
143
|
+
extensions: []
|
144
|
+
extra_rdoc_files: []
|
145
|
+
files:
|
146
|
+
- ".gitignore"
|
147
|
+
- ".travis.yml"
|
148
|
+
- CODE_OF_CONDUCT.md
|
149
|
+
- Gemfile
|
150
|
+
- LICENSE.txt
|
151
|
+
- README.md
|
152
|
+
- Rakefile
|
153
|
+
- bin/console
|
154
|
+
- bin/setup
|
155
|
+
- lib/payment_schedule.rb
|
156
|
+
- lib/payment_schedule/component.rb
|
157
|
+
- lib/payment_schedule/core_ext/big_decimal.rb
|
158
|
+
- lib/payment_schedule/instruction.rb
|
159
|
+
- lib/payment_schedule/output.rb
|
160
|
+
- lib/payment_schedule/schedule.rb
|
161
|
+
- lib/payment_schedule/version.rb
|
162
|
+
- media/screenshot-payment-schedule-example-term.png
|
163
|
+
- media/screenshot-payment-schedule-example-xlsx.png
|
164
|
+
- payment_schedule.gemspec
|
165
|
+
homepage: https://github.com/murdho/payment_schedule
|
166
|
+
licenses:
|
167
|
+
- MIT
|
168
|
+
metadata: {}
|
169
|
+
post_install_message:
|
170
|
+
rdoc_options: []
|
171
|
+
require_paths:
|
172
|
+
- lib
|
173
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
174
|
+
requirements:
|
175
|
+
- - ">="
|
176
|
+
- !ruby/object:Gem::Version
|
177
|
+
version: 2.4.0
|
178
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
179
|
+
requirements:
|
180
|
+
- - ">="
|
181
|
+
- !ruby/object:Gem::Version
|
182
|
+
version: '0'
|
183
|
+
requirements: []
|
184
|
+
rubyforge_project:
|
185
|
+
rubygems_version: 2.6.8
|
186
|
+
signing_key:
|
187
|
+
specification_version: 4
|
188
|
+
summary: Mild toolset for changing payment schedule algorithms to lovely Ruby code.
|
189
|
+
test_files: []
|