Sha256: ef106ffa84f6ce36874c7e2861cd779d8ca3e02bb28da0811d518ed2f12332bc
Contents?: true
Size: 1.53 KB
Versions: 3
Compression:
Stored size: 1.53 KB
Contents
module CukeModeler # A class modeling a Cucumber .feature file. class FeatureFile include Containing include Nested # The Feature objects contained by the FeatureFile attr_accessor :features # Creates a new FeatureFile object and, if *file_parsed* is provided, # populates the object. def initialize(file = nil) @file = file @features = [] if file raise(ArgumentError, "Unknown file: #{file.inspect}") unless File.exists?(file) parsed_file = parse_file(file) build_file(parsed_file) end end # Returns the name of the file. def name File.basename(@file.gsub('\\', '/')) end # Returns the path of the file. def path @file end # Returns the immediate child elements of the file(i.e. its Feature object). def contains @features end # Returns the number of features contained in the file. def feature_count @features.count end # Returns the Feature object contained by the FeatureFile. def feature @features.first end # Returns the path of the feature file. def to_s path.to_s end private def parse_file(file_to_parse) source_text = IO.read(file_to_parse) Parsing::parse_text(source_text) end def build_file(parsed_file) unless parsed_file.empty? @features << build_child_element(Feature, parsed_file.first) end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
cuke_modeler-0.1.0 | lib/cuke_modeler/feature_file.rb |
cuke_modeler-0.0.2 | lib/cuke_modeler/feature_file.rb |
cuke_modeler-0.0.1 | lib/cuke_modeler/feature_file.rb |