fcc-content-api 0.0.1 → 0.0.2
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.
- data/.travis.yml +4 -0
- data/Gemfile +2 -0
- data/README.md +10 -2
- data/fixtures/vcr_cassettes/test_all.yml +42 -0
- data/fixtures/vcr_cassettes/test_find.yml +42 -0
- data/fixtures/vcr_cassettes/test_title.yml +42 -0
- data/lib/fcc-content-api.rb +70 -67
- data/lib/fcc-content-api/version.rb +1 -1
- data/test/test_client.rb +45 -43
- data/test/test_helper.rb +1 -1
- data/test/test_query.rb +17 -17
- metadata +12 -8
data/.travis.yml
ADDED
data/Gemfile
CHANGED
data/README.md
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
[](http://travis-ci.org/adelevie/fcc-content-api)
|
|
2
|
+
|
|
1
3
|
The FCC Content API allows you to programmatically access much of the content accessible on [FCC.gov](http://fcc.gov).
|
|
2
4
|
|
|
3
5
|
fcc-content-api is a lightweight Ruby wrapper for the Federal Communication Commission's Content API. The query interface resembles ActiveRecord. The response objects are simple Ruby `Hash`es and `Array`s.
|
|
@@ -27,13 +29,19 @@ FccContentApi::Content.where(:edocs => "true").where(:type => "proceeding").wher
|
|
|
27
29
|
FccContentApi::Content.where({:edocs => "true", :type => "proceeding" :comments => "true"}).all
|
|
28
30
|
```
|
|
29
31
|
|
|
32
|
+
If you know the id of the object you want, use `FccContentApi::Content#find`:
|
|
33
|
+
|
|
34
|
+
```ruby
|
|
35
|
+
FccContentApi::Content.find(38660)
|
|
36
|
+
```
|
|
37
|
+
|
|
30
38
|
## Installation
|
|
31
39
|
|
|
32
40
|
`gem install fcc-content-api` or:
|
|
33
41
|
|
|
34
42
|
```ruby
|
|
35
|
-
|
|
36
|
-
|
|
43
|
+
# Gemfile
|
|
44
|
+
gem "fcc-content-api"
|
|
37
45
|
```
|
|
38
46
|
|
|
39
47
|
## More Info
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
---
|
|
2
|
+
http_interactions:
|
|
3
|
+
- request:
|
|
4
|
+
method: get
|
|
5
|
+
uri: http://www.fcc.gov/api/content.json
|
|
6
|
+
body:
|
|
7
|
+
encoding: US-ASCII
|
|
8
|
+
string: ""
|
|
9
|
+
headers:
|
|
10
|
+
Host:
|
|
11
|
+
- www.fcc.gov
|
|
12
|
+
Accept:
|
|
13
|
+
- "*/*"
|
|
14
|
+
User-Agent:
|
|
15
|
+
- Ruby
|
|
16
|
+
response:
|
|
17
|
+
status:
|
|
18
|
+
code: 200
|
|
19
|
+
message: OK
|
|
20
|
+
headers:
|
|
21
|
+
Server:
|
|
22
|
+
- Apache
|
|
23
|
+
Last-Modified:
|
|
24
|
+
- Fri, 13 Apr 2012 11:48:45 GMT
|
|
25
|
+
Content-Length:
|
|
26
|
+
- "2885"
|
|
27
|
+
Content-Type:
|
|
28
|
+
- application/json
|
|
29
|
+
Cache-Control:
|
|
30
|
+
- no-cache, must-revalidate, post-check=0, pre-check=0
|
|
31
|
+
Expires:
|
|
32
|
+
- Fri, 13 Apr 2012 11:45:17 GMT
|
|
33
|
+
Date:
|
|
34
|
+
- Fri, 13 Apr 2012 11:45:17 GMT
|
|
35
|
+
Connection:
|
|
36
|
+
- keep-alive
|
|
37
|
+
body:
|
|
38
|
+
encoding: US-ASCII
|
|
39
|
+
string: "[{\"count\":\"21171\",\"pages\":2117,\"itemsPerPage\":10,\"currentPage\":0},{\"nid\":\"38892\",\"title\":\"Clyburn Statement on Award of Contract for Literature Review\",\"created\":\"2012-04-12\",\"changed\":\"2012-04-13\",\"type\":\"edoc\",\"webUrl\":\"http:\\/\\/www.fcc.gov\\/document\\/clyburn-statement-award-contract-literature-review\",\"uri\":\"http:\\/\\/www.fcc.gov\\/api\\/content\\/38892\"},{\"nid\":\"38891\",\"title\":\"Broadband Over Power Lines\",\"created\":\"2012-04-12\",\"changed\":\"2012-04-13\",\"type\":\"edoc\",\"webUrl\":\"http:\\/\\/www.fcc.gov\\/document\\/broadband-over-power-lines\",\"uri\":\"http:\\/\\/www.fcc.gov\\/api\\/content\\/38891\"},{\"nid\":\"38890\",\"title\":\"Ex Parte Rules and Other Procedural Rules\",\"created\":\"2012-04-12\",\"changed\":\"2012-04-13\",\"type\":\"edoc\",\"webUrl\":\"http:\\/\\/www.fcc.gov\\/document\\/ex-parte-rules-and-other-procedural-rules\",\"uri\":\"http:\\/\\/www.fcc.gov\\/api\\/content\\/38890\"},{\"nid\":\"38889\",\"title\":\"Commissioner McDowell Remarks: MMTC Honors Commissioner Copps\",\"created\":\"2012-04-12\",\"changed\":\"2012-04-13\",\"type\":\"edoc\",\"webUrl\":\"http:\\/\\/www.fcc.gov\\/document\\/commissioner-mcdowell-remarks-mmtc-honors-commissioner-copps\",\"uri\":\"http:\\/\\/www.fcc.gov\\/api\\/content\\/38889\"},{\"nid\":\"38888\",\"title\":\"WTB seeks comment on waiver of USF support methodology rule\",\"created\":\"2012-04-12\",\"changed\":\"2012-04-13\",\"type\":\"edoc\",\"webUrl\":\"http:\\/\\/www.fcc.gov\\/document\\/wtb-seeks-comment-waiver-usf-support-methodology-rule\",\"uri\":\"http:\\/\\/www.fcc.gov\\/api\\/content\\/38888\"},{\"nid\":\"38887\",\"title\":\"Wireline Bureau Seeks Comment on BelWave Request for Review\",\"created\":\"2012-04-12\",\"changed\":\"2012-04-13\",\"type\":\"edoc\",\"webUrl\":\"http:\\/\\/www.fcc.gov\\/document\\/wireline-bureau-seeks-comment-belwave-request-review\",\"uri\":\"http:\\/\\/www.fcc.gov\\/api\\/content\\/38887\"},{\"nid\":\"38884\",\"title\":\"Collocation Workshop May 1, 2012, Promoting Mobile Brandband\",\"created\":\"2012-04-12\",\"changed\":\"2012-04-13\",\"type\":\"edoc\",\"webUrl\":\"http:\\/\\/www.fcc.gov\\/document\\/collocation-workshop-may-1-2012-promoting-mobile-brandband\",\"uri\":\"http:\\/\\/www.fcc.gov\\/api\\/content\\/38884\"},{\"nid\":\"38883\",\"title\":\"Erratum - Al-Ihsan Academy, South Ozone Park, NY et al.\",\"created\":\"2012-04-12\",\"changed\":\"2012-04-13\",\"type\":\"edoc\",\"webUrl\":\"http:\\/\\/www.fcc.gov\\/document\\/erratum-al-ihsan-academy-south-ozone-park-ny-et-al-0\",\"uri\":\"http:\\/\\/www.fcc.gov\\/api\\/content\\/38883\"},{\"nid\":\"38882\",\"title\":\"LPFM Channel Finder Tool Now Available\",\"created\":\"2012-04-12\",\"changed\":\"2012-04-13\",\"type\":\"edoc\",\"webUrl\":\"http:\\/\\/www.fcc.gov\\/document\\/lpfm-channel-finder-tool-now-available\",\"uri\":\"http:\\/\\/www.fcc.gov\\/api\\/content\\/38882\"},{\"nid\":\"38881\",\"title\":\"DeltaCom, Inc. Order Denying Renewal Deadline Waiver Requests\",\"created\":\"2012-04-12\",\"changed\":\"2012-04-13\",\"type\":\"edoc\",\"webUrl\":\"http:\\/\\/www.fcc.gov\\/document\\/deltacom-inc-order-denying-renewal-deadline-waiver-requests\",\"uri\":\"http:\\/\\/www.fcc.gov\\/api\\/content\\/38881\"}]"
|
|
40
|
+
http_version:
|
|
41
|
+
recorded_at: Fri, 13 Apr 2012 11:45:17 GMT
|
|
42
|
+
recorded_with: VCR 2.0.1
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
---
|
|
2
|
+
http_interactions:
|
|
3
|
+
- request:
|
|
4
|
+
method: get
|
|
5
|
+
uri: http://www.fcc.gov/api/content/38837.json
|
|
6
|
+
body:
|
|
7
|
+
encoding: US-ASCII
|
|
8
|
+
string: ""
|
|
9
|
+
headers:
|
|
10
|
+
Host:
|
|
11
|
+
- www.fcc.gov
|
|
12
|
+
Accept:
|
|
13
|
+
- "*/*"
|
|
14
|
+
User-Agent:
|
|
15
|
+
- Ruby
|
|
16
|
+
response:
|
|
17
|
+
status:
|
|
18
|
+
code: 200
|
|
19
|
+
message: OK
|
|
20
|
+
headers:
|
|
21
|
+
Server:
|
|
22
|
+
- Apache
|
|
23
|
+
Last-Modified:
|
|
24
|
+
- Fri, 13 Apr 2012 11:45:53 GMT
|
|
25
|
+
Content-Type:
|
|
26
|
+
- application/json
|
|
27
|
+
Content-Length:
|
|
28
|
+
- "11396"
|
|
29
|
+
Cache-Control:
|
|
30
|
+
- no-cache, must-revalidate, post-check=0, pre-check=0
|
|
31
|
+
Expires:
|
|
32
|
+
- Fri, 13 Apr 2012 11:45:18 GMT
|
|
33
|
+
Date:
|
|
34
|
+
- Fri, 13 Apr 2012 11:45:18 GMT
|
|
35
|
+
Connection:
|
|
36
|
+
- keep-alive
|
|
37
|
+
body:
|
|
38
|
+
encoding: US-ASCII
|
|
39
|
+
string: "{\"nid\":\"38837\",\"title\":\"WCB seeks comment on petitions for ETC designations\",\"created\":\"2012-04-10\",\"changed\":\"2012-04-11\",\"type\":\"edoc\",\"webUrl\":\"http:\\/\\/www.fcc.gov\\/document\\/wcb-seeks-comment-petitions-etc-designations\",\"taxonomy\":{\"7\":{\"tid\":\"7\",\"vid\":\"1\",\"name\":\"Wireline Competition\",\"description\":\"\",\"weight\":\"21\"},\"49\":{\"tid\":\"49\",\"vid\":\"4\",\"name\":\"Public Notice\",\"description\":\"\",\"weight\":\"49\"}},\"body\":\"<A name=1><\\/a><p><b>PUBLIC NOTICE<\\/b><\\/p>\\n<p><b>Federal Communications Commission<\\/b><\\/p>\\n<p><b>News Media Information 202 \\/ 418-0500<\\/b><\\/p>\\n<b>445 12th St., S.W.<\\/b><br \\/>\\n<p><b>Internet: http:\\/\\/www.fcc.gov<\\/b><\\/p>\\n<p><b>Washington, D.C. 20554<\\/b><\\/p>\\n<p><b>TTY: 1-888-835-5322<\\/b><\\/p>\\n<p><b>DA 12-566<\\/b><\\/p>\\n<p><b>Release Date: April 10, 2012<\\/b><\\/p>\\n<p><b>WIRELINE COMPETITION BUREAU SEEKS COMMENT ON PETITIONS FOR <\\/b><\\/p>\\n<p><b>DESIGNATION AS A LOW-INCOME ELIGIBLE TELECOMMUNICATIONS CARRIER <\\/b><\\/p>\\n<p><b>FILED BY T-MOBILE, KAJEET, TAG MOBILE, TELRITE AND GLOBAL CONNECTION <\\/b><\\/p>\\n<p><b>WC Docket No. 09-197<\\/b><\\/p>\\n<p><b>Comment Date: May 10, 2012<br \\/>Reply Comment Date: May 25, 2012<\\/b><\\/p>\\nThe Wireline Competition Bureau seeks comment on petitions filed by T-Mobile USA, Inc. (T-<br \\/>\\nMobile),1 kajeet, Inc. (kajeet),2 TAG Mobile, LLC (TAG),3 Telrite Corporation (Telrite),4 and Global<br \\/>Connection Inc. of America (Global Connection),5 for limited designation as eligible telecommunications <br \\/>carriers (ETC) for the provision of Lifeline service. kajeet, TAG, Telrite and Global Connection each <br \\/>seek designation as an ETC for the limited purpose of offering Lifeline service in Alabama, Connecticut, <br \\/>Delaware, District of Columbia, Florida, New Hampshire, New York, North Carolina, Tennessee and <br \\/>\\n <br \\/>\\n <br \\/>\\n1 Petition of T-Mobile USA, Inc. for Designation as a Low-Income Eligible Telecommunications Carrier, WC <br \\/>Docket No. 09-197 (filed Jan. 23, 2012) (T-Mobile Petition).<br \\/>\\n2 kajeet, Inc. Petition for Designation as a Lifeline Eligible Telecommunications Carrier, WC Docket No. 09-197 <br \\/>(filed Mar. 26, 2012) (kajeet Petition). kajeet has a compliance plan pending with the Commission and may not be <br \\/>designated an ETC until that plan has been approved by the Wireline Competition Bureau. <i>See <\\/i>kajeet, Inc. <br \\/>Compliance Plan, WC Docket Nos. 09-197 and 11-42 (filed Mar. 26, 2012); <i>see also<\\/i>, <i>Lifeline and Link Up Reform <br \\/>and Modernization et al<\\/i>, WC Dkt No.11-42 <i>et al., <\\/i>Report and Order and Further Notice of Proposed Rulemaking, <br \\/>FCC 12-11, at para. 380 (rel. Feb. 6, 2012) (<i>Lifeline Reform Order<\\/i>).<br \\/>\\n3 TAG Mobile, LLC Petition for Limited Designation as an Eligible Telecommunications Carrier in Alabama, <br \\/>Connecticut, Delaware, the District of Columbia, Florida, New Hampshire, New York, North Carolina, Tennessee <br \\/>and Virginia, WC Docket No. 09-197 (filed Apr. 4, 2012) (TAG Petition). TAG has a compliance plan pending <br \\/>with the Commission and may not be designated an ETC until its plan has been approved by the Wireline <br \\/>Competition Bureau. <i>See <\\/i>TAG Mobile, LLC Compliance Plan, WC Docket Nos. 09-197 and 11-42 (filed Mar. 6, <br \\/>2012); <i>see also<\\/i>, <i>Lifeline Reform Order<\\/i>, FCC 12-11, at para. 380.<br \\/>\\n4 Telrite Corporation Petition for Limited Designation as an Eligible Telecommunications Carrier in Alabama, <br \\/>Connecticut, Delaware, the District of Columbia, Florida, New Hampshire, New York, North Carolina, Tennessee <br \\/>and Virginia, WC Docket No. 09-197 (filed Apr. 4, 2012) (Telrite Petition). Telrite has a compliance plan pending <br \\/>with the Commission and may not be designated an ETC until its plan has been approved by the Wireline <br \\/>Competition Bureau. <i>See <\\/i>Telrite Corporation Compliance Plan, WC Docket Nos. 09-197 and 11-42 (filed Mar. 12, <br \\/>2012); <i>see also<\\/i>, <i>Lifeline Reform Order<\\/i>, FCC 12-11, para. 380.<br \\/>\\n5 Global Connection Inc. of America Petition for Limited Designation as an Eligible Telecommunications Carrier in <br \\/>Alabama, Connecticut, Delaware, the District of Columbia, Florida, New Hampshire, New York, North Carolina, <br \\/>Tennessee and Virginia, WC Docket No. 09-197 (filed Apr. 4, 2012) (Global Connections Petition). Global <br \\/>Connection has a compliance plan pending with the Commission and may not be designated an ETC until its plan <br \\/>has been approved by the Wireline Competition Bureau. <i>See <\\/i>Global Connection Inc. of America Compliance Plan, <br \\/>WC Docket Nos. 09-197 and 11-42 (filed Mar. 8, 2012); <i>see also<\\/i>, <i>Lifeline Reform Order<\\/i>, FCC 12-11, para. 380.<br \\/>\\n<hr>\\n<A name=2><\\/a>Virginia.6 T-Mobile seeks ETC designation for the limited purpose of offering Lifeline service in <br \\/>Alabama, Connecticut, Delaware, District of Columbia, Florida, New Hampshire, New York, Tennessee <br \\/>and Virginia.7<br \\/>\\nPursuant to sections 1.415 and 1.419 of the Commission\\u2019s rules, interested parties may file <br \\/>\\ncomments and reply comments on or before the dates indicated on the first page of this document. <br \\/>Comments may be filed using the Commission\\u2019s Electronic Comment Filing System (ECFS).8 <br \\/>\\n\\u00a7<br \\/>\\nElectronic Filers: Comments may be filed electronically using the Internet by accessing the <br \\/>ECFS: http:\\/\\/fjallfoss.fcc.gov\\/ecfs2\\/. <br \\/>\\n\\u00a7<br \\/>\\nPaper Filers: Parties who choose to file by paper must file an original and one copy of each <br \\/>filing. If more than one docket or rulemaking number appears in the caption of this proceeding, <br \\/>filers must submit two additional copies for each additional docket or rulemaking number.<br \\/>\\nFilings can be sent by hand or messenger delivery, by commercial overnight courier, or by first-<br \\/>class or overnight U.S. Postal Service mail. All filings must be addressed to the Commission\\u2019s <br \\/>Secretary, Office of the Secretary, Federal Communications Commission.<br \\/>\\n\\u00a7<br \\/>\\nAll hand-delivered or messenger-delivered paper filings for the Commission\\u2019s Secretary <br \\/>must be delivered to FCC Headquarters at 445 12th St., SW, Room TW-A325, <br \\/>Washington, DC 20554. The filing hours are 8:00 a.m. to 7:00 p.m. All hand deliveries <br \\/>must be held together with rubber bands or fasteners. Any envelopes and boxes must be <br \\/>disposed of before entering the building. <br \\/>\\n\\u00a7<br \\/>\\nCommercial overnight mail (other than U.S. Postal Service Express Mail and Priority <br \\/>Mail) must be sent to 9300 East Hampton Drive, Capitol Heights, MD 20743.<br \\/>\\n\\u00a7<br \\/>\\nU.S. Postal Service first-class, Express, and Priority mail must be addressed to 445 12th<br \\/>Street, SW, Washington DC 20554.<br \\/>\\nPeople with Disabilities: To request materials in accessible formats for people with disabilities (braille, <br \\/>large print, electronic files, audio format), send an e-mail to fcc504@fcc.gov or call the Consumer & <br \\/>Governmental Affairs Bureau at 202-418-0530 (voice), 202-418-0432 (tty).<br \\/>\\nThe proceeding this Notice initiates shall be treated as a \\u201cpermit-but-disclose\\u201d proceeding in <br \\/>\\naccordance with the Commission\\u2019s <i>ex parte <\\/i>rules.9 Persons making <i>ex parte <\\/i>presentations must file a <br \\/>copy of any written presentation or a memorandum summarizing any oral presentation within two <br \\/>business days after the presentation (unless a different deadline applicable to the Sunshine period applies). <br \\/>Persons making oral <i>ex parte <\\/i>presentations are reminded that memoranda summarizing the presentation <br \\/>must (1) list all persons attending or otherwise participating in the meeting at which the <i>ex parte <br \\/><\\/i>presentation was made, and (2) summarize all data presented and arguments made during the <br \\/>\\n <br \\/>\\n <br \\/>\\n6 kajeet Petition at 1; TAG Petition at 1; Telrite Petition at 1; Global Connection Petition at 1.<br \\/>7 T-Mobile Petition at 1. <br \\/>8 <i>See <\\/i>47 CFR \\u00a7\\u00a7 1.415, 1.419; <i>Electronic Filing of Documents in Rulemaking Proceedings<\\/i>, 63 FR 24121 (1998).<br \\/>9 47 C.F.R. \\u00a7\\u00a7 1.1200 <i>et seq.<\\/i><br \\/>\\n2<br \\/>\\n<hr>\\n<A name=3><\\/a>presentation. If the presentation consisted in whole or in part of the presentation of data or arguments <br \\/>already reflected in the presenter\\u2019s written comments, memoranda or other filings in the proceeding, the <br \\/>presenter may provide citations to such data or arguments in his or her prior comments, memoranda, or <br \\/>other filings (specifying the relevant page and\\/or paragraph numbers where such data or arguments can be <br \\/>found) in lieu of summarizing them in the memorandum. Documents shown or given to Commission <br \\/>staff during <i>ex parte <\\/i>meetings are deemed to be written <i>ex parte <\\/i>presentations and must be filed <br \\/>consistent with rule 1.1206(b). In proceedings governed by rule 1.49(f) or for which the Commission has <br \\/>made available a method of electronic filing, written <i>ex parte <\\/i>presentations and memoranda summarizing <br \\/>oral <i>ex parte <\\/i>presentations, and all attachments thereto, must be filed through the electronic comment <br \\/>filing system available for that proceeding, and must be filed in their native format (<i>e.g.<\\/i>, .doc, .xml, .ppt, <br \\/>searchable .pdf). Participants in this proceeding should familiarize themselves with the Commission\\u2019s <i>ex <br \\/>parte <\\/i>rules.<br \\/>\\nFor further information, please contact Divya S. Shenoy, Telecommunications Access Policy <br \\/>\\nDivision, Wireline Competition Bureau at (202) 418-7400 or TTY (202) 418-0484.<br \\/>\\n<b>- FCC -<\\/b><br \\/>\\n3<br \\/>\\n<hr>\",\"vid\":\"62623\",\"field_short_title\":[{\"value\":null}],\"field_short_description\":[{\"value\":null}],\"field_author\":[{\"value\":null}],\"field_job_title\":[{\"value\":null}],\"field_edoc_internal_id\":[{\"value\":\"313517\"}],\"field_released_date\":[{\"value\":\"2012-04-10T00:00:00\"}],\"field_published_date\":[{\"value\":\"2012-04-10T00:00:00\"}],\"field_adopted_date\":[{\"value\":null}],\"field_comment_date\":[{\"value\":\"2012-05-10T00:00:00\"}],\"field_edoc_id\":[{\"value\":\"DA-12-566\"}],\"field_featured_image\":[{\"fid\":null,\"list\":null,\"data\":null}],\"topics\":[{\"nid\":\"144\",\"title\":\"Connecting America\"},{\"nid\":\"3907\",\"title\":\"Universal Service\"}],\"uri\":\"http:\\/\\/www.fcc.gov\\/api\\/content\\/38837\"}"
|
|
40
|
+
http_version:
|
|
41
|
+
recorded_at: Fri, 13 Apr 2012 11:45:18 GMT
|
|
42
|
+
recorded_with: VCR 2.0.1
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
---
|
|
2
|
+
http_interactions:
|
|
3
|
+
- request:
|
|
4
|
+
method: get
|
|
5
|
+
uri: http://www.fcc.gov/api/content.json?title=Open%2520Internet%2520Workshops%2520and%2520Speeches
|
|
6
|
+
body:
|
|
7
|
+
encoding: US-ASCII
|
|
8
|
+
string: ""
|
|
9
|
+
headers:
|
|
10
|
+
Host:
|
|
11
|
+
- www.fcc.gov
|
|
12
|
+
Accept:
|
|
13
|
+
- "*/*"
|
|
14
|
+
User-Agent:
|
|
15
|
+
- Ruby
|
|
16
|
+
response:
|
|
17
|
+
status:
|
|
18
|
+
code: 200
|
|
19
|
+
message: OK
|
|
20
|
+
headers:
|
|
21
|
+
Server:
|
|
22
|
+
- Apache
|
|
23
|
+
Last-Modified:
|
|
24
|
+
- Fri, 13 Apr 2012 11:44:53 GMT
|
|
25
|
+
Content-Length:
|
|
26
|
+
- "319"
|
|
27
|
+
Content-Type:
|
|
28
|
+
- application/json
|
|
29
|
+
Cache-Control:
|
|
30
|
+
- no-cache, must-revalidate, post-check=0, pre-check=0
|
|
31
|
+
Expires:
|
|
32
|
+
- Fri, 13 Apr 2012 11:44:18 GMT
|
|
33
|
+
Date:
|
|
34
|
+
- Fri, 13 Apr 2012 11:44:18 GMT
|
|
35
|
+
Connection:
|
|
36
|
+
- keep-alive
|
|
37
|
+
body:
|
|
38
|
+
encoding: US-ASCII
|
|
39
|
+
string: "[{\"count\":\"1\",\"pages\":0,\"itemsPerPage\":10,\"currentPage\":0},{\"nid\":\"37071\",\"title\":\"Open Internet Workshops and Speeches\",\"created\":\"2011-12-21\",\"changed\":\"2011-12-21\",\"type\":\"article\",\"webUrl\":\"http:\\/\\/www.fcc.gov\\/encyclopedia\\/open-internet-workshops-and-speeches\",\"uri\":\"http:\\/\\/www.fcc.gov\\/api\\/content\\/37071\"}]"
|
|
40
|
+
http_version:
|
|
41
|
+
recorded_at: Fri, 13 Apr 2012 11:44:18 GMT
|
|
42
|
+
recorded_with: VCR 2.0.1
|
data/lib/fcc-content-api.rb
CHANGED
|
@@ -3,70 +3,73 @@ require "weary"
|
|
|
3
3
|
require "json"
|
|
4
4
|
|
|
5
5
|
module FccContentApi
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
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
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
end
|
|
6
|
+
def self.client
|
|
7
|
+
@@client ||= FccContentApi::Client.new
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
class Content
|
|
11
|
+
def self.where(*args)
|
|
12
|
+
Query.new(self).where(*args)
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def self.all
|
|
16
|
+
Query.new(self).all
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def self.find(id)
|
|
20
|
+
resp = FccContentApi.client.get(:id => id).perform.body
|
|
21
|
+
JSON.parse resp
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
class Query
|
|
26
|
+
def initialize(klass); @klass = klass; end
|
|
27
|
+
|
|
28
|
+
def criteria; @criteria ||= {}; end
|
|
29
|
+
|
|
30
|
+
def where(args)
|
|
31
|
+
criteria.merge! args
|
|
32
|
+
self
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
def all; execute; end
|
|
36
|
+
|
|
37
|
+
def request
|
|
38
|
+
@request ||= FccContentApi.client.all criteria
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
def execute
|
|
42
|
+
resp = request.perform.body
|
|
43
|
+
JSON.parse(resp)
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
class Client < Weary::Client
|
|
49
|
+
domain "http://www.fcc.gov/api"
|
|
50
|
+
|
|
51
|
+
get :all, "/content.json?" do |resource|
|
|
52
|
+
|
|
53
|
+
resource.user_agent "rubygem/fcc-content-api/#{VERSION}"
|
|
54
|
+
|
|
55
|
+
resource.optional :created_before, :created_after, # YYYY-MM-DD
|
|
56
|
+
:changed_before, :changed_after, # YYYY-MM-DD
|
|
57
|
+
:search_string,
|
|
58
|
+
:limit,
|
|
59
|
+
:page,
|
|
60
|
+
:fields, # true
|
|
61
|
+
:edocs, # true
|
|
62
|
+
:comments, # true
|
|
63
|
+
:major_topics,
|
|
64
|
+
:type,
|
|
65
|
+
:term,
|
|
66
|
+
:topic,
|
|
67
|
+
:title
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
get :get, "/content/{id}.json" do |resource|
|
|
71
|
+
resource.user_agent "rubygem/fcc-content-api/#{VERSION}"
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
end
|
|
75
|
+
end
|
data/test/test_client.rb
CHANGED
|
@@ -1,51 +1,53 @@
|
|
|
1
1
|
require "test_helper"
|
|
2
2
|
|
|
3
3
|
class TestClient < Test::Unit::TestCase
|
|
4
|
-
VCR.use_cassette("test_title") do
|
|
5
|
-
def test_title
|
|
6
|
-
title = "Open Internet Workshops and Speeches"
|
|
7
|
-
resp = FccContentApi::Content.where(:title => URI.encode(title)).all
|
|
8
|
-
assert_equal resp.first.keys.sort!, ["count", "pages", "itemsPerPage", "currentPage"].sort!
|
|
9
|
-
assert_equal resp[1].keys.sort!, ["nid", "title", "created", "changed", "type", "webUrl", "uri"].sort!
|
|
10
|
-
assert_equal title, resp[1]["title"]
|
|
11
|
-
end
|
|
12
|
-
end
|
|
13
4
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
5
|
+
def test_title
|
|
6
|
+
VCR.use_cassette("test_title") do
|
|
7
|
+
title = "Open Internet Workshops and Speeches"
|
|
8
|
+
resp = FccContentApi::Content.where(:title => URI.encode(title)).all
|
|
9
|
+
assert_equal resp.first.keys.sort!, ["count", "pages", "itemsPerPage", "currentPage"].sort!
|
|
10
|
+
assert_equal resp[1].keys.sort!, ["nid", "title", "created", "changed", "type", "webUrl", "uri"].sort!
|
|
11
|
+
assert_equal title, resp[1]["title"]
|
|
12
|
+
end
|
|
13
|
+
end
|
|
21
14
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
"field_author", "field_job_title", "field_edoc_internal_id",
|
|
30
|
-
"field_released_date", "field_published_date",
|
|
31
|
-
"field_adopted_date", "field_comment_date", "field_edoc_id",
|
|
32
|
-
"field_featured_image", "topics", "uri"]
|
|
33
|
-
assert_equal resp.keys.sort!, keys.sort!
|
|
34
|
-
end
|
|
35
|
-
end
|
|
15
|
+
def test_all
|
|
16
|
+
VCR.use_cassette("test_all") do
|
|
17
|
+
resp = FccContentApi::Content.all
|
|
18
|
+
assert_equal resp.first.keys.sort!, ["count", "pages", "itemsPerPage", "currentPage"].sort!
|
|
19
|
+
assert_equal resp[1].keys.sort!, ["nid", "title", "created", "changed", "type", "webUrl", "uri"].sort!
|
|
20
|
+
end
|
|
21
|
+
end
|
|
36
22
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
23
|
+
|
|
24
|
+
def test_find
|
|
25
|
+
VCR.use_cassette("test_find") do
|
|
26
|
+
resp = FccContentApi::Content.find 38837
|
|
27
|
+
assert_equal resp.class, Hash
|
|
28
|
+
keys = ["nid", "title", "created", "changed",
|
|
29
|
+
"type", "webUrl", "taxonomy", "body",
|
|
30
|
+
"vid", "field_short_title", "field_short_description",
|
|
31
|
+
"field_author", "field_job_title", "field_edoc_internal_id",
|
|
32
|
+
"field_released_date", "field_published_date",
|
|
33
|
+
"field_adopted_date", "field_comment_date", "field_edoc_id",
|
|
34
|
+
"field_featured_image", "topics", "uri"]
|
|
35
|
+
assert_equal resp.keys.sort!, keys.sort!
|
|
36
|
+
end
|
|
37
|
+
end
|
|
45
38
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
39
|
+
def test_params
|
|
40
|
+
params = {
|
|
41
|
+
:attribute1 => "value1", # invalid
|
|
42
|
+
:search_string => "searchq" # valid
|
|
43
|
+
}
|
|
44
|
+
req = FccContentApi::Content.where(params).request
|
|
45
|
+
assert_equal req.uri.to_s.split("?")[1], "search_string=searchq"
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
def test_equivalent_queries
|
|
49
|
+
q1 = FccContentApi::Content.where({:search_string => "broadband", :created_afer => "2012-1-1"}).request
|
|
50
|
+
q2 = FccContentApi::Content.where(:search_string => "broadband").where(:created_afer => "2012-1-1").request
|
|
51
|
+
assert_equal q1.uri.to_s, q2.uri.to_s
|
|
52
|
+
end
|
|
51
53
|
end
|
data/test/test_helper.rb
CHANGED
data/test/test_query.rb
CHANGED
|
@@ -3,24 +3,24 @@ require "test_helper"
|
|
|
3
3
|
class TestQuery < Test::Unit::TestCase
|
|
4
4
|
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
6
|
+
def test_where
|
|
7
|
+
query = FccContentApi::Query.new(FccContentApi::Content)
|
|
8
|
+
query.where(:attribute => "value")
|
|
9
|
+
assert_equal query.criteria[:attribute], "value"
|
|
10
|
+
end
|
|
11
11
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
12
|
+
def test_stacked_wheres
|
|
13
|
+
query = FccContentApi::Query.new(FccContentApi::Content)
|
|
14
|
+
query.where(:attribute => "value")
|
|
15
|
+
assert_equal query.criteria[:attribute], "value"
|
|
16
|
+
query.where(:second_attribute => "second_value")
|
|
17
|
+
assert_equal query.criteria[:second_attribute], "second_value"
|
|
18
|
+
assert_equal query.criteria[:attribute], "value"
|
|
19
|
+
end
|
|
20
20
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
21
|
+
def test_request
|
|
22
|
+
query = FccContentApi::Query.new(FccContentApi::Content)
|
|
23
|
+
assert_equal query.request.class, Weary::Request
|
|
24
|
+
end
|
|
25
25
|
|
|
26
26
|
end
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: fcc-content-api
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.0.
|
|
4
|
+
version: 0.0.2
|
|
5
5
|
prerelease:
|
|
6
6
|
platform: ruby
|
|
7
7
|
authors:
|
|
@@ -9,11 +9,11 @@ authors:
|
|
|
9
9
|
autorequire:
|
|
10
10
|
bindir: bin
|
|
11
11
|
cert_chain: []
|
|
12
|
-
date: 2012-04-
|
|
12
|
+
date: 2012-04-17 00:00:00.000000000Z
|
|
13
13
|
dependencies:
|
|
14
14
|
- !ruby/object:Gem::Dependency
|
|
15
15
|
name: vcr
|
|
16
|
-
requirement: &
|
|
16
|
+
requirement: &70178652500760 !ruby/object:Gem::Requirement
|
|
17
17
|
none: false
|
|
18
18
|
requirements:
|
|
19
19
|
- - ! '>='
|
|
@@ -21,10 +21,10 @@ dependencies:
|
|
|
21
21
|
version: '0'
|
|
22
22
|
type: :development
|
|
23
23
|
prerelease: false
|
|
24
|
-
version_requirements: *
|
|
24
|
+
version_requirements: *70178652500760
|
|
25
25
|
- !ruby/object:Gem::Dependency
|
|
26
26
|
name: webmock
|
|
27
|
-
requirement: &
|
|
27
|
+
requirement: &70178652500240 !ruby/object:Gem::Requirement
|
|
28
28
|
none: false
|
|
29
29
|
requirements:
|
|
30
30
|
- - ! '>='
|
|
@@ -32,10 +32,10 @@ dependencies:
|
|
|
32
32
|
version: 1.8.0
|
|
33
33
|
type: :development
|
|
34
34
|
prerelease: false
|
|
35
|
-
version_requirements: *
|
|
35
|
+
version_requirements: *70178652500240
|
|
36
36
|
- !ruby/object:Gem::Dependency
|
|
37
37
|
name: weary
|
|
38
|
-
requirement: &
|
|
38
|
+
requirement: &70178652499600 !ruby/object:Gem::Requirement
|
|
39
39
|
none: false
|
|
40
40
|
requirements:
|
|
41
41
|
- - ! '>='
|
|
@@ -43,7 +43,7 @@ dependencies:
|
|
|
43
43
|
version: '0'
|
|
44
44
|
type: :runtime
|
|
45
45
|
prerelease: false
|
|
46
|
-
version_requirements: *
|
|
46
|
+
version_requirements: *70178652499600
|
|
47
47
|
description: A Ruby wrapper for the FCC's Content API
|
|
48
48
|
email:
|
|
49
49
|
- adelevie@gmail.com
|
|
@@ -52,10 +52,14 @@ extensions: []
|
|
|
52
52
|
extra_rdoc_files: []
|
|
53
53
|
files:
|
|
54
54
|
- .gitignore
|
|
55
|
+
- .travis.yml
|
|
55
56
|
- Gemfile
|
|
56
57
|
- README.md
|
|
57
58
|
- Rakefile
|
|
58
59
|
- fcc-content-api.gemspec
|
|
60
|
+
- fixtures/vcr_cassettes/test_all.yml
|
|
61
|
+
- fixtures/vcr_cassettes/test_find.yml
|
|
62
|
+
- fixtures/vcr_cassettes/test_title.yml
|
|
59
63
|
- lib/fcc-content-api.rb
|
|
60
64
|
- lib/fcc-content-api/version.rb
|
|
61
65
|
- test/test_client.rb
|