lib/atp/flow.rb in atp-0.3.3 vs lib/atp/flow.rb in atp-0.4.0

- old
+ new

@@ -5,14 +5,16 @@ attr_reader :program, :name # Returns the raw AST attr_reader :raw attr_accessor :id - def initialize(program, name = nil) + def initialize(program, name = nil, options = {}) + name, options = nil, name if name.is_a?(Hash) + extract_meta!(options) @program = program @name = name - @raw = builder.flow + @raw = builder.flow(name) end # @api private def marshal_dump [@name, @program, Processors::Marshal.new.process(@raw)] @@ -47,10 +49,11 @@ # flow.test ... # end def group(name, options = {}) open_groups.push([]) yield + extract_meta!(options) append builder.group(name, open_groups.pop, options) end # Add a test line to the flow # @@ -266,12 +269,12 @@ end t end def extract_meta!(options) - builder.source_file = options.delete(:source_file) if options[:source_file] - builder.source_line_number = options.delete(:source_line_number) if options[:source_line_number] - builder.description = options.delete(:description) if options[:description] + builder.source_file = options.delete(:source_file) + builder.source_line_number = options.delete(:source_line_number) + builder.description = options.delete(:description) end # For testing def raw=(ast) @raw = ast