statement 0.9.8 → 0.9.9
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +27 -1
- data/lib/statement/tweets.rb +39 -0
- data/lib/statement/version.rb +1 -1
- data/lib/statement.rb +1 -0
- data/statement.gemspec +1 -0
- metadata +36 -43
- checksums.yaml +0 -15
data/README.md
CHANGED
@@ -28,7 +28,12 @@ $ gem install statement
|
|
28
28
|
|
29
29
|
## Usage
|
30
30
|
|
31
|
-
Statement provides access to press releases
|
31
|
+
Statement provides access to press releases, Facebook status updates and tweets from members of Congress. Most congressional offices have RSS feeds but some require HTML scraping.
|
32
|
+
|
33
|
+
|
34
|
+
### Press Releases
|
35
|
+
|
36
|
+
To parse an RSS feed, simply pass the URL to Statement's Feed class:
|
32
37
|
|
33
38
|
```ruby
|
34
39
|
require 'rubygems'
|
@@ -46,6 +51,8 @@ results = Statement::Scraper.billnelson
|
|
46
51
|
members = Statement::Scraper.member_scrapers
|
47
52
|
```
|
48
53
|
|
54
|
+
### Facebook Updates
|
55
|
+
|
49
56
|
Using the `koala` gem, Statement can fetch Facebook status feeds, given a Facebook ID. You'll need to either set environment variables `APP_ID` and `APP_SECRET` or create a `config.yml` file containing `app_id` and `app_secret` keys and values.
|
50
57
|
|
51
58
|
```ruby
|
@@ -66,6 +73,25 @@ In all cases Statement strips out posts that are not by the ID, and returns a Ha
|
|
66
73
|
{:id=>"9307301412_10151632750071413", :body=>"This is Gold Star Mother Larraine McGee whose son, Christopher Everett, Army National Guard, was killed in action September 2005. Precious family.", :link=>"http://www.facebook.com/photo.php?fbid=10151632750021413&set=a.118418671412.133511.9307301412&type=1&relevant_count=1", :title=>nil, :type=>"photo", :status_type=>"added_photos", :created_time=>#<DateTime: 2013-05-28T14:49:08+00:00 ((2456441j,53348s,0n),+0s,2299161j)>, :updated_time=>#<DateTime: 2013-05-28T17:41:37+00:00 ((2456441j,63697s,0n),+0s,2299161j)>, :facebook_id=>"9307301412"}
|
67
74
|
```
|
68
75
|
|
76
|
+
### Tweets
|
77
|
+
|
78
|
+
Using the `twitter` gem, Statement can retrieve individual user timelines or list timelines:
|
79
|
+
|
80
|
+
```ruby
|
81
|
+
t = Statement::Tweets.new
|
82
|
+
t.timeline('Robert_Aderholt')
|
83
|
+
[{:id=>344168849484169216, :body=>"Check out the @GOPLeader's weekly schedule for the House this week. http://t.co/mh3FZnK4a8", :link=>"http://majorityleader.gov/floor/weekly.html", :in_reply_to_screen_name=>nil, :total_tweets=>699, :created_time=>2013-06-10 15:07:02 -0400, :retweets=>0, :favorites=>0, :screen_name=>"Robert_Aderholt"}...]
|
84
|
+
```
|
85
|
+
Note that the `created_time` attribute is a Ruby Time object, as returned by the `twitter` gem.
|
86
|
+
|
87
|
+
To retrieve a list's timeline, pass in the owner (defaults to nil) and list slug:
|
88
|
+
|
89
|
+
```ruby
|
90
|
+
t = Statement::Tweets.new
|
91
|
+
t.bulk_timeline('congress')
|
92
|
+
[:id=>343541632844587008, :body=>"On the Skagit river getting a close-up view of the bridge repairs. http://t.co/SMsdwiFaR6", :link=>nil, :in_reply_to_screen_name=>nil, :total_tweets=>226, :created_time=>2013-06-08 21:34:42 -0400, :retweets=>1, :favorites=>2, :screen_name=>"RepDelBene"}..]
|
93
|
+
```
|
94
|
+
|
69
95
|
## Tests
|
70
96
|
|
71
97
|
Statement uses MiniTest, to run tests:
|
@@ -0,0 +1,39 @@
|
|
1
|
+
require 'twitter'
|
2
|
+
require 'yaml'
|
3
|
+
|
4
|
+
module Statement
|
5
|
+
class Tweets
|
6
|
+
|
7
|
+
attr_accessor :client, :timeline, :bulk_timeline
|
8
|
+
|
9
|
+
def initialize
|
10
|
+
@@config = YAML.load_file("config.yml") rescue nil || {}
|
11
|
+
@client = Twitter::Client.new(
|
12
|
+
:consumer_key => ENV['CONSUMER_KEY'] || @@config['consumer_key'],
|
13
|
+
:consumer_secret => ENV['CONSUMER_SECRET'] || @@config['consumer_secret'],
|
14
|
+
:oauth_token => ENV['OAUTH_TOKEN'] || @@config['oauth_token'],
|
15
|
+
:oauth_token_secret => ENV['OAUTH_TOKEN_SECRET'] || @@config['oauth_token_secret']
|
16
|
+
)
|
17
|
+
end
|
18
|
+
|
19
|
+
# fetches single twitter user's timeline
|
20
|
+
def timeline(member_id)
|
21
|
+
process_results(client.user_timeline(member_id))
|
22
|
+
end
|
23
|
+
|
24
|
+
# fetches latest 100 tweets from a list (derekwillis twitter acct has a public congress list)
|
25
|
+
def bulk_timeline(list_owner=nil, list_id)
|
26
|
+
process_results(client.list_timeline(list_owner, list_id, {:count => 100}))
|
27
|
+
end
|
28
|
+
|
29
|
+
def process_results(tweets)
|
30
|
+
results = []
|
31
|
+
tweets.each do |tweet|
|
32
|
+
url = tweet[:urls].first ? tweet[:urls].first[:expanded_url] : nil
|
33
|
+
results << { :id => tweet[:id], :body => tweet[:text], :link => url, :in_reply_to_screen_name => tweet[:in_reply_to_screen_name], :total_tweets => tweet[:user][:statuses_count], :created_time => tweet[:created_at], :retweets => tweet[:retweet_count], :favorites => tweet[:favorite_count], :screen_name => tweet[:user][:screen_name]}
|
34
|
+
end
|
35
|
+
results
|
36
|
+
end
|
37
|
+
|
38
|
+
end
|
39
|
+
end
|
data/lib/statement/version.rb
CHANGED
data/lib/statement.rb
CHANGED
data/statement.gemspec
CHANGED
metadata
CHANGED
@@ -1,113 +1,104 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: statement
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.9.
|
4
|
+
version: 0.9.9
|
5
|
+
prerelease:
|
5
6
|
platform: ruby
|
6
7
|
authors:
|
7
8
|
- Derek Willis
|
8
9
|
autorequire:
|
9
10
|
bindir: bin
|
10
11
|
cert_chain: []
|
11
|
-
date: 2013-06-
|
12
|
+
date: 2013-06-10 00:00:00.000000000 Z
|
12
13
|
dependencies:
|
13
14
|
- !ruby/object:Gem::Dependency
|
14
15
|
name: bundler
|
15
|
-
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirement: &2160388100 !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
16
18
|
requirements:
|
17
19
|
- - ~>
|
18
20
|
- !ruby/object:Gem::Version
|
19
21
|
version: '1.3'
|
20
22
|
type: :development
|
21
23
|
prerelease: false
|
22
|
-
version_requirements:
|
23
|
-
requirements:
|
24
|
-
- - ~>
|
25
|
-
- !ruby/object:Gem::Version
|
26
|
-
version: '1.3'
|
24
|
+
version_requirements: *2160388100
|
27
25
|
- !ruby/object:Gem::Dependency
|
28
26
|
name: rake
|
29
|
-
requirement: !ruby/object:Gem::Requirement
|
27
|
+
requirement: &2160387540 !ruby/object:Gem::Requirement
|
28
|
+
none: false
|
30
29
|
requirements:
|
31
30
|
- - ! '>='
|
32
31
|
- !ruby/object:Gem::Version
|
33
32
|
version: '0'
|
34
33
|
type: :development
|
35
34
|
prerelease: false
|
36
|
-
version_requirements:
|
37
|
-
requirements:
|
38
|
-
- - ! '>='
|
39
|
-
- !ruby/object:Gem::Version
|
40
|
-
version: '0'
|
35
|
+
version_requirements: *2160387540
|
41
36
|
- !ruby/object:Gem::Dependency
|
42
37
|
name: webmock
|
43
|
-
requirement: !ruby/object:Gem::Requirement
|
38
|
+
requirement: &2160386960 !ruby/object:Gem::Requirement
|
39
|
+
none: false
|
44
40
|
requirements:
|
45
41
|
- - ! '>='
|
46
42
|
- !ruby/object:Gem::Version
|
47
43
|
version: '0'
|
48
44
|
type: :development
|
49
45
|
prerelease: false
|
50
|
-
version_requirements:
|
51
|
-
requirements:
|
52
|
-
- - ! '>='
|
53
|
-
- !ruby/object:Gem::Version
|
54
|
-
version: '0'
|
46
|
+
version_requirements: *2160386960
|
55
47
|
- !ruby/object:Gem::Dependency
|
56
48
|
name: american_date
|
57
|
-
requirement: !ruby/object:Gem::Requirement
|
49
|
+
requirement: &2160386260 !ruby/object:Gem::Requirement
|
50
|
+
none: false
|
58
51
|
requirements:
|
59
52
|
- - ! '>='
|
60
53
|
- !ruby/object:Gem::Version
|
61
54
|
version: '0'
|
62
55
|
type: :runtime
|
63
56
|
prerelease: false
|
64
|
-
version_requirements:
|
65
|
-
requirements:
|
66
|
-
- - ! '>='
|
67
|
-
- !ruby/object:Gem::Version
|
68
|
-
version: '0'
|
57
|
+
version_requirements: *2160386260
|
69
58
|
- !ruby/object:Gem::Dependency
|
70
59
|
name: nokogiri
|
71
|
-
requirement: !ruby/object:Gem::Requirement
|
60
|
+
requirement: &2160385680 !ruby/object:Gem::Requirement
|
61
|
+
none: false
|
72
62
|
requirements:
|
73
63
|
- - ! '>='
|
74
64
|
- !ruby/object:Gem::Version
|
75
65
|
version: '0'
|
76
66
|
type: :runtime
|
77
67
|
prerelease: false
|
78
|
-
version_requirements:
|
79
|
-
requirements:
|
80
|
-
- - ! '>='
|
81
|
-
- !ruby/object:Gem::Version
|
82
|
-
version: '0'
|
68
|
+
version_requirements: *2160385680
|
83
69
|
- !ruby/object:Gem::Dependency
|
84
70
|
name: koala
|
85
|
-
requirement: !ruby/object:Gem::Requirement
|
71
|
+
requirement: &2160385220 !ruby/object:Gem::Requirement
|
72
|
+
none: false
|
86
73
|
requirements:
|
87
74
|
- - ! '>='
|
88
75
|
- !ruby/object:Gem::Version
|
89
76
|
version: '0'
|
90
77
|
type: :runtime
|
91
78
|
prerelease: false
|
92
|
-
version_requirements:
|
93
|
-
requirements:
|
94
|
-
- - ! '>='
|
95
|
-
- !ruby/object:Gem::Version
|
96
|
-
version: '0'
|
79
|
+
version_requirements: *2160385220
|
97
80
|
- !ruby/object:Gem::Dependency
|
98
81
|
name: oj
|
99
|
-
requirement: !ruby/object:Gem::Requirement
|
82
|
+
requirement: &2160384700 !ruby/object:Gem::Requirement
|
83
|
+
none: false
|
100
84
|
requirements:
|
101
85
|
- - ! '>='
|
102
86
|
- !ruby/object:Gem::Version
|
103
87
|
version: '0'
|
104
88
|
type: :runtime
|
105
89
|
prerelease: false
|
106
|
-
version_requirements:
|
90
|
+
version_requirements: *2160384700
|
91
|
+
- !ruby/object:Gem::Dependency
|
92
|
+
name: twitter
|
93
|
+
requirement: &2160384260 !ruby/object:Gem::Requirement
|
94
|
+
none: false
|
107
95
|
requirements:
|
108
96
|
- - ! '>='
|
109
97
|
- !ruby/object:Gem::Version
|
110
98
|
version: '0'
|
99
|
+
type: :runtime
|
100
|
+
prerelease: false
|
101
|
+
version_requirements: *2160384260
|
111
102
|
description: Crawls congressional websites for press releases.
|
112
103
|
email:
|
113
104
|
- dwillis@gmail.com
|
@@ -124,6 +115,7 @@ files:
|
|
124
115
|
- lib/statement/facebook.rb
|
125
116
|
- lib/statement/feed.rb
|
126
117
|
- lib/statement/scraper.rb
|
118
|
+
- lib/statement/tweets.rb
|
127
119
|
- lib/statement/utils.rb
|
128
120
|
- lib/statement/version.rb
|
129
121
|
- spec/bill_nelson_press.html
|
@@ -138,26 +130,27 @@ files:
|
|
138
130
|
homepage: ''
|
139
131
|
licenses:
|
140
132
|
- Apache
|
141
|
-
metadata: {}
|
142
133
|
post_install_message:
|
143
134
|
rdoc_options: []
|
144
135
|
require_paths:
|
145
136
|
- lib
|
146
137
|
required_ruby_version: !ruby/object:Gem::Requirement
|
138
|
+
none: false
|
147
139
|
requirements:
|
148
140
|
- - ! '>='
|
149
141
|
- !ruby/object:Gem::Version
|
150
142
|
version: '0'
|
151
143
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
144
|
+
none: false
|
152
145
|
requirements:
|
153
146
|
- - ! '>='
|
154
147
|
- !ruby/object:Gem::Version
|
155
148
|
version: '0'
|
156
149
|
requirements: []
|
157
150
|
rubyforge_project:
|
158
|
-
rubygems_version:
|
151
|
+
rubygems_version: 1.8.17
|
159
152
|
signing_key:
|
160
|
-
specification_version:
|
153
|
+
specification_version: 3
|
161
154
|
summary: Given a url, Statement returns links to press releases and official statements.
|
162
155
|
test_files:
|
163
156
|
- spec/bill_nelson_press.html
|
checksums.yaml
DELETED
@@ -1,15 +0,0 @@
|
|
1
|
-
---
|
2
|
-
!binary "U0hBMQ==":
|
3
|
-
metadata.gz: !binary |-
|
4
|
-
M2UzMWMzZTk0NWMwMDQ3YTc5MDljNmRjNzE4MWE1MGNjMjU0MDBkZg==
|
5
|
-
data.tar.gz: !binary |-
|
6
|
-
MmE5M2Q4YjUyMGExNzk0ZTI5YTEwMjZkNTkyMmQ0OWRiNzJkZjZmMA==
|
7
|
-
!binary "U0hBNTEy":
|
8
|
-
metadata.gz: !binary |-
|
9
|
-
YmVkYzlkMzFlNWJmMWU1MjhlZmM1YjJkN2MyNGQwY2Q1YmM1ODQ0ZDk3ZGY2
|
10
|
-
ZjEyZGMxOTljYjk2MDM1ZTU3NjhjYjczZDU4NDkzYWZkZTJkMjQ3ZDEzMzE5
|
11
|
-
NTU4OTlmNDk5OTkyNWQ5NjMxZmZhMTZlOGNhMmYwNmYzNTAxNmM=
|
12
|
-
data.tar.gz: !binary |-
|
13
|
-
ODBiNDQ1ZTBmZDE4MzQwNDEzOGEwYzFiZDVlYjY5YTVjOTJjMDI3OWU1ZDdi
|
14
|
-
MzkxZDM1NzBjNzQ2NjRjZDkwODA3ODI1OTU0MTI3MTBlNTE3NTJkZDE4ZTM2
|
15
|
-
ZDQ2MzczNjNkODk0MmQwMmVkOGE0ZjBlZDBhNzVjZjVhMWZiNGM=
|