Sha256: d2678b8e174251fbecee5196368efadde058b3aa4948994b8d1a7cdedfa7b9c7

Contents?: true

Size: 1.48 KB

Versions: 35

Compression:

Stored size: 1.48 KB

Contents

$:.unshift(File.expand_path('../../lib', __FILE__))

require 'dynflow'

class ExampleHelper
  class << self
    def world
      @world ||= create_world
    end

    def set_world(world)
      @world = world
    end

    def create_world
      config = Dynflow::Config.new
      config.persistence_adapter = persistence_adapter
      config.logger_adapter      = logger_adapter
      config.auto_rescue         = false
      yield config if block_given?
      Dynflow::World.new(config).tap do |world|
        puts "World #{world.id} started..."
      end
    end

    def persistence_conn_string
      ENV['DB_CONN_STRING'] || 'sqlite:/'
    end

    def persistence_adapter
      Dynflow::PersistenceAdapters::Sequel.new persistence_conn_string
    end

    def logger_adapter
      Dynflow::LoggerAdapters::Simple.new $stderr, 4
    end

    def run_web_console(world = ExampleHelper.world)
      require 'dynflow/web'
      dynflow_console = Dynflow::Web.setup do
        set :world, world
      end
      Rack::Server.new(:app => dynflow_console, :Port => 4567).start
    end

    # for simulation of the execution failing for the first time
    def something_should_fail!
      @should_fail = true
    end

    # for simulation of the execution failing for the first time
    def something_should_fail?
      @should_fail
    end

    def nothing_should_fail!
      @should_fail = false
    end

    def terminate
      @world.terminate.wait if @world
    end
  end
end

at_exit { ExampleHelper.terminate }

Version data entries

35 entries across 35 versions & 1 rubygems

Version Path
dynflow-1.1.0 examples/example_helper.rb
dynflow-1.0.5 examples/example_helper.rb
dynflow-1.0.4 examples/example_helper.rb
dynflow-1.0.3 examples/example_helper.rb
dynflow-1.0.2 examples/example_helper.rb
dynflow-1.0.1 examples/example_helper.rb
dynflow-1.0.0 examples/example_helper.rb
dynflow-0.8.37 examples/example_helper.rb
dynflow-0.8.36 examples/example_helper.rb
dynflow-0.8.35 examples/example_helper.rb
dynflow-0.8.34 examples/example_helper.rb
dynflow-0.8.33 examples/example_helper.rb
dynflow-0.8.32 examples/example_helper.rb
dynflow-0.8.31 examples/example_helper.rb
dynflow-0.8.30 examples/example_helper.rb
dynflow-0.8.29 examples/example_helper.rb
dynflow-0.8.28 examples/example_helper.rb
dynflow-0.8.27 examples/example_helper.rb
dynflow-0.8.26 examples/example_helper.rb
dynflow-0.8.25 examples/example_helper.rb