billinfo 0.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 +7 -0
- data/.gitignore +8 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/Gemfile +9 -0
- data/LICENSE.txt +21 -0
- data/README.md +37 -0
- data/Rakefile +2 -0
- data/billinfo.gemspec +43 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/lib/billinfo.rb +125 -0
- data/lib/billinfo/version.rb +3 -0
- data/lib/billinfo_methods.rb +129 -0
- metadata +114 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA1:
|
|
3
|
+
metadata.gz: a72ef1c301dc6c67c0f46d692d4c401e6f913bfa
|
|
4
|
+
data.tar.gz: d1b1428ba496911b404f621d6ec514d5651fdd8b
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: e136ba27cb545d54790c46f208d65e39b6859adc800be2c7f55140bbcd5608c69754dadb8484b6a5739e542c682e34392bebe3d71b1d715ee7e0223481ef5ddd
|
|
7
|
+
data.tar.gz: 470383576d51b1c74fa9d910494e736f2178687716d4c266d57ec20b80b5b8e19676903cece5210b036a7727773b4a993b06312014ffffd75a5db0d323c8dd5d
|
data/.gitignore
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 rcabej@gmail.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) 2019 mepyyeti
|
|
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,37 @@
|
|
|
1
|
+
# Billinfo
|
|
2
|
+
|
|
3
|
+
A simple bill payment repository. Use the gem as a log of bills paid.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
Add this line to your application's Gemfile:
|
|
8
|
+
|
|
9
|
+
```ruby
|
|
10
|
+
gem 'billinfo'
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
And then execute:
|
|
14
|
+
|
|
15
|
+
$ bundle
|
|
16
|
+
|
|
17
|
+
Or install it yourself as:
|
|
18
|
+
|
|
19
|
+
$ gem install billinfo
|
|
20
|
+
|
|
21
|
+
## Development
|
|
22
|
+
|
|
23
|
+
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.
|
|
24
|
+
|
|
25
|
+
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 tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
|
26
|
+
|
|
27
|
+
## Contributing
|
|
28
|
+
|
|
29
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/billinfo. 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.
|
|
30
|
+
|
|
31
|
+
## License
|
|
32
|
+
|
|
33
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
|
34
|
+
|
|
35
|
+
## Code of Conduct
|
|
36
|
+
|
|
37
|
+
Everyone interacting in the Billinfo project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/mepyyeti/billinfo/blob/master/CODE_OF_CONDUCT.md).
|
data/Rakefile
ADDED
data/billinfo.gemspec
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
|
|
2
|
+
lib = File.expand_path("../lib", __FILE__)
|
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
4
|
+
require "billinfo/version"
|
|
5
|
+
|
|
6
|
+
Gem::Specification.new do |spec|
|
|
7
|
+
spec.name = "billinfo"
|
|
8
|
+
spec.version = Billinfo::VERSION
|
|
9
|
+
spec.authors = ["mepyyeti"]
|
|
10
|
+
spec.email = ["rcabej@gmail.com"]
|
|
11
|
+
|
|
12
|
+
spec.summary = %q{A bill repository. Organizes monthly bills by category. Calculates inclusive/exclusive means. Sums categories.}
|
|
13
|
+
spec.homepage = "https://www.github.com/mepyyeti/billinfo"
|
|
14
|
+
spec.files = 'git ls-files'.split($/)
|
|
15
|
+
spec.require_paths = ["lib"]
|
|
16
|
+
spec.license = "MIT"
|
|
17
|
+
|
|
18
|
+
# Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
|
|
19
|
+
# to allow pushing to a single host or delete this section to allow pushing to any host.
|
|
20
|
+
if spec.respond_to?(:metadata)
|
|
21
|
+
spec.metadata["allowed_push_host"] = 'https://rubygems.org'
|
|
22
|
+
|
|
23
|
+
spec.metadata["homepage_uri"] = spec.homepage
|
|
24
|
+
spec.metadata["source_code_uri"] = spec.homepage
|
|
25
|
+
else
|
|
26
|
+
raise "RubyGems 2.0 or newer is required to protect against " \
|
|
27
|
+
"public gem pushes."
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
# Specify which files should be added to the gem when it is released.
|
|
31
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
|
32
|
+
spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
|
|
33
|
+
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
|
34
|
+
end
|
|
35
|
+
spec.bindir = "exe"
|
|
36
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
|
37
|
+
spec.require_paths = ["lib"]
|
|
38
|
+
|
|
39
|
+
spec.add_development_dependency "bundler", "~> 2.0"
|
|
40
|
+
spec.add_development_dependency "rake", "~> 10.5.0", ">= 10.5.0"
|
|
41
|
+
spec.add_runtime_dependency "sqlite3", "~> 1.4.0", ">= 1.4.0"
|
|
42
|
+
spec.post_install_message = "thx. https://www.github.com/mepyyeti/billinfo"
|
|
43
|
+
end
|
data/bin/console
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
|
|
3
|
+
require "bundler/setup"
|
|
4
|
+
require "billinfo"
|
|
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
|
+
# Pry.start
|
|
12
|
+
|
|
13
|
+
require "irb"
|
|
14
|
+
IRB.start(__FILE__)
|
data/bin/setup
ADDED
data/lib/billinfo.rb
ADDED
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
#billinfo.rb
|
|
3
|
+
|
|
4
|
+
require './billinfo_methods'
|
|
5
|
+
require "./billinfo/version"
|
|
6
|
+
|
|
7
|
+
module Billinfo
|
|
8
|
+
class Error < StandardError; end
|
|
9
|
+
|
|
10
|
+
go = true
|
|
11
|
+
while go
|
|
12
|
+
time = Time.new
|
|
13
|
+
year = time.year
|
|
14
|
+
puts "[1] to make a new entry\n[2] to display entries by category\n[3] to exit"
|
|
15
|
+
puts
|
|
16
|
+
choice = gets.chomp.to_i
|
|
17
|
+
choice_ary = [1,2,3]
|
|
18
|
+
choice_foo = [choice]
|
|
19
|
+
unless !choice_foo.empty? || (choice_ary & choice_foo)
|
|
20
|
+
print "choose 1 or 2: "
|
|
21
|
+
choice = gets.chomp.to_i
|
|
22
|
+
end
|
|
23
|
+
categories = ['electricity','water','cable','streaming','rent','food','clothes','out \'n about']
|
|
24
|
+
|
|
25
|
+
if choice == 1
|
|
26
|
+
puts "enter a category such as: #{categories}: "
|
|
27
|
+
print "category: "
|
|
28
|
+
category = gets.chomp.to_s
|
|
29
|
+
new_cat = category
|
|
30
|
+
category = [category]
|
|
31
|
+
|
|
32
|
+
while (category & categories).empty?
|
|
33
|
+
puts "your category is not listed."
|
|
34
|
+
print "\nwould you like to add #{category} as a category? [y/n]: "
|
|
35
|
+
choice = gets.chomp.downcase
|
|
36
|
+
if choice == 'y' or choice 'yes'
|
|
37
|
+
categories << new_cat
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
puts
|
|
42
|
+
print "enter Month: "
|
|
43
|
+
month = gets.chomp.to_s.capitalize
|
|
44
|
+
month = [month]
|
|
45
|
+
months = ['January','February','March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December']
|
|
46
|
+
|
|
47
|
+
while (month & months).empty?
|
|
48
|
+
puts "You must enter a month."
|
|
49
|
+
print "\nAcceptable months are: " , months
|
|
50
|
+
puts "enter a month: "
|
|
51
|
+
month = [gets.chomp.to_s.capitalize]
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
print "enter amount: "
|
|
55
|
+
amt = Float(gets.chomp)
|
|
56
|
+
while !amt.is_a?(Float)
|
|
57
|
+
puts "amount must be a number."
|
|
58
|
+
print "\nplease enter a numeric value: "
|
|
59
|
+
amt = gets.chomp
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
info_hash = {category: category, month: month, amt: amt, year: year}
|
|
63
|
+
|
|
64
|
+
billdb(info_hash)
|
|
65
|
+
billtotal(info_hash)
|
|
66
|
+
observations(info_hash)
|
|
67
|
+
billavginc(info_hash)
|
|
68
|
+
billavgx(info_hash)
|
|
69
|
+
|
|
70
|
+
elsif choice == 2
|
|
71
|
+
print categories
|
|
72
|
+
puts "\nenter a category from choices above"
|
|
73
|
+
print "category: "
|
|
74
|
+
category = [gets.chomp.downcase.to_s]
|
|
75
|
+
|
|
76
|
+
while (category & categories).empty?
|
|
77
|
+
puts "your category is not listed."
|
|
78
|
+
puts "You must choose from the categories above."
|
|
79
|
+
category = [gets.chomp.downcase]
|
|
80
|
+
end
|
|
81
|
+
|
|
82
|
+
print "enter year to search (form: XXXX): "
|
|
83
|
+
year_foo = [gets.chomp]
|
|
84
|
+
yrs = uniq_yrs
|
|
85
|
+
|
|
86
|
+
while year_foo.is_a?(String) || year_foo.empty? || (year_foo & yrs).empty?
|
|
87
|
+
puts "year must be one of the following:"
|
|
88
|
+
print yrs
|
|
89
|
+
puts
|
|
90
|
+
print "enter year to search (form: XXXX): "
|
|
91
|
+
year_foo = gets.chomp
|
|
92
|
+
end
|
|
93
|
+
|
|
94
|
+
year = Integer(year_foo.pop)
|
|
95
|
+
|
|
96
|
+
while year.is_a?(Integer)==false
|
|
97
|
+
puts "You must enter a numeric year (such as 2019)."
|
|
98
|
+
puts "Please retry."
|
|
99
|
+
year = [gets.chomp]
|
|
100
|
+
end
|
|
101
|
+
year = [year]
|
|
102
|
+
|
|
103
|
+
info_hash = {category: category, year: year}
|
|
104
|
+
printinfo(info_hash)
|
|
105
|
+
|
|
106
|
+
elsif choice == 3
|
|
107
|
+
go = false
|
|
108
|
+
|
|
109
|
+
else
|
|
110
|
+
next
|
|
111
|
+
end
|
|
112
|
+
|
|
113
|
+
if choice <= 2
|
|
114
|
+
print "exit?"
|
|
115
|
+
choice = gets.chomp
|
|
116
|
+
if choice == 'y'
|
|
117
|
+
go = false
|
|
118
|
+
else
|
|
119
|
+
next
|
|
120
|
+
end
|
|
121
|
+
end
|
|
122
|
+
|
|
123
|
+
end
|
|
124
|
+
|
|
125
|
+
end
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
#billinfo_methods.rb
|
|
3
|
+
|
|
4
|
+
require 'sqlite3'
|
|
5
|
+
|
|
6
|
+
def billdb(info_hash)
|
|
7
|
+
begin
|
|
8
|
+
db = SQLite3::Database.open('billinfo.db')
|
|
9
|
+
puts db.get_first_value "select SQLite_version()"
|
|
10
|
+
db.transaction
|
|
11
|
+
db.execute2 "CREATE table if not exists bills(Id INTEGER PRIMARY KEY, Type TEXT, Month TEXT, Year INTEGER, Amount FLOAT, AvgInc FLOAT, AvgX FLOAT, Total FLOAT)"
|
|
12
|
+
db.execute2 "INSERT into bills(Type, Month, Year, Amount) values(:Type, :Month, :Year, :Amount)", info_hash[:category], info_hash[:month], info_hash[:year], info_hash[:amt]
|
|
13
|
+
db.commit
|
|
14
|
+
puts db.changes.to_s + " change made"
|
|
15
|
+
rescue SQLite3::Exception => e
|
|
16
|
+
puts e
|
|
17
|
+
db.rollback
|
|
18
|
+
ensure
|
|
19
|
+
db.close if db
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
def billtotal(info_hash)
|
|
24
|
+
begin
|
|
25
|
+
db = SQLite3::Database.open('billinfo.db')
|
|
26
|
+
db.transaction
|
|
27
|
+
get_amt = db.execute2 "SELECT sum(Amount) from bills WHERE Type = :Type AND Year = :Year", info_hash[:category], info_hash[:year]
|
|
28
|
+
puts "foo"
|
|
29
|
+
db.execute2 "UPDATE bills SET Total = :Total WHERE Type = :Type AND Year = :Year", get_amt[1][0], info_hash[:category], info_hash[:year]
|
|
30
|
+
@total_amt=get_amt[1][0]
|
|
31
|
+
puts db.changes.to_s + " changes made"
|
|
32
|
+
db.commit
|
|
33
|
+
rescue SQLite3::Exception => e
|
|
34
|
+
puts "error here " , e
|
|
35
|
+
ensure
|
|
36
|
+
db.close if db
|
|
37
|
+
end
|
|
38
|
+
@total_amt
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
def observations(info_hash)
|
|
42
|
+
begin
|
|
43
|
+
db = SQLite3::Database.open('billinfo.db')
|
|
44
|
+
total_rows = db.execute2 "SELECT COUNT(*) from bills WHERE Type = :Type AND Year = :Year", info_hash[:category], info_hash[:year]
|
|
45
|
+
rescue SQLite3::Exception => e
|
|
46
|
+
puts "error here " , e
|
|
47
|
+
ensure
|
|
48
|
+
db.close if db
|
|
49
|
+
end
|
|
50
|
+
@total_rows=total_rows[1][0]
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
def billavginc(info_hash)
|
|
54
|
+
begin
|
|
55
|
+
db = SQLite3::Database.open('billinfo.db')
|
|
56
|
+
db.transaction
|
|
57
|
+
@avginc = @total_amt / @total_rows
|
|
58
|
+
update_avginc = db.execute2 "SELECT Amount from bills WHERE Type = :Type AND Year = :Year", info_hash[:category], info_hash[:year]
|
|
59
|
+
update_avginc.each do |line|
|
|
60
|
+
db.execute2 "UPDATE bills SET AvgInc = :AvgInc WHERE Type = :Type AND Year = :Year", @avginc, info_hash[:category], info_hash[:year]
|
|
61
|
+
end
|
|
62
|
+
puts db.changes.to_s + " changes made " + "for #{info_hash[:year].to_s}"
|
|
63
|
+
db.commit
|
|
64
|
+
rescue SQLite3::Exception => e
|
|
65
|
+
puts "error here " , e
|
|
66
|
+
ensure
|
|
67
|
+
db.close if db
|
|
68
|
+
end
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
def billavgx(info_hash)
|
|
72
|
+
begin
|
|
73
|
+
db = SQLite3::Database.open('billinfo.db')
|
|
74
|
+
db.results_as_hash = true
|
|
75
|
+
db.transaction
|
|
76
|
+
specific_amt = db.prepare "SELECT Amount FROM bills WHERE Type = :Type AND Year = :Year"
|
|
77
|
+
specific_amt.execute info_hash[:category], info_hash[:year]
|
|
78
|
+
specific_amt.each do |specific_row|
|
|
79
|
+
if @total_rows == 1
|
|
80
|
+
avgx = @total_amt / @total_rows
|
|
81
|
+
elsif @total_rows > 1
|
|
82
|
+
avgx = (@total_amt - specific_row[0]) / (@total_rows - 1)
|
|
83
|
+
else
|
|
84
|
+
puts "insufficient entries"
|
|
85
|
+
return "insufficient entries"
|
|
86
|
+
end
|
|
87
|
+
db.execute2 "UPDATE bills SET AvgX = :AvgX WHERE Amount = :Amount AND Type = :Type AND Year = :Year", avgx, specific_row[0], info_hash[:category], info_hash[:year]
|
|
88
|
+
end
|
|
89
|
+
puts db.changes.to_s + " changes made " + "to #{info_hash[:year].to_s}"
|
|
90
|
+
db.commit
|
|
91
|
+
rescue SQLite3::Exception => e
|
|
92
|
+
puts "error here " , e
|
|
93
|
+
ensure
|
|
94
|
+
specific_amt.close if specific_amt
|
|
95
|
+
db.close if db
|
|
96
|
+
end
|
|
97
|
+
end
|
|
98
|
+
|
|
99
|
+
def uniq_yrs
|
|
100
|
+
begin
|
|
101
|
+
db = SQLite3::Database.open('billinfo.db')
|
|
102
|
+
yrs = []
|
|
103
|
+
db_print = db.execute2 "SELECT Year FROM bills"
|
|
104
|
+
db_print.each do |yr|
|
|
105
|
+
yrs << yr
|
|
106
|
+
end
|
|
107
|
+
yrs.shift
|
|
108
|
+
@yrs = yrs.uniq
|
|
109
|
+
rescue SQLite3::Exception => e
|
|
110
|
+
puts e
|
|
111
|
+
ensure
|
|
112
|
+
db.close if db
|
|
113
|
+
end
|
|
114
|
+
@yrs
|
|
115
|
+
end
|
|
116
|
+
|
|
117
|
+
def printinfo(info_hash)
|
|
118
|
+
begin
|
|
119
|
+
db = SQLite3::Database.open('billinfo.db')
|
|
120
|
+
db_print = db.execute2 "SELECT * FROM bills WHERE Type = :Type AND Year = :Year", info_hash[:category], info_hash[:year]
|
|
121
|
+
db_print.each do |line|
|
|
122
|
+
puts "%s %s %s %s %s [%s | %s] %s" % [line[0], line[1], line[2], line[3], line[4], line[5], line[6], line[7], line[8]]
|
|
123
|
+
end
|
|
124
|
+
rescue SQLite3::Exception => e
|
|
125
|
+
puts e
|
|
126
|
+
ensure
|
|
127
|
+
db.close if db
|
|
128
|
+
end
|
|
129
|
+
end
|
metadata
ADDED
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: billinfo
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.0.1
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- mepyyeti
|
|
8
|
+
autorequire:
|
|
9
|
+
bindir: exe
|
|
10
|
+
cert_chain: []
|
|
11
|
+
date: 2019-04-13 00:00:00.000000000 Z
|
|
12
|
+
dependencies:
|
|
13
|
+
- !ruby/object:Gem::Dependency
|
|
14
|
+
name: bundler
|
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
|
16
|
+
requirements:
|
|
17
|
+
- - "~>"
|
|
18
|
+
- !ruby/object:Gem::Version
|
|
19
|
+
version: '2.0'
|
|
20
|
+
type: :development
|
|
21
|
+
prerelease: false
|
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
23
|
+
requirements:
|
|
24
|
+
- - "~>"
|
|
25
|
+
- !ruby/object:Gem::Version
|
|
26
|
+
version: '2.0'
|
|
27
|
+
- !ruby/object:Gem::Dependency
|
|
28
|
+
name: rake
|
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
|
30
|
+
requirements:
|
|
31
|
+
- - "~>"
|
|
32
|
+
- !ruby/object:Gem::Version
|
|
33
|
+
version: 10.5.0
|
|
34
|
+
- - ">="
|
|
35
|
+
- !ruby/object:Gem::Version
|
|
36
|
+
version: 10.5.0
|
|
37
|
+
type: :development
|
|
38
|
+
prerelease: false
|
|
39
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
40
|
+
requirements:
|
|
41
|
+
- - "~>"
|
|
42
|
+
- !ruby/object:Gem::Version
|
|
43
|
+
version: 10.5.0
|
|
44
|
+
- - ">="
|
|
45
|
+
- !ruby/object:Gem::Version
|
|
46
|
+
version: 10.5.0
|
|
47
|
+
- !ruby/object:Gem::Dependency
|
|
48
|
+
name: sqlite3
|
|
49
|
+
requirement: !ruby/object:Gem::Requirement
|
|
50
|
+
requirements:
|
|
51
|
+
- - "~>"
|
|
52
|
+
- !ruby/object:Gem::Version
|
|
53
|
+
version: 1.4.0
|
|
54
|
+
- - ">="
|
|
55
|
+
- !ruby/object:Gem::Version
|
|
56
|
+
version: 1.4.0
|
|
57
|
+
type: :runtime
|
|
58
|
+
prerelease: false
|
|
59
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
60
|
+
requirements:
|
|
61
|
+
- - "~>"
|
|
62
|
+
- !ruby/object:Gem::Version
|
|
63
|
+
version: 1.4.0
|
|
64
|
+
- - ">="
|
|
65
|
+
- !ruby/object:Gem::Version
|
|
66
|
+
version: 1.4.0
|
|
67
|
+
description:
|
|
68
|
+
email:
|
|
69
|
+
- rcabej@gmail.com
|
|
70
|
+
executables: []
|
|
71
|
+
extensions: []
|
|
72
|
+
extra_rdoc_files: []
|
|
73
|
+
files:
|
|
74
|
+
- ".gitignore"
|
|
75
|
+
- CODE_OF_CONDUCT.md
|
|
76
|
+
- Gemfile
|
|
77
|
+
- LICENSE.txt
|
|
78
|
+
- README.md
|
|
79
|
+
- Rakefile
|
|
80
|
+
- billinfo.gemspec
|
|
81
|
+
- bin/console
|
|
82
|
+
- bin/setup
|
|
83
|
+
- lib/billinfo.rb
|
|
84
|
+
- lib/billinfo/version.rb
|
|
85
|
+
- lib/billinfo_methods.rb
|
|
86
|
+
homepage: https://www.github.com/mepyyeti/billinfo
|
|
87
|
+
licenses:
|
|
88
|
+
- MIT
|
|
89
|
+
metadata:
|
|
90
|
+
allowed_push_host: https://rubygems.org
|
|
91
|
+
homepage_uri: https://www.github.com/mepyyeti/billinfo
|
|
92
|
+
source_code_uri: https://www.github.com/mepyyeti/billinfo
|
|
93
|
+
post_install_message: thx. https://www.github.com/mepyyeti/billinfo
|
|
94
|
+
rdoc_options: []
|
|
95
|
+
require_paths:
|
|
96
|
+
- lib
|
|
97
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
98
|
+
requirements:
|
|
99
|
+
- - ">="
|
|
100
|
+
- !ruby/object:Gem::Version
|
|
101
|
+
version: '0'
|
|
102
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
103
|
+
requirements:
|
|
104
|
+
- - ">="
|
|
105
|
+
- !ruby/object:Gem::Version
|
|
106
|
+
version: '0'
|
|
107
|
+
requirements: []
|
|
108
|
+
rubyforge_project:
|
|
109
|
+
rubygems_version: 2.5.2.3
|
|
110
|
+
signing_key:
|
|
111
|
+
specification_version: 4
|
|
112
|
+
summary: A bill repository. Organizes monthly bills by category. Calculates inclusive/exclusive
|
|
113
|
+
means. Sums categories.
|
|
114
|
+
test_files: []
|