Sha256: 5d28cdb2f8a1ed8604e4aef4efc3e1ed0de45e278dc385d3b7d7118d36014bfd

Contents?: true

Size: 1.18 KB

Versions: 22

Compression:

Stored size: 1.18 KB

Contents

module ETL #:nodoc:
  module Parser #:nodoc:
    # Base parser class. Implementation classes must extend this class and implement
    # the each method. The each method should return each row of the source data as 
    # a Hash.
    class Parser
      include Enumerable
      class << self
        # Convert the name (string or symbol) to a parser class.
        #
        # Example:
        #   <tt>class_for_name(:fixed_width)</tt> returns a FixedWidthParser class
        def class_for_name(name)
          ETL::Parser.const_get("#{name.to_s.camelize}Parser")
        end
      end
      
      # The Source object for the data
      attr_reader :source
      
      # Options Hash for the parser
      attr_reader :options
      
      def initialize(source, options={})
        @source = source
        @options = options || {}
      end
      
      protected
      def file
        path = Pathname.new(source.configuration[:file])
        path = path.absolute? ? path : Pathname.new(File.dirname(source.control.file)) + path
        path
      end
      
      def raise_with_info(error, message, file, line)
        raise error, "#{message} (line #{line} in #{file})"
      end
    end
  end
end

Version data entries

22 entries across 22 versions & 9 rubygems

Version Path
aeden-activewarehouse-etl-0.9.1 etl/lib/etl/parser/parser.rb
colincasey-activewarehouse-etl-0.9.4 lib/etl/parser/parser.rb
colincasey-activewarehouse-etl-0.9.5 lib/etl/parser/parser.rb
factorylabs-activewarehouse-etl-0.9.1.2 lib/etl/parser/parser.rb
factorylabs-activewarehouse-etl-0.9.1.3 lib/etl/parser/parser.rb
factorylabs-activewarehouse-etl-0.9.1.4 lib/etl/parser/parser.rb
factorylabs-activewarehouse-etl-0.9.1.5 lib/etl/parser/parser.rb
factorylabs-activewarehouse-etl-0.9.1.6 lib/etl/parser/parser.rb
factorylabs-activewarehouse-etl-0.9.1.7 lib/etl/parser/parser.rb
jayzes-activewarehouse-etl-0.9.1.1 lib/etl/parser/parser.rb
jayzes-activewarehouse-etl-0.9.1.2 lib/etl/parser/parser.rb
jayzes-activewarehouse-etl-0.9.1 lib/etl/parser/parser.rb
activewarehouse-etl-1.0.0 lib/etl/parser/parser.rb
activewarehouse-etl-1.0.0.rc1 lib/etl/parser/parser.rb
etl-0.9.5.rc1 lib/etl/parser/parser.rb
activewarehouse-etl-sgonyea-0.9.6 lib/etl/parser/parser.rb
activewarehouse-etl-0.9.5.rc1 lib/etl/parser/parser.rb
darrell-activewarehouse-etl-0.9.1.6 lib/etl/parser/parser.rb
darrell-activewarehouse-etl-0.9.1.4 lib/etl/parser/parser.rb
factorylabs-activewarehouse-etl-0.9.1.8 lib/etl/parser/parser.rb