Module: FeedMe
- Defined in:
- lib/feedme.rb,
lib/feedme-util.rb,
lib/hpricot-util.rb,
lib/html-cleaner.rb,
lib/nokogiri-util.rb
Defined Under Namespace
Classes: FeedData, FeedMeError, HpricotUtil, HtmlCleaner, InfiniteCallLoopError, NokogiriUtil, Parser, ParserBuilder, StrictParserBuilder
Constant Summary collapse
- RSS =
The value of Parser#fm_type for RSS feeds.
:RSS
- RDF =
The value of Parser#fm_type for RDF (RSS 1.0) feeds.
:RDF
- ATOM =
The value of Parser#fm_type for Atom feeds.
:ATOM
- CONTENT_KEY =
The key used to access the content element of a mixed tag.
:content
- NOKOGIRI_HELPER =
Helper libraries for HTML functions
'nokogiri-util.rb'
- HPRICOT_HELPER =
'hpricot-util.rb'
- DEFAULT_RELS =
default rels to accept, in order of preference
[ 'self', 'alternate', 'enclosure', 'related', 'edit', 'replies', 'via' ]
- @@instance =
NokogiriUtil.new
Class Method Summary collapse
- .html_helper ⇒ Object
-
.parse(source, options = {}) ⇒ Object
Parse a feed using the promiscuous parser.
-
.parse_strict(source, options = {}) ⇒ Object
Parse a feed using the strict parser.
-
.pretty_to_s(obj, indent_step = 2, indent = 0, code = nil) ⇒ Object
Pretty-print an object, with special formatting for hashes and arrays.
Class Method Details
.html_helper ⇒ Object
40 41 42 |
# File 'lib/hpricot-util.rb', line 40 def FeedMe.html_helper @@instance end |
.parse(source, options = {}) ⇒ Object
Parse a feed using the promiscuous parser.
24 25 26 |
# File 'lib/feedme.rb', line 24 def FeedMe.parse(source, ={}) ParserBuilder.new().parse(source) end |
.parse_strict(source, options = {}) ⇒ Object
Parse a feed using the strict parser.
29 30 31 |
# File 'lib/feedme.rb', line 29 def FeedMe.parse_strict(source, ={}) StrictParserBuilder.new().parse(source) end |
.pretty_to_s(obj, indent_step = 2, indent = 0, code = nil) ⇒ Object
Pretty-print an object, with special formatting for hashes and arrays.
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/feedme-util.rb', line 4 def FeedMe.pretty_to_s(obj, indent_step=2, indent=0, code=nil) new_indent = indent + indent_step space = ' ' * indent new_space = ' ' * new_indent str = '' if (obj.is_a?(FeedData) || obj.is_a?(Hash)) str << "#{obj.fm_tag_name} " if obj.is_a?(FeedData) str << "{" obj.each_with_index do |item, index| key, value = code.call(*item) if code str << "\n#{new_space}" str << FeedMe.pretty_to_s(key, indent_step, new_indent, code) str << " => " str << FeedMe.pretty_to_s(value, indent_step, new_indent, code) str << ',' unless index == obj.size-1 end str << "\n#{space}}" elsif obj.is_a?(Array) str << "[" obj.each_with_index do |value, index| str << "\n#{new_space}" str << FeedMe.pretty_to_s(value, indent_step, new_indent, code) str << ',' unless index == obj.size-1 end str << "\n#{space}]" elsif obj.is_a? Symbol str << obj.inspect else str << obj.to_s.strip.inspect end return str end |