Class: FeedMe::StrictParserBuilder

Inherits:
ParserBuilder show all
Defined in:
lib/feedme.rb

Overview

This class is used to create strict parsers

Instance Attribute Summary collapse

Attributes inherited from ParserBuilder

#aliases, #atom_entry_tags, #atom_tags, #date_tags, #default_transformation, #default_value_selector, #default_value_tags, #html_helper_lib, #options, #rss_item_tags, #rss_tags, #transformation_fns, #transformations, #value_selectors, #value_tags

Instance Method Summary collapse

Methods inherited from ParserBuilder

#emulate_atom!, #emulate_rss!, #parse

Constructor Details

#initialize(options = {}) ⇒ StrictParserBuilder

Returns a new instance of StrictParserBuilder.



246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
# File 'lib/feedme.rb', line 246

def initialize(options={})
  super(options)
  
  # rss tags
  @rss_tags = [
    {
      :image     => [ :url, :title, :link, :width, :height, :description ],
      :textinput => [ :title, :description, :name, :link ],
      :skiphours => [ :hour ],
      :skipdays  => [ :day ],
      :items     => [ 
        {
          :rdf_seq => [ :rdf_li ]
        },
        :rdf_seq 
      ],
     #:item      => @item_tags
    },
    :title, :link, :description,                          # required
    :language, :copyright, :managingeditor, :webmaster,   # optional
    :pubdate, :lastbuilddate, :category, :generator,
    :docs, :cloud, :ttl, :rating,
    :image, :textinput, :skiphours, :skipdays, :item,     # have subtags
    :items
  ]
  @rss_item_tags = [
    {},
    :title, :description,                                 # required
    :link, :author, :category, :comments, :enclosure,     # optional
    :guid, :pubdate, :source, :expirationdate
  ]

  #atom tags
  person_tags = [ :name, :uri, :email ]
  @atom_tags = [
    {
      :author       => person_tags,
      :contributor  => person_tags,
     #:entry        => @entry_tags
    },
    :id, :author, :title, :updated,                     # required
    :category, :contributor, :generator, :icon, :logo,  # optional
    :link, :rights, :subtitle
  ]
  @atom_entry_tags = [
    {
      :author       => person_tags, 
      :contributor  => person_tags
    },
    :id, :author, :title, :updated, :summary,           # required
    :category, :content, :contributor, :link, 
    :published, :rights, :source
  ]
  
  @rels = {
    :link => DEFAULT_RELS
  }
  
  # extensions
  @feed_ext_tags = [ 
    :dc_date, :feedburner_browserfriendly, 
    :itunes_author, :itunes_category
  ]
  @item_ext_tags = [ 
    :dc_date, :dc_subject, :dc_creator, 
    :dc_title, :dc_rights, :dc_publisher, 
    :trackback_ping, :trackback_about,
    :feedburner_origlink, :media_content,
    :content_encoded
  ]
end

Instance Attribute Details

#feed_ext_tagsObject

Returns the value of attribute feed_ext_tags.



244
245
246
# File 'lib/feedme.rb', line 244

def feed_ext_tags
  @feed_ext_tags
end

#item_ext_tagsObject

Returns the value of attribute item_ext_tags.



244
245
246
# File 'lib/feedme.rb', line 244

def item_ext_tags
  @item_ext_tags
end

#relsObject

Returns the value of attribute rels.



244
245
246
# File 'lib/feedme.rb', line 244

def rels
  @rels
end

Instance Method Details

#all_atom_tagsObject



324
325
326
327
328
# File 'lib/feedme.rb', line 324

def all_atom_tags
  all_tags = atom_tags + (feed_ext_tags or [])
  all_tags[0][:entry] =  + (item_ext_tags or [])
  return all_tags
end

#all_rss_tagsObject



318
319
320
321
322
# File 'lib/feedme.rb', line 318

def all_rss_tags
  all_tags = rss_tags + (feed_ext_tags or [])
  all_tags[0][:item] = rss_item_tags + (item_ext_tags or [])
  return all_tags
end