orsos 0.0.6 → 0.0.7

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 583b7c177d70e612ff2119874e9929f089942e53
4
- data.tar.gz: 6b0399d8c7e9076e019323a70cab445ba0905270
3
+ metadata.gz: 4b9ba5e8b35fc60d3a36534f70e73f04f7f8962c
4
+ data.tar.gz: f8cb4234383f9a4d771992b794827ccb779352c9
5
5
  SHA512:
6
- metadata.gz: fa7196f3a009cb2d5b2f6ec3d55bfb5b2c2876d4d559367d526bb5c351e244ce849b924bfe293da284e11e4caeb89db4c36c37fc582397fd452255b95205a12e
7
- data.tar.gz: 79182511ef087494b19b1ac2a739d977ec38f51985ae62bebb0dca419bf27d282b7e1e95d437ed2738f138eab43222e314616c5f4fcd68bf2dcf660c857ef5c0
6
+ metadata.gz: 3a3024f06a558ea6e41021c65adcfefd0638f964bde5c611a075e12edf591f7e51d5783850fbef426f1fa4c3de27ce483be97bc10f4dafe567616cb268d75188
7
+ data.tar.gz: b0d0b12f00cc4e49c4c4120eb0dbcedea790c77c788b1ae22a28763a97ad6800f1fa863f31b41327932d165c6d00fd20a81311e99e0b8955e6b807e82b00eb41
data/README.md CHANGED
@@ -3,8 +3,7 @@
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
- - Candidate Filings
7
- - Committees
6
+ - add more query params to actions
8
7
 
9
8
  ## Requirements
10
9
  - Only tested with Ruby 2.1.2
@@ -86,8 +85,25 @@ TODO: Write usage instructions here
86
85
 
87
86
  $ orsos get help
88
87
  get commands:
89
- orsos get help [COMMAND] # Describe subcommands or one specific subcommand
90
- orsos get transactions FROM [TO] # Download campaign finance transactions daily between FROM ti...
88
+ orsos get candidate_filings FROM [TO] # Download candidate_filings between FROM till TO into sos_candidate_filings_{from %Y%m%d}-{to %Y%m%d}-{current time stamp}. eg., orsos get candidate_filings 20...
89
+ orsos get committees # Download committees information sos_committees_{search query}. eg., orsos get committees kitzhaber.
90
+ orsos get help [COMMAND] # Describe subcommands or one specific subcommand
91
+ orsos get transactions FROM [TO] # Download campaign finance transactions daily between FROM till TO and saves each day to sos_transactions_{%Y%m%d}-{current time stamp}. eg., orsos get transac...
92
+
93
+ Options:
94
+ [--in2csv], [--no-in2csv] # use in2csv to convert downloaded xls to csv
95
+ [--xls2csv], [--no-xls2csv] # use xls2csv to convert downloaded xls to csv
96
+ [--stdout], [--no-stdout] # output to stdout
97
+ [--verbose], [--no-verbose] # turn on verbose logging of search
98
+
99
+ $ orsos get transactions 2014-10-21 2014-10-22
100
+ downloading transactions for 2014-10-21
101
+ saved transactions for 2014-10-21 to sos_transactions_20141021-20141022121911.xls
102
+ downloading transactions for 2014-10-22
103
+ saved transactions for 2014-10-22 to sos_transactions_20141022-20141022121927.xls
104
+
105
+ $ ls *.xls
106
+ sos_transactions_20141021-20141022121911.xls sos_transactions_20141022-20141022121927.xls
91
107
 
92
108
  $ orsos get transactions 2014-10-21 2014-10-22
93
109
  downloading transactions for 2014-10-21
@@ -98,6 +114,24 @@ TODO: Write usage instructions here
98
114
  $ ls *.xls
99
115
  sos_transactions_20141021-20141022121911.xls sos_transactions_20141022-20141022121927.xls
100
116
 
