Class: Peachy::Parsers::ParserFactory

Inherits:
Object
  • Object
show all
Defined in:
lib/peachy/parsers/parser_factory.rb

Instance Method Summary collapse

Instance Method Details

#load_parserObject

Loads the first available XML parser defined in the list of parsers that Peachy can use. This requires the Gem for the parser and creates the method make_from, which will return a new instance of the ParserWrapper for that library. In order of preference, the Gems that Peachy can currently use for parsing XML are:

* Nokogiri
* REXML


12
13
14
15
16
17
# File 'lib/peachy/parsers/parser_factory.rb', line 12

def load_parser
  preferred_parser = Parsers.find {|parser| Gem.available? parser[:gem] }
  preferred_parser = DefaultParser if preferred_parser.nil?
  puts "Loading #{preferred_parser[:gem]} as the XML parser to use" if Peachy.whiny?
  set_the_parser preferred_parser
end