budget_validator 0.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.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 1ee92a36b40300814db39581ac05348b945ad47b7acffc254f827b2eceb2efeb
4
+ data.tar.gz: 130d3461a50546d69dd86b7242d12d72accaf9127dd9e7e86f23fe7605ceb190
5
+ SHA512:
6
+ metadata.gz: ed945734f517ffc4ac0c1ce06516c3a94340c6be9f213edb4ab837b9ef086663b07422b68a3e68bdf596404e4315613b150f952c19fe8e85684d0b91c225f6b8
7
+ data.tar.gz: ed3e6ac22d4b45620126b555adf2dd156df34a52ad94ab0a37abc27fe332cfb3d7739aff5746cb99d402fe16c58241568aa10a21de8614792d1ab24b7c46abba
data/README.md ADDED
@@ -0,0 +1,35 @@
1
+ # BudgetValidator
2
+
3
+ TODO: Delete this and the text below, and describe your gem
4
+
5
+ Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/budget_validator`. To experiment with that code, run `bin/console` for an interactive prompt.
6
+
7
+ ## Installation
8
+
9
+ TODO: Replace `UPDATE_WITH_YOUR_GEM_NAME_IMMEDIATELY_AFTER_RELEASE_TO_RUBYGEMS_ORG` with your gem name right after releasing it to RubyGems.org. Please do not do it earlier due to security reasons. Alternatively, replace this section with instructions to install your gem from git if you don't plan to release to RubyGems.org.
10
+
11
+ Install the gem and add to the application's Gemfile by executing:
12
+
13
+ ```bash
14
+ bundle add UPDATE_WITH_YOUR_GEM_NAME_IMMEDIATELY_AFTER_RELEASE_TO_RUBYGEMS_ORG
15
+ ```
16
+
17
+ If bundler is not being used to manage dependencies, install the gem by executing:
18
+
19
+ ```bash
20
+ gem install UPDATE_WITH_YOUR_GEM_NAME_IMMEDIATELY_AFTER_RELEASE_TO_RUBYGEMS_ORG
21
+ ```
22
+
23
+ ## Usage
24
+
25
+ TODO: Write usage instructions here
26
+
27
+ ## Development
28
+
29
+ After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
30
+
31
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
32
+
33
+ ## Contributing
34
+
35
+ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/budget_validator.
data/Rakefile ADDED
@@ -0,0 +1,4 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "bundler/gem_tasks"
4
+ task default: %i[]
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module BudgetValidator
4
+ VERSION = "0.1.0"
5
+ end
@@ -0,0 +1,33 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "budget_validator/version"
4
+
5
+ module BudgetValidator
6
+ class BudgetChecker
7
+ attr_reader :budget
8
+
9
+ def initialize(budget)
10
+ @budget = budget
11
+ @total_expenses = 0;
12
+ end
13
+
14
+ def add_expense(amount)
15
+ raise ArgumentError, "Amount must be positive" if amount.negative?
16
+ new_total = @total_expenses + amount
17
+ if new_total > @budget
18
+ raise StandardError,
19
+ "Budget has been exceeded. Total is: #{new_total}, Budget is: #{@budget}"
20
+ end
21
+
22
+ @total_expenses = new_total
23
+ @total_expenses
24
+ end
25
+
26
+ def total_expenses
27
+ @total_expenses
28
+ end
29
+
30
+
31
+ class Error < StandardError; end
32
+ # Your code goes here...
33
+ end
@@ -0,0 +1,4 @@
1
+ module BudgetValidator
2
+ VERSION: String
3
+ # See the writing guide of rbs: https://github.com/ruby/rbs#guides
4
+ end
metadata ADDED
@@ -0,0 +1,49 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: budget_validator
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Shaneburk3
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2024-12-01 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: A gem that checks the users expenses and causes an error when budget
14
+ is reached.
15
+ email:
16
+ - shane18280@gmail.com
17
+ executables: []
18
+ extensions: []
19
+ extra_rdoc_files: []
20
+ files:
21
+ - README.md
22
+ - Rakefile
23
+ - lib/budget_validator.rb
24
+ - lib/budget_validator/version.rb
25
+ - sig/budget_validator.rbs
26
+ homepage: https://rubygems.org/gems/budget_validator
27
+ licenses: []
28
+ metadata:
29
+ homepage_uri: https://rubygems.org/gems/budget_validator
30
+ post_install_message:
31
+ rdoc_options: []
32
+ require_paths:
33
+ - lib
34
+ required_ruby_version: !ruby/object:Gem::Requirement
35
+ requirements:
36
+ - - ">="
37
+ - !ruby/object:Gem::Version
38
+ version: 3.0.0
39
+ required_rubygems_version: !ruby/object:Gem::Requirement
40
+ requirements:
41
+ - - ">="
42
+ - !ruby/object:Gem::Version
43
+ version: '0'
44
+ requirements: []
45
+ rubygems_version: 3.5.23
46
+ signing_key:
47
+ specification_version: 4
48
+ summary: if the user goes over the budget, an error will be displayed.
49
+ test_files: []