summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/dslkeywords/file.rb21
-rw-r--r--lib/rcm.rb13
2 files changed, 17 insertions, 17 deletions
diff --git a/lib/dslkeywords/file.rb b/lib/dslkeywords/file.rb
index a22e52f..8411d53 100644
--- a/lib/dslkeywords/file.rb
+++ b/lib/dslkeywords/file.rb
@@ -22,26 +22,25 @@ module RCM
end
def content(content = nil)
- content.nil? ? @content : @content = content
+ return @content if content.nil?
+
+ @content = content.instance_of?(Array) ? content.join("\n") : content
end
def create_parent_directory
@create_parent = true
- self
end
- def from_file(...)
- @from_file = true
- self
+ def from_sourcefile
+ @from_sourcefile = true
end
- def from_template(...)
+ def from_template
@from_template = true
- self
end
def do!
- content = file_content
+ content = real_content
dirname = ::File.dirname(@path)
if !::File.directory?(dirname) && @create_parent
@@ -59,8 +58,8 @@ module RCM
private
- def file_content
- content = @from_file ? ::File.read(@content) : @content
+ def real_content
+ content = @from_sourcefile ? ::File.read(@content) : @content
@from_template ? ERB.new(content).result : content
end
end
@@ -71,7 +70,7 @@ module RCM
return unless @conds_met
f = File.new(path)
- f.instance_eval(&block)
+ f.content(f.instance_eval(&block))
self << f
end
end
diff --git a/lib/rcm.rb b/lib/rcm.rb
index e341405..a740cb2 100644
--- a/lib/rcm.rb
+++ b/lib/rcm.rb
@@ -10,17 +10,18 @@ module RCM
class RCM
attr_reader :id
- @@rcm_counter = 0
+ @@rcm_counter = -1
+ @@objs = {}
include Config
include Options
include Log
def initialize
+ @@rcm_counter += 1
@id = "#{self.class}(#{@@rcm_counter})"
- @objs = {}
@conds_met = true
- @@rcm_counter += 1
+ @scheduled = []
end
def to_s
@@ -28,12 +29,12 @@ module RCM
end
def do!
- @objs.each_value(&:do!)
+ @scheduled.each(&:do!)
end
def <<(obj)
- fatal_exit "Object #{obj.id} already declared!" if @objs.key?(obj.id)
- @objs[obj.id] = obj
+ fatal_exit "Object #{obj.id} already declared!" if @@objs.key?(obj.id)
+ @scheduled << @@objs[obj.id] = obj
end
end
end