statement 0.1

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/.gitignore ADDED
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in statement.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2013 Derek Willis
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,40 @@
1
+ # Statement
2
+
3
+ Statement parses RSS feeds and HTML pages containing press releases and other official statements from members of Congress, and produces hashes with information about those pages.
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'statement'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install statement
18
+
19
+ ## Usage
20
+
21
+ require 'rubygems'
22
+ require 'statement'
23
+
24
+ results = Statement::Link.house_gop('http://www.gop.gov/republicans/news?offset=03/29/11')
25
+ puts results.first
26
+ {:source=>"http://www.gop.gov/republicans/news?offset=03/29/11", :url=>"http://poe.house.gov/News/DocumentSingle.aspx?DocumentID=233004", :title=>"Poe: War in the Name of Humanity", :date=> <Date: 2011-03-29 ((2455650j,0s,0n),+0s,2299161j)>, :domain=>"poe.house.gov"}
27
+
28
+ ## Tests
29
+
30
+ Statement uses MiniTest, to run tests:
31
+
32
+ rake test
33
+
34
+ ## Contributing
35
+
36
+ 1. Fork it
37
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
38
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
39
+ 4. Push to the branch (`git push origin my-new-feature`)
40
+ 5. Create new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,13 @@
1
+ #!/usr/bin/env rake
2
+ require 'bundler'
3
+ require "bundler/gem_tasks"
4
+ Bundler::GemHelper.install_tasks
5
+
6
+ require 'rake/testtask'
7
+ Rake::TestTask.new(:test) do |test|
8
+ test.libs << 'lib' << 'test'
9
+ test.pattern = 'spec/*.rb'
10
+ test.verbose = true
11
+ end
12
+
13
+ task :default => :test
data/lib/statement.rb ADDED
@@ -0,0 +1,27 @@
1
+ require "statement/version"
2
+ require 'uri'
3
+ require 'open-uri'
4
+ require 'american_date'
5
+ require 'nokogiri'
6
+
7
+ module Statement
8
+
9
+ class Link
10
+
11
+ def self.from_rss(url)
12
+ doc = Nokogiri::XML(open(url))
13
+ links = doc.xpath('//item')
14
+ links.map{|link| {:source => url, :url => link.xpath('link').text, :title => link.xpath('title').text, :date => Date.parse(link.xpath('pubDate').text), :domain => URI.parse(link.xpath('link').text).host }}
15
+ end
16
+
17
+ def self.house_gop(url)
18
+ uri = URI.parse(url)
19
+ date = Date.parse(uri.query.split('=').last)
20
+ doc = Nokogiri::HTML(open(url).read)
21
+ links = doc.xpath("//ul[@id='membernews']").search('a')
22
+ links.map{|link| {:source => url, :url => link["href"], :title => link.text.strip, :date => date, :domain => URI.parse(link["href"]).host}}
23
+ end
24
+
25
+ end
26
+
27
+ end
@@ -0,0 +1,3 @@
1
+ module Statement
2
+ VERSION = "0.1"
3
+ end
@@ -0,0 +1,15 @@
1
+ require "minitest/autorun"
2
+ require_relative "../lib/statement"
3
+
4
+ describe Statement do
5
+ it "parses an rss feed" do
6
+ @results = Statement::Link.from_rss("http://ruiz.house.gov/rss.xml")
7
+ @results.first[:domain].must_equal "ruiz.house.gov"
8
+ end
9
+
10
+ it "parses House GOP press release page" do
11
+ @results = Statement::Link.house_gop("http://www.gop.gov/republicans/news?offset=03/29/13")
12
+ @results.first[:source].must_equal "http://www.gop.gov/republicans/news?offset=03/29/13"
13
+ end
14
+
15
+ end
data/statement.gemspec ADDED
@@ -0,0 +1,25 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'statement/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "statement"
8
+ spec.version = Statement::VERSION
9
+ spec.authors = ["Derek Willis"]
10
+ spec.email = ["dwillis@gmail.com"]
11
+ spec.description = %q{Crawls congressional websites for press releases.}
12
+ spec.summary = %q{Given a url, Statement returns links to press releases and official statements.}
13
+ spec.homepage = ""
14
+ spec.license = "Apache"
15
+
16
+ spec.files = `git ls-files`.split($/)
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_development_dependency "bundler", "~> 1.3"
22
+ spec.add_development_dependency "rake"
23
+ spec.add_dependency "american_date"
24
+ spec.add_dependency "nokogiri"
25
+ end
metadata ADDED
@@ -0,0 +1,100 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: statement
3
+ version: !ruby/object:Gem::Version
4
+ version: '0.1'
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Derek Willis
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2013-04-04 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: bundler
16
+ requirement: &2151816480 !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ~>
20
+ - !ruby/object:Gem::Version
21
+ version: '1.3'
22
+ type: :development
23
+ prerelease: false
24
+ version_requirements: *2151816480
25
+ - !ruby/object:Gem::Dependency
26
+ name: rake
27
+ requirement: &2151815620 !ruby/object:Gem::Requirement
28
+ none: false
29
+ requirements:
30
+ - - ! '>='
31
+ - !ruby/object:Gem::Version
32
+ version: '0'
33
+ type: :development
34
+ prerelease: false
35
+ version_requirements: *2151815620
36
+ - !ruby/object:Gem::Dependency
37
+ name: american_date
38
+ requirement: &2151814280 !ruby/object:Gem::Requirement
39
+ none: false
40
+ requirements:
41
+ - - ! '>='
42
+ - !ruby/object:Gem::Version
43
+ version: '0'
44
+ type: :runtime
45
+ prerelease: false
46
+ version_requirements: *2151814280
47
+ - !ruby/object:Gem::Dependency
48
+ name: nokogiri
49
+ requirement: &2151813120 !ruby/object:Gem::Requirement
50
+ none: false
51
+ requirements:
52
+ - - ! '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ type: :runtime
56
+ prerelease: false
57
+ version_requirements: *2151813120
58
+ description: Crawls congressional websites for press releases.
59
+ email:
60
+ - dwillis@gmail.com
61
+ executables: []
62
+ extensions: []
63
+ extra_rdoc_files: []
64
+ files:
65
+ - .gitignore
66
+ - Gemfile
67
+ - LICENSE.txt
68
+ - README.md
69
+ - Rakefile
70
+ - lib/statement.rb
71
+ - lib/statement/version.rb
72
+ - spec/statement_spec.rb
73
+ - statement.gemspec
74
+ homepage: ''
75
+ licenses:
76
+ - Apache
77
+ post_install_message:
78
+ rdoc_options: []
79
+ require_paths:
80
+ - lib
81
+ required_ruby_version: !ruby/object:Gem::Requirement
82
+ none: false
83
+ requirements:
84
+ - - ! '>='
85
+ - !ruby/object:Gem::Version
86
+ version: '0'
87
+ required_rubygems_version: !ruby/object:Gem::Requirement
88
+ none: false
89
+ requirements:
90
+ - - ! '>='
91
+ - !ruby/object:Gem::Version
92
+ version: '0'
93
+ requirements: []
94
+ rubyforge_project:
95
+ rubygems_version: 1.8.17
96
+ signing_key:
97
+ specification_version: 3
98
+ summary: Given a url, Statement returns links to press releases and official statements.
99
+ test_files:
100
+ - spec/statement_spec.rb