From f976730a2788c480b13aa19f7d59f235387c05ec Mon Sep 17 00:00:00 2001 From: Dominik Richter Date: Mon, 2 Nov 2015 20:12:06 +0100 Subject: [PATCH 1/3] api: make control the default keyword --- lib/inspec/profile_context.rb | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/inspec/profile_context.rb b/lib/inspec/profile_context.rb index 1eec38ccd..d7596e9fc 100644 --- a/lib/inspec/profile_context.rb +++ b/lib/inspec/profile_context.rb @@ -92,13 +92,18 @@ module Inspec Class.new do include dsl - define_method :rule do |*args, &block| + define_method :control do |*args, &block| id = args[0] opts = args[1] || {} return if @skip_profile __register_rule rule_class.new(id, opts, &block) end + define_method :rule do |*args, &block| + # TODO: add deprecation notice + control(*args, &block) + end + define_method :describe do |*args, &block| path = block.source_location[0] line = block.source_location[1] From ccabe55608b5003c304ff792f9affa597f360d38 Mon Sep 17 00:00:00 2001 From: Dominik Richter Date: Mon, 2 Nov 2015 20:20:14 +0100 Subject: [PATCH 2/3] api: change require/include_rules -> require/include_controls --- lib/inspec/dsl.rb | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/lib/inspec/dsl.rb b/lib/inspec/dsl.rb index cd40995f2..2846c1232 100644 --- a/lib/inspec/dsl.rb +++ b/lib/inspec/dsl.rb @@ -5,14 +5,17 @@ # author: Christoph Hartmann module Inspec::DSL - def require_rules(id, &block) + def require_controls(id, &block) ::Inspec::DSL.load_spec_files_for_profile self, id, false, &block end - def include_rules(id, &block) + def include_controls(id, &block) ::Inspec::DSL.load_spec_files_for_profile self, id, true, &block end + alias_method :require_rules, :require_controls + alias_method :include_rules, :include_controls + # Register a given rule with RSpec and # let it run. This happens after everything # else is merged in. From 7a07c02b4d210807dec45af2e63c54fb3cf695ed Mon Sep 17 00:00:00 2001 From: Dominik Richter Date: Mon, 2 Nov 2015 22:43:20 +0100 Subject: [PATCH 3/3] alias rule instead of recreating it --- lib/inspec/profile_context.rb | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/lib/inspec/profile_context.rb b/lib/inspec/profile_context.rb index d7596e9fc..ae7672671 100644 --- a/lib/inspec/profile_context.rb +++ b/lib/inspec/profile_context.rb @@ -99,10 +99,7 @@ module Inspec __register_rule rule_class.new(id, opts, &block) end - define_method :rule do |*args, &block| - # TODO: add deprecation notice - control(*args, &block) - end + alias_method :rule, :control define_method :describe do |*args, &block| path = block.source_location[0]