politico_rss 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 1ec936becbbb3518b7aa43d62878409e103c2370
4
+ data.tar.gz: 59a06bc63f037567de8c6a63fcbc4a2e6771d27f
5
+ SHA512:
6
+ metadata.gz: 462f39f200c4e563afbc723620aad9578e1e13d183129a7343b0017011fe00c41c9af83f1b296e0e0e7e7f26ecad6c862000e583b1a8cc3fe8e50ccaf024193f
7
+ data.tar.gz: 0947a5da4112c6f40528b7867028c47482ffd04ad5dc5ca9bcb1cff7bfb2a06bdb5b1dd6c2ad46769e04dce1608da6bdb6a6c6fd2937c0509279ed56b326690d
@@ -0,0 +1,9 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format documentation
2
+ --color
@@ -0,0 +1,4 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.2.0
4
+ before_install: gem install bundler -v 1.10.5
@@ -0,0 +1,2 @@
1
+ --markup-provider=redcarpet
2
+ --markup=markdown
@@ -0,0 +1,6 @@
1
+ # Credits, Notes, and Reference
2
+
3
+ + http://www.politico.com/rss
4
+ + http://stackoverflow.com/questions/1230741/convert-a-nokogiri-document-to-a-ruby-hash
5
+ + http://kmckelvin.com/blog/2014/06/renaming-items-in-a-ruby-hash
6
+ + http://xmlprettyprint.com/
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in politico_rss.gemspec
4
+ gemspec
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2016 MJ Rossetti (@s2t2)
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
@@ -0,0 +1,44 @@
1
+ # POLITICO RSS - Ruby
2
+
3
+ A ruby interface to [POLITICO RSS feeds](http://www.politico.com/rss). Includes feed contents and metadata.
4
+
5
+ ## Installation
6
+
7
+ Add `gem 'politico_rss'` to your Gemfile and run `bundle install`, or install with:
8
+
9
+ ```` sh
10
+ gem install politico_rss
11
+ ````
12
+
13
+ ## Usage
14
+
15
+ Get feed contents and metadata.
16
+
17
+ ```` rb
18
+ feed = PoliticoRSS.feed("playbook")
19
+ ````
20
+
21
+ > NOTE: you can find the feed's name (e.g. `playbook`) from its URL (e.g. `http://www.politico.com/rss/playbook.xml`). A full list of known feed names is maintained in `spec/politico_rss_spec.rb`.
22
+
23
+ ## Development
24
+
25
+ ```` sh
26
+ git clone git@github.com:debate-watch/politico-rss-ruby.git
27
+ cd politico_rss/
28
+ ````
29
+
30
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake rspec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
31
+
32
+ ## Contributing
33
+
34
+ Bug reports and pull requests are welcome on GitHub at https://github.com/debate-watch/politico-rss-ruby.
35
+
36
+ ## Maintenance
37
+
38
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
39
+
40
+ Run `bundle exec yard doc` to parse comments and/or `bundle exec yard server` to view documentation at `localhost:8808`.
41
+
42
+ ## License
43
+
44
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "politico_rss"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ require "pry"
11
+ Pry.start
12
+
13
+ # require "irb"
14
+ # IRB.start
@@ -0,0 +1,7 @@
1
+ #!/bin/bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+
5
+ bundle install
6
+
7
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,32 @@
1
+ require "politico_rss/version"
2
+
3
+ require 'nokogiri'
4
+ require 'open-uri'
5
+ require 'active_support/core_ext/hash/conversions' # enables .from_xml method
6
+ require 'plissken' # enables .to_snake_keys method
7
+
8
+ # A module for parsing POLITICO RSS feeds (http://www.politico.com/rss).
9
+ module PoliticoRSS
10
+
11
+ # Request information about, and contents of, a given RSS feed.
12
+ #
13
+ # @param [String] feed_name The name of the POLITICO RSS feed. Get this from the feed's URL.
14
+ #
15
+ # @example PoliticoRSS.feed("politics08")
16
+ #
17
+ # @return [Hash]
18
+ #
19
+ def self.feed(feed_name)
20
+ feed_url = "http://www.politico.com/rss/#{feed_name}.xml"
21
+
22
+ doc = Nokogiri::XML(open(feed_url))
23
+ response = Hash.from_xml(doc.to_s)
24
+ response = response["rss"]["channel"]
25
+ response = response.to_snake_keys # rename "pubDate" attribute to "pub_date", and rename any other camel-cased keys that might exist in the future
26
+ response[:link] = response[:link][0][:href] unless response[:link].kind_of?(String) # simplify "link" attribute from a Hash to a String (if necessary - sometimes its just a string)
27
+ response[:items] = response.delete(:item) # rename "item" attribute to "items"
28
+ response[:items] = [response[:items]] unless response[:items].kind_of?(Array) # ensure the "items" attribute is an array, even if there is only one item, in which case it was a hash
29
+
30
+ return response
31
+ end
32
+ end
@@ -0,0 +1,4 @@
1
+ module PoliticoRSS
2
+ # Please observe semantic versioning (http://semver.org/).
3
+ VERSION = "1.0.0"
4
+ end
@@ -0,0 +1,33 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'politico_rss/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "politico_rss"
8
+ spec.version = PoliticoRSS::VERSION
9
+ spec.authors = ["MJ Rossetti (@s2t2)"]
10
+ spec.email = ["debatewatch2016@gmail.com"]
11
+
12
+ spec.summary = %q{ A ruby interface to POLITICO RSS feeds. }
13
+ spec.description = %q{ A ruby interface to POLITICO RSS feeds. Includes feed contents and metadata.}
14
+ spec.homepage = "https://github.com/debate-watch/politico-rss-ruby"
15
+ spec.license = "MIT"
16
+
17
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
18
+ spec.bindir = "exe"
19
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
20
+ spec.require_paths = ["lib"]
21
+
22
+ spec.add_development_dependency "bundler", "~> 1.10"
23
+ spec.add_development_dependency "rake", "~> 10.0"
24
+ spec.add_development_dependency "rspec"
25
+ spec.add_development_dependency "pry", "~> 0.10"
26
+ spec.add_development_dependency "yard"
27
+ spec.add_development_dependency "redcarpet"
28
+ spec.add_development_dependency "github-markup"
29
+
30
+ spec.add_dependency "nokogiri"
31
+ spec.add_dependency "activesupport"
32
+ spec.add_dependency "plissken"
33
+ end
metadata ADDED
@@ -0,0 +1,200 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: politico_rss
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - MJ Rossetti (@s2t2)
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2016-05-23 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.10'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.10'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: pry
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '0.10'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '0.10'
69
+ - !ruby/object:Gem::Dependency
70
+ name: yard
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: redcarpet
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: github-markup
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
+ - !ruby/object:Gem::Dependency
112
+ name: nokogiri
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - ">="
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ type: :runtime
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - ">="
123
+ - !ruby/object:Gem::Version
124
+ version: '0'
125
+ - !ruby/object:Gem::Dependency
126
+ name: activesupport
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - ">="
130
+ - !ruby/object:Gem::Version
131
+ version: '0'
132
+ type: :runtime
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - ">="
137
+ - !ruby/object:Gem::Version
138
+ version: '0'
139
+ - !ruby/object:Gem::Dependency
140
+ name: plissken
141
+ requirement: !ruby/object:Gem::Requirement
142
+ requirements:
143
+ - - ">="
144
+ - !ruby/object:Gem::Version
145
+ version: '0'
146
+ type: :runtime
147
+ prerelease: false
148
+ version_requirements: !ruby/object:Gem::Requirement
149
+ requirements:
150
+ - - ">="
151
+ - !ruby/object:Gem::Version
152
+ version: '0'
153
+ description: " A ruby interface to POLITICO RSS feeds. Includes feed contents and
154
+ metadata."
155
+ email:
156
+ - debatewatch2016@gmail.com
157
+ executables: []
158
+ extensions: []
159
+ extra_rdoc_files: []
160
+ files:
161
+ - ".gitignore"
162
+ - ".rspec"
163
+ - ".travis.yml"
164
+ - ".yardopts"
165
+ - CREDITS.md
166
+ - Gemfile
167
+ - LICENSE.txt
168
+ - README.md
169
+ - Rakefile
170
+ - bin/console
171
+ - bin/setup
172
+ - lib/politico_rss.rb
173
+ - lib/politico_rss/version.rb
174
+ - politico_rss.gemspec
175
+ homepage: https://github.com/debate-watch/politico-rss-ruby
176
+ licenses:
177
+ - MIT
178
+ metadata: {}
179
+ post_install_message:
180
+ rdoc_options: []
181
+ require_paths:
182
+ - lib
183
+ required_ruby_version: !ruby/object:Gem::Requirement
184
+ requirements:
185
+ - - ">="
186
+ - !ruby/object:Gem::Version
187
+ version: '0'
188
+ required_rubygems_version: !ruby/object:Gem::Requirement
189
+ requirements:
190
+ - - ">="
191
+ - !ruby/object:Gem::Version
192
+ version: '0'
193
+ requirements: []
194
+ rubyforge_project:
195
+ rubygems_version: 2.4.5
196
+ signing_key:
197
+ specification_version: 4
198
+ summary: A ruby interface to POLITICO RSS feeds.
199
+ test_files: []
200
+ has_rdoc: