Class: ECFS::FilingsQuery
- Inherits:
-
Object
- Object
- ECFS::FilingsQuery
- Includes:
- Query
- Defined in:
- lib/ecfs/filings_query.rb
Instance Attribute Summary
Attributes included from Query
Instance Method Summary collapse
- #base_url ⇒ Object
- #constraints_dictionary ⇒ Object
- #download_spreadsheet! ⇒ Object
- #get ⇒ Object
- #mechanize_agent ⇒ Object
- #page_contains_ecfs_error_message?(page) ⇒ Boolean
- #row_to_filing(row) ⇒ Object
Methods included from Query
#eq, #format_constraint, #initialize, #query_string, #url
Instance Method Details
#base_url ⇒ Object
53 54 55 |
# File 'lib/ecfs/filings_query.rb', line 53 def base_url "http://apps.fcc.gov/ecfs/comment_search/execute" end |
#constraints_dictionary ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/ecfs/filings_query.rb', line 13 def constraints_dictionary { "docket_number" => "proceeding", "applicant" => "applicant", "lawfirm" => "lawfirm", "author" => "author", "posted_after" => "disseminated.minDate", "posted_before" => "disseminated.maxDate", "received_after" => "recieved.minDate", "received_before" => "recieved.maxDate", "comment_period_after" => "dateCommentPeriod.minDate", "comment_period_before" => "dateCommentPeriod.maxDate", "reply_comment_period_after" => "dateReplyComment.minDate", "reply_comment_period_before" => "dateReplyComment.maxDate", "city" => "address.city", "state_code" => "address.state.stateCd", "zip" => "address.zip", "da_number" => "daNumber", "file_number" => "fileNumber", "bureau_id_number" => "bureauIdentificationNumber", "report_number" => "reportNumber", "submission_type_id" => "submissionTypeId", "exparte" => "__checkbox_exParte", } end |
#download_spreadsheet! ⇒ Object
85 86 87 88 89 90 91 92 93 94 95 96 97 |
# File 'lib/ecfs/filings_query.rb', line 85 def download_spreadsheet! agent = mechanize_agent page = agent.get(url) if (page) raise ECFS::TooManyFilingsError.new else link_text = "\r\n \t \t \tExport to Excel file\r\n \t \t" link = page.link_with(:text => link_text) @rows = agent.click(link).rows end end |
#get ⇒ Object
57 58 59 60 |
# File 'lib/ecfs/filings_query.rb', line 57 def get download_spreadsheet! @typecast_results ? @rows.map {|row| row_to_filing(row)} : @rows end |
#mechanize_agent ⇒ Object
66 67 68 69 70 71 |
# File 'lib/ecfs/filings_query.rb', line 66 def mechanize_agent Mechanize.new.tap do |agent| agent. = true agent.pluggable_parser["application/vnd.ms-excel"] = ECFS::SpreadsheetParser end end |
#page_contains_ecfs_error_message?(page) ⇒ Boolean
73 74 75 76 77 78 79 80 81 82 83 |
# File 'lib/ecfs/filings_query.rb', line 73 def (page) xpath = "//*[@id='yui-main']/div/table/tbody/tr[2]/td/span[1]" text = page.search(xpath).text.gsub(/\s+/, " ").strip if text == "Retrieved the 10,000 most recent records. To view older records narrow your search criteria." result = true else result = false end result end |