Sha256: 951ee69f86f02d6748d3214f0367a4ddceb516cb675ffefb96228e1913d633b8

Contents?: true

Size: 747 Bytes

Versions: 3

Compression:

Stored size: 747 Bytes

Contents

class TacoRc
  class ParseError < Exception; end
  
  def initialize(path)
    raise ArgumentError.new("no such file: #{path}") unless File.exists? path
    @path = path
  end
  
  def update_schema!(schema)
    open(@path) do |f|
      f.readlines.each_with_index do |line, index|
        next if line =~ /^#/ || line =~ /^\s*$/
  
        raise ParseError.new("Parse error on line #{index+1} of #{@path}: line does not begin with schema_attr_update") unless line =~ /^\s*schema_attr_update /
        
        begin
          eval "#{schema}.#{line.strip}"
        rescue KeyError, TypeError, NameError => e
          raise ParseError.new("Parse error on line #{index+1} of #{@path}: #{e.to_s}")           
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
taco_it-1.4.2 lib/taco/tacorc.rb
taco_it-1.4.1 lib/taco/tacorc.rb
taco_it-1.4.0 lib/taco/tacorc.rb