117
+ $ orsos get transactions 2014-10-01 2014-10-02 --filer_id=13920 --single-file --in2csv --stdout | head -n 5
118
+ Tran Id,Original Id,Tran Date,Tran Status,Filer,Contributor/Payee,Sub Type,Amount,Aggregate Amount,Contributor/Payee Committee ID,Filer Id,Attest By Name,Attest Date,Review By Name,Review Date,Due Date,Occptn Ltr Date,Pymt Sched Txt,Purp Desc,Intrst Rate,Check Nbr,Tran Stsfd Ind,Filed By Name,Filed Date,Addr book Agent Name,Book Type,Title Txt,Occptn Txt,Emp Name,Emp City,Emp State,Employ Ind,Self Employ Ind,Addr Line1,Addr Line2,City,State,Zip,Zip Plus Four,County,Purpose Codes,Exp Date
119
+ 1850201,1850201,10/02/2014,Original,Kitzhaber for Governor,Anne Philiben,Cash Contribution,100.0,150.0,,13920,Kevin F Neely,10/02/2014,eliack,10/16/2014,10/09/2014,,,,,,N,Kevin F Neely,10/02/2014,,Individual,,,,,,Y,N,1114 SE Palmwood Ct,,Bend,OR,97702,,,,
120
+ 1850213,1850213,10/02/2014,Original,Kitzhaber for Governor,Patrick Egan,Cash Contribution,500.0,500.0,,13920,Kevin F Neely,10/02/2014,eliack,10/16/2014,10/09/2014,,,,,,N,Kevin F Neely,10/02/2014,,Individual,,Vice president,Pacific Power,Portland,OR,N,N,55 Aquinas St,,Lake Oswego,OR,97035,,,,
121
+ 1850216,1850216,10/02/2014,Original,Kitzhaber for Governor,Miscellaneous Cash Contributions $100 and under ,Cash Contribution,980.0,,,13920,Kevin F Neely,10/02/2014,,,10/09/2014,,,,,,N,Kevin F Neely,10/02/2014,,,,,,,,N,N,,,,,,,,,
122
+ 1847069,1847069,10/01/2014,Original,Kitzhaber for Governor,Alan Hilles,Cash Contribution,20.0,180.0,,13920,Kevin F Neely,10/01/2014,eliack,10/16/2014,10/08/2014,,,,,,N,Kevin F Neely,10/01/2014,,Individual,,physician,Bend Memorial Clinic,Bend,OR,N,N,2874 NW Fairway Hts Dr,,Bend,OR,97701,,,,
123
+
124
+ $ orsos get committees --committee-name-contains=kitzhaber --in2csv --stdout
125
+ Committee Id,Committee Name,Committee Type,Committee SubType,Candidate Office,Candidate Office Group,Filing Date,Organization Filing Date,Treasurer First Name,Treasurer Last Name,Treasurer Mailing Address,Treasurer Work Phone,Treasurer Fax,Candidate First Name,Candidate Last Name,Candidate Maling Address,Candidate Work Phone,Candidate Residence Phone,Candidate Fax,Candidate Email,Active Election,Measure
126
+ 13920,Kitzhaber for Governor,CC,,statewide,Governor,05/28/2014,09/02/2009,Kevin,Neely,PO Box 42307 Portland OR 97242,,(503)295-0670,John,Kitzhaber,PO Box 42307 Portland OR 97242,,,,info@c-esystems.com,2014 General Election,
127
+
128
+ $ orsos get candidate_filings 2014-08-01 2014-10-01 --in2csv --stdout | head -n 5
129
+ Election Txt,Election Year,Office Group,ID Nbr,Office,Candidate Office,Candidate File RSN,File Mthd Ind,Filetype Descr,Party Descr,Major Party Ind,Cand Ballot Name Txt,Occptn Txt,Education Bckgrnd Txt,Occptn Bkgrnd Txt,School - Grade - Diploma/Degree/Certificate - Course of Study,Prev Govt Bkgrnd Txt,Judge Incbnt Ind,Qlf Ind,Filed Date,File Fee Rfnd Date,Witdrw Date,Withdrw Resn Txt,Pttn File Date,Pttn Sgnr Rqd Nbr,Pttn Signr Filed Nbr,Pttn Cmplt Date,Ballot Order Nbr,Prfx Name Cd,First Name,Mdle Name,Last Name,Sufx Name,Title Txt,Mailing Addr Line 1,Mailing Addr Line 2,Mailing City Name,Mailing St Cd,Mailing Zip Code,Mailing Zip Plus Four,Residence Addr Line 1,Residence Addr Line 2,Residence City Name,Residence St Cd,Residence Zip code,Residence Zip Plus Four,Home Phone,Cell Phone,Fax Phone,Email,Work Phone,Web Address
130
+ 2014 General Election,2014,State Representative,1251,51st District,"State Representative, 51st District",15697,P,Minor Party,Libertarian,N,Jodi Bailey,"Membership Director, Building a Better America Council",,"Small Business owner, Sales, National Builders Hardware",,Happy Valley Police & Public Safety Committee ,N,Y,08/13/2014,,,,,,,,3,,Jodi,K,Bailey,,,9803 SE Plover Dr,,Happy Valley,OR,97086,,9803 SE Plover Dr,,Happy Valley,OR,97086,,,(503)504-5611,,jodikbailey@yahoo.com,(503)724-8239,jodibailey.com
131
+ 2014 General Election,2014,State Representative,1228,28th District,"State Representative, 28th District",15729,P,Minor Party,Working Families,N,Jeff Barker,State Representative House Dist. 28,,"State Representative 2003-Present
132
+
133
+ Portland Police Bureau 1974-2001
134
+
101
135
 
102
136
  ## Contributing
103
137
 
@@ -7,6 +7,7 @@ module Orsos::Commands
7
7
  class_option :xls2csv, type: :boolean, desc: 'use xls2csv to convert downloaded xls to csv'
8
8
  class_option :stdout, type: :boolean, desc: 'output to stdout'
9
9
  class_option :verbose, type: :boolean, desc: 'turn on verbose logging of search'
