Class: Caml::Config
- Inherits:
-
Object
show all
- Defined in:
- lib/caml/config.rb
Defined Under Namespace
Classes: Malformed, NotFound
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Constructor Details
#initialize(tasks) ⇒ Config
Returns a new instance of Config.
37
38
39
|
# File 'lib/caml/config.rb', line 37
def initialize(tasks)
@tasks = tasks
end
|
Instance Attribute Details
#tasks ⇒ Object
Returns the value of attribute tasks.
11
12
13
|
# File 'lib/caml/config.rb', line 11
def tasks
@tasks
end
|
Class Method Details
.discover(start_dir) ⇒ Object
20
21
22
23
24
25
26
27
28
29
30
31
|
# File 'lib/caml/config.rb', line 20
def self.discover(start_dir)
dir = File.expand_path(start_dir)
loop do
candidate = File.join(dir, 'caml.yaml')
return candidate if File.file?(candidate)
parent = File.dirname(dir)
return nil if parent == dir
dir = parent
end
end
|
.from_tasks(tasks) ⇒ Object
33
34
35
|
# File 'lib/caml/config.rb', line 33
def self.from_tasks(tasks)
new(tasks)
end
|
.load(path) ⇒ Object
13
14
15
16
17
18
|
# File 'lib/caml/config.rb', line 13
def self.load(path)
raise NotFound, "caml.yaml not found at #{path}" unless File.file?(path)
raw = parse(File.read(path), path)
from_raw(raw)
end
|