lib/glimmer/dsl/engine.rb in glimmer-0.9.0 vs lib/glimmer/dsl/engine.rb in glimmer-0.9.1

- old
+ new

@@ -54,10 +54,14 @@ a_parent_stack.clear end dsl_stack.clear disabled_dsls.clear end + + def no_dsls? + static_expressions.empty? && dynamic_expression_chains_of_responsibility.empty? + end # Dynamic expression chains of responsibility indexed by dsl def dynamic_expression_chains_of_responsibility @dynamic_expression_chains_of_responsibility ||= {} end @@ -138,9 +142,13 @@ "#{expression_name}_expression".camelcase(:upper) end # Interprets Glimmer dynamic DSL expression consisting of keyword, args, and block (e.g. shell(:no_resize) { ... }) def interpret(keyword, *args, &block) + if no_dsls? + puts "Glimmer has no DSLs configured. Add glimmer-dsl-swt gem or visit https://github.com/AndyObtiva/glimmer#multi-dsl-support for more details.\n" + return + end keyword = keyword.to_s dynamic_expression_dsl = (dynamic_expression_chains_of_responsibility.keys - disabled_dsls).first if dsl.nil? dsl_stack.push(dynamic_expression_dsl || dsl) expression = dynamic_expression_chains_of_responsibility[dsl].handle(parent, keyword, *args, &block) expression.interpret(parent, keyword, *args, &block).tap do |ui_object|