sps_bill 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.travis.yml +6 -1
- data/CHANGELOG +9 -0
- data/Gemfile +1 -2
- data/Gemfile.lock +5 -5
- data/README.rdoc +15 -5
- data/lib/sps_bill.rb +1 -5
- data/lib/sps_bill/bill.rb +12 -9
- data/lib/sps_bill/bill_collection.rb +26 -17
- data/lib/sps_bill/bill_parser.rb +83 -37
- data/lib/sps_bill/shell.rb +4 -2
- data/lib/sps_bill/version.rb +1 -1
- data/scripts/data/all_services.csv.sample +70 -0
- data/scripts/data/all_services.sample.pdf +0 -0
- data/scripts/data/elec_and_water_only.csv.sample +53 -0
- data/scripts/data/elec_and_water_only.sample.pdf +0 -0
- data/scripts/full_analysis.R +191 -0
- data/spec/support/bill_examples.rb +1 -1
- data/spec/support/pdf_samples_helper.rb +2 -2
- data/spec/unit/bill_collection_spec.rb +6 -6
- data/spec/unit/shell_spec.rb +1 -1
- data/sps_bill.gemspec +11 -14
- metadata +27 -38
- data/lib/pdf/object_hash.rb +0 -39
- data/lib/pdf/positional_text_receiver.rb +0 -16
- data/lib/pdf/structured_reader.rb +0 -108
- data/lib/pdf/textangle.rb +0 -27
- data/spec/fixtures/pdf_samples/junk_prefix.pdf +0 -71
- data/spec/unit/pdf/object_hash_spec.rb +0 -15
data/lib/sps_bill/version.rb
CHANGED
@@ -0,0 +1,70 @@
|
|
1
|
+
invoice_month,measure,kwh,cubic_m,rate,amount
|
2
|
+
2011-05-01,total_charges,,,,251.44
|
3
|
+
2011-06-01,total_charges,,,,235.7
|
4
|
+
2011-07-01,total_charges,,,,220.05
|
5
|
+
2011-08-01,total_charges,,,,259.2
|
6
|
+
2011-09-01,total_charges,,,,119.97
|
7
|
+
2011-10-01,total_charges,,,,168.86
|
8
|
+
2011-11-01,total_charges,,,,196.46
|
9
|
+
2011-12-01,total_charges,,,,176.54
|
10
|
+
2012-01-01,total_charges,,,,165.74
|
11
|
+
2012-02-01,total_charges,,,,162.64
|
12
|
+
2012-03-01,total_charges,,,,193.2
|
13
|
+
2012-04-01,total_charges,,,,192.48
|
14
|
+
2012-05-01,total_charges,,,,157.31
|
15
|
+
2012-06-01,total_charges,,,,177.63
|
16
|
+
2011-05-01,electricity,4.0,,0.241,0.97
|
17
|
+
2011-05-01,electricity,616.0,,0.2558,157.57
|
18
|
+
2011-06-01,electricity,519.0,,0.2558,132.76
|
19
|
+
2011-07-01,electricity,-14.0,,0.2558,-3.58
|
20
|
+
2011-07-01,electricity,458.0,,0.2728,124.94
|
21
|
+
2011-08-01,electricity,539.0,,0.2728,147.04
|
22
|
+
2011-09-01,electricity,391.0,,0.2728,106.66
|
23
|
+
2011-10-01,electricity,14.0,,0.2728,3.82
|
24
|
+
2011-10-01,electricity,444.0,,0.2698,119.79
|
25
|
+
2011-11-01,electricity,2.0,,0.2728,0.54
|
26
|
+
2011-11-01,electricity,537.0,,0.2698,144.88
|
27
|
+
2011-12-01,electricity,482.0,,0.2698,130.04
|
28
|
+
2012-01-01,electricity,-33.0,,0.2698,-8.9
|
29
|
+
2012-01-01,electricity,450.0,,0.2759,124.16
|
30
|
+
2012-02-01,electricity,421.0,,0.2759,116.15
|
31
|
+
2012-03-01,electricity,526.0,,0.2759,145.13
|
32
|
+
2012-04-01,electricity,16.0,,0.2759,4.41
|
33
|
+
2012-04-01,electricity,482.0,,0.2878,138.72
|
34
|
+
2012-05-01,electricity,-2.0,,0.2759,-0.55
|
35
|
+
2012-05-01,electricity,385.0,,0.2878,110.8
|
36
|
+
2012-06-01,electricity,448.0,,0.2878,128.93
|
37
|
+
2011-05-01,gas,18.0,,0.1799,3.24
|
38
|
+
2011-06-01,gas,15.0,,0.1799,2.7
|
39
|
+
2011-07-01,gas,34.0,,0.1799,6.12
|
40
|
+
2011-08-01,gas,2.0,,0.1799,0.36
|
41
|
+
2011-08-01,gas,25.0,,0.1961,4.9
|
42
|
+
2011-09-01,gas,-1.0,,0.1799,-0.18
|
43
|
+
2011-09-01,gas,-2.0,,0.1961,-0.39
|
44
|
+
2011-10-01,gas,12.0,,0.1961,2.35
|
45
|
+
2011-11-01,gas,12.0,,0.2117,2.54
|
46
|
+
2011-12-01,gas,12.0,,0.2117,2.54
|
47
|
+
2012-01-01,gas,12.0,,0.2117,2.54
|
48
|
+
2012-02-01,gas,11.0,,0.2145,2.36
|
49
|
+
2012-03-01,gas,25.0,,0.2145,5.36
|
50
|
+
2012-04-01,gas,19.0,,0.2145,4.08
|
51
|
+
2012-05-01,gas,-4.0,,0.2145,-0.86
|
52
|
+
2012-05-01,gas,15.0,,0.2216,3.32
|
53
|
+
2012-06-01,gas,15.0,,0.2216,3.32
|
54
|
+
2011-05-01,water,,36.1,1.17,42.24
|
55
|
+
2011-05-01,water,,-3.0,1.4,-4.2
|
56
|
+
2011-06-01,water,,38.7,1.17,45.28
|
57
|
+
2011-07-01,water,,35.0,1.17,40.95
|
58
|
+
2011-08-01,water,,40.0,1.17,46.8
|
59
|
+
2011-08-01,water,,1.2,1.4,1.68
|
60
|
+
2011-09-01,water,,-3.5,1.17,-4.1
|
61
|
+
2011-09-01,water,,-1.2,1.4,-1.68
|
62
|
+
2011-10-01,water,,8.4,1.17,9.83
|
63
|
+
2011-11-01,water,,11.4,1.17,13.34
|
64
|
+
2011-12-01,water,,9.6,1.17,11.23
|
65
|
+
2012-01-01,water,,12.2,1.17,14.28
|
66
|
+
2012-02-01,water,,10.2,1.17,11.93
|
67
|
+
2012-03-01,water,,8.3,1.17,9.72
|
68
|
+
2012-04-01,water,,9.7,1.17,11.35
|
69
|
+
2012-05-01,water,,10.6,1.17,12.4
|
70
|
+
2012-06-01,water,,10.3,1.17,12.05
|
Binary file
|
@@ -0,0 +1,53 @@
|
|
1
|
+
invoice_month,measure,kwh,cubic_m,rate,amount
|
2
|
+
2011-05-01,total_charges,,,,251.44
|
3
|
+
2011-06-01,total_charges,,,,235.7
|
4
|
+
2011-07-01,total_charges,,,,220.05
|
5
|
+
2011-08-01,total_charges,,,,259.2
|
6
|
+
2011-09-01,total_charges,,,,119.97
|
7
|
+
2011-10-01,total_charges,,,,168.86
|
8
|
+
2011-11-01,total_charges,,,,196.46
|
9
|
+
2011-12-01,total_charges,,,,176.54
|
10
|
+
2012-01-01,total_charges,,,,165.74
|
11
|
+
2012-02-01,total_charges,,,,162.64
|
12
|
+
2012-03-01,total_charges,,,,193.2
|
13
|
+
2012-04-01,total_charges,,,,192.48
|
14
|
+
2012-05-01,total_charges,,,,157.31
|
15
|
+
2012-06-01,total_charges,,,,177.63
|
16
|
+
2011-05-01,electricity,4.0,,0.241,0.97
|
17
|
+
2011-05-01,electricity,616.0,,0.2558,157.57
|
18
|
+
2011-06-01,electricity,519.0,,0.2558,132.76
|
19
|
+
2011-07-01,electricity,-14.0,,0.2558,-3.58
|
20
|
+
2011-07-01,electricity,458.0,,0.2728,124.94
|
21
|
+
2011-08-01,electricity,539.0,,0.2728,147.04
|
22
|
+
2011-09-01,electricity,391.0,,0.2728,106.66
|
23
|
+
2011-10-01,electricity,14.0,,0.2728,3.82
|
24
|
+
2011-10-01,electricity,444.0,,0.2698,119.79
|
25
|
+
2011-11-01,electricity,2.0,,0.2728,0.54
|
26
|
+
2011-11-01,electricity,537.0,,0.2698,144.88
|
27
|
+
2011-12-01,electricity,482.0,,0.2698,130.04
|
28
|
+
2012-01-01,electricity,-33.0,,0.2698,-8.9
|
29
|
+
2012-01-01,electricity,450.0,,0.2759,124.16
|
30
|
+
2012-02-01,electricity,421.0,,0.2759,116.15
|
31
|
+
2012-03-01,electricity,526.0,,0.2759,145.13
|
32
|
+
2012-04-01,electricity,16.0,,0.2759,4.41
|
33
|
+
2012-04-01,electricity,482.0,,0.2878,138.72
|
34
|
+
2012-05-01,electricity,-2.0,,0.2759,-0.55
|
35
|
+
2012-05-01,electricity,385.0,,0.2878,110.8
|
36
|
+
2012-06-01,electricity,448.0,,0.2878,128.93
|
37
|
+
2011-05-01,water,,36.1,1.17,42.24
|
38
|
+
2011-05-01,water,,-3.0,1.4,-4.2
|
39
|
+
2011-06-01,water,,38.7,1.17,45.28
|
40
|
+
2011-07-01,water,,35.0,1.17,40.95
|
41
|
+
2011-08-01,water,,40.0,1.17,46.8
|
42
|
+
2011-08-01,water,,1.2,1.4,1.68
|
43
|
+
2011-09-01,water,,-3.5,1.17,-4.1
|
44
|
+
2011-09-01,water,,-1.2,1.4,-1.68
|
45
|
+
2011-10-01,water,,8.4,1.17,9.83
|
46
|
+
2011-11-01,water,,11.4,1.17,13.34
|
47
|
+
2011-12-01,water,,9.6,1.17,11.23
|
48
|
+
2012-01-01,water,,12.2,1.17,14.28
|
49
|
+
2012-02-01,water,,10.2,1.17,11.93
|
50
|
+
2012-03-01,water,,8.3,1.17,9.72
|
51
|
+
2012-04-01,water,,9.7,1.17,11.35
|
52
|
+
2012-05-01,water,,10.6,1.17,12.4
|
53
|
+
2012-06-01,water,,10.3,1.17,12.05
|
Binary file
|
@@ -0,0 +1,191 @@
|
|
1
|
+
#!/usr/bin/Rscript
|
2
|
+
#
|
3
|
+
# This is an example R script that generates a single-page PDF summary.
|
4
|
+
#
|
5
|
+
# It requires two packages to be installed. Do this from the R command line:
|
6
|
+
# install.packages('gplots','zoo')
|
7
|
+
#
|
8
|
+
# Some sample data and example out is provided:
|
9
|
+
#
|
10
|
+
# data/all_services.csv.sample - sample CSV data for a years worth of elec, gas, and water
|
11
|
+
# data/all_services.sample.pdf - PDF analysis produced by this script for all_services.csv.sample
|
12
|
+
# data/elec_and_water_only.csv.sample - sample CSV data for a years worth of elec and water
|
13
|
+
# data/elec_and_water_only.sample.pdf - PDF analysis produced by this script for elec_and_water_only.csv.sample
|
14
|
+
#
|
15
|
+
# Usage:
|
16
|
+
# ./full_analysis.R data_file.csv
|
17
|
+
#
|
18
|
+
# Output is written to a file called 'full_analysis.pdf' in the current directory
|
19
|
+
#
|
20
|
+
# data_file.csv has the collowing columns (with a header row):
|
21
|
+
# invoice_month,measure,kwh,cubic_m,rate,amount
|
22
|
+
#
|
23
|
+
# NB: the script scan_all_bills.sh is an example of how to produce a suitable file
|
24
|
+
#
|
25
|
+
|
26
|
+
# data_file <-'data/all_services.csv.sample'
|
27
|
+
argv <- commandArgs(TRUE)
|
28
|
+
data_file <- argv[1]
|
29
|
+
output_file <- 'full_analysis.pdf'
|
30
|
+
|
31
|
+
cat("Analyzing SP Service billing data from:",data_file,"\n")
|
32
|
+
cat("Results are written to:",output_file,"\n\n")
|
33
|
+
|
34
|
+
# required libs
|
35
|
+
library(gplots)
|
36
|
+
library(zoo)
|
37
|
+
|
38
|
+
#reads: invoice_month,measure,kwh,cubic_m,rate,amount
|
39
|
+
bills <- read.csv(data_file)
|
40
|
+
|
41
|
+
# core data
|
42
|
+
charges <- subset(bills, subset=(measure == 'total_charges'), select = c(-measure,-kwh,-cubic_m,-rate))
|
43
|
+
electricity <- subset(bills, subset=(measure == 'electricity'), select = c(-measure,-cubic_m))
|
44
|
+
gas <- subset(bills, subset=(measure == 'gas'), select = c(-measure,-cubic_m))
|
45
|
+
water <- subset(bills, subset=(measure == 'water'), select = c(-measure,-kwh))
|
46
|
+
|
47
|
+
# moving averages over 3 months
|
48
|
+
ma_over <- 3
|
49
|
+
|
50
|
+
# summarise electricity usage
|
51
|
+
#
|
52
|
+
electricity.raw.kwh_by_month <- tapply(electricity$kwh, electricity$invoice_month, sum)
|
53
|
+
electricity.raw.amount_by_month <- tapply(electricity$amount, electricity$invoice_month, sum)
|
54
|
+
|
55
|
+
kwh <- zoo(
|
56
|
+
as.vector(electricity.raw.kwh_by_month),
|
57
|
+
as.Date(unlist(dimnames(electricity.raw.kwh_by_month)))
|
58
|
+
)
|
59
|
+
amount <- zoo(
|
60
|
+
as.vector(electricity.raw.amount_by_month),
|
61
|
+
as.Date(unlist(dimnames(electricity.raw.amount_by_month)))
|
62
|
+
)
|
63
|
+
meter <- merge(kwh,amount)
|
64
|
+
ma <- rollmean(meter, ma_over, align="center")
|
65
|
+
electricity.timeseries <- merge(meter,ma)
|
66
|
+
|
67
|
+
# summarise gas usage
|
68
|
+
#
|
69
|
+
gas.raw.kwh_by_month <- tapply(gas$kwh, gas$invoice_month, sum)
|
70
|
+
gas.raw.amount_by_month <- tapply(gas$amount, gas$invoice_month, sum)
|
71
|
+
|
72
|
+
kwh <- zoo(
|
73
|
+
as.vector(gas.raw.kwh_by_month),
|
74
|
+
as.Date(unlist(dimnames(gas.raw.kwh_by_month)))
|
75
|
+
)
|
76
|
+
amount <- zoo(
|
77
|
+
as.vector(gas.raw.amount_by_month),
|
78
|
+
as.Date(unlist(dimnames(gas.raw.amount_by_month)))
|
79
|
+
)
|
80
|
+
meter <- merge(kwh,amount)
|
81
|
+
ma <- rollmean(meter, ma_over, align="center")
|
82
|
+
gas.timeseries <- merge(meter,ma)
|
83
|
+
|
84
|
+
|
85
|
+
# summarise water usage
|
86
|
+
#
|
87
|
+
water.raw.cubic_m_by_month <- tapply(water$cubic_m, water$invoice_month, sum)
|
88
|
+
water.raw.amount_by_month <- tapply(water$amount, water$invoice_month, sum)
|
89
|
+
|
90
|
+
cubic_m <- zoo(
|
91
|
+
as.vector(water.raw.cubic_m_by_month),
|
92
|
+
as.Date(unlist(dimnames(water.raw.cubic_m_by_month)))
|
93
|
+
)
|
94
|
+
amount <- zoo(
|
95
|
+
as.vector(water.raw.amount_by_month),
|
96
|
+
as.Date(unlist(dimnames(water.raw.amount_by_month)))
|
97
|
+
)
|
98
|
+
meter <- merge(cubic_m,amount)
|
99
|
+
ma <- rollmean(meter, ma_over, align="center")
|
100
|
+
water.timeseries <- merge(meter,ma)
|
101
|
+
|
102
|
+
# summarise charges
|
103
|
+
#
|
104
|
+
charges.raw.amount_by_month <- tapply(charges$amount, charges$invoice_month, sum)
|
105
|
+
|
106
|
+
amount <- zoo(
|
107
|
+
as.vector(charges.raw.amount_by_month),
|
108
|
+
as.Date(unlist(dimnames(charges.raw.amount_by_month)))
|
109
|
+
)
|
110
|
+
ma <- rollmean(amount, ma_over, align="center")
|
111
|
+
charges.timeseries <- merge(amount,ma)
|
112
|
+
|
113
|
+
# combined timeseries
|
114
|
+
ts <- merge(charges.timeseries,gas.timeseries,electricity.timeseries,water.timeseries)
|
115
|
+
|
116
|
+
|
117
|
+
# begin output
|
118
|
+
pdf(output_file)
|
119
|
+
|
120
|
+
# split the page into regions for plotting
|
121
|
+
par(mfrow=c(3,2))
|
122
|
+
|
123
|
+
# print charge summary
|
124
|
+
charge_summary <- subset(ts, select=c(amount,amount.meter.electricity.timeseries,amount.meter.gas.timeseries,amount.meter.water.timeseries))
|
125
|
+
colnames(charge_summary) <- c('Total','Electricity','Gas','Water')
|
126
|
+
textplot(
|
127
|
+
capture.output(summary(as.matrix(charge_summary))),
|
128
|
+
valign="top", halign="center", mar=c(4, 1, 4, 1) + 0.1
|
129
|
+
)
|
130
|
+
title("Total Charges SGD$")
|
131
|
+
|
132
|
+
# plot charge summary
|
133
|
+
amount <- as.vector(charges.timeseries$amount)
|
134
|
+
bp <- barplot2(amount,
|
135
|
+
main="Total Monthly Bill",
|
136
|
+
names.arg=index(charges.timeseries),
|
137
|
+
ylab="Invoice Amount (SGD$)")
|
138
|
+
lines(bp, as.vector(charges.timeseries$ma), lty="dashed", lwd=2)
|
139
|
+
|
140
|
+
# alternative plot elec usage summary - basic bar chart
|
141
|
+
# barplot(electricity.timeseries$kwh.meter,
|
142
|
+
# main="Electricity Usage",
|
143
|
+
# names.arg=index(electricity.timeseries),
|
144
|
+
# ylab="kwh")
|
145
|
+
|
146
|
+
# plot elec usage summary - bar chart with moving average
|
147
|
+
kwh <- as.vector(electricity.timeseries$kwh.meter)
|
148
|
+
colors <- colorpanel(length(kwh),'red','yellow')
|
149
|
+
bp <- barplot2(kwh,
|
150
|
+
main="Electricity Usage",
|
151
|
+
names.arg=index(electricity.timeseries),
|
152
|
+
col=colors,
|
153
|
+
ylab="kwh")
|
154
|
+
lines(bp, as.vector(electricity.timeseries$kwh.ma), lty="dashed", lwd=2)
|
155
|
+
legend('bottomleft', inset=0.05, legend=c("3m MA"), lty=c("dashed"), bty='o', bg='white')
|
156
|
+
|
157
|
+
# plot elec charges summary - line chart with moving average
|
158
|
+
df <- subset(electricity.timeseries, select=c(amount.meter,amount.ma))
|
159
|
+
x <- index(electricity.timeseries)
|
160
|
+
plot(df, screens=1,
|
161
|
+
lty=c("solid", "dashed"), lwd=c(1,2), col=c('red','black'),
|
162
|
+
main="Electricity Charges", xlab='', ylab="SGD$",
|
163
|
+
xaxt = 'n')
|
164
|
+
axis(1, x, x)
|
165
|
+
legend('bottomleft', legend=c("meter","3m MA"), lty=c("solid", "dashed"), col=c('red','black'), bty='n')
|
166
|
+
|
167
|
+
# plot gas summary
|
168
|
+
kwh <- as.vector(gas.timeseries$kwh.meter)
|
169
|
+
kwh[is.na(kwh)] <- 0 # in case no values
|
170
|
+
colors <- colorpanel(length(kwh),'#0014EB','#0077EB')
|
171
|
+
bp <- barplot2(kwh,
|
172
|
+
main="Gas Usage",
|
173
|
+
names.arg=index(gas.timeseries),
|
174
|
+
col=colors,
|
175
|
+
ylab="kwh")
|
176
|
+
lines(bp, as.vector(gas.timeseries$kwh.ma), lty="dashed", lwd=2)
|
177
|
+
|
178
|
+
# plot water summary
|
179
|
+
cubic_m <- as.vector(water.timeseries$cubic_m.meter)
|
180
|
+
colors <- colorpanel(length(cubic_m),'#00EBEB','#009D62')
|
181
|
+
bp <- barplot2(cubic_m,
|
182
|
+
main="Water Usage",
|
183
|
+
names.arg=index(water.timeseries),
|
184
|
+
col=colors,
|
185
|
+
ylab="m^3")
|
186
|
+
lines(bp, as.vector(water.timeseries$cubic_m.ma), lty="dashed", lwd=2)
|
187
|
+
|
188
|
+
|
189
|
+
cat("Completed analyzing SP Service billing data from:",data_file,"\n")
|
190
|
+
cat("Results are written to:",output_file,"\n\n")
|
191
|
+
|
@@ -20,11 +20,11 @@ module PdfSamplesHelper
|
|
20
20
|
end
|
21
21
|
|
22
22
|
def personal_pdf_sample_names
|
23
|
-
Dir[
|
23
|
+
Dir[personal_pdf_sample_path.join("*.pdf")]
|
24
24
|
end
|
25
25
|
|
26
26
|
def personal_pdf_sample_expectations_path
|
27
|
-
Pathname.new(
|
27
|
+
Pathname.new(personal_pdf_sample_path.join('expectations.yml'))
|
28
28
|
end
|
29
29
|
|
30
30
|
def personal_pdf_sample_expectations
|
@@ -96,9 +96,9 @@ describe SpsBill::BillCollection do
|
|
96
96
|
let(:bills) { SpsBill::BillCollection.new }
|
97
97
|
before do
|
98
98
|
bill_a.instance_variable_set(:@invoice_month, Date.parse('2012-02-01'))
|
99
|
-
bill_a.instance_variable_set(:@electricity_usage, [{ kwh
|
99
|
+
bill_a.instance_variable_set(:@electricity_usage, [{ :kwh => 12.0, :rate => 0.1234, :amount => 12.34 }] )
|
100
100
|
bill_b.instance_variable_set(:@invoice_month, Date.parse('2012-03-01'))
|
101
|
-
bill_b.instance_variable_set(:@electricity_usage, [{ kwh
|
101
|
+
bill_b.instance_variable_set(:@electricity_usage, [{ :kwh => 24.0, :rate => 0.5678, :amount => 56.78 }])
|
102
102
|
bills << bill_a
|
103
103
|
bills << bill_b
|
104
104
|
end
|
@@ -122,9 +122,9 @@ describe SpsBill::BillCollection do
|
|
122
122
|
let(:bills) { SpsBill::BillCollection.new }
|
123
123
|
before do
|
124
124
|
bill_a.instance_variable_set(:@invoice_month, Date.parse('2012-02-01'))
|
125
|
-
bill_a.instance_variable_set(:@gas_usage, [{ kwh
|
125
|
+
bill_a.instance_variable_set(:@gas_usage, [{ :kwh => 12.0, :rate => 0.1234, :amount => 12.34 }] )
|
126
126
|
bill_b.instance_variable_set(:@invoice_month, Date.parse('2012-03-01'))
|
127
|
-
bill_b.instance_variable_set(:@gas_usage, [{ kwh
|
127
|
+
bill_b.instance_variable_set(:@gas_usage, [{ :kwh => 24.0, :rate => 0.5678, :amount => 56.78 }])
|
128
128
|
bills << bill_a
|
129
129
|
bills << bill_b
|
130
130
|
end
|
@@ -147,9 +147,9 @@ describe SpsBill::BillCollection do
|
|
147
147
|
let(:bills) { SpsBill::BillCollection.new }
|
148
148
|
before do
|
149
149
|
bill_a.instance_variable_set(:@invoice_month, Date.parse('2012-02-01'))
|
150
|
-
bill_a.instance_variable_set(:@water_usage, [{ cubic_m
|
150
|
+
bill_a.instance_variable_set(:@water_usage, [{ :cubic_m => 12.0, :rate => 0.1234, :amount => 12.34 }] )
|
151
151
|
bill_b.instance_variable_set(:@invoice_month, Date.parse('2012-03-01'))
|
152
|
-
bill_b.instance_variable_set(:@water_usage, [{ cubic_m
|
152
|
+
bill_b.instance_variable_set(:@water_usage, [{ :cubic_m => 24.0, :rate => 0.5678, :amount => 56.78 }])
|
153
153
|
bills << bill_a
|
154
154
|
bills << bill_b
|
155
155
|
end
|
data/spec/unit/shell_spec.rb
CHANGED
@@ -6,7 +6,7 @@ describe SpsBill::Shell do
|
|
6
6
|
describe "##usage" do
|
7
7
|
subject { SpsBill::Shell.usage }
|
8
8
|
it "should print help" do
|
9
|
-
STDOUT.should_receive(:puts)
|
9
|
+
STDOUT.should_receive(:puts) if RUBY_ENGINE.to_s != 'jruby' # cannot get this to work with JRuby yet
|
10
10
|
subject
|
11
11
|
end
|
12
12
|
end
|
data/sps_bill.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = "sps_bill"
|
8
|
-
s.version = "0.1.
|
8
|
+
s.version = "0.1.1"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Paul Gallagher"]
|
12
|
-
s.date = "2012-
|
12
|
+
s.date = "2012-08-01"
|
13
13
|
s.description = "a library that can read SP Services PDF bills and extract and summarize the bill details"
|
14
14
|
s.email = "gallagher.paul@gmail.com"
|
15
15
|
s.executables = ["sps_bill"]
|
@@ -22,6 +22,7 @@ Gem::Specification.new do |s|
|
|
22
22
|
".rspec",
|
23
23
|
".rvmrc",
|
24
24
|
".travis.yml",
|
25
|
+
"CHANGELOG",
|
25
26
|
"Gemfile",
|
26
27
|
"Gemfile.lock",
|
27
28
|
"Guardfile",
|
@@ -29,10 +30,6 @@ Gem::Specification.new do |s|
|
|
29
30
|
"README.rdoc",
|
30
31
|
"Rakefile",
|
31
32
|
"bin/sps_bill",
|
32
|
-
"lib/pdf/object_hash.rb",
|
33
|
-
"lib/pdf/positional_text_receiver.rb",
|
34
|
-
"lib/pdf/structured_reader.rb",
|
35
|
-
"lib/pdf/textangle.rb",
|
36
33
|
"lib/sps_bill.rb",
|
37
34
|
"lib/sps_bill/bill.rb",
|
38
35
|
"lib/sps_bill/bill_collection.rb",
|
@@ -40,9 +37,13 @@ Gem::Specification.new do |s|
|
|
40
37
|
"lib/sps_bill/shell.rb",
|
41
38
|
"lib/sps_bill/version.rb",
|
42
39
|
"scripts/data/.gitkeep",
|
40
|
+
"scripts/data/all_services.csv.sample",
|
41
|
+
"scripts/data/all_services.sample.pdf",
|
42
|
+
"scripts/data/elec_and_water_only.csv.sample",
|
43
|
+
"scripts/data/elec_and_water_only.sample.pdf",
|
44
|
+
"scripts/full_analysis.R",
|
43
45
|
"scripts/scan_all_bills.sh",
|
44
46
|
"spec/fixtures/pdf_samples/.gitkeep",
|
45
|
-
"spec/fixtures/pdf_samples/junk_prefix.pdf",
|
46
47
|
"spec/fixtures/personal_pdf_samples/.gitkeep",
|
47
48
|
"spec/fixtures/personal_pdf_samples/expectations.yml.sample",
|
48
49
|
"spec/integration/personal_samples_spec.rb",
|
@@ -51,7 +52,6 @@ Gem::Specification.new do |s|
|
|
51
52
|
"spec/support/pdf_samples_helper.rb",
|
52
53
|
"spec/unit/bill_collection_spec.rb",
|
53
54
|
"spec/unit/bill_spec.rb",
|
54
|
-
"spec/unit/pdf/object_hash_spec.rb",
|
55
55
|
"spec/unit/shell_spec.rb",
|
56
56
|
"sps_bill.gemspec"
|
57
57
|
]
|
@@ -65,32 +65,29 @@ Gem::Specification.new do |s|
|
|
65
65
|
s.specification_version = 3
|
66
66
|
|
67
67
|
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
68
|
-
s.add_runtime_dependency(%q<pdf-reader>, ["
|
68
|
+
s.add_runtime_dependency(%q<pdf-reader-turtletext>, ["~> 0.2.2"])
|
69
69
|
s.add_runtime_dependency(%q<getoptions>, ["~> 0.3"])
|
70
70
|
s.add_development_dependency(%q<bundler>, ["~> 1.1.4"])
|
71
71
|
s.add_development_dependency(%q<jeweler>, ["~> 1.6.4"])
|
72
|
-
s.add_development_dependency(%q<rcov>, [">= 0"])
|
73
72
|
s.add_development_dependency(%q<rake>, ["~> 0.9.2.2"])
|
74
73
|
s.add_development_dependency(%q<rspec>, ["~> 2.8.0"])
|
75
74
|
s.add_development_dependency(%q<rdoc>, ["~> 3.11"])
|
76
75
|
s.add_development_dependency(%q<guard-rspec>, [">= 0"])
|
77
76
|
else
|
78
|
-
s.add_dependency(%q<pdf-reader>, ["
|
77
|
+
s.add_dependency(%q<pdf-reader-turtletext>, ["~> 0.2.2"])
|
79
78
|
s.add_dependency(%q<getoptions>, ["~> 0.3"])
|
80
79
|
s.add_dependency(%q<bundler>, ["~> 1.1.4"])
|
81
80
|
s.add_dependency(%q<jeweler>, ["~> 1.6.4"])
|
82
|
-
s.add_dependency(%q<rcov>, [">= 0"])
|
83
81
|
s.add_dependency(%q<rake>, ["~> 0.9.2.2"])
|
84
82
|
s.add_dependency(%q<rspec>, ["~> 2.8.0"])
|
85
83
|
s.add_dependency(%q<rdoc>, ["~> 3.11"])
|
86
84
|
s.add_dependency(%q<guard-rspec>, [">= 0"])
|
87
85
|
end
|
88
86
|
else
|
89
|
-
s.add_dependency(%q<pdf-reader>, ["
|
87
|
+
s.add_dependency(%q<pdf-reader-turtletext>, ["~> 0.2.2"])
|
90
88
|
s.add_dependency(%q<getoptions>, ["~> 0.3"])
|
91
89
|
s.add_dependency(%q<bundler>, ["~> 1.1.4"])
|
92
90
|
s.add_dependency(%q<jeweler>, ["~> 1.6.4"])
|
93
|
-
s.add_dependency(%q<rcov>, [">= 0"])
|
94
91
|
s.add_dependency(%q<rake>, ["~> 0.9.2.2"])
|
95
92
|
s.add_dependency(%q<rspec>, ["~> 2.8.0"])
|
96
93
|
s.add_dependency(%q<rdoc>, ["~> 3.11"])
|