bouch 2.0.0 → 2.0.1

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1703d82906883118087626db522e171f841ca1b3bfa9792731da9e05ebbbf08c
4
- data.tar.gz: 8a956f18ac52e62a4648172743eb9ecbcd0e846913abc9ac6dac1f615b0e7a9d
3
+ metadata.gz: 3591c24557e25403cacda4cd01cdb2885239a0f5e71908ccdc53d09fec55d229
4
+ data.tar.gz: 81ddaf8e49d0557e5c753c0c85604b35f549723a886fad30f949cac119984eec
5
5
  SHA512:
6
- metadata.gz: f8eee437173dc3411bd5378553995c633a266d4ebdbe1539cd9eb26dc10ee148c13c85190c90516ebd8d9304810804f93923c13535db87224c5e81e6a1ee6adc
7
- data.tar.gz: be2a6e3cd8771180dcd430bd931326af2c8a261f9333c340be766cfc2ab85bce7475a18e97ceb596a57df2a59fd4471123c11314a9855009bf6fd4cb3d645b56
6
+ metadata.gz: 1238cbc844c7a5767c5d0ed5c15b20592bf15e86a11018f993fa2769e9091ac987fb6af1664c4de4bbd811bd91a9ff15a2e6297a4d3bf5e9427366ab51aaeb05
7
+ data.tar.gz: 791d31224bb22952f710a874ff159cab6da456acd0a15103efe328f7cad06657703f777da1bb877dcf6fa7ba1c50e2568f2c79564bf9db8569ed81770fb9d0e1
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- bouch (2.0.0)
4
+ bouch (2.0.1)
5
5
  paint (~> 2.3)
6
6
 
7
7
  GEM
@@ -10,19 +10,19 @@ GEM
10
10
  ast (2.4.3)
11
11
  diff-lcs (1.6.2)
12
12
  docile (1.4.1)
13
- json (2.18.1)
13
+ json (2.19.5)
14
14
  language_server-protocol (3.17.0.5)
15
15
  lint_roller (1.1.0)
16
16
  paint (2.3.0)
17
- parallel (1.27.0)
18
- parser (3.3.10.2)
17
+ parallel (2.1.0)
18
+ parser (3.3.11.1)
19
19
  ast (~> 2.4.1)
20
20
  racc
21
21
  prism (1.9.0)
22
22
  racc (1.8.1)
23
23
  rainbow (3.1.1)
24
- rake (13.3.1)
25
- regexp_parser (2.11.3)
24
+ rake (13.4.2)
25
+ regexp_parser (2.12.0)
26
26
  rspec (3.13.2)
27
27
  rspec-core (~> 3.13.0)
28
28
  rspec-expectations (~> 3.13.0)
@@ -32,22 +32,22 @@ GEM
32
32
  rspec-expectations (3.13.5)
33
33
  diff-lcs (>= 1.2.0, < 2.0)
34
34
  rspec-support (~> 3.13.0)
35
- rspec-mocks (3.13.7)
35
+ rspec-mocks (3.13.8)
36
36
  diff-lcs (>= 1.2.0, < 2.0)
37
37
  rspec-support (~> 3.13.0)
38
38
  rspec-support (3.13.7)
39
- rubocop (1.84.2)
39
+ rubocop (1.86.2)
40
40
  json (~> 2.3)
41
41
  language_server-protocol (~> 3.17.0.2)
42
42
  lint_roller (~> 1.1.0)
43
- parallel (~> 1.10)
43
+ parallel (>= 1.10)
44
44
  parser (>= 3.3.0.2)
45
45
  rainbow (>= 2.2.2, < 4.0)
46
46
  regexp_parser (>= 2.9.3, < 3.0)
47
47
  rubocop-ast (>= 1.49.0, < 2.0)
48
48
  ruby-progressbar (~> 1.7)
49
49
  unicode-display_width (>= 2.4.0, < 4.0)
50
- rubocop-ast (1.49.0)
50
+ rubocop-ast (1.49.1)
51
51
  parser (>= 3.3.7.2)
52
52
  prism (~> 1.7)
53
53
  ruby-progressbar (1.13.0)
@@ -76,4 +76,4 @@ RUBY VERSION
76
76
  ruby 4.0.1
77
77
 
78
78
  BUNDLED WITH
79
- 4.0.6
79
+ 4.0.10
data/README.md CHANGED
@@ -1,5 +1,5 @@
1
1
  # Bouch
