douglas-ne-checks 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +18 -0
- data/.travis.yml +6 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +97 -0
- data/Rakefile +6 -0
- data/douglas-ne-checks.gemspec +31 -0
- data/lib/.rspec +2 -0
- data/lib/douglas/ne/checks/file.rb +80 -0
- data/lib/douglas/ne/checks/version.rb +3 -0
- data/lib/douglas/ne/checks.rb +2 -0
- data/spec/data/2013-06-04.htm +1993 -0
- data/spec/data/2013-09-09.htm +1754 -0
- data/spec/file_spec.rb +115 -0
- data/spec/spec_helper.rb +31 -0
- metadata +189 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 33edfc3be6ddd141940d567939b4b5d143ef0e96
|
4
|
+
data.tar.gz: 17d5aea2e1669bb5cd1e5dd9235d4226f8c2dcba
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: b30239590eb4d942908e519b46fabde531475ca8d362d98edd70ae6b7678e09f3bd8d58af0a2f3478bda2eac4aa6fb12a40fd4df9af64c11a931e032e19f0c72
|
7
|
+
data.tar.gz: 7e6890fac1c8788b7d97f902d68a80e6b4b145b175a6d35351fe26ab830fa17c803fcfb1c2adac26e4577bc2839e57ceb534a7781a4873aab0d3ed548b7da0ab
|
data/.gitignore
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2013 Aramis Group, LLC dba code lever
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,97 @@
|
|
1
|
+
# Douglas::NE::Checks
|
2
|
+
[![Build Status](https://travis-ci.org/code-lever/douglas-ne-checks.png)](https://travis-ci.org/code-lever/douglas-ne-checks) [![Dependency Status](https://gemnasium.com/code-lever/douglas-ne-checks.png)](https://gemnasium.com/code-lever/douglas-ne-checks) [![Code Climate](https://codeclimate.com/github/code-lever/douglas-ne-checks.png)](https://codeclimate.com/github/code-lever/douglas-ne-checks)
|
3
|
+
|
4
|
+
Inspired by [@OpenNebraska](https://twitter.com/OpenNebraska)'s presentation @ [HOW Conf 2013](http://www.howconf.org), I figured I'd do a little civic hacking.
|
5
|
+
|
6
|
+
This gem will convert (as of the time of writing, of course) the [HTML dumps of supplier's checks](http://www.douglascountyclerk.org/supplierchecks) that the Douglas County Clerk's office provides weekly.
|
7
|
+
|
8
|
+
So instead of this: [2013-09-10 check dump](http://www.douglascountyclerk.org/images/stories/supplierchecks/2013-09-10%20Supplier%20Checks%20by%20dept.htm).
|
9
|
+
|
10
|
+
We can have this:
|
11
|
+
|
12
|
+
{
|
13
|
+
"11111 - GENERAL" => {
|
14
|
+
"501015 - REAL ESTATE APPRAISE" => [
|
15
|
+
[0] {
|
16
|
+
:supplier => "COSTAR REALTY INFORMATION INC",
|
17
|
+
:account => "42411 - MAINTENANCE CONTRACT",
|
18
|
+
:description => "COSTAR GROUP, INC - Inv. 102152750 (August)",
|
19
|
+
:invoice => "102152750",
|
20
|
+
:check_number => 363593,
|
21
|
+
:check_date => #<Date: 2013-09-10 ((2456546j,0s,0n),+0s,2299161j)>,
|
22
|
+
:check_status => "NEGOTIABLE",
|
23
|
+
:amount => 500.0
|
24
|
+
}
|
25
|
+
],
|
26
|
+
"502011 - ADMIN COUNTY CLERK" => [
|
27
|
+
[0] {
|
28
|
+
:supplier => "TOSHIBA FINANCIAL SERVICES",
|
29
|
+
:account => "42471 - LEASE COPY MACHINES",
|
30
|
+
:description => "CO CLERK S/N CEI02847 ESTUDIO 855/CONTRACT 500-279467-000",
|
31
|
+
:invoice => "233826767",
|
32
|
+
:check_number => 363494,
|
33
|
+
:check_date => #<Date: 2013-09-10 ((2456546j,0s,0n),+0s,2299161j)>,
|
34
|
+
:check_status => "NEGOTIABLE",
|
35
|
+
:amount => 334.72
|
36
|
+
}
|
37
|
+
],
|
38
|
+
"502012 - RECORDS COUNTY CLERK" => [
|
39
|
+
[0] {
|
40
|
+
:supplier => "DOT COMM",
|
41
|
+
:account => "42411 - MAINTENANCE CONTRACT",
|
42
|
+
:description => "PSI Capture annual maintenance.",
|
43
|
+
:invoice => "93311",
|
44
|
+
:check_number => 363484,
|
45
|
+
:check_date => #<Date: 2013-09-10 ((2456546j,0s,0n),+0s,2299161j)>,
|
46
|
+
:check_status => "NEGOTIABLE",
|
47
|
+
:amount => 575.0
|
48
|
+
}
|
49
|
+
],
|
50
|
+
# ...
|
51
|
+
}
|
52
|
+
# ...
|
53
|
+
}
|
54
|
+
|
55
|
+
Where the basic structure is:
|
56
|
+
|
57
|
+
{
|
58
|
+
"FUND 1" => {
|
59
|
+
"ORGANIZATION 1" => [
|
60
|
+
[0] { entry 0 },
|
61
|
+
[1] { entry 0 }
|
62
|
+
],
|
63
|
+
"ORGANIZATION 2" => [
|
64
|
+
[0] { entry 0 }
|
65
|
+
],
|
66
|
+
}
|
67
|
+
"FUND 2" => { ... }
|
68
|
+
}
|
69
|
+
|
70
|
+
|
71
|
+
* http://hackomaha.mindmixer.com/identifying-hack-omaha-projects/make-a-government-checkbook-app
|
72
|
+
|
73
|
+
## Installation
|
74
|
+
|
75
|
+
Add this line to your application's Gemfile:
|
76
|
+
|
77
|
+
gem 'douglas-ne-checks'
|
78
|
+
|
79
|
+
And then execute:
|
80
|
+
|
81
|
+
$ bundle
|
82
|
+
|
83
|
+
Or install it yourself as:
|
84
|
+
|
85
|
+
$ gem install douglas-ne-checks
|
86
|
+
|
87
|
+
## Usage
|
88
|
+
|
89
|
+
TODO: Write usage instructions here
|
90
|
+
|
91
|
+
## Contributing
|
92
|
+
|
93
|
+
1. Fork it
|
94
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
95
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
96
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
97
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'douglas/ne/checks/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "douglas-ne-checks"
|
8
|
+
spec.version = Douglas::NE::Checks::VERSION
|
9
|
+
spec.authors = ["Nick Veys"]
|
10
|
+
spec.email = ["nick@codelever.com"]
|
11
|
+
spec.description = %q{Read and convert Douglas County NE check dumps to something more useful.}
|
12
|
+
spec.summary = %q{Douglas County, NE check log reader}
|
13
|
+
spec.homepage = ""
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files`.split($/)
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_dependency 'nokogiri', '~> 1.0'
|
22
|
+
|
23
|
+
spec.add_development_dependency 'awesome_print'
|
24
|
+
spec.add_development_dependency 'bundler', '~> 1.3'
|
25
|
+
spec.add_development_dependency 'ci_reporter', '= 1.8.4'
|
26
|
+
spec.add_development_dependency 'rake', '~> 10.0'
|
27
|
+
spec.add_development_dependency 'rspec', '~> 2.13'
|
28
|
+
spec.add_development_dependency 'simplecov'
|
29
|
+
spec.add_development_dependency 'simplecov-gem-adapter'
|
30
|
+
spec.add_development_dependency 'simplecov-rcov'
|
31
|
+
end
|
data/lib/.rspec
ADDED
@@ -0,0 +1,80 @@
|
|
1
|
+
require 'nokogiri'
|
2
|
+
require 'open-uri'
|
3
|
+
|
4
|
+
module Douglas; module NE; module Checks
|
5
|
+
|
6
|
+
class File
|
7
|
+
|
8
|
+
attr_reader :funds
|
9
|
+
|
10
|
+
def initialize(uri)
|
11
|
+
|
12
|
+
@funds = {}
|
13
|
+
|
14
|
+
# open the file and snag the two main elements
|
15
|
+
doc = Nokogiri::HTML(open(uri))
|
16
|
+
title = doc.at_xpath('//discotitlexhtml')
|
17
|
+
table = doc.at_xpath('//body/table')
|
18
|
+
|
19
|
+
# initialize the state tracking variables
|
20
|
+
fund_rows = 0
|
21
|
+
fund = nil
|
22
|
+
org_rows = 0
|
23
|
+
org = nil
|
24
|
+
|
25
|
+
table.children.each_with_index do |row, idx|
|
26
|
+
|
27
|
+
# first row is a header
|
28
|
+
next if idx == 0
|
29
|
+
|
30
|
+
cols = row.children
|
31
|
+
|
32
|
+
# rows with TOTAL don't include useful data
|
33
|
+
if cols.last.text.include? 'TOTAL'
|
34
|
+
fund_rows -= 1
|
35
|
+
next
|
36
|
+
end
|
37
|
+
|
38
|
+
# first cell has number of rows for the fund, if we're not already in one
|
39
|
+
offset = 0
|
40
|
+
if fund_rows <= 0
|
41
|
+
fund_rows = cols[0]['rowspan'].to_i
|
42
|
+
org_rows = 0
|
43
|
+
fund = cols[0].text.strip
|
44
|
+
@funds[fund] = {}
|
45
|
+
offset += 1
|
46
|
+
end
|
47
|
+
|
48
|
+
# second cell has number of rows for the organization, if we're not already in one
|
49
|
+
if org_rows == 0
|
50
|
+
org_rows = cols[0 + offset]['rowspan'].to_i
|
51
|
+
org = cols[0 + offset].text.strip
|
52
|
+
@funds[fund][org] = []
|
53
|
+
offset += 1
|
54
|
+
end
|
55
|
+
|
56
|
+
# finally, data, pick it all out!
|
57
|
+
values = cols.drop(offset).map(&:text)
|
58
|
+
@funds[fund][org] << {
|
59
|
+
supplier: values[0],
|
60
|
+
account: values[1],
|
61
|
+
description: values[2],
|
62
|
+
invoice: values[3],
|
63
|
+
check_number: values[4].to_i,
|
64
|
+
check_date: Date.parse(values[5]),
|
65
|
+
check_status: values[6],
|
66
|
+
amount: values[7].gsub(/,/, '').to_f,
|
67
|
+
}
|
68
|
+
|
69
|
+
fund_rows -= 1
|
70
|
+
org_rows -= 1
|
71
|
+
|
72
|
+
end
|
73
|
+
|
74
|
+
rescue
|
75
|
+
raise ArgumentError, 'File does not appear to be a Supplier Checks Report by Department report'
|
76
|
+
end
|
77
|
+
|
78
|
+
end
|
79
|
+
|
80
|
+
end; end; end
|