Class: Gn
- Inherits:
-
Object
show all
- Defined in:
- lib/gn.rb,
lib/gn/dsl.rb
Defined Under Namespace
Modules: DSL
Classes: Blueprint
Constant Summary
collapse
- PLAN_FILE =
"plan.rb"
Instance Attribute Summary collapse
Instance Method Summary
collapse
Constructor Details
#initialize(name) ⇒ Gn
Returns a new instance of Gn.
33
34
35
|
# File 'lib/gn.rb', line 33
def initialize(name)
@name = name
end
|
Instance Attribute Details
#name ⇒ Object
Returns the value of attribute name.
31
32
33
|
# File 'lib/gn.rb', line 31
def name
@name
end
|
Instance Method Details
#blueprints ⇒ Object
63
64
65
66
67
|
# File 'lib/gn.rb', line 63
def blueprints
Plan.constants.map do |constant|
Blueprint.new(self, Plan.const_get(constant))
end
end
|
#edit(file) ⇒ Object
59
60
61
|
# File 'lib/gn.rb', line 59
def edit(file)
system "%s %s" % [editor, file.path]
end
|
#editor ⇒ Object
55
56
57
|
# File 'lib/gn.rb', line 55
def editor
ENV["EDITOR"] || "vi"
end
|
#load! ⇒ Object
41
42
43
44
45
46
47
48
49
50
51
52
53
|
# File 'lib/gn.rb', line 41
def load!
file = Tempfile.new([PLAN_FILE, ".rb"])
file.write(File.read(path(PLAN_FILE)))
file.close
edit(file)
if $?.success?
load file.path
else
exit 1
end
end
|
#path(file) ⇒ Object
37
38
39
|
# File 'lib/gn.rb', line 37
def path(file)
File.join(Dir.home, ".gn", name, file)
end
|