Module: Asgard

Defined in:
lib/asgard.rb,
lib/asgard/base.rb,
lib/asgard/shell.rb,
lib/asgard/version.rb

Defined Under Namespace

Modules: Shell Classes: Base, CircularDependencyError, Error

Constant Summary collapse

VERSION =
"0.3.0"

Class Method Summary collapse

Class Method Details

.find_task_fileObject

Search the current directory and its ancestors for a .loki task file. Returns the path string, or nil if not found.



15
16
17
# File 'lib/asgard.rb', line 15

def self.find_task_file
  loki_up
end

.run!(argv) ⇒ Object

Main entry point invoked by the asgard executable.



20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/asgard.rb', line 20

def self.run!(argv)
  abort "asgard: unknown command '#{argv.first}'" if argv.first&.start_with?("_")
  task_file = find_task_file or abort "asgard: no .loki file found in #{Dir.pwd}"
  before = Asgard::Base.subclasses.dup
  load task_file
  newly_defined = Asgard::Base.subclasses - before
  (newly_defined + [Tasks]).uniq.each(&:validate_deps!)
  Tasks._reset_ran!
  Tasks.start(argv)
rescue CircularDependencyError => e
  abort "asgard: circular dependency — #{e.message}"
rescue Error => e
  abort "asgard: #{e.message}"
end