From 36dc0ed218e3400fd186628e3152111568f2c64f Mon Sep 17 00:00:00 2001 From: John Keiser Date: Thu, 3 Dec 2015 13:26:30 -0800 Subject: immediately_before -> before --- lib/chef/resource.rb | 20 ++++++++-------- lib/chef/run_context.rb | 28 +++++++++++----------- lib/chef/runner.rb | 12 +++++----- spec/functional/notifications_spec.rb | 14 +++++------ .../shared/integration/integration_helper.rb | 2 +- 5 files changed, 38 insertions(+), 38 deletions(-) diff --git a/lib/chef/resource.rb b/lib/chef/resource.rb index fb6ee71e81..e7cb2416cc 100644 --- a/lib/chef/resource.rb +++ b/lib/chef/resource.rb @@ -208,7 +208,7 @@ class Chef # actions have been run. This is the default. # - `immediate`, `immediately`: Will run the action on the other resource # immediately (before any other action is run). - # - `immediately_before`: Will run the action on the other resource + # - `before`: Will run the action on the other resource # immediately *before* the action is actually run. # # @example Resource by string @@ -252,11 +252,11 @@ class Chef notifies_delayed(action, resource) when 'immediate', 'immediately' notifies_immediately(action, resource) - when 'immediately_before' - notifies_immediately_before(action, resource) + when 'before' + notifies_before(action, resource) else raise ArgumentError, "invalid timing: #{timing} for notifies(#{action}, #{resources.inspect}, #{timing}) resource #{self} "\ - "Valid timings are: :delayed, :immediate, :immediately, :immediately_before" + "Valid timings are: :delayed, :immediate, :immediately, :before" end end @@ -280,7 +280,7 @@ class Chef # actions have been run. This is the default. # - `immediate`, `immediately`: The action will run immediately following # the other resource being updated. - # - `immediately_before`: The action will run immediately before the + # - `before`: The action will run immediately before the # other resource is updated. # # @example Resources by string @@ -1243,7 +1243,7 @@ class Chef # resolve_resource_reference on each in turn, causing them to # resolve lazy/forward references. def resolve_notification_references - run_context.immediately_before_notifications(self).each { |n| + run_context.before_notifications(self).each { |n| n.resolve_resource_reference(run_context.resource_collection) } run_context.immediate_notifications(self).each { |n| @@ -1255,8 +1255,8 @@ class Chef end # Helper for #notifies - def notifies_immediately_before(action, resource_spec) - run_context.notifies_immediately_before(Notification.new(resource_spec, action, self)) + def notifies_before(action, resource_spec) + run_context.notifies_before(Notification.new(resource_spec, action, self)) end # Helper for #notifies @@ -1354,8 +1354,8 @@ class Chef "#{declared_type}[#{@name}]" end - def immediately_before_notifications - run_context.immediately_before_notifications(self) + def before_notifications + run_context.before_notifications(self) end def immediate_notifications diff --git a/lib/chef/run_context.rb b/lib/chef/run_context.rb index b725857bc5..6e02f47ff1 100644 --- a/lib/chef/run_context.rb +++ b/lib/chef/run_context.rb @@ -104,13 +104,13 @@ class Chef # # - # A Hash containing the immediately_before notifications triggered by resources + # A Hash containing the before notifications triggered by resources # during the converge phase of the chef run. # # @return [Hash[String, Array[Chef::Resource::Notification]]] A hash from # => # - attr_reader :immediately_before_notification_collection + attr_reader :before_notification_collection # # A Hash containing the immediate notifications triggered by resources @@ -173,22 +173,22 @@ class Chef def initialize_child_state @audits = {} @resource_collection = Chef::ResourceCollection.new - @immediately_before_notification_collection = Hash.new {|h,k| h[k] = []} + @before_notification_collection = Hash.new {|h,k| h[k] = []} @immediate_notification_collection = Hash.new {|h,k| h[k] = []} @delayed_notification_collection = Hash.new {|h,k| h[k] = []} end # - # Adds an immediately_before notification to the +immediately_before_notification_collection+. + # Adds an before notification to the +before_notification_collection+. # # @param [Chef::Resource::Notification] The notification to add. # - def notifies_immediately_before(notification) + def notifies_before(notification) nr = notification.notifying_resource if nr.instance_of?(Chef::Resource) - immediately_before_notification_collection[nr.name] << notification + before_notification_collection[nr.name] << notification else - immediately_before_notification_collection[nr.declared_key] << notification + before_notification_collection[nr.declared_key] << notification end end @@ -221,18 +221,18 @@ class Chef end # - # Get the list of immediately_before notifications sent by the given resource. + # Get the list of before notifications sent by the given resource. # # TODO seriously, this is actually wrong. resource.name is not unique, # you need the type as well. # # @return [Array[Notification]] # - def immediately_before_notifications(resource) + def before_notifications(resource) if resource.instance_of?(Chef::Resource) - return immediately_before_notification_collection[resource.name] + return before_notification_collection[resource.name] else - return immediately_before_notification_collection[resource.declared_key] + return before_notification_collection[resource.declared_key] end end @@ -648,13 +648,13 @@ ERROR_MESSAGE immediate_notification_collection immediate_notification_collection= immediate_notifications - immediately_before_notification_collection - immediately_before_notifications + before_notification_collection + before_notifications include_recipe initialize_child_state load_recipe load_recipe_file - notifies_immediately_before + notifies_before notifies_immediately notifies_delayed parent_run_context diff --git a/lib/chef/runner.rb b/lib/chef/runner.rb index 50554dcdbc..e1b4e98f89 100644 --- a/lib/chef/runner.rb +++ b/lib/chef/runner.rb @@ -47,22 +47,22 @@ class Chef # execute it. def run_action(resource, action, notification_type=nil, notifying_resource=nil) - # If there are any immediately_before notifications, why-run the resource + # If there are any before notifications, why-run the resource # and notify anyone who needs notifying - if !run_context.immediately_before_notifications(resource).empty? + if !run_context.before_notifications(resource).empty? whyrun_before = Chef::Config[:why_run] begin Chef::Config[:why_run] = true - Chef::Log.info("#{resource} running why-run #{action} action to support immediately_before action") + Chef::Log.info("#{resource} running why-run #{action} action to support before action") resource.run_action(action, notification_type, notifying_resource) ensure Chef::Config[:why_run] = whyrun_before end if resource.updated_by_last_action? - run_context.immediately_before_notifications(resource).each do |notification| - Chef::Log.info("#{resource} sending #{notification.action} action to #{notification.resource} (immediately_before)") - run_action(notification.resource, notification.action, :immediately_before, resource) + run_context.before_notifications(resource).each do |notification| + Chef::Log.info("#{resource} sending #{notification.action} action to #{notification.resource} (before)") + run_action(notification.resource, notification.action, :before, resource) end end diff --git a/spec/functional/notifications_spec.rb b/spec/functional/notifications_spec.rb index 42702a8bb2..f14f35ebba 100644 --- a/spec/functional/notifications_spec.rb +++ b/spec/functional/notifications_spec.rb @@ -74,11 +74,11 @@ describe "Notifications" do runner.converge end - it "should notify from one resource to another immediately_before" do + it "should notify from one resource to another before" do log_resource = recipe.declare_resource(:log, "log") do message "This is a log message" action :write - notifies :install, "package[vim]", :immediately_before + notifies :install, "package[vim]", :before end update_action(log_resource, 2) @@ -102,19 +102,19 @@ describe "Notifications" do expect(actions).to eq [ # First it runs why-run to check if the resource would update { resource: log_resource.to_s, action: :write, why_run: true }, - # Then it runs the immediately_before action - { resource: package_resource.to_s, action: :install, notification_type: :immediately_before, notifying_resource: log_resource.to_s }, + # Then it runs the before action + { resource: package_resource.to_s, action: :install, notification_type: :before, notifying_resource: log_resource.to_s }, # Then it runs the actual action { resource: log_resource.to_s, action: :write }, { resource: package_resource.to_s, action: :nothing } ] end - it "should not notify from one resource to another immediately_before if the resource is not updated" do + it "should not notify from one resource to another before if the resource is not updated" do log_resource = recipe.declare_resource(:log, "log") do message "This is a log message" action :write - notifies :install, "package[vim]", :immediately_before + notifies :install, "package[vim]", :before end package_resource = recipe.declare_resource(:package, "vim") do @@ -137,7 +137,7 @@ describe "Notifications" do expect(actions).to eq [ # First it runs why-run to check if the resource would update { resource: log_resource.to_s, action: :write, why_run: true }, - # Then it does NOT run the immediately_before action + # Then it does NOT run the before action # Then it runs the actual action { resource: log_resource.to_s, action: :write }, { resource: package_resource.to_s, action: :nothing } diff --git a/spec/support/shared/integration/integration_helper.rb b/spec/support/shared/integration/integration_helper.rb index f5a1647b8f..7d62a698d8 100644 --- a/spec/support/shared/integration/integration_helper.rb +++ b/spec/support/shared/integration/integration_helper.rb @@ -29,7 +29,7 @@ require 'spec_helper' module Cheffish class BasicChefClient - def_delegators :@run_context, :immediately_before_notifications + def_delegators :@run_context, :before_notifications end end -- cgit v1.2.1