atom_feed 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/CHANGELOG.md +4 -0
- data/LICENSE +23 -0
- data/README.md +11 -0
- data/lib/atom_feed.rb +30 -0
- data/lib/atom_feed/atom_category.rb +23 -0
- data/lib/atom_feed/atom_feed.rb +144 -0
- data/lib/atom_feed/atom_feed_entry.rb +85 -0
- data/lib/atom_feed/atom_generator.rb +25 -0
- data/lib/atom_feed/atom_link.rb +98 -0
- data/lib/atom_feed/atom_person.rb +23 -0
- data/lib/atom_feed/atom_text.rb +36 -0
- data/lib/atom_feed/core_ext.rb +2 -0
- data/lib/atom_feed/core_ext/string_ext.rb +2 -0
- data/lib/atom_feed/core_ext/try.rb +9 -0
- data/lib/atom_feed/open_search.rb +44 -0
- data/lib/atom_feed/open_search_query.rb +28 -0
- metadata +132 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: b74b11f808c446e829d35bd5eb51cc436c19f086
|
4
|
+
data.tar.gz: 3a9393324ff29f23f1a052606360b9d764bc10e4
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: c94274e5c1bff7d0269caa7d1e3d0f1b020c78f1c69794e13a65779f6055d6983371dbc2ba3ba8ef6353a6cd31eb438f2ec39caed2e53bb9491842b87b55cfbc
|
7
|
+
data.tar.gz: e45c36644bd1bce341c020d8aedd23dd745762fce317ba2877a4ba3b9ba619368ccee45cac5df32ae289ea6f81f89486c75ad03bffb941a4def85155460b156f
|
data/CHANGELOG.md
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
(The MIT License)
|
2
|
+
|
3
|
+
Copyright (c) 2011 Oliver Eilhard
|
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 NONINFRINGEMENT.
|
19
|
+
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
20
|
+
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
21
|
+
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
22
|
+
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
23
|
+
|
data/README.md
ADDED
@@ -0,0 +1,11 @@
|
|
1
|
+
# AtomFeed
|
2
|
+
|
3
|
+
Convenient classes for parsing an [Atom feed](http://tools.ietf.org/html/rfc4287).
|
4
|
+
|
5
|
+
## Links
|
6
|
+
|
7
|
+
* [The Atom Syndication Format (RFC 4287)](http://tools.ietf.org/html/rfc4287)
|
8
|
+
* [AtomEnabled](http://www.atomenabled.org/)
|
9
|
+
* [Atom on Wikipedia](http://en.wikipedia.org/wiki/Atom_(standard))
|
10
|
+
* [The Atom Publishing Protocol (RFC 5023)](http://bitworking.org/projects/atom/rfc5023.html)
|
11
|
+
|
data/lib/atom_feed.rb
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
# Copyright (C) 2011 Oliver Eilhard
|
2
|
+
#
|
3
|
+
# This library is freely distributable under
|
4
|
+
# the terms of an MIT-style license.
|
5
|
+
# See COPYING or http://www.opensource.org/licenses/mit-license.php.
|
6
|
+
|
7
|
+
# This library is for parsing Atom feeds.
|
8
|
+
|
9
|
+
module AtomFeed
|
10
|
+
VERSION = "0.1.1"
|
11
|
+
|
12
|
+
# Atom 1.0 namespace
|
13
|
+
NS_ATOM_2005 = "http://www.w3.org/2005/Atom"
|
14
|
+
|
15
|
+
# OpenSearch 1.1 Draft 4 namespace
|
16
|
+
NS_OPENSEARCH_11 = "http://a9.com/-/spec/opensearch/1.1/"
|
17
|
+
|
18
|
+
# Well-known namespaces for use in Nokogiri
|
19
|
+
NS = {"atom" => NS_ATOM_2005, "opensearch" => NS_OPENSEARCH_11}
|
20
|
+
|
21
|
+
autoload :CoreExt, 'atom_feed/core_ext.rb'
|
22
|
+
autoload :AtomFeed, 'atom_feed/atom_feed.rb'
|
23
|
+
autoload :AtomFeedEntry, 'atom_feed/atom_feed_entry.rb'
|
24
|
+
autoload :AtomCategory, 'atom_feed/atom_category.rb'
|
25
|
+
autoload :AtomGenerator, 'atom_feed/atom_generator.rb'
|
26
|
+
autoload :AtomLink, 'atom_feed/atom_link.rb'
|
27
|
+
autoload :AtomPerson, 'atom_feed/atom_person.rb'
|
28
|
+
autoload :OpenSearch, 'atom_feed/open_search.rb'
|
29
|
+
autoload :OpenSearchQuery, 'atom_feed/open_search_query.rb'
|
30
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
module AtomFeed
|
2
|
+
class AtomCategory
|
3
|
+
# Initializes the link.
|
4
|
+
def initialize(node)
|
5
|
+
@node = node
|
6
|
+
end
|
7
|
+
|
8
|
+
# Identifies the category (required).
|
9
|
+
def term
|
10
|
+
@node["term"]
|
11
|
+
end
|
12
|
+
|
13
|
+
# A categorization scheme (optional).
|
14
|
+
def scheme
|
15
|
+
@node["scheme"]
|
16
|
+
end
|
17
|
+
|
18
|
+
# Human readable label (optional).
|
19
|
+
def label
|
20
|
+
@node["label"]
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,144 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'nokogiri'
|
4
|
+
require 'atom_feed/core_ext'
|
5
|
+
require 'atom_feed/atom_feed_entry'
|
6
|
+
require 'atom_feed/atom_category'
|
7
|
+
require 'atom_feed/atom_generator'
|
8
|
+
require 'atom_feed/atom_link'
|
9
|
+
require 'atom_feed/atom_person'
|
10
|
+
require 'atom_feed/atom_text'
|
11
|
+
require 'atom_feed/open_search'
|
12
|
+
|
13
|
+
module AtomFeed
|
14
|
+
# AtomFeed::AtomFeed is the central place for
|
15
|
+
# working with feeds in the Atom format.
|
16
|
+
#
|
17
|
+
# Opening an atom feed from the network or a file system
|
18
|
+
# is done like this:
|
19
|
+
#
|
20
|
+
# feed = AtomFeed::AtomFeed.open(open("http://example.com/atom.xml"))
|
21
|
+
#
|
22
|
+
# If you have a file you should do:
|
23
|
+
#
|
24
|
+
# f = File.open("feed.xml")
|
25
|
+
# feed = AtomFeed::AtomFeed.open(f)
|
26
|
+
# f.close
|
27
|
+
#
|
28
|
+
# If you have an XML string you can do:
|
29
|
+
#
|
30
|
+
# feed = AtomFeed::AtomFeed.open("<feed ...")
|
31
|
+
#
|
32
|
+
# One can open and parse the feed like so:
|
33
|
+
#
|
34
|
+
# AtomFeed::AtomFeed.open(...) do |feed|
|
35
|
+
# puts feed.title
|
36
|
+
# feed.entries do |entry|
|
37
|
+
# puts entry.title
|
38
|
+
# end
|
39
|
+
# end
|
40
|
+
#
|
41
|
+
# You can access OpenSearch extensions by using +AtomFeed.open_search+.
|
42
|
+
# Access to other embedded XML types are available by using AtomFeed.doc+
|
43
|
+
# directly. It's a +Nokogiri::XML+ instance.
|
44
|
+
#
|
45
|
+
# AtomFeed uses Nokogiri for parsing.
|
46
|
+
#
|
47
|
+
class AtomFeed
|
48
|
+
|
49
|
+
attr_reader :doc
|
50
|
+
|
51
|
+
def initialize(doc)
|
52
|
+
@doc = doc
|
53
|
+
end
|
54
|
+
|
55
|
+
def self.open(string_or_io, url = nil, encoding = nil)
|
56
|
+
doc = Nokogiri::XML(string_or_io, url, encoding)
|
57
|
+
feed = AtomFeed.new(doc)
|
58
|
+
yield feed if block_given?
|
59
|
+
feed
|
60
|
+
end
|
61
|
+
|
62
|
+
# Feed id (required).
|
63
|
+
def id
|
64
|
+
@doc.at_xpath("atom:feed/atom:id", ::AtomFeed::NS).content
|
65
|
+
end
|
66
|
+
|
67
|
+
# Feed title (required).
|
68
|
+
def title
|
69
|
+
@doc.at_xpath("atom:feed/atom:title", ::AtomFeed::NS).content
|
70
|
+
end
|
71
|
+
|
72
|
+
# Feed update date (required).
|
73
|
+
def updated
|
74
|
+
Time.parse @doc.at_xpath("atom:feed/atom:updated", ::AtomFeed::NS).content
|
75
|
+
end
|
76
|
+
|
77
|
+
# Array of Authors (optional).
|
78
|
+
def authors
|
79
|
+
nodes = @doc.xpath("atom:feed/atom:author", ::AtomFeed::NS) || []
|
80
|
+
nodes.map { |node| AtomPerson.new(node) }
|
81
|
+
end
|
82
|
+
|
83
|
+
# Array of links (optional).
|
84
|
+
def links
|
85
|
+
nodes = @doc.xpath("atom:feed/atom:link", ::AtomFeed::NS) || []
|
86
|
+
nodes.map { |node| AtomLink.new(node) }
|
87
|
+
end
|
88
|
+
|
89
|
+
# Array of feed entries (optional).
|
90
|
+
def entries
|
91
|
+
nodes = @doc.xpath("atom:feed/atom:entry", ::AtomFeed::NS) || []
|
92
|
+
nodes.map { |node| AtomFeedEntry.new(node) }
|
93
|
+
end
|
94
|
+
|
95
|
+
# Array of feed categories (optional).
|
96
|
+
def categories
|
97
|
+
nodes = @doc.xpath("atom:feed/atom:category", ::AtomFeed::NS) || []
|
98
|
+
nodes.map { |node| AtomCategory.new(node) }
|
99
|
+
end
|
100
|
+
|
101
|
+
# Array of contributors (optional).
|
102
|
+
def contributors
|
103
|
+
nodes = @doc.xpath("atom:feed/atom:contributor", ::AtomFeed::NS) || []
|
104
|
+
nodes.map { |node| AtomPerson.new(node) }
|
105
|
+
end
|
106
|
+
|
107
|
+
# Generator (optional).
|
108
|
+
def generator
|
109
|
+
node = @doc.at_xpath("atom:feed/atom:generator", ::AtomFeed::NS)
|
110
|
+
return nil unless node
|
111
|
+
AtomGenerator.new(node)
|
112
|
+
end
|
113
|
+
|
114
|
+
# Icon (optional).
|
115
|
+
def icon
|
116
|
+
@doc.at_xpath("atom:feed/atom:icon", ::AtomFeed::NS).try(:content)
|
117
|
+
end
|
118
|
+
|
119
|
+
# Logo (optional).
|
120
|
+
def logo
|
121
|
+
@doc.at_xpath("atom:feed/atom:logo", ::AtomFeed::NS).try(:content)
|
122
|
+
end
|
123
|
+
|
124
|
+
# rights (optional)
|
125
|
+
def rights
|
126
|
+
node = @doc.at_xpath("atom:feed/atom:rights", ::AtomFeed::NS)
|
127
|
+
return nil unless node
|
128
|
+
AtomText.new(node)
|
129
|
+
end
|
130
|
+
|
131
|
+
# subtitle (optional)
|
132
|
+
def subtitle
|
133
|
+
node = @doc.at_xpath("atom:feed/atom:subtitle", ::AtomFeed::NS)
|
134
|
+
return nil unless node
|
135
|
+
AtomText.new(node)
|
136
|
+
end
|
137
|
+
|
138
|
+
# Open Search extensions (optional)
|
139
|
+
def open_search
|
140
|
+
@open_search ||= OpenSearch.new(@doc)
|
141
|
+
end
|
142
|
+
|
143
|
+
end
|
144
|
+
end
|
@@ -0,0 +1,85 @@
|
|
1
|
+
module AtomFeed
|
2
|
+
class AtomFeedEntry
|
3
|
+
|
4
|
+
attr_reader :node
|
5
|
+
|
6
|
+
def initialize(node)
|
7
|
+
@node = node
|
8
|
+
end
|
9
|
+
|
10
|
+
# Entry id (required).
|
11
|
+
def id
|
12
|
+
@node.at_xpath("atom:id", ::AtomFeed::NS).content
|
13
|
+
end
|
14
|
+
|
15
|
+
# Entry title (required).
|
16
|
+
def title
|
17
|
+
@node.at_xpath("atom:title", ::AtomFeed::NS).content
|
18
|
+
end
|
19
|
+
|
20
|
+
# Entry update date (required).
|
21
|
+
def updated
|
22
|
+
Time.parse @node.at_xpath("atom:updated", ::AtomFeed::NS).content
|
23
|
+
end
|
24
|
+
|
25
|
+
# Array of authors (optional).
|
26
|
+
def authors
|
27
|
+
nodes = @node.xpath("atom:author", ::AtomFeed::NS) || []
|
28
|
+
nodes.map { |node| AtomPerson.new(node) }
|
29
|
+
end
|
30
|
+
|
31
|
+
# Array of links (optional).
|
32
|
+
def links
|
33
|
+
nodes = @node.xpath("atom:link", ::AtomFeed::NS) || []
|
34
|
+
nodes.map { |node| AtomLink.new(node) }
|
35
|
+
end
|
36
|
+
|
37
|
+
# Content (optional)
|
38
|
+
def content
|
39
|
+
node = @node.at_xpath("atom:content", ::AtomFeed::NS)
|
40
|
+
return nil unless node
|
41
|
+
AtomText.new(node)
|
42
|
+
end
|
43
|
+
|
44
|
+
# Summary (optional)
|
45
|
+
def summary
|
46
|
+
node = @node.at_xpath("atom:summary", ::AtomFeed::NS)
|
47
|
+
return nil unless node
|
48
|
+
AtomText.new(node)
|
49
|
+
end
|
50
|
+
|
51
|
+
# categories (optional)
|
52
|
+
def categories
|
53
|
+
nodes = @node.xpath("atom:category", ::AtomFeed::NS) || []
|
54
|
+
nodes.map { |node| AtomCategory.new(node) }
|
55
|
+
end
|
56
|
+
|
57
|
+
# contributors (optional)
|
58
|
+
def contributors
|
59
|
+
nodes = @node.xpath("atom:contributor", ::AtomFeed::NS) || []
|
60
|
+
nodes.map { |node| AtomPerson.new(node) }
|
61
|
+
end
|
62
|
+
|
63
|
+
# Published (optional)
|
64
|
+
def published
|
65
|
+
time = @node.at_xpath("atom:published", ::AtomFeed::NS).try(:content)
|
66
|
+
return nil unless time
|
67
|
+
Time.parse(time)
|
68
|
+
end
|
69
|
+
|
70
|
+
# source (optional)
|
71
|
+
def source
|
72
|
+
if node = @node.at_xpath("atom:source", ::AtomFeed::NS)
|
73
|
+
AtomFeedEntry.new(node)
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
# rights (optional)
|
78
|
+
def rights
|
79
|
+
node = @node.at_xpath("atom:rights", ::AtomFeed::NS)
|
80
|
+
return nil unless node
|
81
|
+
AtomText.new(node)
|
82
|
+
end
|
83
|
+
|
84
|
+
end
|
85
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
module AtomFeed
|
2
|
+
class AtomGenerator
|
3
|
+
# Initializes the generator element.
|
4
|
+
def initialize(node)
|
5
|
+
@node = node
|
6
|
+
end
|
7
|
+
|
8
|
+
# Content of the generator
|
9
|
+
def to_s
|
10
|
+
@node.content
|
11
|
+
end
|
12
|
+
|
13
|
+
alias_method :content, :to_s
|
14
|
+
|
15
|
+
# URI (optional)
|
16
|
+
def uri
|
17
|
+
@node["uri"]
|
18
|
+
end
|
19
|
+
|
20
|
+
# Version (optional)
|
21
|
+
def version
|
22
|
+
@node["version"]
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,98 @@
|
|
1
|
+
module AtomFeed
|
2
|
+
class AtomLink
|
3
|
+
# Initializes the link.
|
4
|
+
def initialize(node)
|
5
|
+
@node = node
|
6
|
+
end
|
7
|
+
|
8
|
+
# The URI of the referenced resource (required).
|
9
|
+
def href
|
10
|
+
@node["href"]
|
11
|
+
end
|
12
|
+
|
13
|
+
# A single link relationship type (optional).
|
14
|
+
# It could be a full URI or one of some predefined
|
15
|
+
# values. Returns "alternate" as default.
|
16
|
+
def rel
|
17
|
+
@node["rel"] || "alternate"
|
18
|
+
end
|
19
|
+
|
20
|
+
# An alternate represenation of the entry or feed, e.g. a
|
21
|
+
# permalink to the HTML version of the resource?
|
22
|
+
def alternate?
|
23
|
+
self.rel == "alternate"
|
24
|
+
end
|
25
|
+
|
26
|
+
# A related resource (potentially large in size and might need
|
27
|
+
# special handling), e.g. an image or video recording?
|
28
|
+
def enclosure?
|
29
|
+
self.rel == "enclosure"
|
30
|
+
end
|
31
|
+
|
32
|
+
# A document related to the feed or entry?
|
33
|
+
def related?
|
34
|
+
self.rel == "related"
|
35
|
+
end
|
36
|
+
|
37
|
+
# The feed itself?
|
38
|
+
def self?
|
39
|
+
self.rel == "self"
|
40
|
+
end
|
41
|
+
|
42
|
+
# Source of the information provided in the entry?
|
43
|
+
def via?
|
44
|
+
self.rel == "via"
|
45
|
+
end
|
46
|
+
|
47
|
+
# Link to edit?
|
48
|
+
def edit?
|
49
|
+
self.rel == "edit"
|
50
|
+
end
|
51
|
+
|
52
|
+
# Reference to OpenSearch description document (OpenSearch extension)?
|
53
|
+
def search?
|
54
|
+
self.rel == "search"
|
55
|
+
end
|
56
|
+
|
57
|
+
# Reference to first search result in OpenSearch (OpenSearch extension)?
|
58
|
+
def first?
|
59
|
+
self.rel == "first"
|
60
|
+
end
|
61
|
+
|
62
|
+
# Reference to previous search results in OpenSearch (OpenSearch extension)?
|
63
|
+
def previous?
|
64
|
+
self.rel == "previous"
|
65
|
+
end
|
66
|
+
|
67
|
+
# Reference to next search results in OpenSearch (OpenSearch extension)?
|
68
|
+
def next?
|
69
|
+
self.rel == "next"
|
70
|
+
end
|
71
|
+
|
72
|
+
# Reference to last search result in OpenSearch (OpenSearch extension)?
|
73
|
+
def last?
|
74
|
+
self.rel == "last"
|
75
|
+
end
|
76
|
+
|
77
|
+
# Media type of the resource (optional)
|
78
|
+
def type
|
79
|
+
@node["type"]
|
80
|
+
end
|
81
|
+
|
82
|
+
# Language of the referenced resource (optional)
|
83
|
+
def hreflang
|
84
|
+
@node["hreflang"]
|
85
|
+
end
|
86
|
+
|
87
|
+
# Human readable information about the link (optional)
|
88
|
+
def title
|
89
|
+
@node["title"]
|
90
|
+
end
|
91
|
+
|
92
|
+
# Length of the resource in bytes (optional).
|
93
|
+
def length
|
94
|
+
@node["length"]
|
95
|
+
end
|
96
|
+
|
97
|
+
end
|
98
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
module AtomFeed
|
2
|
+
class AtomPerson
|
3
|
+
# Initializes the person.
|
4
|
+
def initialize(node)
|
5
|
+
@node = node
|
6
|
+
end
|
7
|
+
|
8
|
+
# Human readable name of the person (required)
|
9
|
+
def name
|
10
|
+
@node.at_xpath("atom:name", ::AtomFeed::NS).content
|
11
|
+
end
|
12
|
+
|
13
|
+
# Home page for the person (optional)
|
14
|
+
def uri
|
15
|
+
@node.at_xpath("atom:uri", ::AtomFeed::NS).try(:content)
|
16
|
+
end
|
17
|
+
|
18
|
+
# Email address of the person (optional)
|
19
|
+
def email
|
20
|
+
@node.at_xpath("atom:email", ::AtomFeed::NS).try(:content)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
module AtomFeed
|
2
|
+
class AtomText
|
3
|
+
# Initializes the text element.
|
4
|
+
def initialize(node)
|
5
|
+
@node = node
|
6
|
+
end
|
7
|
+
|
8
|
+
# Content of the text
|
9
|
+
def to_s
|
10
|
+
@node.content
|
11
|
+
end
|
12
|
+
|
13
|
+
alias_method :content, :to_s
|
14
|
+
|
15
|
+
# Determines how the information is encoded.
|
16
|
+
# Default is "text"
|
17
|
+
def type
|
18
|
+
@node["type"] || "text"
|
19
|
+
end
|
20
|
+
|
21
|
+
# Plain text
|
22
|
+
def text?
|
23
|
+
self.type == "text"
|
24
|
+
end
|
25
|
+
|
26
|
+
# Entity escaped HTML
|
27
|
+
def html?
|
28
|
+
self.type == "html"
|
29
|
+
end
|
30
|
+
|
31
|
+
# Inline XHTML
|
32
|
+
def xhtml?
|
33
|
+
self.type == "xhtml"
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
require 'atom_feed/open_search_query'
|
2
|
+
|
3
|
+
module AtomFeed
|
4
|
+
class OpenSearch
|
5
|
+
# Initializes the Open Search extensions.
|
6
|
+
def initialize(node)
|
7
|
+
@node = node
|
8
|
+
end
|
9
|
+
|
10
|
+
def present?
|
11
|
+
!self.total_results.nil?
|
12
|
+
end
|
13
|
+
|
14
|
+
def total_results
|
15
|
+
@node.at_xpath("atom:feed/opensearch:totalResults", ::AtomFeed::NS).content.to_i rescue nil
|
16
|
+
end
|
17
|
+
|
18
|
+
def start_index
|
19
|
+
@node.at_xpath("atom:feed/opensearch:startIndex", ::AtomFeed::NS).content.to_i rescue nil
|
20
|
+
end
|
21
|
+
|
22
|
+
=begin
|
23
|
+
def start_page
|
24
|
+
@node.at_xpath("atom:feed/opensearch:startPage", ::AtomFeed::NS).content.to_i rescue nil
|
25
|
+
end
|
26
|
+
=end
|
27
|
+
|
28
|
+
def items_per_page
|
29
|
+
@node.at_xpath("atom:feed/opensearch:itemsPerPage", ::AtomFeed::NS).content.to_i rescue nil
|
30
|
+
end
|
31
|
+
|
32
|
+
# queries
|
33
|
+
def queries
|
34
|
+
nodes = @node.xpath("atom:feed/opensearch:Query", ::AtomFeed::NS) rescue nil
|
35
|
+
nodes.map { |node| OpenSearchQuery.new(node) } if nodes
|
36
|
+
end
|
37
|
+
|
38
|
+
# first
|
39
|
+
# previous
|
40
|
+
# next
|
41
|
+
# last
|
42
|
+
# search
|
43
|
+
end
|
44
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
module AtomFeed
|
2
|
+
class OpenSearchQuery
|
3
|
+
# Initializes the Open Search Query element.
|
4
|
+
def initialize(node)
|
5
|
+
@node = node
|
6
|
+
end
|
7
|
+
|
8
|
+
def role
|
9
|
+
@node["role"]
|
10
|
+
end
|
11
|
+
|
12
|
+
def search_terms
|
13
|
+
@node["searchTerms"]
|
14
|
+
end
|
15
|
+
|
16
|
+
def start_page
|
17
|
+
@node["startPage"].to_i
|
18
|
+
end
|
19
|
+
|
20
|
+
def start_index
|
21
|
+
@node["startIndex"].to_i
|
22
|
+
end
|
23
|
+
|
24
|
+
def items_per_page
|
25
|
+
@node["itemsPerPage"].to_i
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
metadata
ADDED
@@ -0,0 +1,132 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: atom_feed
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Oliver Eilhard
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2018-03-30 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.0'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rdoc
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '3.12'
|
34
|
+
- - ">="
|
35
|
+
- !ruby/object:Gem::Version
|
36
|
+
version: 3.12.1
|
37
|
+
type: :development
|
38
|
+
prerelease: false
|
39
|
+
version_requirements: !ruby/object:Gem::Requirement
|
40
|
+
requirements:
|
41
|
+
- - "~>"
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: '3.12'
|
44
|
+
- - ">="
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: 3.12.1
|
47
|
+
- !ruby/object:Gem::Dependency
|
48
|
+
name: rake
|
49
|
+
requirement: !ruby/object:Gem::Requirement
|
50
|
+
requirements:
|
51
|
+
- - "~>"
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '12.3'
|
54
|
+
type: :development
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
requirements:
|
58
|
+
- - "~>"
|
59
|
+
- !ruby/object:Gem::Version
|
60
|
+
version: '12.3'
|
61
|
+
- !ruby/object:Gem::Dependency
|
62
|
+
name: nokogiri
|
63
|
+
requirement: !ruby/object:Gem::Requirement
|
64
|
+
requirements:
|
65
|
+
- - "~>"
|
66
|
+
- !ruby/object:Gem::Version
|
67
|
+
version: '1.8'
|
68
|
+
- - ">="
|
69
|
+
- !ruby/object:Gem::Version
|
70
|
+
version: 1.8.2
|
71
|
+
type: :development
|
72
|
+
prerelease: false
|
73
|
+
version_requirements: !ruby/object:Gem::Requirement
|
74
|
+
requirements:
|
75
|
+
- - "~>"
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: '1.8'
|
78
|
+
- - ">="
|
79
|
+
- !ruby/object:Gem::Version
|
80
|
+
version: 1.8.2
|
81
|
+
description: Ruby library for parsing Atom feeds.
|
82
|
+
email:
|
83
|
+
- oliver.eilhard@gmail.com
|
84
|
+
executables: []
|
85
|
+
extensions: []
|
86
|
+
extra_rdoc_files:
|
87
|
+
- CHANGELOG.md
|
88
|
+
- LICENSE
|
89
|
+
- README.md
|
90
|
+
files:
|
91
|
+
- CHANGELOG.md
|
92
|
+
- LICENSE
|
93
|
+
- README.md
|
94
|
+
- lib/atom_feed.rb
|
95
|
+
- lib/atom_feed/atom_category.rb
|
96
|
+
- lib/atom_feed/atom_feed.rb
|
97
|
+
- lib/atom_feed/atom_feed_entry.rb
|
98
|
+
- lib/atom_feed/atom_generator.rb
|
99
|
+
- lib/atom_feed/atom_link.rb
|
100
|
+
- lib/atom_feed/atom_person.rb
|
101
|
+
- lib/atom_feed/atom_text.rb
|
102
|
+
- lib/atom_feed/core_ext.rb
|
103
|
+
- lib/atom_feed/core_ext/string_ext.rb
|
104
|
+
- lib/atom_feed/core_ext/try.rb
|
105
|
+
- lib/atom_feed/open_search.rb
|
106
|
+
- lib/atom_feed/open_search_query.rb
|
107
|
+
homepage: http://github.com/olivere/atom_feed
|
108
|
+
licenses:
|
109
|
+
- MIT
|
110
|
+
metadata: {}
|
111
|
+
post_install_message:
|
112
|
+
rdoc_options:
|
113
|
+
- "--charset=UTF-8"
|
114
|
+
require_paths:
|
115
|
+
- lib
|
116
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
117
|
+
requirements:
|
118
|
+
- - ">="
|
119
|
+
- !ruby/object:Gem::Version
|
120
|
+
version: '0'
|
121
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
122
|
+
requirements:
|
123
|
+
- - ">="
|
124
|
+
- !ruby/object:Gem::Version
|
125
|
+
version: 1.3.6
|
126
|
+
requirements: []
|
127
|
+
rubyforge_project:
|
128
|
+
rubygems_version: 2.5.2
|
129
|
+
signing_key:
|
130
|
+
specification_version: 4
|
131
|
+
summary: Ruby library for parsing Atom feeds.
|
132
|
+
test_files: []
|