billinfo 0.0.1 → 0.0.2
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 +4 -4
- data/Gemfile.lock +26 -0
- data/billinfo-0.0.1.gem +0 -0
- data/billinfo.gemspec +2 -2
- data/lib/billinfo.rb +31 -27
- data/lib/billinfo/version.rb +1 -1
- data/lib/billinfo_methods.rb +65 -7
- metadata +9 -4
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: bcbed057e6d6e100e5b7825607f227d86f612a00
|
|
4
|
+
data.tar.gz: ea9fb3b5acb5a3a12a3d1aed7dff7b7ef4562613
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: ac0eeb7eb8fb5ec852514ae02b214360956aa96246d7aea4cd69ece8bfcc11b5f63911e98c1c305a7d7723c7675ca4d30bc2c6451fe07f7e00306251d7a5be03
|
|
7
|
+
data.tar.gz: 57cd3136512936202030cfdd6b0473dbfdc1fdbc0d8e860ca40f1058ca40af06a1ccc1761893e146c0034142520ce58cf55a36aacdacce0db584ad7663d51db4
|
data/Gemfile.lock
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
PATH
|
|
2
|
+
remote: .
|
|
3
|
+
specs:
|
|
4
|
+
billinfo (0.0.1)
|
|
5
|
+
sqlite3 (~> 1.4.0, >= 1.4.0)
|
|
6
|
+
|
|
7
|
+
GEM
|
|
8
|
+
remote: https://rubygems.org/
|
|
9
|
+
specs:
|
|
10
|
+
rake (10.5.0)
|
|
11
|
+
sqlite3 (1.4.0)
|
|
12
|
+
|
|
13
|
+
PLATFORMS
|
|
14
|
+
ruby
|
|
15
|
+
|
|
16
|
+
DEPENDENCIES
|
|
17
|
+
billinfo!
|
|
18
|
+
bundler (~> 2.0)
|
|
19
|
+
rake (~> 10.5.0, >= 10.5.0)
|
|
20
|
+
sqlite3 (~> 1.4.0, >= 1.4.0)
|
|
21
|
+
|
|
22
|
+
RUBY VERSION
|
|
23
|
+
ruby 2.3.7p456
|
|
24
|
+
|
|
25
|
+
BUNDLED WITH
|
|
26
|
+
2.0.1
|
data/billinfo-0.0.1.gem
ADDED
|
Binary file
|
data/billinfo.gemspec
CHANGED
|
@@ -8,8 +8,8 @@ Gem::Specification.new do |spec|
|
|
|
8
8
|
spec.version = Billinfo::VERSION
|
|
9
9
|
spec.authors = ["mepyyeti"]
|
|
10
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.}
|
|
11
|
+
spec.description = %q{A bill repository. Organizes monthly bills by category. Calculates inclusive/exclusive means. Sums categories. Bug in Display option fixed. Added functionality that permanently adds custom categories}
|
|
12
|
+
spec.summary = %q{A bill repository. Organizes monthly bills by category. Calculates inclusive/exclusive means. Sums categories. Bug in Display option fixed. Added functionality that permanently adds custom categories}
|
|
13
13
|
spec.homepage = "https://www.github.com/mepyyeti/billinfo"
|
|
14
14
|
spec.files = 'git ls-files'.split($/)
|
|
15
15
|
spec.require_paths = ["lib"]
|
data/lib/billinfo.rb
CHANGED
|
@@ -20,30 +20,39 @@ module Billinfo
|
|
|
20
20
|
print "choose 1 or 2: "
|
|
21
21
|
choice = gets.chomp.to_i
|
|
22
22
|
end
|
|
23
|
-
|
|
24
|
-
|
|
23
|
+
|
|
25
24
|
if choice == 1
|
|
26
|
-
|
|
27
|
-
|
|
25
|
+
create_categories
|
|
26
|
+
categories = print_standard_categories
|
|
27
|
+
print "enter a category such as: " , categories
|
|
28
|
+
print "\ncategory: "
|
|
28
29
|
category = gets.chomp.to_s
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
30
|
+
|
|
31
|
+
if category.empty?
|
|
32
|
+
print "you must enter a category\n"
|
|
33
|
+
next
|
|
34
|
+
else
|
|
35
|
+
category = [category]
|
|
36
|
+
end
|
|
37
|
+
|
|
32
38
|
while (category & categories).empty?
|
|
33
39
|
puts "your category is not listed."
|
|
34
40
|
print "\nwould you like to add #{category} as a category? [y/n]: "
|
|
35
41
|
choice = gets.chomp.downcase
|
|
36
|
-
if choice == 'y' or choice 'yes'
|
|
37
|
-
|
|
42
|
+
if choice == 'y' or choice =='yes'
|
|
43
|
+
create_categories(category)
|
|
44
|
+
categories = print_standard_categories
|
|
45
|
+
else
|
|
46
|
+
next
|
|
38
47
|
end
|
|
39
48
|
end
|
|
40
|
-
|
|
49
|
+
|
|
41
50
|
puts
|
|
42
51
|
print "enter Month: "
|
|
43
52
|
month = gets.chomp.to_s.capitalize
|
|
44
53
|
month = [month]
|
|
45
54
|
months = ['January','February','March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December']
|
|
46
|
-
|
|
55
|
+
|
|
47
56
|
while (month & months).empty?
|
|
48
57
|
puts "You must enter a month."
|
|
49
58
|
print "\nAcceptable months are: " , months
|
|
@@ -68,6 +77,13 @@ module Billinfo
|
|
|
68
77
|
billavgx(info_hash)
|
|
69
78
|
|
|
70
79
|
elsif choice == 2
|
|
80
|
+
if !File.file?('billinfo.db')
|
|
81
|
+
puts "You have not made any entries yet - there is nothing to show."
|
|
82
|
+
next
|
|
83
|
+
end
|
|
84
|
+
|
|
85
|
+
categories = print_standard_categories
|
|
86
|
+
|
|
71
87
|
print categories
|
|
72
88
|
puts "\nenter a category from choices above"
|
|
73
89
|
print "category: "
|
|
@@ -80,32 +96,21 @@ module Billinfo
|
|
|
80
96
|
end
|
|
81
97
|
|
|
82
98
|
print "enter year to search (form: XXXX): "
|
|
83
|
-
year_foo = [gets.chomp]
|
|
99
|
+
year_foo = [gets.chomp.to_i]
|
|
84
100
|
yrs = uniq_yrs
|
|
85
101
|
|
|
86
102
|
while year_foo.is_a?(String) || year_foo.empty? || (year_foo & yrs).empty?
|
|
87
103
|
puts "year must be one of the following:"
|
|
88
|
-
print yrs
|
|
89
|
-
puts
|
|
90
104
|
print "enter year to search (form: XXXX): "
|
|
91
|
-
year_foo = gets.chomp
|
|
105
|
+
year_foo = [gets.chomp.to_i]
|
|
92
106
|
end
|
|
93
|
-
|
|
94
|
-
year =
|
|
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
|
-
|
|
107
|
+
|
|
108
|
+
year = [year_foo]
|
|
103
109
|
info_hash = {category: category, year: year}
|
|
104
110
|
printinfo(info_hash)
|
|
105
111
|
|
|
106
112
|
elsif choice == 3
|
|
107
113
|
go = false
|
|
108
|
-
|
|
109
114
|
else
|
|
110
115
|
next
|
|
111
116
|
end
|
|
@@ -121,5 +126,4 @@ module Billinfo
|
|
|
121
126
|
end
|
|
122
127
|
|
|
123
128
|
end
|
|
124
|
-
|
|
125
129
|
end
|
data/lib/billinfo/version.rb
CHANGED
data/lib/billinfo_methods.rb
CHANGED
|
@@ -3,15 +3,64 @@
|
|
|
3
3
|
|
|
4
4
|
require 'sqlite3'
|
|
5
5
|
|
|
6
|
+
def create_categories(new_category = nil)
|
|
7
|
+
unless File.file?('billinfo.db')
|
|
8
|
+
categories = ['electricity','water','cable','streaming','rent','food','clothes','out \'n about']
|
|
9
|
+
begin
|
|
10
|
+
db = SQLite3::Database.open('billinfo.db')
|
|
11
|
+
db.transaction
|
|
12
|
+
db.execute2 "CREATE table if not exists categories(Type TEXT PRIMARY KEY)"
|
|
13
|
+
categories.each { |cat| db.execute2 "INSERT into categories(Type) values(:Type)", cat }
|
|
14
|
+
db.commit
|
|
15
|
+
rescue SQLite3::Exception => e
|
|
16
|
+
puts e
|
|
17
|
+
db.rollback
|
|
18
|
+
ensure
|
|
19
|
+
db.close if db
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
if new_category != nil
|
|
23
|
+
begin
|
|
24
|
+
db = SQLite3::Database.open('billinfo.db')
|
|
25
|
+
db.transaction
|
|
26
|
+
db.execute2 "INSERT into categories(Type) values(:new_category)", new_category
|
|
27
|
+
db.commit
|
|
28
|
+
puts db.changes.to_s + " new category added"
|
|
29
|
+
rescue SQLite3::Exception => e
|
|
30
|
+
puts e
|
|
31
|
+
db.rollback
|
|
32
|
+
ensure
|
|
33
|
+
db.close if db
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
def print_standard_categories
|
|
39
|
+
begin
|
|
40
|
+
db = SQLite3::Database.open('billinfo.db')
|
|
41
|
+
db.results_as_hash = true
|
|
42
|
+
categories_to_print = []
|
|
43
|
+
categories = db.prepare "SELECT Type FROM categories"
|
|
44
|
+
categories.execute
|
|
45
|
+
categories.each { |cat| categories_to_print << cat[0] }
|
|
46
|
+
@categories_to_print = categories_to_print
|
|
47
|
+
rescue SQLite3::Exception => e
|
|
48
|
+
puts e
|
|
49
|
+
ensure
|
|
50
|
+
categories.close if categories
|
|
51
|
+
db.close if db
|
|
52
|
+
end
|
|
53
|
+
@categories_to_print
|
|
54
|
+
end
|
|
55
|
+
|
|
6
56
|
def billdb(info_hash)
|
|
7
57
|
begin
|
|
8
58
|
db = SQLite3::Database.open('billinfo.db')
|
|
9
|
-
puts db.get_first_value "select SQLite_version()"
|
|
10
59
|
db.transaction
|
|
11
60
|
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
61
|
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
62
|
db.commit
|
|
14
|
-
puts db.changes.to_s + "
|
|
63
|
+
puts db.changes.to_s + " entry made"
|
|
15
64
|
rescue SQLite3::Exception => e
|
|
16
65
|
puts e
|
|
17
66
|
db.rollback
|
|
@@ -25,10 +74,14 @@ def billtotal(info_hash)
|
|
|
25
74
|
db = SQLite3::Database.open('billinfo.db')
|
|
26
75
|
db.transaction
|
|
27
76
|
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
77
|
db.execute2 "UPDATE bills SET Total = :Total WHERE Type = :Type AND Year = :Year", get_amt[1][0], info_hash[:category], info_hash[:year]
|
|
30
78
|
@total_amt=get_amt[1][0]
|
|
31
|
-
|
|
79
|
+
if db.changes == 1
|
|
80
|
+
alter = "change"
|
|
81
|
+
else
|
|
82
|
+
alter = "changes"
|
|
83
|
+
end
|
|
84
|
+
puts db.changes.to_s + " #{alter} made to " + info_hash[:category].to_s + " for " + info_hash[:year].to_s
|
|
32
85
|
db.commit
|
|
33
86
|
rescue SQLite3::Exception => e
|
|
34
87
|
puts "error here " , e
|
|
@@ -59,7 +112,12 @@ def billavginc(info_hash)
|
|
|
59
112
|
update_avginc.each do |line|
|
|
60
113
|
db.execute2 "UPDATE bills SET AvgInc = :AvgInc WHERE Type = :Type AND Year = :Year", @avginc, info_hash[:category], info_hash[:year]
|
|
61
114
|
end
|
|
62
|
-
|
|
115
|
+
if db.changes == 1
|
|
116
|
+
alter = "change"
|
|
117
|
+
else
|
|
118
|
+
alter = "changes"
|
|
119
|
+
end
|
|
120
|
+
puts db.changes.to_s + " #{alter} made " + "for #{info_hash[:year].to_s}"
|
|
63
121
|
db.commit
|
|
64
122
|
rescue SQLite3::Exception => e
|
|
65
123
|
puts "error here " , e
|
|
@@ -86,7 +144,6 @@ def billavgx(info_hash)
|
|
|
86
144
|
end
|
|
87
145
|
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
146
|
end
|
|
89
|
-
puts db.changes.to_s + " changes made " + "to #{info_hash[:year].to_s}"
|
|
90
147
|
db.commit
|
|
91
148
|
rescue SQLite3::Exception => e
|
|
92
149
|
puts "error here " , e
|
|
@@ -102,7 +159,7 @@ def uniq_yrs
|
|
|
102
159
|
yrs = []
|
|
103
160
|
db_print = db.execute2 "SELECT Year FROM bills"
|
|
104
161
|
db_print.each do |yr|
|
|
105
|
-
yrs << yr
|
|
162
|
+
yrs << yr[0]
|
|
106
163
|
end
|
|
107
164
|
yrs.shift
|
|
108
165
|
@yrs = yrs.uniq
|
|
@@ -111,6 +168,7 @@ def uniq_yrs
|
|
|
111
168
|
ensure
|
|
112
169
|
db.close if db
|
|
113
170
|
end
|
|
171
|
+
p @yrs.class
|
|
114
172
|
@yrs
|
|
115
173
|
end
|
|
116
174
|
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: billinfo
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.0.
|
|
4
|
+
version: 0.0.2
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- mepyyeti
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2019-04-
|
|
11
|
+
date: 2019-04-15 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: bundler
|
|
@@ -64,7 +64,9 @@ dependencies:
|
|
|
64
64
|
- - ">="
|
|
65
65
|
- !ruby/object:Gem::Version
|
|
66
66
|
version: 1.4.0
|
|
67
|
-
description:
|
|
67
|
+
description: A bill repository. Organizes monthly bills by category. Calculates inclusive/exclusive
|
|
68
|
+
means. Sums categories. Bug in Display option fixed. Added functionality that permanently
|
|
69
|
+
adds custom categories
|
|
68
70
|
email:
|
|
69
71
|
- rcabej@gmail.com
|
|
70
72
|
executables: []
|
|
@@ -74,9 +76,11 @@ files:
|
|
|
74
76
|
- ".gitignore"
|
|
75
77
|
- CODE_OF_CONDUCT.md
|
|
76
78
|
- Gemfile
|
|
79
|
+
- Gemfile.lock
|
|
77
80
|
- LICENSE.txt
|
|
78
81
|
- README.md
|
|
79
82
|
- Rakefile
|
|
83
|
+
- billinfo-0.0.1.gem
|
|
80
84
|
- billinfo.gemspec
|
|
81
85
|
- bin/console
|
|
82
86
|
- bin/setup
|
|
@@ -110,5 +114,6 @@ rubygems_version: 2.5.2.3
|
|
|
110
114
|
signing_key:
|
|
111
115
|
specification_version: 4
|
|
112
116
|
summary: A bill repository. Organizes monthly bills by category. Calculates inclusive/exclusive
|
|
113
|
-
means. Sums categories.
|
|
117
|
+
means. Sums categories. Bug in Display option fixed. Added functionality that permanently
|
|
118
|
+
adds custom categories
|
|
114
119
|
test_files: []
|