Sha256: 3c37f2141f6efe17c2bbc7e02eed48e00cd6bfd485e3e79c081a1eab31bbb81e
Contents?: true
Size: 946 Bytes
Versions: 2
Compression:
Stored size: 946 Bytes
Contents
require 'janis/proxy_website_parser' Dir[File.dirname(__FILE__) + '/specific_parsers/*.rb'].each { |file| require file } module Janis module Parsing class ParserFactory attr_reader :parser_klasses def initialize @parser_klasses = Janis::Parsing::SpecificParsers::ProxyWebsiteParser.subclasses end def create_parser(website_name) namespacing_prefix = "Janis::Parsing::SpecificParsers::" @parser_klasses.find { |parser_klass| parser_klass.to_s == namespacing_prefix + parser_klass_name_for(website_name) }.new end private #TODO: This should be probably moved to a name helper module # website_name should be a :symbol_in_snake_lower_case. eg: :hide_my_ass will mean HideMyAssParser def parser_klass_name_for(website_name) website_name.to_s.split('_').map { |word| word.capitalize}.join + "Parser" end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
janis-0.1.4 | lib/janis/parser_factory.rb |
janis-0.1.3 | lib/janis/parser_factory.rb |