10
+ class_option :raise_error_if_no_data, type: :boolean, desc: 'raise an error if no data returned from ORSOS website'
10
11
 
11
12
  desc "transactions FROM [TO]", "Download campaign finance transactions daily between FROM till TO and saves each day to sos_transactions_{%Y%m%d}-{current time stamp}. eg., orsos get transactions 2014-10-01 2014-10-31. TO defaults to today's date"
12
13
  option :filer_id, type: :numeric, desc: 'conduct search by filer_id'
@@ -105,7 +106,8 @@ module Orsos::Commands
105
106
  verbose: options[:verbose],
106
107
  csvbin: csvbin,
107
108
  stdout: options['stdout'],
108
- filename: "#{filename}.#{fileext}"
109
+ filename: "#{filename}.#{fileext}",
110
+ raise_error_if_no_data: options['raise_error_if_no_data']
109
111
  }
110
112
  end
111
113
  end
@@ -1,3 +1,3 @@
1
1
  module Orsos
2
- VERSION = "0.0.6"
2
+ VERSION = "0.0.7"
3
3
  end
@@ -7,53 +7,55 @@ module MakeMakefile::Logging
7
7
  end
8
8
 
9
9
  class Orsos::Webdownloader
10
- def initialize(verbose: false, csvbin: nil, stdout: false, filename: nil)
10
+ def initialize(verbose: false, csvbin: nil, stdout: false, filename: nil, raise_error_if_no_data: false)
11
11
  @verbose = verbose
12
12
  @csvbin = csvbin
13
13
  @stdout = stdout
14
14
  @filename = filename
15
+ @raise_error_if_no_data = raise_error_if_no_data
15
16
  end
16
17
 
17
18
  def save_campaign_finance_transactions from_date:, to_date:, options: {}
18
19
  save("transactions for #{from_date.strftime('%Y-%m-%d')} till #{to_date.strftime('%Y-%m-%d')}") do
19
- export_page = download_campaign_finance_transactions from_date: from_date, to_date: to_date, filer_id: options['filer_id']
20
- raise "could not download campaign finance transactions" if export_page.nil?
21
-
22
- export_page.body
20
+ download_campaign_finance_transactions from_date: from_date, to_date: to_date, filer_id: options['filer_id']
23
21
  end
24
22
  end
25
23
 
26
24
  def save_committees committee_name_contains:, options: {}
27
25
  save("committees searched by #{committee_name_contains}") do
28
- export_page = download_committees committee_name: committee_name_contains, committee_name_search_type: 'contains'
29
- raise "could not download committees" if export_page.nil?
30
- export_page.body
26
+ download_committees committee_name: committee_name_contains, committee_name_search_type: 'contains'
31
27
  end
32
28
  end
33
29
 
34
30
  def save_candidate_filings from_date: , to_date: , options: {}
35
31
  save("candidates filings for #{from_date.strftime('%Y-%m-%d')} till #{to_date.strftime('%Y-%m-%d')}") do
36
- export_page = download_candidate_filings from_date: from_date, to_date: to_date
37
- raise "could not download committees" if export_page.nil?
38
- export_page.body
32
+ download_candidate_filings from_date: from_date, to_date: to_date
39
33
  end
40
-
41
34
  end
42
35
 
43
-
44
- private
45
36
  def save msg, &block
46
- puts "downloading #{msg}" if !@stdout
37
+ puts "[ORSOS] [#{Time.now}] downloading #{msg}" if !@stdout
47
38
 
48
- body = block.call
49
- data = !@csvbin.nil? ? convert_to_csv(body) : body
39
+ export_page = block.call
40
+
41
+ if export_page.nil?
42
+ if @raise_error_if_no_data
43
+ raise "could not download file. no data returned"
44
+ elsif !@stdout
45
+ puts "[ORSOS] [#{Time.now}] no data returned"
46
+ end
50
47
 
51
- if @stdout
52
- $stdout.write data
53
48
  else
54
- File.open(@filename, 'wb') {|f| f.write(data) }
55
- puts "saved #{msg} to #{@filename}"
49
+ data = !@csvbin.nil? ? convert_to_csv(export.body) : export.body
50
+
51
+ if @stdout
52
+ $stdout.write data
53
+ else
54
+ File.open(@filename, 'wb') {|f| f.write(data) }
55
+ puts "[ORSOS] [#{Time.now}] saved #{msg} to #{@filename}"
56
+ end
56
57
  end
58
+
57
59
  end
58
60
 
59
61
  def download_campaign_finance_transactions from_date:, to_date:, filer_id: nil
@@ -127,6 +129,8 @@ private
127
129
  return export_page
128
130
  end
129
131
 
132
+ private
133
+
130
134
  def convert_to_csv body
131
135
  csvpath = find_executable0 @csvbin
132
136
  raise "could not find #{@csvbin} in $PATH" if csvpath.nil?
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: orsos
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.6
4
+ version: 0.0.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jonathan Chang