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