bouch 1.1.0 → 1.2.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 +5 -5
- data/Gemfile.lock +22 -22
- data/README.md +15 -7
- data/lib/bouch.rb +22 -4
- data/lib/bouch/calc.rb +12 -2
- data/lib/bouch/version.rb +1 -1
- data/pouch.example.yml +1 -0
- data/spec/bouch_calc_spec.rb +11 -0
- data/spec/bouch_pouch_yaml_spec.rb +5 -1
- data/spec/bouch_spec.rb +24 -0
- metadata +2 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
|
-
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: fb58a99429b5afdc33cb7f65053580cf742aca9da08f2461861429ceaa75325f
|
|
4
|
+
data.tar.gz: e15f9cab5a04bebd6ce4cd6f1aca42943ee82f18a8359911632709572559aabd
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 0a396b50771862a7ae3187f8da5ee6bd9e903b0c2e58a02b383541412bcc131c86f1ed0b0b79633e8cc92d711aa460bc7c1e4ac1f399e7050dd26b0505e297ec
|
|
7
|
+
data.tar.gz: b17ba90c8d8e9b4b090282c85accc8a6bcdaa3e9b0983c4b4122e9c72e01bdb2c673db304a2caeeb070a4dfebc829ea5a9bba348982703217a135ee68b6b13e5
|
data/Gemfile.lock
CHANGED
|
@@ -1,34 +1,34 @@
|
|
|
1
1
|
PATH
|
|
2
2
|
remote: .
|
|
3
3
|
specs:
|
|
4
|
-
bouch (1.
|
|
4
|
+
bouch (1.2.0)
|
|
5
5
|
|
|
6
6
|
GEM
|
|
7
7
|
remote: https://rubygems.org/
|
|
8
8
|
specs:
|
|
9
9
|
ast (2.4.0)
|
|
10
10
|
diff-lcs (1.3)
|
|
11
|
-
docile (1.3.
|
|
12
|
-
json (2.
|
|
13
|
-
parallel (1.
|
|
14
|
-
parser (2.
|
|
11
|
+
docile (1.3.2)
|
|
12
|
+
json (2.3.0)
|
|
13
|
+
parallel (1.19.1)
|
|
14
|
+
parser (2.7.0.1)
|
|
15
15
|
ast (~> 2.4.0)
|
|
16
|
-
powerpack (0.1.
|
|
16
|
+
powerpack (0.1.2)
|
|
17
17
|
rainbow (3.0.0)
|
|
18
|
-
rake (
|
|
19
|
-
rspec (3.
|
|
20
|
-
rspec-core (~> 3.
|
|
21
|
-
rspec-expectations (~> 3.
|
|
22
|
-
rspec-mocks (~> 3.
|
|
23
|
-
rspec-core (3.
|
|
24
|
-
rspec-support (~> 3.
|
|
25
|
-
rspec-expectations (3.
|
|
18
|
+
rake (13.0.1)
|
|
19
|
+
rspec (3.9.0)
|
|
20
|
+
rspec-core (~> 3.9.0)
|
|
21
|
+
rspec-expectations (~> 3.9.0)
|
|
22
|
+
rspec-mocks (~> 3.9.0)
|
|
23
|
+
rspec-core (3.9.1)
|
|
24
|
+
rspec-support (~> 3.9.1)
|
|
25
|
+
rspec-expectations (3.9.0)
|
|
26
26
|
diff-lcs (>= 1.2.0, < 2.0)
|
|
27
|
-
rspec-support (~> 3.
|
|
28
|
-
rspec-mocks (3.
|
|
27
|
+
rspec-support (~> 3.9.0)
|
|
28
|
+
rspec-mocks (3.9.0)
|
|
29
29
|
diff-lcs (>= 1.2.0, < 2.0)
|
|
30
|
-
rspec-support (~> 3.
|
|
31
|
-
rspec-support (3.
|
|
30
|
+
rspec-support (~> 3.9.0)
|
|
31
|
+
rspec-support (3.9.2)
|
|
32
32
|
rubocop (0.56.0)
|
|
33
33
|
parallel (~> 1.10)
|
|
34
34
|
parser (>= 2.5)
|
|
@@ -36,13 +36,13 @@ GEM
|
|
|
36
36
|
rainbow (>= 2.2.2, < 4.0)
|
|
37
37
|
ruby-progressbar (~> 1.7)
|
|
38
38
|
unicode-display_width (~> 1.0, >= 1.0.1)
|
|
39
|
-
ruby-progressbar (1.
|
|
40
|
-
simplecov (0.
|
|
39
|
+
ruby-progressbar (1.10.1)
|
|
40
|
+
simplecov (0.17.1)
|
|
41
41
|
docile (~> 1.1)
|
|
42
42
|
json (>= 1.8, < 3)
|
|
43
43
|
simplecov-html (~> 0.10.0)
|
|
44
44
|
simplecov-html (0.10.2)
|
|
45
|
-
unicode-display_width (1.
|
|
45
|
+
unicode-display_width (1.6.0)
|
|
46
46
|
|
|
47
47
|
PLATFORMS
|
|
48
48
|
ruby
|
|
@@ -59,4 +59,4 @@ RUBY VERSION
|
|
|
59
59
|
ruby 2.5.0p0
|
|
60
60
|
|
|
61
61
|
BUNDLED WITH
|
|
62
|
-
1.
|
|
62
|
+
1.17.3
|
data/README.md
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
# Bouch
|
|
2
|
-
[](https://gitlab.com/ssofos/bouch/commits/master) [](https://gitlab.com/ssofos/bouch/commits/master)
|
|
2
|
+
[](https://badge.fury.io/rb/bouch) [](https://gitlab.com/ssofos/bouch/commits/master) [](https://gitlab.com/ssofos/bouch/commits/master)
|
|
3
3
|
|
|
4
4
|
`Bouch` is the budget pouch. A simple tool to calculate and project your annual personal budget based on fiscal quarter expenditures, income, assets, and debts.
|
|
5
5
|
|
|
@@ -44,7 +44,9 @@ Budget Annual Total: 12100.00
|
|
|
44
44
|
Budget Annual Income: 28808.00
|
|
45
45
|
Budget Income Percent: 42.00%
|
|
46
46
|
----------------------
|
|
47
|
-
Assets Total:
|
|
47
|
+
Assets Total: 500.00
|
|
48
|
+
Equity Total: 500.00
|
|
49
|
+
Net Worth: 1000.00
|
|
48
50
|
----------------------
|
|
49
51
|
Debt Total: 420.00
|
|
50
52
|
Debt Ratio: 0.4200
|
|
@@ -58,22 +60,23 @@ To use bouch to calculate your own budget you must create a customized budget po
|
|
|
58
60
|
|
|
59
61
|
Budget pouch files are written in Ruby friendly YAML and currently use the following schema:
|
|
60
62
|
|
|
61
|
-
*
|
|
62
|
-
* Think of hashes as simple groupings of keys
|
|
63
|
+
* Nested mappings, also know as hashes in Ruby
|
|
64
|
+
* Think of hashes as simple groupings of keys value pairs
|
|
63
65
|
* Primary hash keys:
|
|
64
66
|
* **Budget**
|
|
65
67
|
* **Salary**
|
|
66
68
|
* **Assets**
|
|
69
|
+
* **Equity**
|
|
67
70
|
* **Debts**
|
|
68
71
|
* **Budget** nested keys and values:
|
|
69
72
|
* **Q1**
|
|
70
73
|
* foo
|
|
71
74
|
* Value: Integer or Float
|
|
72
|
-
* Equals a budget item's quarterly cost
|
|
75
|
+
* Equals a single budget item's quarterly cost
|
|
73
76
|
* bar
|
|
74
77
|
* **cost**
|
|
75
78
|
* Value: Integer or Float
|
|
76
|
-
* Equals the
|
|
79
|
+
* Equals the repeated budget item's monthly cost
|
|
77
80
|
* **repeat**
|
|
78
81
|
* Value: true
|
|
79
82
|
* Enables quarterly auto-calculation of the repeat payment
|
|
@@ -94,8 +97,12 @@ Budget pouch files are written in Ruby friendly YAML and currently use the follo
|
|
|
94
97
|
* foo
|
|
95
98
|
* Value: Integer or Float
|
|
96
99
|
* Equals an asset's total valued amount
|
|
97
|
-
* **
|
|
100
|
+
* **Equity** nested keys and values:
|
|
98
101
|
* bar
|
|
102
|
+
* Value: Integer or Float
|
|
103
|
+
* Equals the total value of equity in a specific asset
|
|
104
|
+
* **Debts** nested keys and values:
|
|
105
|
+
* fizz
|
|
99
106
|
* Value: Integer or Float
|
|
100
107
|
* Equals a debt's total valued amount
|
|
101
108
|
* All non-primary nested keys are case insensitive
|
|
@@ -134,6 +141,7 @@ Salary:
|
|
|
134
141
|
frequency: 2
|
|
135
142
|
Assets:
|
|
136
143
|
foo: 500
|
|
144
|
+
Equity:
|
|
137
145
|
bar: 500
|
|
138
146
|
Debts:
|
|
139
147
|
baz: 120
|
data/lib/bouch.rb
CHANGED
|
@@ -6,19 +6,21 @@ require 'bouch/calc'
|
|
|
6
6
|
# Calculate and create simple financial budgets
|
|
7
7
|
# by parsing a single YAML file as input
|
|
8
8
|
class Bouch
|
|
9
|
-
attr_accessor :assets, :debts, :pouch, :quarters
|
|
9
|
+
attr_accessor :assets, :debts, :equity, :net_worth, :pouch, :quarters
|
|
10
10
|
include BouchCalculate
|
|
11
11
|
|
|
12
12
|
def initialize(file)
|
|
13
13
|
@assets = Array.new
|
|
14
14
|
@debts = Array.new
|
|
15
|
+
@equity = Array.new
|
|
16
|
+
@net_worth = nil
|
|
15
17
|
@pouch = YAML.safe_load(IO.read(file))
|
|
16
18
|
@quarters = Hash.new
|
|
17
19
|
end
|
|
18
20
|
|
|
19
21
|
# Summarize and show aggregate asset totals
|
|
20
22
|
def show_assets_total
|
|
21
|
-
calc_assets(@pouch['Assets']) if @assets.empty?
|
|
23
|
+
calc_assets(@pouch['Assets'], 'assets') if @assets.empty?
|
|
22
24
|
puts '----------------------'
|
|
23
25
|
puts format('%-30s %.2f', 'Assets Total:', @assets.sum)
|
|
24
26
|
end
|
|
@@ -33,14 +35,28 @@ class Bouch
|
|
|
33
35
|
# Summarize and show debt ratio
|
|
34
36
|
def show_debt_ratio
|
|
35
37
|
calc_assets(@pouch['Assets']) if @assets.empty?
|
|
38
|
+
calc_assets(@pouch['Equity'], 'equity') if @equity.empty?
|
|
39
|
+
calc_net_worth(@assets, @equity) if @net_worth.nil?
|
|
36
40
|
calc_debts(@pouch['Debts']) if @debts.empty?
|
|
37
|
-
puts format('%-30s %.4f', 'Debt Ratio:', calc_debt_ratio(@debts.sum, @
|
|
41
|
+
puts format('%-30s %.4f', 'Debt Ratio:', calc_debt_ratio(@debts.sum, @net_worth))
|
|
38
42
|
puts format('%-30s %.2f%s', 'Debt Ratio Percent:',
|
|
39
|
-
calc_debt_ratio_percent(calc_debt_ratio(@debts.sum, @
|
|
43
|
+
calc_debt_ratio_percent(calc_debt_ratio(@debts.sum, @net_worth)),
|
|
40
44
|
'%')
|
|
41
45
|
puts '----------------------'
|
|
42
46
|
end
|
|
43
47
|
|
|
48
|
+
# Summarize and show aggregate equity totals
|
|
49
|
+
def show_equity_total
|
|
50
|
+
calc_assets(@pouch['Equity'], 'equity') if @equity.empty?
|
|
51
|
+
puts format('%-30s %.2f', 'Equity Total:', @equity.sum)
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
# Summarize and show Net Worth
|
|
55
|
+
def show_net_worth
|
|
56
|
+
calc_net_worth(@assets, @equity) if @net_worth.nil?
|
|
57
|
+
puts format('%-30s %.2f', 'Net Worth:', @net_worth)
|
|
58
|
+
end
|
|
59
|
+
|
|
44
60
|
# Summarize and show all financial quarter budgets
|
|
45
61
|
def show_quarters
|
|
46
62
|
calc_quarters_raw(@pouch['Budget']) if @quarters.empty?
|
|
@@ -83,6 +99,8 @@ class Bouch
|
|
|
83
99
|
show_annual_income
|
|
84
100
|
show_budget_percentage
|
|
85
101
|
show_assets_total
|
|
102
|
+
show_equity_total
|
|
103
|
+
show_net_worth
|
|
86
104
|
show_debts_total
|
|
87
105
|
show_debt_ratio
|
|
88
106
|
end
|
data/lib/bouch/calc.rb
CHANGED
|
@@ -3,9 +3,14 @@
|
|
|
3
3
|
# Financial budget calculation and operations for Bouch
|
|
4
4
|
module BouchCalculate
|
|
5
5
|
# Calculate asset value aggregate amount
|
|
6
|
-
def calc_assets(assets)
|
|
6
|
+
def calc_assets(assets, type = 'assets')
|
|
7
7
|
assets.each_value do |value|
|
|
8
|
-
|
|
8
|
+
case type
|
|
9
|
+
when 'assets'
|
|
10
|
+
@assets.push(value)
|
|
11
|
+
when 'equity'
|
|
12
|
+
@equity.push(value)
|
|
13
|
+
end
|
|
9
14
|
end
|
|
10
15
|
end
|
|
11
16
|
|
|
@@ -31,6 +36,11 @@ module BouchCalculate
|
|
|
31
36
|
(debt_ratio.to_f * 100).round(2)
|
|
32
37
|
end
|
|
33
38
|
|
|
39
|
+
# Calcuate a Net Worth sum
|
|
40
|
+
def calc_net_worth(assets = [], equity = [])
|
|
41
|
+
@net_worth = (assets + equity).sum.to_f.round(2)
|
|
42
|
+
end
|
|
43
|
+
|
|
34
44
|
# Calculate a quarterly repeating budget item amount
|
|
35
45
|
def calc_repeating(item)
|
|
36
46
|
(item.to_f * 3).round(2)
|
data/lib/bouch/version.rb
CHANGED
data/pouch.example.yml
CHANGED
data/spec/bouch_calc_spec.rb
CHANGED
|
@@ -68,6 +68,17 @@ describe BouchCalculate do
|
|
|
68
68
|
end
|
|
69
69
|
end
|
|
70
70
|
|
|
71
|
+
describe '.calc_net_worth' do
|
|
72
|
+
context 'given an two Arrays of assets and equity' do
|
|
73
|
+
it 'returns a Float number' do
|
|
74
|
+
expect(@bouch.calc_net_worth([500], [500])).to be_a_kind_of(Float)
|
|
75
|
+
end
|
|
76
|
+
it 'returns a net worth sum of assets and equity' do
|
|
77
|
+
expect(@bouch.calc_net_worth([500], [500])).to eq(1000.00)
|
|
78
|
+
end
|
|
79
|
+
end
|
|
80
|
+
end
|
|
81
|
+
|
|
71
82
|
describe '.calc_repeating' do
|
|
72
83
|
context 'given a numerical cost amount' do
|
|
73
84
|
it 'returns a Float number' do
|
|
@@ -9,7 +9,7 @@ describe 'Pouch YAML Schema' do
|
|
|
9
9
|
end
|
|
10
10
|
|
|
11
11
|
it 'has four major Hash keys' do
|
|
12
|
-
expect(@pouch.keys.length).to eq(
|
|
12
|
+
expect(@pouch.keys.length).to eq(5)
|
|
13
13
|
end
|
|
14
14
|
|
|
15
15
|
it 'has a Hash key named Budget' do
|
|
@@ -24,6 +24,10 @@ describe 'Pouch YAML Schema' do
|
|
|
24
24
|
expect(@pouch.key?('Assets')).to be_truthy
|
|
25
25
|
end
|
|
26
26
|
|
|
27
|
+
it 'has a Hash key named Equity' do
|
|
28
|
+
expect(@pouch.key?('Equity')).to be_truthy
|
|
29
|
+
end
|
|
30
|
+
|
|
27
31
|
it 'has a Hash key named Debts' do
|
|
28
32
|
expect(@pouch.key?('Debts')).to be_truthy
|
|
29
33
|
end
|
data/spec/bouch_spec.rb
CHANGED
|
@@ -24,6 +24,18 @@ describe Bouch do
|
|
|
24
24
|
end
|
|
25
25
|
end
|
|
26
26
|
|
|
27
|
+
describe '#equity' do
|
|
28
|
+
it 'returns an empty Array of equity' do
|
|
29
|
+
expect(@bouch.equity).to be_empty
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
describe '#net_worth' do
|
|
34
|
+
it 'returns a Nil net_worth' do
|
|
35
|
+
expect(@bouch.net_worth).to be_nil
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
|
|
27
39
|
describe '#pouch' do
|
|
28
40
|
it 'loads the budget pouch YAML file' do
|
|
29
41
|
expect(@bouch.pouch).to eq(YAML.safe_load(IO.read(@yaml)))
|
|
@@ -54,6 +66,18 @@ describe Bouch do
|
|
|
54
66
|
end
|
|
55
67
|
end
|
|
56
68
|
|
|
69
|
+
describe '.show_equity_total' do
|
|
70
|
+
it 'outputs financial budget equity sum' do
|
|
71
|
+
expect { @bouch.show_equity_total }.to output.to_stdout
|
|
72
|
+
end
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
describe '.show_net_worth' do
|
|
76
|
+
it 'outputs financial budget net worth' do
|
|
77
|
+
expect { @bouch.show_net_worth }.to output.to_stdout
|
|
78
|
+
end
|
|
79
|
+
end
|
|
80
|
+
|
|
57
81
|
describe '.show_quarters' do
|
|
58
82
|
it 'outputs financial budget quarters sums' do
|
|
59
83
|
expect { @bouch.show_quarters }.to output.to_stdout
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: bouch
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.
|
|
4
|
+
version: 1.2.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Shane R. Sofos
|
|
@@ -131,8 +131,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
131
131
|
- !ruby/object:Gem::Version
|
|
132
132
|
version: '0'
|
|
133
133
|
requirements: []
|
|
134
|
-
|
|
135
|
-
rubygems_version: 2.6.14
|
|
134
|
+
rubygems_version: 3.0.3
|
|
136
135
|
signing_key:
|
|
137
136
|
specification_version: 4
|
|
138
137
|
summary: A simple tool to calculate and project your annual personal budget based
|