Sha256: 6608972d37596c5a9e2c1b330b5889d89ce2e2228f71cf97319ec1543f4ab7cc

Contents?: true

Size: 827 Bytes

Versions: 15

Compression:

Stored size: 827 Bytes

Contents

module ATP
  # Program is the top-level container for a collection of test flows
  class Program
    # Load a program from a previously saved file
    def self.load(file)
      p = nil
      File.open(file) do |f|
        p = Marshal.load(f)
      end
      p
    end

    def flow(name, options = {})
      flows[name] ||= Flow.new(self, name, options)
    end

    def flows
      @flows ||= {}
    end

    # Save the program to a file
    def save(file)
      File.open(file, 'w') do |f|
        Marshal.dump(self, f)
      end
    end

    def respond_to?(*args)
      flows.key?(args.first) || super
    end

    def method_missing(method, *args, &block) # :nodoc:
      if f = flows[method]
        define_singleton_method method do
          f
        end
        f
      else
        super
      end
    end
  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
atp-1.1.3 lib/atp/program.rb
atp-1.1.2 lib/atp/program.rb
atp-1.1.1 lib/atp/program.rb
atp-1.1.0 lib/atp/program.rb
atp-1.0.0 lib/atp/program.rb
atp-0.8.0 lib/atp/program.rb
atp-0.7.0 lib/atp/program.rb
atp-0.6.0 lib/atp/program.rb
atp-0.5.4 lib/atp/program.rb
atp-0.5.3 lib/atp/program.rb
atp-0.5.0 lib/atp/program.rb
atp-0.4.3 lib/atp/program.rb
atp-0.4.2 lib/atp/program.rb
atp-0.4.1 lib/atp/program.rb
atp-0.4.0 lib/atp/program.rb