orsos 0.0.2 → 0.0.3
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 +4 -4
- data/README.md +4 -1
- data/lib/orsos/commands/get.rb +3 -0
- data/lib/orsos/version.rb +1 -1
- data/lib/orsos/webdownloader.rb +15 -9
- data/orsos.gemspec +3 -3
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4daeccd073d079878e80756f06b33222d04b213f
|
4
|
+
data.tar.gz: 1e6971e2368992ebb19f0a5f198941208a791d1b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 184aa25f26a56421b842dff289c72dfcf5743e6cc956a82b29628744872afcffe782ad7a8828c2d618a54efa249eac596092ba4f130c21f3138b8dde59e1eb10
|
7
|
+
data.tar.gz: fb54071bd1ac435393629112bf0e4a1f15de323727065ee6279bdfe15bbb2c5f3a207ce46f8a5cf50e5a792d139cc7667c3a8e8d9c995c6cbea90b72a4ee7894
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,10 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
orsos (0.0.
|
4
|
+
orsos (0.0.3)
|
5
|
+
mechanize
|
6
|
+
rest_client (~> 1.7.3)
|
7
|
+
thor
|
5
8
|
|
6
9
|
GEM
|
7
10
|
remote: https://rubygems.org/
|
@@ -58,10 +61,7 @@ PLATFORMS
|
|
58
61
|
|
59
62
|
DEPENDENCIES
|
60
63
|
bundler (~> 1.6)
|
61
|
-
mechanize
|
62
64
|
orsos!
|
63
65
|
pry-byebug
|
64
66
|
rake
|
65
67
|
repl_rake
|
66
|
-
rest_client (~> 1.7.3)
|
67
|
-
thor
|
data/README.md
CHANGED
@@ -3,10 +3,13 @@
|
|
3
3
|
Oregon Secretary of State Website Client. Use this tool to easily download transactions, candidate filings and committees excel files. Also provides a client to Hack Oregon API
|
4
4
|
|
5
5
|
## TODO
|
6
|
-
- Transactions by commitee filing id
|
7
6
|
- Candidate Filings
|
8
7
|
- Committees
|
9
8
|
|
9
|
+
## Requirements
|
10
|
+
- Only tested with Ruby 2.1.2
|
11
|
+
- If you want CSV support you'll need to install CSVKit (in2csv binary) or CatDoc (xls2csv).
|
12
|
+
|
10
13
|
## Installation
|
11
14
|
|
12
15
|
Add this line to your application's Gemfile:
|
data/lib/orsos/commands/get.rb
CHANGED
@@ -9,6 +9,7 @@ module Orsos::Commands
|
|
9
9
|
option :single_file, type: :boolean, desc: 'search and save data in date range as a single file rather than one search per day'
|
10
10
|
option :in2csv, type: :boolean, desc: 'use in2csv to convert downloaded xls to csv'
|
11
11
|
option :xls2csv, type: :boolean, desc: 'use xls2csv to convert downloaded xls to csv'
|
12
|
+
option :stdout, type: :boolean, desc: 'output to stdout'
|
12
13
|
def transactions(from, to=Date.today)
|
13
14
|
from_date = case from
|
14
15
|
when Date
|
@@ -47,6 +48,7 @@ module Orsos::Commands
|
|
47
48
|
to_date: to_date,
|
48
49
|
filename: filename,
|
49
50
|
csvbin: csvbin,
|
51
|
+
stdout: options['stdout'],
|
50
52
|
options: trans_opts
|
51
53
|
|
52
54
|
else
|
@@ -58,6 +60,7 @@ module Orsos::Commands
|
|
58
60
|
to_date: date,
|
59
61
|
filename: filename,
|
60
62
|
csvbin: csvbin,
|
63
|
+
stdout: options['stdout'],
|
61
64
|
options: trans_opts
|
62
65
|
end
|
63
66
|
end
|
data/lib/orsos/version.rb
CHANGED
data/lib/orsos/webdownloader.rb
CHANGED
@@ -2,19 +2,23 @@ require 'mechanize'
|
|
2
2
|
require 'logger'
|
3
3
|
require 'mkmf'
|
4
4
|
|
5
|
+
module MakeMakefile::Logging
|
6
|
+
@logfile = File::NULL
|
7
|
+
end
|
8
|
+
|
5
9
|
class Orsos::Webdownloader
|
6
10
|
def initialize(verbose=false)
|
7
11
|
@verbose = verbose
|
8
12
|
end
|
9
13
|
|
10
|
-
def save_campaign_finance_transactions from_date:, to_date:, filename: , csvbin:, options: {}
|
11
|
-
puts "downloading transactions for #{from_date.strftime('%Y-%m-%d')} till #{to_date.strftime('%Y-%m-%d')}"
|
14
|
+
def save_campaign_finance_transactions from_date:, to_date:, filename: , csvbin:, stdout:, options: {}
|
15
|
+
puts "downloading transactions for #{from_date.strftime('%Y-%m-%d')} till #{to_date.strftime('%Y-%m-%d')}" if !stdout
|
12
16
|
|
13
17
|
export_page = download_campaign_finance_transactions from_date: from_date, to_date: to_date, filer_id: options['filer_id']
|
14
18
|
raise "could not download campaign finance transactions" if export_page.nil?
|
15
19
|
|
16
|
-
if !csvbin.nil?
|
17
|
-
csvpath =
|
20
|
+
data = if !csvbin.nil?
|
21
|
+
csvpath = find_executable0 csvbin
|
18
22
|
raise "could not find #{csvbin} in $PATH" if csvpath.nil?
|
19
23
|
file = Tempfile.new(['xls2csv-', '.xls'])
|
20
24
|
file.binmode
|
@@ -22,17 +26,19 @@ class Orsos::Webdownloader
|
|
22
26
|
file.write(export_page.body)
|
23
27
|
file.rewind
|
24
28
|
|
25
|
-
|
26
|
-
|
27
|
-
File.open(filename, 'wb') {|f| f.write(data) } if data
|
29
|
+
`#{csvpath} #{file.path}`
|
28
30
|
ensure
|
29
31
|
file.close
|
30
32
|
file.unlink
|
31
33
|
end
|
34
|
+
else
|
35
|
+
export_page.body
|
36
|
+
end
|
32
37
|
|
33
|
-
|
38
|
+
if stdout
|
39
|
+
$stdout.write data
|
34
40
|
else
|
35
|
-
File.open(filename, 'wb') {|f| f.write(
|
41
|
+
File.open(filename, 'wb') {|f| f.write(data) }
|
36
42
|
puts "saved transactions for #{from_date.strftime("%Y-%m-%d")} till #{to_date.strftime('%Y-%m-%d')} to #{filename}"
|
37
43
|
end
|
38
44
|
end
|
data/orsos.gemspec
CHANGED
@@ -20,7 +20,7 @@ Gem::Specification.new do |spec|
|
|
20
20
|
|
21
21
|
spec.add_development_dependency "bundler", "~> 1.6"
|
22
22
|
spec.add_development_dependency "rake"
|
23
|
-
spec.
|
24
|
-
spec.
|
25
|
-
spec.
|
23
|
+
spec.add_dependency "mechanize"
|
24
|
+
spec.add_dependency "thor"
|
25
|
+
spec.add_dependency "rest_client", "~> 1.7.3"
|
26
26
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: orsos
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jonathan Chang
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-10-
|
11
|
+
date: 2014-10-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -45,7 +45,7 @@ dependencies:
|
|
45
45
|
- - ">="
|
46
46
|
- !ruby/object:Gem::Version
|
47
47
|
version: '0'
|
48
|
-
type: :
|
48
|
+
type: :runtime
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
@@ -59,7 +59,7 @@ dependencies:
|
|
59
59
|
- - ">="
|
60
60
|
- !ruby/object:Gem::Version
|
61
61
|
version: '0'
|
62
|
-
type: :
|
62
|
+
type: :runtime
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
@@ -73,7 +73,7 @@ dependencies:
|
|
73
73
|
- - "~>"
|
74
74
|
- !ruby/object:Gem::Version
|
75
75
|
version: 1.7.3
|
76
|
-
type: :
|
76
|
+
type: :runtime
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|