Module: MiGA::Common::Path

Included in:
MiGA
Defined in:
lib/miga/common/path.rb

Instance Method Summary collapse

Instance Method Details

#root_pathObject

Root path to MiGA (as estimated from the location of the current file).



6
7
8
# File 'lib/miga/common/path.rb', line 6

def root_path
  File.expand_path('../../../..', __FILE__)
end

#script_path(task, opts = {}) ⇒ Object

Path to a script to be executed for task. Supported opts are:

  • :miga Path to the MiGA home to use. If not passed, the home of the library is used).

  • :project MiGA::Project object to check within plugins. If not passed, only core scripts are supported.



16
17
18
19
20
21
22
23
24
25
26
# File 'lib/miga/common/path.rb', line 16

def script_path(task, opts={})
  opts[:miga] ||= root_path
  unless opts[:project].nil?
    opts[:project].plugins.each do |pl|
      if File.exist? File.expand_path("scripts/#{task}.bash", pl)
        opts[:miga] = pl
      end
    end
  end
  File.expand_path("scripts/#{task}.bash", opts[:miga])
end