summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2024-12-07 14:36:21 +0200
committerPaul Buetow <paul@buetow.org>2024-12-07 14:36:21 +0200
commitf0b0dae5bb2e16cf45223fc31396708bd069d06c (patch)
tree5a7f3cd159c8d7029006fb900ec79dad05e0e212 /lib
parent7d5264aea075c3845e6d5e4be65aaacdea54e71f (diff)
cosmetics
Diffstat (limited to 'lib')
-rw-r--r--lib/dsl.rb (renamed from lib/rcm.rb)21
-rw-r--r--lib/dslkeywords/file.rb4
-rw-r--r--lib/dslkeywords/only_when.rb2
3 files changed, 14 insertions, 13 deletions
diff --git a/lib/rcm.rb b/lib/dsl.rb
index a740cb2..160c1ac 100644
--- a/lib/rcm.rb
+++ b/lib/dsl.rb
@@ -7,7 +7,7 @@ Dir["#{Dir.pwd}/lib/dslkeywords/*.rb"].each { |m| require m }
# Ruby Configiration Management system
module RCM
# Here all starts
- class RCM
+ class DSL
attr_reader :id
@@rcm_counter = -1
@@ -18,18 +18,18 @@ module RCM
include Log
def initialize
- @@rcm_counter += 1
- @id = "#{self.class}(#{@@rcm_counter})"
+ @id = "#{self.class}(#{@@rcm_counter += 1})"
@conds_met = true
@scheduled = []
+ yield self if block_given?
end
def to_s
"RCM #{@number}"
end
- def do!
- @scheduled.each(&:do!)
+ def evaluate!
+ @scheduled.each(&:evaluate!)
end
def <<(obj)
@@ -39,9 +39,10 @@ module RCM
end
end
-def make_it_so(&block)
- rcm = RCM::RCM.new
- rcm.info('Making it so...')
- rcm.instance_eval(&block)
- rcm.do!
+def configure(&block)
+ RCM::DSL.new do |rcm|
+ rcm.info('Configuring...')
+ rcm.instance_eval(&block)
+ rcm.evaluate!
+ end
end
diff --git a/lib/dslkeywords/file.rb b/lib/dslkeywords/file.rb
index 746b41c..35db9c2 100644
--- a/lib/dslkeywords/file.rb
+++ b/lib/dslkeywords/file.rb
@@ -39,7 +39,7 @@ module RCM
@from_template = true
end
- def do!
+ def evaluate!
content = real_content
dirname = ::File.dirname(@path)
@@ -65,7 +65,7 @@ module RCM
end
# Add file keyword to the DSL
- class RCM
+ class DSL
def file(path, &block)
return unless @conds_met
diff --git a/lib/dslkeywords/only_when.rb b/lib/dslkeywords/only_when.rb
index 2700bee..2f493b2 100644
--- a/lib/dslkeywords/only_when.rb
+++ b/lib/dslkeywords/only_when.rb
@@ -27,7 +27,7 @@ module RCM
end
# Add 'only_when' to DSL
- class RCM
+ class DSL
def only_when(&block)
conds = OnlyWhen.new
conds.instance_eval(&block)