statement 0.9.1 → 0.9.3

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore CHANGED
@@ -17,3 +17,4 @@ spec/reports
17
17
  test/tmp
18
18
  test/version_tmp
19
19
  tmp
20
+ config.yml
data/README.md CHANGED
@@ -28,15 +28,24 @@ $ gem install statement
28
28
 
29
29
  ## Usage
30
30
 
31
+ Statement provides access to press releases and Facebook status updates from members of Congress. Most congressional offices have RSS feeds but some require HTML scraping. To parse an RSS feed, simply pass the URL to Statement's Feed class:
32
+
31
33
  ```ruby
32
34
  require 'rubygems'
33
35
  require 'statement'
34
36
 
35
- results = Statement::Link.from_rss('http://blumenauer.house.gov/index.php?option=com_bca-rss-syndicator&feed_id=1')
37
+ results = Statement::Feed.from_rss('http://blumenauer.house.gov/index.php?option=com_bca-rss-syndicator&feed_id=1')
36
38
  puts results.first
37
39
  {:source=>"http://blumenauer.house.gov/index.php?option=com_bca-rss-syndicator&feed_id=1", :url=>"http://blumenauer.house.gov/index.php?option=com_content&amp;view=article&amp;id=2203:blumenauer-qwe-need-a-national-system-that-speaks-to-the-transportation-challenges-of-todayq&amp;catid=66:2013-press-releases", :title=>"Blumenauer: &quot;We need a national system that speaks to the transportation challenges of ...", :date=>#<Date: 2013-04-24 ((2456407j,0s,0n),+0s,2299161j)>, :domain=>"blumenauer.house.gov"}
38
40
  ```
39
41
 
42
+ The sites that require HTML scraping are detailed in individual methods, and can be called individually or in bulk:
43
+
44
+ ```
45
+ `results = Statement::Scraper.billnelson`
46
+ `all_scraped_members = Statement::Scraper.member_scrapers`
47
+ ```
48
+
40
49
  ## Tests
41
50
 
42
51
  Statement uses MiniTest, to run tests:
@@ -0,0 +1,32 @@
1
+ require 'koala'
2
+ require 'oj'
3
+ require 'yaml'
4
+
5
+ module Statement
6
+ class Facebook
7
+
8
+ attr_accessor :graph, :feed, :batch
9
+
10
+ def initialize
11
+ @@config = YAML.load_file("config.yml") rescue nil || {}
12
+ app_id = ENV['APP_ID'] || @@config['app_id']
13
+ app_secret = ENV['APP_SECRET'] || @@config['app_secret']
14
+ oauth = Koala::Facebook::OAuth.new(app_id, app_secret)
15
+ @graph = Koala::Facebook::API.new(oauth.get_app_access_token)
16
+ end
17
+
18
+ def feed(member_id)
19
+ graph.get_connection(member_id, 'feed')
20
+ end
21
+
22
+ # given an array of congressional facebook ids, pulls feeds in batches of 50.
23
+ def batch(member_ids, slice)
24
+ results = []
25
+ member_ids.each_slice(slice) do |members|
26
+ results << graph.batch {|batch_api| members.each {|member| batch_api.get_connection(member, 'feed')}}
27
+ end
28
+ results
29
+ end
30
+
31
+ end
32
+ end
@@ -3,7 +3,6 @@ require 'uri'
3
3
  require 'open-uri'
4
4
  require 'american_date'
5
5
  require 'nokogiri'
6
- include Statement
7
6
 
8
7
  module Statement
9
8
  class Feed
@@ -1,3 +1,3 @@
1
1
  module Statement
2
- VERSION = "0.9.1"
2
+ VERSION = "0.9.3"
3
3
  end
data/lib/statement.rb CHANGED
@@ -2,7 +2,7 @@ require "statement/version"
2
2
  require "statement/feed"
3
3
  require "statement/scraper"
4
4
  require "statement/utils"
5
- include Statement
5
+ require "statement/facebook"
6
6
 
7
7
  module Statement
8
8
  extend Utils
data/statement.gemspec CHANGED
@@ -23,4 +23,6 @@ Gem::Specification.new do |spec|
23
23
  spec.add_development_dependency 'webmock'
24
24
  spec.add_dependency "american_date"
25
25
  spec.add_dependency "nokogiri"
26
+ spec.add_dependency "koala"
27
+ spec.add_dependency "oj"
26
28
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: statement
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.1
4
+ version: 0.9.3
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: 2013-05-20 00:00:00.000000000 Z
12
+ date: 2013-05-22 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler
16
- requirement: &2151797840 !ruby/object:Gem::Requirement
16
+ requirement: &2151865900 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ~>
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: '1.3'
22
22
  type: :development
23
23
  prerelease: false
24
- version_requirements: *2151797840
24
+ version_requirements: *2151865900
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: rake
27
- requirement: &2151812980 !ruby/object:Gem::Requirement
27
+ requirement: &2151865380 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: '0'
33
33
  type: :development
34
34
  prerelease: false
35
- version_requirements: *2151812980
35
+ version_requirements: *2151865380
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: webmock
38
- requirement: &2151811780 !ruby/object:Gem::Requirement
38
+ requirement: &2151864860 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ! '>='
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: '0'
44
44
  type: :development
45
45
  prerelease: false
46
- version_requirements: *2151811780
46
+ version_requirements: *2151864860
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: american_date
49
- requirement: &2151810340 !ruby/object:Gem::Requirement
49
+ requirement: &2151864300 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ! '>='
@@ -54,10 +54,10 @@ dependencies:
54
54
  version: '0'
55
55
  type: :runtime
56
56
  prerelease: false
57
- version_requirements: *2151810340
57
+ version_requirements: *2151864300
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: nokogiri
60
- requirement: &2151809600 !ruby/object:Gem::Requirement
60
+ requirement: &2151863820 !ruby/object:Gem::Requirement
61
61
  none: false
62
62
  requirements:
63
63
  - - ! '>='
@@ -65,7 +65,29 @@ dependencies:
65
65
  version: '0'
66
66
  type: :runtime
67
67
  prerelease: false
68
- version_requirements: *2151809600
68
+ version_requirements: *2151863820
69
+ - !ruby/object:Gem::Dependency
70
+ name: koala
71
+ requirement: &2151863260 !ruby/object:Gem::Requirement
72
+ none: false
73
+ requirements:
74
+ - - ! '>='
75
+ - !ruby/object:Gem::Version
76
+ version: '0'
77
+ type: :runtime
78
+ prerelease: false
79
+ version_requirements: *2151863260
80
+ - !ruby/object:Gem::Dependency
81
+ name: oj
82
+ requirement: &2151877300 !ruby/object:Gem::Requirement
83
+ none: false
84
+ requirements:
85
+ - - ! '>='
86
+ - !ruby/object:Gem::Version
87
+ version: '0'
88
+ type: :runtime
89
+ prerelease: false
90
+ version_requirements: *2151877300
69
91
  description: Crawls congressional websites for press releases.
70
92
  email:
71
93
  - dwillis@gmail.com
@@ -79,6 +101,7 @@ files:
79
101
  - README.md
80
102
  - Rakefile
81
103
  - lib/statement.rb
104
+ - lib/statement/facebook.rb
82
105
  - lib/statement/feed.rb
83
106
  - lib/statement/scraper.rb
84
107
  - lib/statement/utils.rb