bouch 1.1.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.
@@ -0,0 +1,48 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'bouch/cli'
4
+
5
+ describe 'Bouch::CLI' do
6
+ before :all do
7
+ @cli = Bouch::CLI.new('pouch.example.yml')
8
+ end
9
+
10
+ it 'is a Bouch::CLI object' do
11
+ expect(@cli).to be_kind_of(Bouch::CLI)
12
+ end
13
+
14
+ describe '#yaml_file' do
15
+ it 'returns a name of a file that is a String' do
16
+ expect(@cli.yaml_file).to be_kind_of(String)
17
+ end
18
+ end
19
+
20
+ describe '.start' do
21
+ context 'when no file is supplied as the first CLI argument' do
22
+ it 'outputs warning and usage help messages' do
23
+ @cli.yaml_file = nil
24
+ expect { @cli.start }.to output.to_stdout
25
+ end
26
+ end
27
+
28
+ context 'when an existent file is supplied as the first CLI argument' do
29
+ it 'calculates a budget from a budget pouch file and outputs it' do
30
+ @cli.yaml_file = 'pouch.example.yml'
31
+ expect { @cli.start }.to output.to_stdout
32
+ end
33
+ end
34
+
35
+ context 'when a non-existent file is supplied as the first CLI argument' do
36
+ it 'ouputs a warning and usage help messsages' do
37
+ @cli.yaml_file = 'foobar.yml'
38
+ expect { @cli.start }.to output.to_stdout
39
+ end
40
+ end
41
+ end
42
+
43
+ describe '.usage' do
44
+ it 'outputs a bouch usage help message' do
45
+ expect { @cli.usage }.to output.to_stdout
46
+ end
47
+ end
48
+ end
@@ -0,0 +1,46 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'yaml'
4
+
5
+ describe 'Pouch YAML Schema' do
6
+ before :all do
7
+ @yaml = File.realdirpath('pouch.example.yml')
8
+ @pouch = YAML.safe_load(IO.read(@yaml))
9
+ end
10
+
11
+ it 'has four major Hash keys' do
12
+ expect(@pouch.keys.length).to eq(4)
13
+ end
14
+
15
+ it 'has a Hash key named Budget' do
16
+ expect(@pouch.key?('Budget')).to be_truthy
17
+ end
18
+
19
+ it 'has a Hash key named Salary' do
20
+ expect(@pouch.key?('Salary')).to be_truthy
21
+ end
22
+
23
+ it 'has a Hash key named Assets' do
24
+ expect(@pouch.key?('Assets')).to be_truthy
25
+ end
26
+
27
+ it 'has a Hash key named Debts' do
28
+ expect(@pouch.key?('Debts')).to be_truthy
29
+ end
30
+
31
+ it 'has Budget values that are Hashes' do
32
+ expect(@pouch['Budget']).to be_a_kind_of(Hash)
33
+ end
34
+
35
+ it 'has Salary values that are Hashes' do
36
+ expect(@pouch['Salary']).to be_a_kind_of(Hash)
37
+ end
38
+
39
+ it 'has Asset values that are Hashes' do
40
+ expect(@pouch['Assets']).to be_a_kind_of(Hash)
41
+ end
42
+
43
+ it 'has Debt values that are Hashes' do
44
+ expect(@pouch['Debts']).to be_a_kind_of(Hash)
45
+ end
46
+ end
@@ -0,0 +1,86 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'bouch'
4
+
5
+ describe Bouch do
6
+ before :all do
7
+ @yaml = File.realdirpath('pouch.example.yml')
8
+ @bouch = Bouch.new(@yaml)
9
+ end
10
+
11
+ it 'is a Bouch object' do
12
+ expect(@bouch).to be_kind_of(Bouch)
13
+ end
14
+
15
+ describe '#assets' do
16
+ it 'returns an empty Array of assets' do
17
+ expect(@bouch.assets).to be_empty
18
+ end
19
+ end
20
+
21
+ describe '#debts' do
22
+ it 'returns an empty Array of debts' do
23
+ expect(@bouch.debts).to be_empty
24
+ end
25
+ end
26
+
27
+ describe '#pouch' do
28
+ it 'loads the budget pouch YAML file' do
29
+ expect(@bouch.pouch).to eq(YAML.safe_load(IO.read(@yaml)))
30
+ end
31
+ end
32
+
33
+ describe '#quarters' do
34
+ it 'returns an empty Hash of fiscal quarters' do
35
+ expect(@bouch.quarters).to be_empty
36
+ end
37
+ end
38
+
39
+ describe '.show_assets_total' do
40
+ it 'outputs financial budget assests sum' do
41
+ expect { @bouch.show_assets_total }.to output.to_stdout
42
+ end
43
+ end
44
+
45
+ describe '.show_debts_total' do
46
+ it 'outputs financial budget debts sum' do
47
+ expect { @bouch.show_debts_total }.to output.to_stdout
48
+ end
49
+ end
50
+
51
+ describe '.show_debt_ratio' do
52
+ it 'outputs financial budget debt ratio' do
53
+ expect { @bouch.show_debt_ratio }.to output.to_stdout
54
+ end
55
+ end
56
+
57
+ describe '.show_quarters' do
58
+ it 'outputs financial budget quarters sums' do
59
+ expect { @bouch.show_quarters }.to output.to_stdout
60
+ end
61
+ end
62
+
63
+ describe '.show_annual_total' do
64
+ it 'outputs financial budget quarters aggregate sum' do
65
+ expect { @bouch.show_annual_total }.to output.to_stdout
66
+ end
67
+ end
68
+
69
+ describe '.show_budget_percentage' do
70
+ it 'outputs financial budget income percentage' do
71
+ expect { @bouch.show_budget_percentage }.to output.to_stdout
72
+ end
73
+ end
74
+
75
+ describe '.show_annual_income' do
76
+ it 'outputs financial budget income sum' do
77
+ expect { @bouch.show_annual_income }.to output.to_stdout
78
+ end
79
+ end
80
+
81
+ describe '.show_budget' do
82
+ it 'outputs all financial budget summed components' do
83
+ expect { @bouch.show_budget }.to output.to_stdout
84
+ end
85
+ end
86
+ end
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'bouch/version'
4
+
5
+ describe 'Bouch::Version' do
6
+ it 'returns the RubyGem version of Bouch as a string' do
7
+ expect(Bouch::VERSION).to be_a_kind_of(String)
8
+ end
9
+ end
@@ -0,0 +1,81 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'simplecov'
4
+
5
+ # This file was generated by the `rspec --init` command. Conventionally, all
6
+ # specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
7
+ # The generated `.rspec` file contains `--require spec_helper` which will cause
8
+ # this file to always be loaded, without a need to explicitly require it in any
9
+ # files.
10
+ #
11
+ # Given that it is always loaded, you are encouraged to keep this file as
12
+ # light-weight as possible. Requiring heavyweight dependencies from this file
13
+ # will add to the boot time of your test suite on EVERY test run, even for an
14
+ # individual file that may not need all of that loaded. Instead, consider making
15
+ # a separate helper file that requires the additional dependencies and performs
16
+ # the additional setup, and require it from the spec files that actually need
17
+ # it.
18
+ #
19
+ # See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
20
+ RSpec.configure do |config|
21
+ # rspec-expectations config goes here. You can use an alternate
22
+ # assertion/expectation library such as wrong or the stdlib/minitest
23
+ # assertions if you prefer.
24
+ config.expect_with :rspec do |expectations|
25
+ # This option will default to `true` in RSpec 4. It makes the `description`
26
+ # and `failure_message` of custom matchers include text for helper methods
27
+ # defined using `chain`, e.g.:
28
+ # be_bigger_than(2).and_smaller_than(4).description
29
+ # # => "be bigger than 2 and smaller than 4"
30
+ # ...rather than:
31
+ # # => "be bigger than 2"
32
+ expectations.include_chain_clauses_in_custom_matcher_descriptions = true
33
+ end
34
+
35
+ # rspec-mocks config goes here. You can use an alternate test double
36
+ # library (such as bogus or mocha) by changing the `mock_with` option here.
37
+ config.mock_with :rspec do |mocks|
38
+ # Prevents you from mocking or stubbing a method that does not exist on
39
+ # a real object. This is generally recommended, and will default to
40
+ # `true` in RSpec 4.
41
+ mocks.verify_partial_doubles = true
42
+ end
43
+
44
+ # This option will default to `:apply_to_host_groups` in RSpec 4 (and will
45
+ # have no way to turn it off -- the option exists only for backwards
46
+ # compatibility in RSpec 3). It causes shared context metadata to be
47
+ # inherited by the metadata hash of host groups and examples, rather than
48
+ # triggering implicit auto-inclusion in groups with matching metadata.
49
+ config.shared_context_metadata_behavior = :apply_to_host_groups
50
+
51
+ # Many RSpec users commonly either run the entire suite or an individual
52
+ # file, and it's useful to allow more verbose output when running an
53
+ # individual spec file.
54
+ if config.files_to_run.one?
55
+ # Use the documentation formatter for detailed output,
56
+ # unless a formatter has already been configured
57
+ # (e.g. via a command-line flag).
58
+ config.default_formatter = 'doc'
59
+ end
60
+
61
+ # This setting enables warnings. It's recommended, but in some cases may
62
+ # be too noisy due to issues in dependencies.
63
+ config.warnings = true
64
+
65
+ # Print the 10 slowest examples and example groups at the
66
+ # end of the spec run, to help surface which specs are running
67
+ # particularly slow.
68
+ config.profile_examples = 10
69
+
70
+ # Run specs in random order to surface order dependencies. If you find an
71
+ # order dependency and want to debug it, you can fix the order by providing
72
+ # the seed, which is printed after each run.
73
+ # --seed 1234
74
+ # config.order = :random
75
+
76
+ # Seed global randomization in this process using the `--seed` CLI option.
77
+ # Setting this allows you to use `--seed` to deterministically reproduce
78
+ # test failures related to randomization by passing the same `--seed` value
79
+ # as the one that triggered the failure.
80
+ Kernel.srand config.seed
81
+ end
metadata ADDED
@@ -0,0 +1,146 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: bouch
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Shane R. Sofos
8
+ autorequire:
9
+ bindir:
10
+ - bin
11
+ cert_chain: []
12
+ date: 2018-06-09 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: bundler
16
+ requirement: !ruby/object:Gem::Requirement
17
+ requirements:
18
+ - - ">="
19
+ - !ruby/object:Gem::Version
20
+ version: '0'
21
+ type: :development
22
+ prerelease: false
23
+ version_requirements: !ruby/object:Gem::Requirement
24
+ requirements:
25
+ - - ">="
26
+ - !ruby/object:Gem::Version
27
+ version: '0'
28
+ - !ruby/object:Gem::Dependency
29
+ name: rake
30
+ requirement: !ruby/object:Gem::Requirement
31
+ requirements:
32
+ - - ">="
33
+ - !ruby/object:Gem::Version
34
+ version: '0'
35
+ type: :development
36
+ prerelease: false
37
+ version_requirements: !ruby/object:Gem::Requirement
38
+ requirements:
39
+ - - ">="
40
+ - !ruby/object:Gem::Version
41
+ version: '0'
42
+ - !ruby/object:Gem::Dependency
43
+ name: rspec
44
+ requirement: !ruby/object:Gem::Requirement
45
+ requirements:
46
+ - - ">="
47
+ - !ruby/object:Gem::Version
48
+ version: '0'
49
+ type: :development
50
+ prerelease: false
51
+ version_requirements: !ruby/object:Gem::Requirement
52
+ requirements:
53
+ - - ">="
54
+ - !ruby/object:Gem::Version
55
+ version: '0'
56
+ - !ruby/object:Gem::Dependency
57
+ name: rubocop
58
+ requirement: !ruby/object:Gem::Requirement
59
+ requirements:
60
+ - - "<="
61
+ - !ruby/object:Gem::Version
62
+ version: 0.56.0
63
+ type: :development
64
+ prerelease: false
65
+ version_requirements: !ruby/object:Gem::Requirement
66
+ requirements:
67
+ - - "<="
68
+ - !ruby/object:Gem::Version
69
+ version: 0.56.0
70
+ - !ruby/object:Gem::Dependency
71
+ name: simplecov
72
+ requirement: !ruby/object:Gem::Requirement
73
+ requirements:
74
+ - - ">="
75
+ - !ruby/object:Gem::Version
76
+ version: '0'
77
+ type: :development
78
+ prerelease: false
79
+ version_requirements: !ruby/object:Gem::Requirement
80
+ requirements:
81
+ - - ">="
82
+ - !ruby/object:Gem::Version
83
+ version: '0'
84
+ description: The Budget Pouch. Fast annual budget projections.
85
+ email:
86
+ - ssofos@gmail.com
87
+ executables:
88
+ - bouch
89
+ extensions: []
90
+ extra_rdoc_files: []
91
+ files:
92
+ - ".gitignore"
93
+ - ".gitlab-ci.yml"
94
+ - ".rspec"
95
+ - ".rubocop.yml"
96
+ - ".simplecov"
97
+ - Gemfile
98
+ - Gemfile.lock
99
+ - LICENSE
100
+ - README.md
101
+ - Rakefile
102
+ - bin/bouch
103
+ - bouch.gemspec
104
+ - lib/bouch.rb
105
+ - lib/bouch/calc.rb
106
+ - lib/bouch/cli.rb
107
+ - lib/bouch/version.rb
108
+ - pouch.example.yml
109
+ - spec/bouch_calc_spec.rb
110
+ - spec/bouch_cli_spec.rb
111
+ - spec/bouch_pouch_yaml_spec.rb
112
+ - spec/bouch_spec.rb
113
+ - spec/bouch_version_spec.rb
114
+ - spec/spec_helper.rb
115
+ homepage: https://gitlab.com/ssofos/bouch
116
+ licenses:
117
+ - GPL-3.0
118
+ metadata: {}
119
+ post_install_message:
120
+ rdoc_options: []
121
+ require_paths:
122
+ - lib
123
+ required_ruby_version: !ruby/object:Gem::Requirement
124
+ requirements:
125
+ - - ">="
126
+ - !ruby/object:Gem::Version
127
+ version: 2.4.0
128
+ required_rubygems_version: !ruby/object:Gem::Requirement
129
+ requirements:
130
+ - - ">="
131
+ - !ruby/object:Gem::Version
132
+ version: '0'
133
+ requirements: []
134
+ rubyforge_project:
135
+ rubygems_version: 2.6.14
136
+ signing_key:
137
+ specification_version: 4
138
+ summary: A simple tool to calculate and project your annual personal budget based
139
+ on fiscal quarters expenditures, income, assets, and debts.
140
+ test_files:
141
+ - spec/bouch_calc_spec.rb
142
+ - spec/bouch_cli_spec.rb
143
+ - spec/bouch_pouch_yaml_spec.rb
144
+ - spec/bouch_spec.rb
145
+ - spec/bouch_version_spec.rb
146
+ - spec/spec_helper.rb