Edit File by line
/home/barbar84/public_h.../wp-conte.../plugins/sujqvwi/AnonR/anonr.TX.../opt/alt/ruby27/share/ruby/rss
File: 0.9.rb
# frozen_string_literal: false
[0] Fix | Delete
require_relative "parser"
[1] Fix | Delete
[2] Fix | Delete
module RSS
[3] Fix | Delete
[4] Fix | Delete
##
[5] Fix | Delete
# = RSS 0.9 support
[6] Fix | Delete
#
[7] Fix | Delete
# RSS has three different versions. This module contains support for version
[8] Fix | Delete
# 0.9.1[http://www.rssboard.org/rss-0-9-1-netscape].
[9] Fix | Delete
#
[10] Fix | Delete
# == Producing RSS 0.9
[11] Fix | Delete
#
[12] Fix | Delete
# Producing our own RSS feeds is easy as well. Let's make a very basic feed:
[13] Fix | Delete
#
[14] Fix | Delete
# require "rss"
[15] Fix | Delete
#
[16] Fix | Delete
# rss = RSS::Maker.make("0.91") do |maker|
[17] Fix | Delete
# maker.channel.language = "en"
[18] Fix | Delete
# maker.channel.author = "matz"
[19] Fix | Delete
# maker.channel.updated = Time.now.to_s
[20] Fix | Delete
# maker.channel.link = "http://www.ruby-lang.org/en/feeds/news.rss"
[21] Fix | Delete
# maker.channel.title = "Example Feed"
[22] Fix | Delete
# maker.channel.description = "A longer description of my feed."
[23] Fix | Delete
# maker.image.url = "http://www.ruby-lang.org/images/logo.gif"
[24] Fix | Delete
# maker.image.title = "An image"
[25] Fix | Delete
# maker.items.new_item do |item|
[26] Fix | Delete
# item.link = "http://www.ruby-lang.org/en/news/2010/12/25/ruby-1-9-2-p136-is-released/"
[27] Fix | Delete
# item.title = "Ruby 1.9.2-p136 is released"
[28] Fix | Delete
# item.updated = Time.now.to_s
[29] Fix | Delete
# end
[30] Fix | Delete
# end
[31] Fix | Delete
#
[32] Fix | Delete
# puts rss
[33] Fix | Delete
#
[34] Fix | Delete
# As you can see, this is a very Builder-like DSL. This code will spit out an
[35] Fix | Delete
# RSS 0.9 feed with one item. If we needed a second item, we'd make another
[36] Fix | Delete
# block with maker.items.new_item and build a second one.
[37] Fix | Delete
module RSS09
[38] Fix | Delete
NSPOOL = {}
[39] Fix | Delete
ELEMENTS = []
[40] Fix | Delete
[41] Fix | Delete
def self.append_features(klass)
[42] Fix | Delete
super
[43] Fix | Delete
[44] Fix | Delete
klass.install_must_call_validator('', "")
[45] Fix | Delete
end
[46] Fix | Delete
end
[47] Fix | Delete
[48] Fix | Delete
class Rss < Element
[49] Fix | Delete
[50] Fix | Delete
include RSS09
[51] Fix | Delete
include RootElementMixin
[52] Fix | Delete
[53] Fix | Delete
%w(channel).each do |name|
[54] Fix | Delete
install_have_child_element(name, "", nil)
[55] Fix | Delete
end
[56] Fix | Delete
[57] Fix | Delete
attr_writer :feed_version
[58] Fix | Delete
alias_method(:rss_version, :feed_version)
[59] Fix | Delete
alias_method(:rss_version=, :feed_version=)
[60] Fix | Delete
[61] Fix | Delete
def initialize(feed_version, version=nil, encoding=nil, standalone=nil)
[62] Fix | Delete
super
[63] Fix | Delete
@feed_type = "rss"
[64] Fix | Delete
end
[65] Fix | Delete
[66] Fix | Delete
def items
[67] Fix | Delete
if @channel
[68] Fix | Delete
@channel.items
[69] Fix | Delete
else
[70] Fix | Delete
[]
[71] Fix | Delete
end
[72] Fix | Delete
end
[73] Fix | Delete
[74] Fix | Delete
def image
[75] Fix | Delete
if @channel
[76] Fix | Delete
@channel.image
[77] Fix | Delete
else
[78] Fix | Delete
nil
[79] Fix | Delete
end
[80] Fix | Delete
end
[81] Fix | Delete
[82] Fix | Delete
def textinput
[83] Fix | Delete
if @channel
[84] Fix | Delete
@channel.textInput
[85] Fix | Delete
else
[86] Fix | Delete
nil
[87] Fix | Delete
end
[88] Fix | Delete
end
[89] Fix | Delete
[90] Fix | Delete
def setup_maker_elements(maker)
[91] Fix | Delete
super
[92] Fix | Delete
items.each do |item|
[93] Fix | Delete
item.setup_maker(maker.items)
[94] Fix | Delete
end
[95] Fix | Delete
image.setup_maker(maker) if image
[96] Fix | Delete
textinput.setup_maker(maker) if textinput
[97] Fix | Delete
end
[98] Fix | Delete
[99] Fix | Delete
private
[100] Fix | Delete
def _attrs
[101] Fix | Delete
[
[102] Fix | Delete
["version", true, "feed_version"],
[103] Fix | Delete
]
[104] Fix | Delete
end
[105] Fix | Delete
[106] Fix | Delete
class Channel < Element
[107] Fix | Delete
[108] Fix | Delete
include RSS09
[109] Fix | Delete
[110] Fix | Delete
[
[111] Fix | Delete
["title", nil, :text],
[112] Fix | Delete
["link", nil, :text],
[113] Fix | Delete
["description", nil, :text],
[114] Fix | Delete
["language", nil, :text],
[115] Fix | Delete
["copyright", "?", :text],
[116] Fix | Delete
["managingEditor", "?", :text],
[117] Fix | Delete
["webMaster", "?", :text],
[118] Fix | Delete
["rating", "?", :text],
[119] Fix | Delete
["pubDate", "?", :date, :rfc822],
[120] Fix | Delete
["lastBuildDate", "?", :date, :rfc822],
[121] Fix | Delete
["docs", "?", :text],
[122] Fix | Delete
["cloud", "?", :have_attribute],
[123] Fix | Delete
["skipDays", "?", :have_child],
[124] Fix | Delete
["skipHours", "?", :have_child],
[125] Fix | Delete
["image", nil, :have_child],
[126] Fix | Delete
["item", "*", :have_children],
[127] Fix | Delete
["textInput", "?", :have_child],
[128] Fix | Delete
].each do |name, occurs, type, *args|
[129] Fix | Delete
__send__("install_#{type}_element", name, "", occurs, name, *args)
[130] Fix | Delete
end
[131] Fix | Delete
alias date pubDate
[132] Fix | Delete
alias date= pubDate=
[133] Fix | Delete
[134] Fix | Delete
private
[135] Fix | Delete
def maker_target(maker)
[136] Fix | Delete
maker.channel
[137] Fix | Delete
end
[138] Fix | Delete
[139] Fix | Delete
def setup_maker_elements(channel)
[140] Fix | Delete
super
[141] Fix | Delete
[
[142] Fix | Delete
[skipDays, "day"],
[143] Fix | Delete
[skipHours, "hour"],
[144] Fix | Delete
].each do |skip, key|
[145] Fix | Delete
if skip
[146] Fix | Delete
skip.__send__("#{key}s").each do |val|
[147] Fix | Delete
target_skips = channel.__send__("skip#{key.capitalize}s")
[148] Fix | Delete
new_target = target_skips.__send__("new_#{key}")
[149] Fix | Delete
new_target.content = val.content
[150] Fix | Delete
end
[151] Fix | Delete
end
[152] Fix | Delete
end
[153] Fix | Delete
end
[154] Fix | Delete
[155] Fix | Delete
def not_need_to_call_setup_maker_variables
[156] Fix | Delete
%w(image textInput)
[157] Fix | Delete
end
[158] Fix | Delete
[159] Fix | Delete
class SkipDays < Element
[160] Fix | Delete
include RSS09
[161] Fix | Delete
[162] Fix | Delete
[
[163] Fix | Delete
["day", "*"]
[164] Fix | Delete
].each do |name, occurs|
[165] Fix | Delete
install_have_children_element(name, "", occurs)
[166] Fix | Delete
end
[167] Fix | Delete
[168] Fix | Delete
class Day < Element
[169] Fix | Delete
include RSS09
[170] Fix | Delete
[171] Fix | Delete
content_setup
[172] Fix | Delete
[173] Fix | Delete
def initialize(*args)
[174] Fix | Delete
if Utils.element_initialize_arguments?(args)
[175] Fix | Delete
super
[176] Fix | Delete
else
[177] Fix | Delete
super()
[178] Fix | Delete
self.content = args[0]
[179] Fix | Delete
end
[180] Fix | Delete
end
[181] Fix | Delete
[182] Fix | Delete
end
[183] Fix | Delete
[184] Fix | Delete
end
[185] Fix | Delete
[186] Fix | Delete
class SkipHours < Element
[187] Fix | Delete
include RSS09
[188] Fix | Delete
[189] Fix | Delete
[
[190] Fix | Delete
["hour", "*"]
[191] Fix | Delete
].each do |name, occurs|
[192] Fix | Delete
install_have_children_element(name, "", occurs)
[193] Fix | Delete
end
[194] Fix | Delete
[195] Fix | Delete
class Hour < Element
[196] Fix | Delete
include RSS09
[197] Fix | Delete
[198] Fix | Delete
content_setup(:integer)
[199] Fix | Delete
[200] Fix | Delete
def initialize(*args)
[201] Fix | Delete
if Utils.element_initialize_arguments?(args)
[202] Fix | Delete
super
[203] Fix | Delete
else
[204] Fix | Delete
super()
[205] Fix | Delete
self.content = args[0]
[206] Fix | Delete
end
[207] Fix | Delete
end
[208] Fix | Delete
end
[209] Fix | Delete
[210] Fix | Delete
end
[211] Fix | Delete
[212] Fix | Delete
class Image < Element
[213] Fix | Delete
[214] Fix | Delete
include RSS09
[215] Fix | Delete
[216] Fix | Delete
%w(url title link).each do |name|
[217] Fix | Delete
install_text_element(name, "", nil)
[218] Fix | Delete
end
[219] Fix | Delete
[
[220] Fix | Delete
["width", :integer],
[221] Fix | Delete
["height", :integer],
[222] Fix | Delete
["description"],
[223] Fix | Delete
].each do |name, type|
[224] Fix | Delete
install_text_element(name, "", "?", name, type)
[225] Fix | Delete
end
[226] Fix | Delete
[227] Fix | Delete
def initialize(*args)
[228] Fix | Delete
if Utils.element_initialize_arguments?(args)
[229] Fix | Delete
super
[230] Fix | Delete
else
[231] Fix | Delete
super()
[232] Fix | Delete
self.url = args[0]
[233] Fix | Delete
self.title = args[1]
[234] Fix | Delete
self.link = args[2]
[235] Fix | Delete
self.width = args[3]
[236] Fix | Delete
self.height = args[4]
[237] Fix | Delete
self.description = args[5]
[238] Fix | Delete
end
[239] Fix | Delete
end
[240] Fix | Delete
[241] Fix | Delete
private
[242] Fix | Delete
def maker_target(maker)
[243] Fix | Delete
maker.image
[244] Fix | Delete
end
[245] Fix | Delete
end
[246] Fix | Delete
[247] Fix | Delete
class Cloud < Element
[248] Fix | Delete
[249] Fix | Delete
include RSS09
[250] Fix | Delete
[251] Fix | Delete
[
[252] Fix | Delete
["domain", "", true],
[253] Fix | Delete
["port", "", true, :integer],
[254] Fix | Delete
["path", "", true],
[255] Fix | Delete
["registerProcedure", "", true],
[256] Fix | Delete
["protocol", "", true],
[257] Fix | Delete
].each do |name, uri, required, type|
[258] Fix | Delete
install_get_attribute(name, uri, required, type)
[259] Fix | Delete
end
[260] Fix | Delete
[261] Fix | Delete
def initialize(*args)
[262] Fix | Delete
if Utils.element_initialize_arguments?(args)
[263] Fix | Delete
super
[264] Fix | Delete
else
[265] Fix | Delete
super()
[266] Fix | Delete
self.domain = args[0]
[267] Fix | Delete
self.port = args[1]
[268] Fix | Delete
self.path = args[2]
[269] Fix | Delete
self.registerProcedure = args[3]
[270] Fix | Delete
self.protocol = args[4]
[271] Fix | Delete
end
[272] Fix | Delete
end
[273] Fix | Delete
end
[274] Fix | Delete
[275] Fix | Delete
class Item < Element
[276] Fix | Delete
[277] Fix | Delete
include RSS09
[278] Fix | Delete
[279] Fix | Delete
[
[280] Fix | Delete
["title", '?', :text],
[281] Fix | Delete
["link", '?', :text],
[282] Fix | Delete
["description", '?', :text],
[283] Fix | Delete
["category", '*', :have_children, "categories"],
[284] Fix | Delete
["source", '?', :have_child],
[285] Fix | Delete
["enclosure", '?', :have_child],
[286] Fix | Delete
].each do |tag, occurs, type, *args|
[287] Fix | Delete
__send__("install_#{type}_element", tag, "", occurs, tag, *args)
[288] Fix | Delete
end
[289] Fix | Delete
[290] Fix | Delete
private
[291] Fix | Delete
def maker_target(items)
[292] Fix | Delete
if items.respond_to?("items")
[293] Fix | Delete
# For backward compatibility
[294] Fix | Delete
items = items.items
[295] Fix | Delete
end
[296] Fix | Delete
items.new_item
[297] Fix | Delete
end
[298] Fix | Delete
[299] Fix | Delete
def setup_maker_element(item)
[300] Fix | Delete
super
[301] Fix | Delete
@enclosure.setup_maker(item) if @enclosure
[302] Fix | Delete
@source.setup_maker(item) if @source
[303] Fix | Delete
end
[304] Fix | Delete
[305] Fix | Delete
class Source < Element
[306] Fix | Delete
[307] Fix | Delete
include RSS09
[308] Fix | Delete
[309] Fix | Delete
[
[310] Fix | Delete
["url", "", true]
[311] Fix | Delete
].each do |name, uri, required|
[312] Fix | Delete
install_get_attribute(name, uri, required)
[313] Fix | Delete
end
[314] Fix | Delete
[315] Fix | Delete
content_setup
[316] Fix | Delete
[317] Fix | Delete
def initialize(*args)
[318] Fix | Delete
if Utils.element_initialize_arguments?(args)
[319] Fix | Delete
super
[320] Fix | Delete
else
[321] Fix | Delete
super()
[322] Fix | Delete
self.url = args[0]
[323] Fix | Delete
self.content = args[1]
[324] Fix | Delete
end
[325] Fix | Delete
end
[326] Fix | Delete
[327] Fix | Delete
private
[328] Fix | Delete
def maker_target(item)
[329] Fix | Delete
item.source
[330] Fix | Delete
end
[331] Fix | Delete
[332] Fix | Delete
def setup_maker_attributes(source)
[333] Fix | Delete
source.url = url
[334] Fix | Delete
source.content = content
[335] Fix | Delete
end
[336] Fix | Delete
end
[337] Fix | Delete
[338] Fix | Delete
class Enclosure < Element
[339] Fix | Delete
[340] Fix | Delete
include RSS09
[341] Fix | Delete
[342] Fix | Delete
[
[343] Fix | Delete
["url", "", true],
[344] Fix | Delete
["length", "", true, :integer],
[345] Fix | Delete
["type", "", true],
[346] Fix | Delete
].each do |name, uri, required, type|
[347] Fix | Delete
install_get_attribute(name, uri, required, type)
[348] Fix | Delete
end
[349] Fix | Delete
[350] Fix | Delete
def initialize(*args)
[351] Fix | Delete
if Utils.element_initialize_arguments?(args)
[352] Fix | Delete
super
[353] Fix | Delete
else
[354] Fix | Delete
super()
[355] Fix | Delete
self.url = args[0]
[356] Fix | Delete
self.length = args[1]
[357] Fix | Delete
self.type = args[2]
[358] Fix | Delete
end
[359] Fix | Delete
end
[360] Fix | Delete
[361] Fix | Delete
private
[362] Fix | Delete
def maker_target(item)
[363] Fix | Delete
item.enclosure
[364] Fix | Delete
end
[365] Fix | Delete
[366] Fix | Delete
def setup_maker_attributes(enclosure)
[367] Fix | Delete
enclosure.url = url
[368] Fix | Delete
enclosure.length = length
[369] Fix | Delete
enclosure.type = type
[370] Fix | Delete
end
[371] Fix | Delete
end
[372] Fix | Delete
[373] Fix | Delete
class Category < Element
[374] Fix | Delete
[375] Fix | Delete
include RSS09
[376] Fix | Delete
[377] Fix | Delete
[
[378] Fix | Delete
["domain", "", false]
[379] Fix | Delete
].each do |name, uri, required|
[380] Fix | Delete
install_get_attribute(name, uri, required)
[381] Fix | Delete
end
[382] Fix | Delete
[383] Fix | Delete
content_setup
[384] Fix | Delete
[385] Fix | Delete
def initialize(*args)
[386] Fix | Delete
if Utils.element_initialize_arguments?(args)
[387] Fix | Delete
super
[388] Fix | Delete
else
[389] Fix | Delete
super()
[390] Fix | Delete
self.domain = args[0]
[391] Fix | Delete
self.content = args[1]
[392] Fix | Delete
end
[393] Fix | Delete
end
[394] Fix | Delete
[395] Fix | Delete
private
[396] Fix | Delete
def maker_target(item)
[397] Fix | Delete
item.new_category
[398] Fix | Delete
end
[399] Fix | Delete
[400] Fix | Delete
def setup_maker_attributes(category)
[401] Fix | Delete
category.domain = domain
[402] Fix | Delete
category.content = content
[403] Fix | Delete
end
[404] Fix | Delete
[405] Fix | Delete
end
[406] Fix | Delete
[407] Fix | Delete
end
[408] Fix | Delete
[409] Fix | Delete
class TextInput < Element
[410] Fix | Delete
[411] Fix | Delete
include RSS09
[412] Fix | Delete
[413] Fix | Delete
%w(title description name link).each do |name|
[414] Fix | Delete
install_text_element(name, "", nil)
[415] Fix | Delete
end
[416] Fix | Delete
[417] Fix | Delete
def initialize(*args)
[418] Fix | Delete
if Utils.element_initialize_arguments?(args)
[419] Fix | Delete
super
[420] Fix | Delete
else
[421] Fix | Delete
super()
[422] Fix | Delete
self.title = args[0]
[423] Fix | Delete
self.description = args[1]
[424] Fix | Delete
self.name = args[2]
[425] Fix | Delete
self.link = args[3]
[426] Fix | Delete
end
[427] Fix | Delete
end
[428] Fix | Delete
[429] Fix | Delete
private
[430] Fix | Delete
def maker_target(maker)
[431] Fix | Delete
maker.textinput
[432] Fix | Delete
end
[433] Fix | Delete
end
[434] Fix | Delete
[435] Fix | Delete
end
[436] Fix | Delete
[437] Fix | Delete
end
[438] Fix | Delete
[439] Fix | Delete
RSS09::ELEMENTS.each do |name|
[440] Fix | Delete
BaseListener.install_get_text_element("", name, name)
[441] Fix | Delete
end
[442] Fix | Delete
[443] Fix | Delete
module ListenerMixin
[444] Fix | Delete
private
[445] Fix | Delete
def initial_start_rss(tag_name, prefix, attrs, ns)
[446] Fix | Delete
check_ns(tag_name, prefix, ns, "", false)
[447] Fix | Delete
[448] Fix | Delete
@rss = Rss.new(attrs['version'], @version, @encoding, @standalone)
[449] Fix | Delete
@rss.do_validate = @do_validate
[450] Fix | Delete
@rss.xml_stylesheets = @xml_stylesheets
[451] Fix | Delete
@last_element = @rss
[452] Fix | Delete
pr = Proc.new do |text, tags|
[453] Fix | Delete
@rss.validate_for_stream(tags, @ignore_unknown_element) if @do_validate
[454] Fix | Delete
end
[455] Fix | Delete
@proc_stack.push(pr)
[456] Fix | Delete
end
[457] Fix | Delete
[458] Fix | Delete
end
[459] Fix | Delete
[460] Fix | Delete
end
[461] Fix | Delete
[462] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function