Sha256: 0e35fe2f145c6ece2d95666c2833cc9e4d2edba361ab8f948919369aa634a12a
Contents?: true
Size: 859 Bytes
Versions: 2
Compression:
Stored size: 859 Bytes
Contents
require 'ruby2ruby' require 'ruby_parser' require 'to_factory/parsing/syntax' require 'to_factory/parsing/new_syntax' require 'to_factory/parsing/old_syntax' module ToFactory module Parsing class File delegate :multiple_factories?, :header?, :parse, :to => :parser attr_reader :contents def self.parse(filename) from_file(filename).parse end def self.from_file(filename) contents = ::File.read filename rescue nil raise ArgumentError.new "Invalid file #{filename}" if contents.to_s.length == 0 new(contents) end def initialize(contents) @contents = contents end def parser @parser ||= parser_klass.new(@contents) end private def parser_klass ToFactory.new_syntax? ? NewSyntax : OldSyntax end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
to_factory-0.2.1 | lib/to_factory/parsing/file.rb |
to_factory-0.2.0 | lib/to_factory/parsing/file.rb |