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.1.2"
Class Method Summary collapse
-
.find_task_file ⇒ Object
Search the current directory and its ancestors for a .loki task file.
-
.load_loki(dir) ⇒ Object
Load all *.loki files from dir in alphabetical order.
-
.run!(argv) ⇒ Object
Main entry point invoked by the asgard executable.
Class Method Details
.find_task_file ⇒ Object
Search the current directory and its ancestors for a .loki task file. Returns the path string, or nil if not found.
14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/asgard.rb', line 14 def self.find_task_file dir = Dir.pwd loop do candidate = File.join(dir, ".loki") return candidate if File.exist?(candidate) parent = File.dirname(dir) break if parent == dir dir = parent end nil end |
.load_loki(dir) ⇒ Object
Load all *.loki files from dir in alphabetical order. Each file typically reopens class Tasks to add tasks. The .loki entry point is excluded — it is loaded separately by run!.
29 30 31 |
# File 'lib/asgard.rb', line 29 def self.load_loki(dir) Dir.glob(File.join(dir, "*.loki")).sort.each { |f| load f } end |
.run!(argv) ⇒ Object
Main entry point invoked by the asgard executable.
34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/asgard.rb', line 34 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}" load_loki(File.dirname(task_file)) load task_file Tasks.validate_deps! Tasks._reset_ran! Tasks.start(argv) rescue CircularDependencyError => e abort "asgard: circular dependency — #{e.}" end |