Sha256: 331ae43bc0ee815f61813022c35ed1a2efba4ba1d5488249b3e27ce8237133cb
Contents?: true
Size: 1.12 KB
Versions: 3
Compression:
Stored size: 1.12 KB
Contents
module Msewage::Importer module Importers class Base class << self def type(*file_types) file_types.each do |file_type| Importers::Base.importers[file_type] = self end end def factory(file_name) #load_importers importers.each_pair do |extension, class_name| if file_name =~ %r{#{extension}} return class_name.new(file_name) end end end def load_importers #dirname = File.dirname(__FILE__) #Dir[File.join(dirname, "*.rb")].each do |f| # require f.gsub(%r{#{dirname}/lib/}, '').gsub(/.rb/, '') unless f =~ /base/ #end end def importers @importers ||= {} end end def initialize(file_name) @file_name = file_name end def import raise "OVERRIDE ME" end private attr_reader :file_name end end end dirname = File.dirname(__FILE__) Dir[File.join(dirname, "*.rb")].each do |f| require f.gsub(%r{#{dirname}/lib/}, '').gsub(/.rb/, '') unless f =~ /base/ end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
msewage-importer-0.0.3 | lib/msewage-importer/importers/base.rb |
msewage-importer-0.0.2 | lib/msewage-importer/importers/base.rb |
msewage-importer-0.0.1 | lib/msewage-importer/importers/base.rb |