2
- [![Gem Version](https://badge.fury.io/rb/bouch.svg)](https://badge.fury.io/rb/bouch) [![pipeline status](https://gitlab.com/ssofos/bouch/badges/master/pipeline.svg)](https://gitlab.com/ssofos/bouch/commits/master) [![coverage report](https://gitlab.com/ssofos/bouch/badges/master/coverage.svg)](https://gitlab.com/ssofos/bouch/commits/master)
2
+ [![Gem Version](https://badge.fury.io/rb/bouch.svg)](https://badge.fury.io/rb/bouch) [![pipeline status](https://gitlab.com/ssofos/bouch/badges/master/pipeline.svg)](https://gitlab.com/ssofos/bouch/commits/master) [![ruby-forthebadge](https://forthebadge.com/badges/made-with-ruby.svg)](https://forthebadge.com/badges/made-with-ruby.svg)
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
 
data/lib/bouch/cli.rb CHANGED
@@ -22,11 +22,18 @@ class Bouch
22
22
  elsif @yaml_file == 'example'
23
23
  puts Bouch::EXAMPLE_POUCH
24
24
  elsif File.exist?(@yaml_file)
25
- budget = Bouch.new(@yaml_file)
26
- budget.show_budget
25
+ begin
26
+ budget = Bouch.new(@yaml_file)
27
+ budget.show_budget
28
+ rescue ArgumentError, Psych::SyntaxError => e
29
+ puts Paint["Whoops. Failed to load the budget pouch file: #{e.message}", :red]
30
+ usage
31
+ exit 1
32
+ end
27
33
  else
28
34
  puts Paint["Whoops. The budget pouch file specified: #{@yaml_file} ; does not exist!", :red]
29
35
  usage
36
+ exit 1
30
37
  end
31
38
  end
32
39
 
data/lib/bouch/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  class Bouch
4
- VERSION = '2.0.0'
4
+ VERSION = '2.0.1'
5
5
  end
data/lib/bouch.rb CHANGED
@@ -19,6 +19,8 @@ class Bouch
19
19
  @equity = []
20
20
  @net_worth = nil
21
21
  @pouch = YAML.safe_load(File.read(file))
22
+ raise ArgumentError, 'Invalid or empty YAML file' unless @pouch.is_a?(Hash)
23
+
22
24
  @quarters = {}
23
25
  end
24
26
 
@@ -81,9 +81,37 @@ describe 'Bouch::CLI' do
81
81
  end
82
82
 
83
83
  context 'when a non-existent file is supplied as the first CLI argument' do
84
- it 'outputs a warning and usage help messages' do
84
+ it 'outputs a warning and usage help messages and exits' do
85
85
  @cli.yaml_file = 'foobar.yml'
86
- expect { @cli.start }.to output.to_stdout
86
+ expect { expect { @cli.start }.to output.to_stdout }.to raise_error(SystemExit)
87
+ end
88
+ end
89
+
90
+ context 'when an empty YAML file is supplied' do
91
+ it 'outputs a friendly error message and exits' do
92
+ empty_yaml = Tempfile.new(['empty', '.yml'])
93
+ begin
94
+ @cli.yaml_file = empty_yaml.path
95
+ expect do
96
+ expect { @cli.start }.to output(/Whoops. Failed to load the budget pouch file: Invalid or empty YAML file/).to_stdout
97
+ end.to raise_error(SystemExit)
98
+ ensure
99
+ empty_yaml.unlink
100
+ end
101
+ end
102
+ end
103
+
104
+ context 'when a malformed YAML file is supplied' do
105
+ it 'outputs a friendly error message and exits' do
106
+ malformed_yaml = Tempfile.new(['malformed', '.yml'])
107
+ malformed_yaml.write("Budget:\n - Q1: :")
108
+ malformed_yaml.close
109
+ begin
110
+ @cli.yaml_file = malformed_yaml.path
111
+ expect { expect { @cli.start }.to output(/Whoops. Failed to load the budget pouch file/).to_stdout }.to raise_error(SystemExit)
112
+ ensure
113
+ malformed_yaml.unlink
114
+ end
87
115
  end
88
116
  end
89
117
  end
data/spec/bouch_spec.rb CHANGED
@@ -145,4 +145,26 @@ describe Bouch do
145
145
  expect { @minimal_bouch.show_budget }.to output.to_stdout
146
146
  end
147
147
  end
148
+
149
+ describe 'invalid or empty YAML' do
150
+ it 'raises ArgumentError for an empty file' do
151
+ empty_yaml = Tempfile.new(['empty', '.yml'])
152
+ begin
153
+ expect { Bouch.new(empty_yaml.path) }.to raise_error(ArgumentError, /Invalid or empty YAML file/)
154
+ ensure
155
+ empty_yaml.unlink
156
+ end
157
+ end
158
+
159
+ it 'raises ArgumentError for a file that is not a Hash' do
160
+ not_a_hash = Tempfile.new(['list', '.yml'])
161
+ not_a_hash.write("- item1\n- item2")
162
+ not_a_hash.close
163
+ begin
164
+ expect { Bouch.new(not_a_hash.path) }.to raise_error(ArgumentError, /Invalid or empty YAML file/)
165
+ ensure
166
+ not_a_hash.unlink
167
+ end
168
+ end
169
+ end
148
170
  end
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: 2.0.0
4
+ version: 2.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Shane R. Sofos
@@ -142,7 +142,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
142
142
  - !ruby/object:Gem::Version
143
143
  version: '0'
144
144
  requirements: []
145
- rubygems_version: 4.0.3
145
+ rubygems_version: 4.0.10
146
146
  specification_version: 4
147
147
  summary: A simple tool to calculate and project your annual personal budget based
148
148
  on fiscal quarters expenditures, income, assets, and debts.