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_directory` and ‘#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
# 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 = opts.fetch(:command_monitor,
                                Aruba.platform.command_monitor.new(announcer: @announcer))

  @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



81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
# File 'lib/aruba/runtime.rb', line 81

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

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

    directory
  end

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

  ArubaPath.new(@fixtures_directory)
end

#setup_already_done?Boolean

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

Returns:

  • (Boolean)


72
73
74
# File 'lib/aruba/runtime.rb', line 72

def setup_already_done?
  @setup_done == true
end

#setup_doneObject

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



65
66
67
# File 'lib/aruba/runtime.rb', line 65

def setup_done
  @setup_done = true
end