Class: Aruba::Runtime

Inherits:
Object
  • Object
show all
Defined in:
lib/aruba/runtime.rb

Overview

Runtime of aruba

Most methods are considered private. Please look for (private) in the attribute descriptions. Only a few like #current_directory, '#root_directoryand#config` are considered to be part of the public API.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(opts = {}) ⇒ Runtime

Returns a new instance of Runtime.



42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
# File 'lib/aruba/runtime.rb', line 42

def initialize(opts = {})
  @event_bus       = EventBus.new(EventBus::NameResolver.new(Aruba::Events))
  @announcer       = opts.fetch(:announcer, Aruba.platform.announcer.new)
  @config          = opts.fetch(:config, ConfigWrapper.new(Aruba.config.make_copy, @event_bus))
  @environment     = opts.fetch(:environment, Aruba.platform.environment_variables.new)
  @current_directory = ArubaPath.new(@config.working_directory)
  @root_directory    = ArubaPath.new(@config.root_directory)

  @environment.update(@config.command_runtime_environment)

  @command_monitor = if Aruba::VERSION < '1'
                       opts.fetch(:command_monitor, Aruba.platform.command_monitor.new(:announcer => @announcer))
                     else
                       opts.fetch(:command_monitor, Aruba.platform.command_monitor.new)
                     end

  @logger = opts.fetch(:logger, Aruba.platform.logger.new)
  @logger.mode = @config.log_level

  @setup_done = false
end

Instance Attribute Details

#announcerObject

Announce information



40
# File 'lib/aruba/runtime.rb', line 40

attr_accessor :config, :environment, :logger, :command_monitor, :announcer, :event_bus

#command_monitorObject

Handler started commands (private)



40
# File 'lib/aruba/runtime.rb', line 40

attr_accessor :config, :environment, :logger, :command_monitor, :announcer, :event_bus

#configObject

Access configuration of aruba



40
41
42
# File 'lib/aruba/runtime.rb', line 40

def config
  @config
end

#current_directoryObject (readonly)

Returns the current working directory



20
21
22
# File 'lib/aruba/runtime.rb', line 20

def current_directory
  @current_directory
end

#environmentObject

Access environment of aruba (private)



40
# File 'lib/aruba/runtime.rb', line 40

attr_accessor :config, :environment, :logger, :command_monitor, :announcer, :event_bus

#event_busObject

Handle events (private)



40
# File 'lib/aruba/runtime.rb', line 40

attr_accessor :config, :environment, :logger, :command_monitor, :announcer, :event_bus

#loggerObject

Logger of aruba (private)



40
# File 'lib/aruba/runtime.rb', line 40

attr_accessor :config, :environment, :logger, :command_monitor, :announcer, :event_bus

#root_directoryObject (readonly)

Returns the value of attribute root_directory.



20
# File 'lib/aruba/runtime.rb', line 20

attr_reader :current_directory, :root_directory

Instance Method Details

#fixtures_directoryArubaPath

The path to the directory which contains fixtures You might want to overwrite this method to place your data else where.

Returns:

  • (ArubaPath)

    The directory to where your fixtures are stored



83
84
85
86
87
88
89
90
91
92
93
94
# File 'lib/aruba/runtime.rb', line 83

def fixtures_directory
  unless @fixtures_directory
    candidates = config.fixtures_directories.map { |dir| File.join(root_directory, dir) }
    @fixtures_directory = candidates.find { |d| Aruba.platform.directory? d }

    fail "No existing fixtures directory found in #{candidates.map { |d| format('"%s"', d) }.join(', ')}. " unless @fixtures_directory
  end

  fail %(Fixtures directory "#{@fixtures_directory}" is not a directory) unless Aruba.platform.directory?(@fixtures_directory)

  ArubaPath.new(@fixtures_directory)
end

#setup_already_done?Boolean

Has aruba already been setup. Should be used only internally.

Returns:

  • (Boolean)


74
75
76
# File 'lib/aruba/runtime.rb', line 74

def setup_already_done?
  @setup_done == true
end

#setup_doneObject

Setup of aruba is finshed. Should be used only internally.



67
68
69
# File 'lib/aruba/runtime.rb', line 67

def setup_done
  @setup_done = true
end