summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorelijah <elijah@riseup.net>2013-07-29 13:39:15 -0700
committerelijah <elijah@riseup.net>2013-07-29 13:39:15 -0700
commit578541a02b85d622f06637b29e2a6f8e32515994 (patch)
tree98d2798cef36b4aa968020fcbfd86c7a7f9db615
parentd188d599de9997db4c905ae252c4efcba9d7d432 (diff)
added assert() macro.
if failed, spits out this on compile: = FAILED assertion while evaluating node 'worm' - assertion: services.include? 'couchdb' - offending key: require_couchdb = bailing out
-rw-r--r--lib/leap_cli/config/macros.rb22
-rw-r--r--lib/leap_cli/config/object.rb6
-rw-r--r--lib/leap_cli/version.rb2
3 files changed, 29 insertions, 1 deletions
diff --git a/lib/leap_cli/config/macros.rb b/lib/leap_cli/config/macros.rb
index f46799c..b5f6a34 100644
--- a/lib/leap_cli/config/macros.rb
+++ b/lib/leap_cli/config/macros.rb
@@ -335,5 +335,27 @@ module LeapCli; module Config
entries.join("\n")
end
+ ##
+ ## UTILITY
+ ##
+
+ class AssertionFailed < Exception
+ attr_accessor :assertion
+ def initialize(assertion)
+ @assertion = assertion
+ end
+ def to_s
+ @assertion
+ end
+ end
+
+ def assert(assertion)
+ if instance_eval(assertion)
+ true
+ else
+ raise AssertionFailed.new(assertion)
+ end
+ end
+
end
end; end
diff --git a/lib/leap_cli/config/object.rb b/lib/leap_cli/config/object.rb
index 00997b1..1d296b3 100644
--- a/lib/leap_cli/config/object.rb
+++ b/lib/leap_cli/config/object.rb
@@ -282,6 +282,12 @@ module LeapCli
Util::log "error message: no file '#{exc}'", :indent => 1
end
end
+ rescue AssertionFailed => exc
+ Util.bail! do
+ Util::log :failed, "assertion while evaluating node '#{@node.name}'"
+ Util::log 'assertion: %s' % exc.assertion, :indent => 1
+ Util::log "offending key: #{key}", :indent => 1
+ end
rescue SyntaxError, StandardError => exc
Util::bail! do
Util::log :error, "while evaluating node '#{@node.name}'"
diff --git a/lib/leap_cli/version.rb b/lib/leap_cli/version.rb
index 0e96de6..30a1b58 100644
--- a/lib/leap_cli/version.rb
+++ b/lib/leap_cli/version.rb
@@ -1,6 +1,6 @@
module LeapCli
unless defined?(LeapCli::VERSION)
- VERSION = '1.1.4'
+ VERSION = '1.2.0'
COMPATIBLE_PLATFORM_VERSION = '0.2.3'..'1.99'
SUMMARY = 'Command line interface to the LEAP platform'
DESCRIPTION = 'The command "leap" can be used to manage a bevy of servers running the LEAP platform from the comfort of your own home.'