ecfs 0.5.1 → 0.6.0
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/.gitignore +9 -18
- data/.rspec +2 -0
- data/.ruby-version +2 -0
- data/.travis.yml +2 -1
- data/CODE_OF_CONDUCT.md +13 -0
- data/LICENSE.txt +17 -18
- data/README.md +107 -230
- data/Rakefile +1 -11
- data/bin/console +14 -0
- data/bin/setup +7 -0
- data/ecfs.gemspec +20 -17
- data/lib/ecfs.rb +209 -13
- data/lib/ecfs/version.rb +1 -1
- metadata +47 -73
- data/test/helper.rb +0 -30
- data/test/test_daily_releases.rb +0 -21
- data/test/test_filing.rb +0 -51
- data/test/test_filings_query.rb +0 -54
- data/test/test_large_proceeding.rb +0 -43
- data/test/test_proceeding.rb +0 -62
- data/test/test_proceedings_query.rb +0 -67
- data/test/test_solr_scrape.rb +0 -72
data/test/helper.rb
DELETED
@@ -1,30 +0,0 @@
|
|
1
|
-
require 'rubygems'
|
2
|
-
require 'bundler'
|
3
|
-
require 'vcr'
|
4
|
-
|
5
|
-
require 'minitest/unit'
|
6
|
-
require 'minitest/autorun'
|
7
|
-
require 'minitest/pride'
|
8
|
-
|
9
|
-
require 'pry-rescue/minitest'
|
10
|
-
|
11
|
-
VCR.configure do |c|
|
12
|
-
c.cassette_library_dir = 'fixtures/vcr_cassettes'
|
13
|
-
c.hook_into :webmock
|
14
|
-
c.allow_http_connections_when_no_cassette = true
|
15
|
-
c.default_cassette_options = { :record => :new_episodes}
|
16
|
-
end
|
17
|
-
|
18
|
-
begin
|
19
|
-
Bundler.setup(:default, :development)
|
20
|
-
rescue Bundler::BundlerError => e
|
21
|
-
$stderr.puts e.message
|
22
|
-
$stderr.puts "Run `bundle install` to install missing gems"
|
23
|
-
exit e.status_code
|
24
|
-
end
|
25
|
-
|
26
|
-
require 'test/unit'
|
27
|
-
|
28
|
-
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
29
|
-
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
30
|
-
require 'ecfs'
|
data/test/test_daily_releases.rb
DELETED
@@ -1,21 +0,0 @@
|
|
1
|
-
require "helper"
|
2
|
-
require "pp"
|
3
|
-
|
4
|
-
class TestDailyReleases < MiniTest::Unit::TestCase
|
5
|
-
|
6
|
-
def test_synopsis
|
7
|
-
VCR.use_cassette('main_cassette') do
|
8
|
-
releases = ECFS::DailyReleasesQuery.new.tap do |q|
|
9
|
-
q.month = '12'
|
10
|
-
q.day = '17'
|
11
|
-
q.year = '2014'
|
12
|
-
end.get
|
13
|
-
|
14
|
-
assert releases.is_a?(ECFS::DailyRelease)
|
15
|
-
assert releases.respond_to?(:pdfs)
|
16
|
-
assert releases.respond_to?(:docxs)
|
17
|
-
assert releases.respond_to?(:txts)
|
18
|
-
end
|
19
|
-
end
|
20
|
-
|
21
|
-
end
|
data/test/test_filing.rb
DELETED
@@ -1,51 +0,0 @@
|
|
1
|
-
require "helper"
|
2
|
-
require "pp"
|
3
|
-
|
4
|
-
class TestFiling < MiniTest::Unit::TestCase
|
5
|
-
|
6
|
-
def test_search
|
7
|
-
VCR.use_cassette('main_cassette') do
|
8
|
-
filings = ECFS::Filing.query.tap do |q|
|
9
|
-
q.docket_number = "12-375"
|
10
|
-
end.get
|
11
|
-
|
12
|
-
assert_equal filings.class, Array
|
13
|
-
|
14
|
-
filing = filings.first
|
15
|
-
|
16
|
-
assert_equal filing.class, ECFS::Filing
|
17
|
-
assert_equal filing["name_of_filer"].class, String
|
18
|
-
assert_equal filing["docket_number"], "12-375"
|
19
|
-
assert_equal filing["lawfirm_name"].class, String
|
20
|
-
assert_equal filing["date_received"].class, String
|
21
|
-
assert_equal filing["date_posted"].class, String
|
22
|
-
|
23
|
-
# checks if value is `true` or `false`--since Ruby does not have a Boolean type
|
24
|
-
# http://stackoverflow.com/a/3033645/94154
|
25
|
-
assert_equal !!filing["exparte"], filings.first["exparte"]
|
26
|
-
|
27
|
-
assert_equal filing["type_of_filing"].class, String
|
28
|
-
assert_equal filing["document_urls"].class, Array
|
29
|
-
|
30
|
-
assert_equal nil, filing.documents
|
31
|
-
|
32
|
-
filing.fetch_documents!
|
33
|
-
documents = filing.documents
|
34
|
-
document = documents.first
|
35
|
-
|
36
|
-
assert_equal Array, documents.class
|
37
|
-
assert_equal ECFS::Document, document.class
|
38
|
-
assert_equal String, document.full_text.class
|
39
|
-
assert_equal Array, document.pages.class
|
40
|
-
page = document.pages.first
|
41
|
-
assert_equal ECFS::Document::Page, page.class
|
42
|
-
assert_equal String, page.text.class
|
43
|
-
assert_equal Fixnum, page.page_number.class
|
44
|
-
|
45
|
-
#VCR.use_cassette('test_proceedings_query_test_get_proceeding_info') do
|
46
|
-
# binding.pry
|
47
|
-
#end
|
48
|
-
end
|
49
|
-
end
|
50
|
-
|
51
|
-
end
|
data/test/test_filings_query.rb
DELETED
@@ -1,54 +0,0 @@
|
|
1
|
-
require "helper"
|
2
|
-
require "pp"
|
3
|
-
|
4
|
-
class TestFilingsQuery < MiniTest::Unit::TestCase
|
5
|
-
|
6
|
-
def test_add_constraint
|
7
|
-
filings_query = ECFS::FilingsQuery.new
|
8
|
-
filings_query.eq("docket_number", "12-375")
|
9
|
-
assert_equal filings_query.constraints, {"docket_number" => "12-375"}
|
10
|
-
end
|
11
|
-
|
12
|
-
def test_constraints_dictionary
|
13
|
-
filings_query = ECFS::FilingsQuery.new
|
14
|
-
dictionary = filings_query.constraints_dictionary
|
15
|
-
assert_equal Hash, dictionary.class
|
16
|
-
end
|
17
|
-
|
18
|
-
def test_query_string
|
19
|
-
filings_query = ECFS::FilingsQuery.new
|
20
|
-
filings_query.eq("docket_number", "12-375")
|
21
|
-
filings_query.eq("lawfirm", "FCC")
|
22
|
-
assert_equal filings_query.query_string, "proceeding=12-375&lawfirm=FCC"
|
23
|
-
end
|
24
|
-
|
25
|
-
def test_url
|
26
|
-
filings_query = ECFS::FilingsQuery.new
|
27
|
-
filings_query.eq("docket_number", "12-375")
|
28
|
-
filings_query.eq("lawfirm", "FCC")
|
29
|
-
url = "http://apps.fcc.gov/ecfs/comment_search/execute?proceeding=12-375&lawfirm=FCC"
|
30
|
-
assert_equal filings_query.url, url
|
31
|
-
end
|
32
|
-
|
33
|
-
def test_get
|
34
|
-
VCR.use_cassette('main_cassette') do
|
35
|
-
filings_query = ECFS::FilingsQuery.new
|
36
|
-
filings_query.eq("docket_number", "12-375")
|
37
|
-
rows = filings_query.get
|
38
|
-
assert_equal rows.class, Array
|
39
|
-
assert_equal rows.first.class, Hash
|
40
|
-
assert_equal rows.first["name_of_filer"].class, String
|
41
|
-
assert_equal rows.first["docket_number"], "12-375"
|
42
|
-
assert_equal rows.first["lawfirm_name"].class, String
|
43
|
-
assert_equal rows.first["date_received"].class, String
|
44
|
-
assert_equal rows.first["date_posted"].class, String
|
45
|
-
|
46
|
-
# checks if value is `true` or `false`--since Ruby does not have a Boolean type
|
47
|
-
# http://stackoverflow.com/a/3033645/94154
|
48
|
-
assert_equal !!rows.first["exparte"], rows.first["exparte"]
|
49
|
-
|
50
|
-
assert_equal rows.first["type_of_filing"].class, String
|
51
|
-
assert_equal rows.first["document_urls"].class, Array
|
52
|
-
end
|
53
|
-
end
|
54
|
-
end
|
@@ -1,43 +0,0 @@
|
|
1
|
-
require "helper"
|
2
|
-
require "pp"
|
3
|
-
|
4
|
-
class TestLargeProceeding < MiniTest::Unit::TestCase
|
5
|
-
|
6
|
-
attr_accessor :results
|
7
|
-
|
8
|
-
# def test_throws_error
|
9
|
-
# VCR.use_cassette('bulk_cassette') do
|
10
|
-
# docket_number = "09-191"
|
11
|
-
# query = ECFS::Filing.query.tap do |q|
|
12
|
-
# q.docket_number = docket_number
|
13
|
-
# end
|
14
|
-
# assert_raises ECFS::TooManyFilingsError do
|
15
|
-
# results = query.get
|
16
|
-
# end
|
17
|
-
# end
|
18
|
-
# end
|
19
|
-
#
|
20
|
-
# def test_bulk_filings_query
|
21
|
-
# VCR.use_cassette('bulk_cassette') do
|
22
|
-
# docket_number = "11-109"
|
23
|
-
# query = ECFS::BulkFilingsQuery.new(docket_number)
|
24
|
-
# filings = query.get
|
25
|
-
# proceeding = ECFS::Proceeding.find(docket_number)
|
26
|
-
#
|
27
|
-
# assert_equal proceeding["total_filings"].to_i, filings.length
|
28
|
-
# end
|
29
|
-
# end
|
30
|
-
|
31
|
-
#def test_bulk_filings_query_xxl
|
32
|
-
# VCR.use_cassette('bulk_cassette') do
|
33
|
-
# docket_number = "09-191"
|
34
|
-
# query = ECFS::BulkFilingsQuery.new(docket_number)
|
35
|
-
# filings = query.get
|
36
|
-
# proceeding = ECFS::Proceeding.find(docket_number)
|
37
|
-
|
38
|
-
# assert_equal proceeding["total_filings"].to_i, filings.length
|
39
|
-
# end
|
40
|
-
#end
|
41
|
-
|
42
|
-
|
43
|
-
end
|
data/test/test_proceeding.rb
DELETED
@@ -1,62 +0,0 @@
|
|
1
|
-
require "helper"
|
2
|
-
require "pp"
|
3
|
-
|
4
|
-
class TestProceeding < MiniTest::Unit::TestCase
|
5
|
-
|
6
|
-
def test_find
|
7
|
-
VCR.use_cassette('main_cassette') do
|
8
|
-
proceeding = ECFS::Proceeding.find("12-375")
|
9
|
-
%w[
|
10
|
-
bureau_name subject date_created status
|
11
|
-
total_filings filings_in_last_30_days
|
12
|
-
docket_number
|
13
|
-
].each do |key|
|
14
|
-
assert proceeding.keys.include?(key)
|
15
|
-
end
|
16
|
-
|
17
|
-
assert_equal ECFS::Proceeding, proceeding.class
|
18
|
-
end
|
19
|
-
end
|
20
|
-
|
21
|
-
# def test_search
|
22
|
-
# VCR.use_cassette('main_cassette') do
|
23
|
-
#
|
24
|
-
# proceedings = ECFS::Proceeding.query.tap do |q|
|
25
|
-
# q.bureau_code = "WC"
|
26
|
-
# q.page_number = "1"
|
27
|
-
# q.per_page = "100"
|
28
|
-
# end.get
|
29
|
-
#
|
30
|
-
# %w[
|
31
|
-
# total_pages first_result last_result total_results
|
32
|
-
# current_page constraints fcc_url results
|
33
|
-
# ].each do |key|
|
34
|
-
# assert proceedings.keys.include?(key)
|
35
|
-
# assert proceedings[key]
|
36
|
-
# end
|
37
|
-
#
|
38
|
-
# assert_equal ECFS::Proceeding::ResultSet, proceedings.class
|
39
|
-
# assert_equal ECFS::ProceedingsQuery, proceedings.next_query.class
|
40
|
-
# next_proceedings = proceedings.next
|
41
|
-
# assert_equal ECFS::Proceeding::ResultSet, next_proceedings.class
|
42
|
-
#
|
43
|
-
# prison_phones = proceedings["results"].select {|p| p["docket_number"] == "12-375"}.first
|
44
|
-
# prison_phones.fetch_filings!
|
45
|
-
#
|
46
|
-
# assert_equal Array, prison_phones["filings"].class
|
47
|
-
#
|
48
|
-
# prison_phones = proceedings["results"].select {|p| p["docket_number"] == "12-375"}.first
|
49
|
-
# assert_equal ECFS::Proceeding, prison_phones.class
|
50
|
-
# fetched = prison_phones.fetch_info!
|
51
|
-
# assert_equal ECFS::Proceeding, prison_phones.class
|
52
|
-
# %w[
|
53
|
-
# bureau_name subject date_created status
|
54
|
-
# total_filings filings_in_last_30_days
|
55
|
-
# ].each do |key|
|
56
|
-
# assert prison_phones.keys.include?(key)
|
57
|
-
# end
|
58
|
-
#
|
59
|
-
# end
|
60
|
-
# end
|
61
|
-
|
62
|
-
end
|
@@ -1,67 +0,0 @@
|
|
1
|
-
require "helper"
|
2
|
-
require "pp"
|
3
|
-
|
4
|
-
class TestProceedingsQuery < MiniTest::Unit::TestCase
|
5
|
-
|
6
|
-
def test_add_constraint
|
7
|
-
proceedings_query = ECFS::ProceedingsQuery.new
|
8
|
-
proceedings_query.eq("docket_number", "12-375")
|
9
|
-
assert_equal proceedings_query.constraints, {"docket_number" => "12-375"}
|
10
|
-
end
|
11
|
-
|
12
|
-
def test_constraints_dictionary
|
13
|
-
proceedings_query = ECFS::ProceedingsQuery.new
|
14
|
-
dictionary = proceedings_query.constraints_dictionary
|
15
|
-
assert_equal Hash, dictionary.class
|
16
|
-
end
|
17
|
-
|
18
|
-
def test_query_string
|
19
|
-
proceedings_query = ECFS::ProceedingsQuery.new
|
20
|
-
proceedings_query.eq("docket_number", "12-375")
|
21
|
-
proceedings_query.eq("subject", "phones")
|
22
|
-
assert_equal proceedings_query.query_string, "name=12-375&subject=phones"
|
23
|
-
end
|
24
|
-
|
25
|
-
def test_url
|
26
|
-
proceedings_query = ECFS::ProceedingsQuery.new
|
27
|
-
proceedings_query.eq("bureau_code", "WC")
|
28
|
-
proceedings_query.eq("subject", "phones")
|
29
|
-
url = "http://apps.fcc.gov/ecfs/proceeding_search/execute?bureauCode=WC&subject=phones"
|
30
|
-
assert_equal proceedings_query.url, url
|
31
|
-
end
|
32
|
-
|
33
|
-
def test_get_proceeding_info
|
34
|
-
VCR.use_cassette('main_cassette') do
|
35
|
-
proceedings_query = ECFS::ProceedingsQuery.new
|
36
|
-
proceedings_query.eq("docket_number", "12-375")
|
37
|
-
results = proceedings_query.get
|
38
|
-
%w[
|
39
|
-
bureau_name subject date_created status
|
40
|
-
total_filings filings_in_last_30_days
|
41
|
-
].each do |key|
|
42
|
-
assert results.keys.include?(key)
|
43
|
-
end
|
44
|
-
end
|
45
|
-
end
|
46
|
-
|
47
|
-
# def test_search_proceedings
|
48
|
-
# VCR.use_cassette('main_cassette') do
|
49
|
-
# proceedings_query = ECFS::ProceedingsQuery.new
|
50
|
-
# proceedings_query.eq("bureau_code", "WC")
|
51
|
-
# proceedings_query.eq("page_number", "1")
|
52
|
-
# proceedings_query.eq("per_page", "100")
|
53
|
-
# results = proceedings_query.get
|
54
|
-
# %w[
|
55
|
-
# total_pages first_result last_result total_results
|
56
|
-
# current_page results
|
57
|
-
# ].each do |key|
|
58
|
-
# assert results.keys.include?(key)
|
59
|
-
# assert results[key]
|
60
|
-
# end
|
61
|
-
#
|
62
|
-
# result = results["results"].first
|
63
|
-
# assert_equal Fixnum, result["filings_in_last_30_days"].class
|
64
|
-
# end
|
65
|
-
# end
|
66
|
-
|
67
|
-
end
|
data/test/test_solr_scrape.rb
DELETED
@@ -1,72 +0,0 @@
|
|
1
|
-
require "helper"
|
2
|
-
require "pp"
|
3
|
-
require "pry"
|
4
|
-
|
5
|
-
class TestSolrScrape < MiniTest::Unit::TestCase
|
6
|
-
|
7
|
-
def test_synopsis
|
8
|
-
VCR.use_cassette('solr_cassette') do
|
9
|
-
filings = ECFS::SolrScrapeQuery.new.tap do |q|
|
10
|
-
q.docket_number = '12-83'
|
11
|
-
end.get
|
12
|
-
|
13
|
-
assert filings.first.is_a?(Hash)
|
14
|
-
assert filings.first.has_key?('docket_number')
|
15
|
-
assert filings.first.has_key?('citation')
|
16
|
-
end
|
17
|
-
end
|
18
|
-
|
19
|
-
def test_received_min_date
|
20
|
-
VCR.use_cassette('solr_cassette') do
|
21
|
-
filings = ECFS::SolrScrapeQuery.new.tap do |q|
|
22
|
-
q.docket_number = '12-83'
|
23
|
-
q.received_min_date = '11/28/14'
|
24
|
-
end.get
|
25
|
-
|
26
|
-
assert filings.first.is_a?(Hash)
|
27
|
-
assert filings.first.has_key?('docket_number')
|
28
|
-
assert filings.first.has_key?('citation')
|
29
|
-
assert filings.first
|
30
|
-
|
31
|
-
filing_date = DateTime.strptime(filings.first['date_received'], "%m/%d/%Y")
|
32
|
-
min_date = DateTime.strptime('11/28/14', "%m/%d/%Y")
|
33
|
-
|
34
|
-
assert filing_date > min_date
|
35
|
-
end
|
36
|
-
end
|
37
|
-
|
38
|
-
class FakeArrayThing
|
39
|
-
def initialize
|
40
|
-
@filings = []
|
41
|
-
end
|
42
|
-
|
43
|
-
def concat(filings)
|
44
|
-
@filings.concat(filings)
|
45
|
-
end
|
46
|
-
|
47
|
-
def filings
|
48
|
-
@filings
|
49
|
-
end
|
50
|
-
end
|
51
|
-
|
52
|
-
def test_after_scrape
|
53
|
-
VCR.use_cassette('solr_cassette') do
|
54
|
-
|
55
|
-
@fake_array_thing = FakeArrayThing.new
|
56
|
-
|
57
|
-
filings = ECFS::SolrScrapeQuery.new.tap do |q|
|
58
|
-
q.docket_number = '12-83'
|
59
|
-
q.after_scrape = Proc.new do |filings|
|
60
|
-
@fake_array_thing.concat(filings)
|
61
|
-
end
|
62
|
-
end.get
|
63
|
-
|
64
|
-
assert filings.first.is_a?(Hash)
|
65
|
-
assert filings.first.has_key?('docket_number')
|
66
|
-
assert filings.first.has_key?('citation')
|
67
|
-
|
68
|
-
assert_equal filings.length, @fake_array_thing.filings.length
|
69
|
-
end
|
70
|
-
end
|
71
|
-
|
72
|
-
end
|