argh_ss 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +9 -0
- data/.travis.yml +5 -0
- data/Gemfile +6 -0
- data/LICENSE.txt +21 -0
- data/README.md +50 -0
- data/Rakefile +10 -0
- data/argh_ss.gemspec +33 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/lib/argh_ss/opml_import.rb +23 -0
- data/lib/argh_ss/rss_feed.rb +24 -0
- data/lib/argh_ss/version.rb +3 -0
- data/lib/argh_ss.rb +9 -0
- metadata +99 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 3b1dbd19a7036b3dad1815590b9208d50453a988
|
4
|
+
data.tar.gz: 51a8b19ccc870a2e758b8cec1fdbe52ea7cf5e7c
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 1953a3775265edb1bd92a54edb62b54a8ae2f7327060fc93a81084dfb16e703d59c171acdcd8360392b2efce4d6aca62c0cf15a74c601453ea6f53a2c94ff127
|
7
|
+
data.tar.gz: f58c53f2c3ed546d2a25904fe8627edb4e664fbd055b83e72abd95e0fb78dcc8dade9c0e7a8a24747b4ececa638e7ae83751716f17b2e6cd4d4cdc111b639b45
|
data/.gitignore
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2016 Toby
|
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.
|
data/README.md
ADDED
@@ -0,0 +1,50 @@
|
|
1
|
+
# ArghSs
|
2
|
+
|
3
|
+
This is a simple RSS feed reader Gem using Ruby's built in library.
|
4
|
+
It can also read most OPML files to import existing feeds.
|
5
|
+
|
6
|
+
## Installation
|
7
|
+
|
8
|
+
Add this line to your application's Gemfile:
|
9
|
+
|
10
|
+
```ruby
|
11
|
+
gem 'argh_ss'
|
12
|
+
```
|
13
|
+
|
14
|
+
And then execute:
|
15
|
+
|
16
|
+
$ bundle
|
17
|
+
|
18
|
+
Or install it yourself as:
|
19
|
+
|
20
|
+
$ gem install argh_ss
|
21
|
+
|
22
|
+
## RSS Feeds
|
23
|
+
|
24
|
+
There are currently 2 basic functionalities, reading a feed and outputting the feed to a hash as "title": "url" eg.
|
25
|
+
|
26
|
+
```ruby
|
27
|
+
{"Article Title"=>"https://www.article.com/feed_url"}
|
28
|
+
```
|
29
|
+
Simply run:
|
30
|
+
|
31
|
+
```ruby
|
32
|
+
url = "https://www.theguardian.com/world/rss"
|
33
|
+
RSSFeed.feed(url)
|
34
|
+
```
|
35
|
+
|
36
|
+
## OPML Import
|
37
|
+
|
38
|
+
For OPML import it will once again output a hash as "title": "url"
|
39
|
+
|
40
|
+
```ruby
|
41
|
+
file = "./my_important.opml"
|
42
|
+
OPMLImport.new(file).to_hash
|
43
|
+
```
|
44
|
+
|
45
|
+
The gem is designed to skip over errors, so if you have an RSS feed url that isn't standard, or an OPML file that doesn't proprly parse with nokogiri, it will fail quietly and move on.
|
46
|
+
|
47
|
+
## License
|
48
|
+
|
49
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
50
|
+
|
data/Rakefile
ADDED
data/argh_ss.gemspec
ADDED
@@ -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 'argh_ss/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "argh_ss"
|
8
|
+
spec.version = ArghSs::VERSION
|
9
|
+
spec.authors = ["Toby Holmes"]
|
10
|
+
spec.email = [""]
|
11
|
+
|
12
|
+
spec.summary = %q{A super simple RSS feed reading gem}
|
13
|
+
spec.description = %q{Read RSS feeds, read simple OPML files}
|
14
|
+
spec.homepage = "https://github.com/tobyond/argh_ss"
|
15
|
+
spec.license = "MIT"
|
16
|
+
|
17
|
+
# Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
|
18
|
+
# to allow pushing to a single host or delete this section to allow pushing to any host.
|
19
|
+
# if spec.respond_to?(:metadata)
|
20
|
+
# spec.metadata['allowed_push_host'] = "TODO: Set to 'http://mygemserver.com'"
|
21
|
+
# else
|
22
|
+
# raise "RubyGems 2.0 or newer is required to protect against public gem pushes."
|
23
|
+
# end
|
24
|
+
|
25
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
26
|
+
spec.bindir = "exe"
|
27
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
28
|
+
spec.require_paths = ["lib"]
|
29
|
+
|
30
|
+
spec.add_development_dependency "bundler", "~> 1.12"
|
31
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
32
|
+
spec.add_development_dependency "minitest", "~> 5.0"
|
33
|
+
end
|
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "argh_ss"
|
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
|
data/bin/setup
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
require 'rss'
|
2
|
+
require 'open-uri'
|
3
|
+
require 'nokogiri'
|
4
|
+
|
5
|
+
class OPMLImport
|
6
|
+
attr_reader :opml ,:to_hash
|
7
|
+
|
8
|
+
def initialize(opml_file)
|
9
|
+
file = File.open(opml_file)
|
10
|
+
@opml = Nokogiri::XML(file)
|
11
|
+
end
|
12
|
+
|
13
|
+
def to_hash
|
14
|
+
opml.xpath('//outline').each_with_object({}) do |ele, result|
|
15
|
+
unless ele['xmlUrl'].nil?
|
16
|
+
result[ele['title']] = ele['xmlUrl'] unless ele['title'].nil?
|
17
|
+
result[ele['text']] = ele['xmlUrl']
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
end
|
23
|
+
|
@@ -0,0 +1,24 @@
|
|
1
|
+
require 'rss'
|
2
|
+
require 'open-uri'
|
3
|
+
|
4
|
+
class RSSFeed
|
5
|
+
|
6
|
+
def self.feed(url)
|
7
|
+
{}.tap do |result|
|
8
|
+
open(url) do |rss|
|
9
|
+
begin
|
10
|
+
feed = RSS::Parser.parse(rss)
|
11
|
+
case feed.feed_type
|
12
|
+
when 'rss'
|
13
|
+
feed.items.each { |item| result[item.title] = item.link }
|
14
|
+
when 'atom'
|
15
|
+
feed.items.each { |item| result[item.title.content] = item.link.content }
|
16
|
+
end
|
17
|
+
rescue
|
18
|
+
next
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
data/lib/argh_ss.rb
ADDED
metadata
ADDED
@@ -0,0 +1,99 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: argh_ss
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Toby Holmes
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-11-14 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.12'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.12'
|
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: minitest
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '5.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '5.0'
|
55
|
+
description: Read RSS feeds, read simple OPML files
|
56
|
+
email:
|
57
|
+
- ''
|
58
|
+
executables: []
|
59
|
+
extensions: []
|
60
|
+
extra_rdoc_files: []
|
61
|
+
files:
|
62
|
+
- ".gitignore"
|
63
|
+
- ".travis.yml"
|
64
|
+
- Gemfile
|
65
|
+
- LICENSE.txt
|
66
|
+
- README.md
|
67
|
+
- Rakefile
|
68
|
+
- argh_ss.gemspec
|
69
|
+
- bin/console
|
70
|
+
- bin/setup
|
71
|
+
- lib/argh_ss.rb
|
72
|
+
- lib/argh_ss/opml_import.rb
|
73
|
+
- lib/argh_ss/rss_feed.rb
|
74
|
+
- lib/argh_ss/version.rb
|
75
|
+
homepage: https://github.com/tobyond/argh_ss
|
76
|
+
licenses:
|
77
|
+
- MIT
|
78
|
+
metadata: {}
|
79
|
+
post_install_message:
|
80
|
+
rdoc_options: []
|
81
|
+
require_paths:
|
82
|
+
- lib
|
83
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
84
|
+
requirements:
|
85
|
+
- - ">="
|
86
|
+
- !ruby/object:Gem::Version
|
87
|
+
version: '0'
|
88
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
89
|
+
requirements:
|
90
|
+
- - ">="
|
91
|
+
- !ruby/object:Gem::Version
|
92
|
+
version: '0'
|
93
|
+
requirements: []
|
94
|
+
rubyforge_project:
|
95
|
+
rubygems_version: 2.5.1
|
96
|
+
signing_key:
|
97
|
+
specification_version: 4
|
98
|
+
summary: A super simple RSS feed reading gem
|
99
|
+
test_files: []
|