rubysl-rss 1.0.0 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +5 -6
- data/lib/rss/0.9.rb +20 -20
- data/lib/rss/1.0.rb +24 -24
- data/lib/rss/2.0.rb +3 -3
- data/lib/rss/atom.rb +94 -4
- data/lib/rss/content/1.0.rb +0 -1
- data/lib/rss/content/2.0.rb +0 -1
- data/lib/rss/converter.rb +22 -14
- data/lib/rss/dublincore.rb +8 -8
- data/lib/rss/dublincore/1.0.rb +0 -1
- data/lib/rss/dublincore/2.0.rb +0 -1
- data/lib/rss/dublincore/atom.rb +0 -1
- data/lib/rss/image.rb +9 -9
- data/lib/rss/maker.rb +40 -6
- data/lib/rss/maker/0.9.rb +64 -23
- data/lib/rss/maker/1.0.rb +7 -6
- data/lib/rss/maker/2.0.rb +11 -11
- data/lib/rss/maker/base.rb +118 -42
- data/lib/rss/maker/dublincore.rb +1 -4
- data/lib/rss/maker/entry.rb +3 -3
- data/lib/rss/maker/feed.rb +3 -6
- data/lib/rss/maker/image.rb +3 -3
- data/lib/rss/maker/itunes.rb +1 -1
- data/lib/rss/maker/taxonomy.rb +4 -4
- data/lib/rss/maker/trackback.rb +1 -1
- data/lib/rss/parser.rb +54 -27
- data/lib/rss/rexmlparser.rb +5 -5
- data/lib/rss/rss.rb +54 -24
- data/lib/rss/syndication.rb +3 -3
- data/lib/rss/taxonomy.rb +9 -9
- data/lib/rss/trackback.rb +18 -18
- data/lib/rss/utils.rb +2 -2
- data/lib/rss/xml-stylesheet.rb +2 -2
- data/lib/rss/xmlparser.rb +7 -7
- data/lib/rss/xmlscanner.rb +5 -5
- data/lib/rubysl/rss/rss.rb +76 -4
- data/lib/rubysl/rss/version.rb +1 -1
- data/rubysl-rss.gemspec +0 -1
- metadata +2 -16
data/lib/rss/syndication.rb
CHANGED
data/lib/rss/taxonomy.rb
CHANGED
@@ -24,7 +24,7 @@ module RSS
|
|
24
24
|
|
25
25
|
module TaxonomyTopicsModel
|
26
26
|
extend BaseModel
|
27
|
-
|
27
|
+
|
28
28
|
def self.append_features(klass)
|
29
29
|
super
|
30
30
|
|
@@ -37,21 +37,21 @@ module RSS
|
|
37
37
|
|
38
38
|
class TaxonomyTopics < Element
|
39
39
|
include RSS10
|
40
|
-
|
40
|
+
|
41
41
|
Bag = ::RSS::RDF::Bag
|
42
42
|
|
43
43
|
class << self
|
44
44
|
def required_prefix
|
45
45
|
TAXO_PREFIX
|
46
46
|
end
|
47
|
-
|
47
|
+
|
48
48
|
def required_uri
|
49
49
|
TAXO_URI
|
50
50
|
end
|
51
51
|
end
|
52
52
|
|
53
53
|
@tag_name = "topics"
|
54
|
-
|
54
|
+
|
55
55
|
install_have_child_element("Bag", RDF::URI, nil)
|
56
56
|
install_must_call_validator('rdf', RDF::URI)
|
57
57
|
|
@@ -84,10 +84,10 @@ module RSS
|
|
84
84
|
end
|
85
85
|
end
|
86
86
|
end
|
87
|
-
|
87
|
+
|
88
88
|
module TaxonomyTopicModel
|
89
89
|
extend BaseModel
|
90
|
-
|
90
|
+
|
91
91
|
def self.append_features(klass)
|
92
92
|
super
|
93
93
|
var_name = "#{TAXO_PREFIX}_topic"
|
@@ -99,12 +99,12 @@ module RSS
|
|
99
99
|
|
100
100
|
include DublinCoreModel
|
101
101
|
include TaxonomyTopicsModel
|
102
|
-
|
102
|
+
|
103
103
|
class << self
|
104
104
|
def required_prefix
|
105
105
|
TAXO_PREFIX
|
106
106
|
end
|
107
|
-
|
107
|
+
|
108
108
|
def required_uri
|
109
109
|
TAXO_URI
|
110
110
|
end
|
@@ -115,7 +115,7 @@ module RSS
|
|
115
115
|
install_get_attribute("about", ::RSS::RDF::URI, true, nil, nil,
|
116
116
|
"#{RDF::PREFIX}:about")
|
117
117
|
install_text_element("link", TAXO_URI, "?", "#{TAXO_PREFIX}_link")
|
118
|
-
|
118
|
+
|
119
119
|
def initialize(*args)
|
120
120
|
if Utils.element_initialize_arguments?(args)
|
121
121
|
super
|
data/lib/rss/trackback.rb
CHANGED
@@ -23,7 +23,7 @@ module RSS
|
|
23
23
|
module BaseTrackBackModel
|
24
24
|
|
25
25
|
ELEMENTS = %w(ping about)
|
26
|
-
|
26
|
+
|
27
27
|
def append_features(klass)
|
28
28
|
super
|
29
29
|
|
@@ -47,7 +47,7 @@ module RSS
|
|
47
47
|
end
|
48
48
|
EOC
|
49
49
|
end
|
50
|
-
|
50
|
+
|
51
51
|
[%w(about s)].each do |name, postfix|
|
52
52
|
var_name = "#{TRACKBACK_PREFIX}_#{name}"
|
53
53
|
klass_name = "TrackBack#{Utils.to_class_name(name)}"
|
@@ -105,7 +105,7 @@ module RSS
|
|
105
105
|
def required_prefix
|
106
106
|
TRACKBACK_PREFIX
|
107
107
|
end
|
108
|
-
|
108
|
+
|
109
109
|
def required_uri
|
110
110
|
TRACKBACK_URI
|
111
111
|
end
|
@@ -141,17 +141,17 @@ module RSS
|
|
141
141
|
include RSS10
|
142
142
|
|
143
143
|
class << self
|
144
|
-
|
144
|
+
|
145
145
|
def required_prefix
|
146
146
|
TRACKBACK_PREFIX
|
147
147
|
end
|
148
|
-
|
148
|
+
|
149
149
|
def required_uri
|
150
150
|
TRACKBACK_URI
|
151
151
|
end
|
152
152
|
|
153
153
|
end
|
154
|
-
|
154
|
+
|
155
155
|
@tag_name = "about"
|
156
156
|
|
157
157
|
[
|
@@ -163,7 +163,7 @@ module RSS
|
|
163
163
|
|
164
164
|
alias_method(:value, :resource)
|
165
165
|
alias_method(:value=, :resource=)
|
166
|
-
|
166
|
+
|
167
167
|
def initialize(*args)
|
168
168
|
if Utils.element_initialize_arguments?(args)
|
169
169
|
super
|
@@ -185,7 +185,7 @@ module RSS
|
|
185
185
|
def setup_maker_attributes(about)
|
186
186
|
about.resource = self.resource
|
187
187
|
end
|
188
|
-
|
188
|
+
|
189
189
|
end
|
190
190
|
end
|
191
191
|
|
@@ -197,7 +197,7 @@ module RSS
|
|
197
197
|
include RSS09
|
198
198
|
|
199
199
|
@tag_name = "ping"
|
200
|
-
|
200
|
+
|
201
201
|
content_setup
|
202
202
|
|
203
203
|
class << self
|
@@ -205,13 +205,13 @@ module RSS
|
|
205
205
|
def required_prefix
|
206
206
|
TRACKBACK_PREFIX
|
207
207
|
end
|
208
|
-
|
208
|
+
|
209
209
|
def required_uri
|
210
210
|
TRACKBACK_URI
|
211
211
|
end
|
212
212
|
|
213
213
|
end
|
214
|
-
|
214
|
+
|
215
215
|
alias_method(:value, :content)
|
216
216
|
alias_method(:value=, :content=)
|
217
217
|
|
@@ -223,26 +223,26 @@ module RSS
|
|
223
223
|
self.content = args[0]
|
224
224
|
end
|
225
225
|
end
|
226
|
-
|
226
|
+
|
227
227
|
def full_name
|
228
228
|
tag_name_with_prefix(TRACKBACK_PREFIX)
|
229
229
|
end
|
230
|
-
|
230
|
+
|
231
231
|
end
|
232
232
|
|
233
233
|
class TrackBackAbout < Element
|
234
234
|
include RSS09
|
235
235
|
|
236
236
|
@tag_name = "about"
|
237
|
-
|
237
|
+
|
238
238
|
content_setup
|
239
239
|
|
240
240
|
class << self
|
241
|
-
|
241
|
+
|
242
242
|
def required_prefix
|
243
243
|
TRACKBACK_PREFIX
|
244
244
|
end
|
245
|
-
|
245
|
+
|
246
246
|
def required_uri
|
247
247
|
TRACKBACK_URI
|
248
248
|
end
|
@@ -260,11 +260,11 @@ module RSS
|
|
260
260
|
self.content = args[0]
|
261
261
|
end
|
262
262
|
end
|
263
|
-
|
263
|
+
|
264
264
|
def full_name
|
265
265
|
tag_name_with_prefix(TRACKBACK_PREFIX)
|
266
266
|
end
|
267
|
-
|
267
|
+
|
268
268
|
end
|
269
269
|
end
|
270
270
|
|
data/lib/rss/utils.rb
CHANGED
@@ -8,7 +8,7 @@ module RSS
|
|
8
8
|
"#{part[0, 1].upcase}#{part[1..-1]}"
|
9
9
|
end.join("")
|
10
10
|
end
|
11
|
-
|
11
|
+
|
12
12
|
def get_file_and_line_from_caller(i=0)
|
13
13
|
file, line, = caller[i].split(':')
|
14
14
|
line = line.to_i
|
@@ -21,7 +21,7 @@ module RSS
|
|
21
21
|
s.to_s.gsub(/&/, "&").gsub(/\"/, """).gsub(/>/, ">").gsub(/</, "<")
|
22
22
|
end
|
23
23
|
alias h html_escape
|
24
|
-
|
24
|
+
|
25
25
|
# If +value+ is an instance of class +klass+, return it, else
|
26
26
|
# create a new instance of +klass+ with value +value+.
|
27
27
|
def new_with_value_if_need(klass, value)
|
data/lib/rss/xml-stylesheet.rb
CHANGED
@@ -8,7 +8,7 @@ module RSS
|
|
8
8
|
super
|
9
9
|
@xml_stylesheets = []
|
10
10
|
end
|
11
|
-
|
11
|
+
|
12
12
|
private
|
13
13
|
def xml_stylesheet_pi
|
14
14
|
xsss = @xml_stylesheets.collect do |xss|
|
@@ -94,7 +94,7 @@ module RSS
|
|
94
94
|
xss.__send__("#{attr}=", __send__(attr))
|
95
95
|
end
|
96
96
|
end
|
97
|
-
|
97
|
+
|
98
98
|
private
|
99
99
|
def guess_type(filename)
|
100
100
|
/\.([^.]+)$/ =~ filename
|
data/lib/rss/xmlparser.rb
CHANGED
@@ -26,9 +26,9 @@ module XML
|
|
26
26
|
end
|
27
27
|
|
28
28
|
module RSS
|
29
|
-
|
29
|
+
|
30
30
|
class REXMLLikeXMLParser < ::XML::Parser
|
31
|
-
|
31
|
+
|
32
32
|
include ::XML::Encoding_ja
|
33
33
|
|
34
34
|
def listener=(listener)
|
@@ -38,7 +38,7 @@ module RSS
|
|
38
38
|
def startElement(name, attrs)
|
39
39
|
@listener.tag_start(name, attrs)
|
40
40
|
end
|
41
|
-
|
41
|
+
|
42
42
|
def endElement(name)
|
43
43
|
@listener.tag_end(name)
|
44
44
|
end
|
@@ -64,7 +64,7 @@ module RSS
|
|
64
64
|
XMLParserListener
|
65
65
|
end
|
66
66
|
end
|
67
|
-
|
67
|
+
|
68
68
|
private
|
69
69
|
def _parse
|
70
70
|
begin
|
@@ -75,13 +75,13 @@ module RSS
|
|
75
75
|
raise NotWellFormedError.new(parser.line){e.message}
|
76
76
|
end
|
77
77
|
end
|
78
|
-
|
78
|
+
|
79
79
|
end
|
80
|
-
|
80
|
+
|
81
81
|
class XMLParserListener < BaseListener
|
82
82
|
|
83
83
|
include ListenerMixin
|
84
|
-
|
84
|
+
|
85
85
|
def xmldecl(version, encoding, standalone)
|
86
86
|
super
|
87
87
|
# Encoding is converted to UTF-8 when XMLParser parses XML.
|
data/lib/rss/xmlscanner.rb
CHANGED
@@ -2,15 +2,15 @@ require 'xmlscan/scanner'
|
|
2
2
|
require 'stringio'
|
3
3
|
|
4
4
|
module RSS
|
5
|
-
|
5
|
+
|
6
6
|
class XMLScanParser < BaseParser
|
7
|
-
|
7
|
+
|
8
8
|
class << self
|
9
9
|
def listener
|
10
10
|
XMLScanListener
|
11
11
|
end
|
12
12
|
end
|
13
|
-
|
13
|
+
|
14
14
|
private
|
15
15
|
def _parse
|
16
16
|
begin
|
@@ -26,11 +26,11 @@ module RSS
|
|
26
26
|
raise NotWellFormedError.new(lineno){e.message}
|
27
27
|
end
|
28
28
|
end
|
29
|
-
|
29
|
+
|
30
30
|
end
|
31
31
|
|
32
32
|
class XMLScanListener < BaseListener
|
33
|
-
|
33
|
+
|
34
34
|
include XMLScan::Visitor
|
35
35
|
include ListenerMixin
|
36
36
|
|
data/lib/rubysl/rss/rss.rb
CHANGED
@@ -1,8 +1,80 @@
|
|
1
|
-
|
2
|
-
#
|
1
|
+
##
|
2
|
+
# = RSS reading and writing
|
3
3
|
#
|
4
|
-
#
|
5
|
-
#
|
4
|
+
# Really Simple Syndication (RSS) is a family of formats that describe 'feeds,'
|
5
|
+
# specially constructed XML documents that allow an interested person to
|
6
|
+
# subscribe and receive updates from a particular web service. This portion of
|
7
|
+
# the standard library provides tooling to read and create these feeds.
|
8
|
+
#
|
9
|
+
# The standard library supports RSS 0.91, 1.0, 2.0, and Atom, a related format.
|
10
|
+
# Here are some links to the standards documents for these formats:
|
11
|
+
#
|
12
|
+
# * RSS
|
13
|
+
# * 0.9.1[http://www.rssboard.org/rss-0-9-1-netscape]
|
14
|
+
# * 1.0[http://web.resource.org/rss/1.0/]
|
15
|
+
# * 2.0[http://www.rssboard.org/rss-specification]
|
16
|
+
# * Atom[http://tools.ietf.org/html/rfc4287]
|
17
|
+
#
|
18
|
+
# == Consuming RSS
|
19
|
+
#
|
20
|
+
# If you'd like to read someone's RSS feed with your Ruby code, you've come to
|
21
|
+
# the right place. It's really easy to do this, but we'll need the help of
|
22
|
+
# open-uri:
|
23
|
+
#
|
24
|
+
# require 'rss'
|
25
|
+
# require 'open-uri'
|
26
|
+
#
|
27
|
+
# url = 'http://www.ruby-lang.org/en/feeds/news.rss'
|
28
|
+
# open(url) do |rss|
|
29
|
+
# feed = RSS::Parser.parse(rss)
|
30
|
+
# puts "Title: #{feed.channel.title}"
|
31
|
+
# feed.items.each do |item|
|
32
|
+
# puts "Item: #{item.title}"
|
33
|
+
# end
|
34
|
+
# end
|
35
|
+
#
|
36
|
+
# As you can see, the workhorse is RSS::Parser#parse, which takes the source of
|
37
|
+
# the feed and a parameter that performs validation on the feed. We get back an
|
38
|
+
# object that has all of the data from our feed, accessible through methods.
|
39
|
+
# This example shows getting the title out of the channel element, and looping
|
40
|
+
# through the list of items.
|
41
|
+
#
|
42
|
+
# == Producing RSS
|
43
|
+
#
|
44
|
+
# Producing our own RSS feeds is easy as well. Let's make a very basic feed:
|
45
|
+
#
|
46
|
+
# require "rss"
|
47
|
+
#
|
48
|
+
# rss = RSS::Maker.make("atom") do |maker|
|
49
|
+
# maker.channel.author = "matz"
|
50
|
+
# maker.channel.updated = Time.now.to_s
|
51
|
+
# maker.channel.about = "http://www.ruby-lang.org/en/feeds/news.rss"
|
52
|
+
# maker.channel.title = "Example Feed"
|
53
|
+
#
|
54
|
+
# maker.items.new_item do |item|
|
55
|
+
# item.link = "http://www.ruby-lang.org/en/news/2010/12/25/ruby-1-9-2-p136-is-released/"
|
56
|
+
# item.title = "Ruby 1.9.2-p136 is released"
|
57
|
+
# item.updated = Time.now.to_s
|
58
|
+
# end
|
59
|
+
# end
|
60
|
+
#
|
61
|
+
# puts rss
|
62
|
+
#
|
63
|
+
# As you can see, this is a very Builder-like DSL. This code will spit out an
|
64
|
+
# Atom feed with one item. If we needed a second item, we'd make another block
|
65
|
+
# with maker.items.new_item and build a second one.
|
66
|
+
#
|
67
|
+
# == Copyright
|
68
|
+
#
|
69
|
+
# Copyright (c) 2003-2007 Kouhei Sutou <kou@cozmixng.org>
|
70
|
+
#
|
71
|
+
# You can redistribute it and/or modify it under the same terms as Ruby.
|
72
|
+
#
|
73
|
+
# There is an additional tutorial by the author of RSS at:
|
74
|
+
# http://www.cozmixng.org/~rwiki/?cmd=view;name=RSS+Parser%3A%3ATutorial.en
|
75
|
+
|
76
|
+
module RSS
|
77
|
+
end
|
6
78
|
|
7
79
|
require 'rss/1.0'
|
8
80
|
require 'rss/2.0'
|
data/lib/rubysl/rss/version.rb
CHANGED
data/rubysl-rss.gemspec
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rubysl-rss
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 2.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Brian Shirai
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-
|
11
|
+
date: 2013-09-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -52,20 +52,6 @@ dependencies:
|
|
52
52
|
- - ~>
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '1.5'
|
55
|
-
- !ruby/object:Gem::Dependency
|
56
|
-
name: rubysl-prettyprint
|
57
|
-
requirement: !ruby/object:Gem::Requirement
|
58
|
-
requirements:
|
59
|
-
- - ~>
|
60
|
-
- !ruby/object:Gem::Version
|
61
|
-
version: '1.0'
|
62
|
-
type: :development
|
63
|
-
prerelease: false
|
64
|
-
version_requirements: !ruby/object:Gem::Requirement
|
65
|
-
requirements:
|
66
|
-
- - ~>
|
67
|
-
- !ruby/object:Gem::Version
|
68
|
-
version: '1.0'
|
69
55
|
description: Ruby standard library rss.
|
70
56
|
email:
|
71
57
|
- brixen@gmail.com
|