summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Dodge <mikedodge04@fb.com>2016-02-15 12:59:41 -0800
committerMike Dodge <mikedodge04@fb.com>2016-02-15 12:59:41 -0800
commitaef381aa1cff43b684ba022d5ce1b2349ea4e4dc (patch)
treefebac97171b1b5af082b7785103bfee2295599fd
parentc2eea28dd0708c0aed8270d0f5c57be7f9cc4707 (diff)
downloadchef-aef381aa1cff43b684ba022d5ce1b2349ea4e4dc.tar.gz
bundle exec chefstyle -a
-rw-r--r--lib/chef/provider/launchd.rb104
-rw-r--r--lib/chef/providers.rb2
-rw-r--r--lib/chef/resource/launchd.rb12
-rw-r--r--lib/chef/resources.rb2
-rw-r--r--spec/unit/provider/launchd_spec.rb86
-rw-r--r--spec/unit/resource/launchd_spec.rb15
6 files changed, 110 insertions, 111 deletions
diff --git a/lib/chef/provider/launchd.rb b/lib/chef/provider/launchd.rb
index eea1fab55a..41c61eafde 100644
--- a/lib/chef/provider/launchd.rb
+++ b/lib/chef/provider/launchd.rb
@@ -16,12 +16,12 @@
# limitations under the License.
#
-require 'chef/provider'
-require 'chef/resource/launchd'
-require 'chef/resource/file'
-require 'chef/resource/cookbook_file'
-require 'chef/resource/macosx_service'
-require 'plist'
+require "chef/provider"
+require "chef/resource/launchd"
+require "chef/resource/file"
+require "chef/resource/cookbook_file"
+require "chef/resource/macosx_service"
+require "plist"
require "forwardable"
class Chef
@@ -50,8 +50,8 @@ class Chef
def gen_path_from_type
types = {
- 'daemon' => "/Library/LaunchDaemons/#{label}.plist",
- 'agent' => "/Library/LaunchAgents/#{label}.plist"
+ "daemon" => "/Library/LaunchDaemons/#{label}.plist",
+ "agent" => "/Library/LaunchAgents/#{label}.plist"
}
types[type]
end
@@ -139,8 +139,8 @@ class Chef
:create, :create_if_missing, :delete, :enable, :disable
) do |a|
type = new_resource.type
- a.assertion { ['daemon', 'agent'].include?(type.to_s) }
- error_msg = 'type must be daemon or agent.'
+ a.assertion { %w{daemon agent}.include?(type.to_s) }
+ error_msg = "type must be daemon or agent."
a.failure_message Chef::Exceptions::ValidationFailed, error_msg
end
end
@@ -157,48 +157,48 @@ class Chef
def gen_hash
return nil unless new_resource.program || new_resource.program_arguments
{
- 'label' => 'Label',
- 'program' => 'Program',
- 'program_arguments' => 'ProgramArguments',
- 'abandon_process_group' => 'AbandonProcessGroup',
- 'debug' => 'Debug',
- 'disabled' => 'Disabled',
- 'enable_globbing' => 'EnableGlobbing',
- 'enable_transactions' => 'EnableTransactions',
- 'environment_variables' => 'EnvironmentVariables',
- 'exit_timeout' => 'ExitTimeout',
- 'ld_group' => 'GroupName',
- 'hard_resource_limits' => 'HardreSourceLimits',
- 'inetd_compatibility' => 'inetdCompatibility',
- 'init_groups' => 'InitGroups',
- 'keep_alive' => 'KeepAlive',
- 'launch_only_once' => 'LaunchOnlyOnce',
- 'limit_load_from_hosts' => 'LimitLoadFromHosts',
- 'limit_load_to_hosts' => 'LimitLoadToHosts',
- 'limit_load_to_session_type' => 'LimitLoadToSessionType',
- 'low_priority_io' => 'LowPriorityIO',
- 'mach_services' => 'MachServices',
- 'nice' => 'Nice',
- 'on_demand' => 'OnDemand',
- 'process_type' => 'ProcessType',
- 'queue_directories' => 'QueueDirectories',
- 'root_directory' => 'RootDirectory',
- 'run_at_load' => 'RunAtLoad',
- 'sockets' => 'Sockets',
- 'soft_resource_limits' => 'SoftResourceLimits',
- 'standard_error_path' => 'StandardErrorPath',
- 'standard_in_path' => 'StandardInPath',
- 'standard_out_path' => 'StandardOutPath',
- 'start_calendar_interval' => 'StartCalendarInterval',
- 'start_interval' => 'StartInterval',
- 'start_on_mount' => 'StartOnMount',
- 'throttle_interval' => 'ThrottleInterval',
- 'time_out' => 'TimeOut',
- 'umask' => 'Umask',
- 'username' => 'UserName',
- 'wait_for_debugger' => 'WaitForDebugger',
- 'watch_paths' => 'WatchPaths',
- 'working_directory' => 'WorkingDirectory',
+ "label" => "Label",
+ "program" => "Program",
+ "program_arguments" => "ProgramArguments",
+ "abandon_process_group" => "AbandonProcessGroup",
+ "debug" => "Debug",
+ "disabled" => "Disabled",
+ "enable_globbing" => "EnableGlobbing",
+ "enable_transactions" => "EnableTransactions",
+ "environment_variables" => "EnvironmentVariables",
+ "exit_timeout" => "ExitTimeout",
+ "ld_group" => "GroupName",
+ "hard_resource_limits" => "HardreSourceLimits",
+ "inetd_compatibility" => "inetdCompatibility",
+ "init_groups" => "InitGroups",
+ "keep_alive" => "KeepAlive",
+ "launch_only_once" => "LaunchOnlyOnce",
+ "limit_load_from_hosts" => "LimitLoadFromHosts",
+ "limit_load_to_hosts" => "LimitLoadToHosts",
+ "limit_load_to_session_type" => "LimitLoadToSessionType",
+ "low_priority_io" => "LowPriorityIO",
+ "mach_services" => "MachServices",
+ "nice" => "Nice",
+ "on_demand" => "OnDemand",
+ "process_type" => "ProcessType",
+ "queue_directories" => "QueueDirectories",
+ "root_directory" => "RootDirectory",
+ "run_at_load" => "RunAtLoad",
+ "sockets" => "Sockets",
+ "soft_resource_limits" => "SoftResourceLimits",
+ "standard_error_path" => "StandardErrorPath",
+ "standard_in_path" => "StandardInPath",
+ "standard_out_path" => "StandardOutPath",
+ "start_calendar_interval" => "StartCalendarInterval",
+ "start_interval" => "StartInterval",
+ "start_on_mount" => "StartOnMount",
+ "throttle_interval" => "ThrottleInterval",
+ "time_out" => "TimeOut",
+ "umask" => "Umask",
+ "username" => "UserName",
+ "wait_for_debugger" => "WaitForDebugger",
+ "watch_paths" => "WatchPaths",
+ "working_directory" => "WorkingDirectory",
}.each_with_object({}) do |(key, val), memo|
memo[val] = new_resource.send(key) if new_resource.send(key)
end
diff --git a/lib/chef/providers.rb b/lib/chef/providers.rb
index ceb4494b1a..6fd67e0068 100644
--- a/lib/chef/providers.rb
+++ b/lib/chef/providers.rb
@@ -35,7 +35,7 @@ require "chef/provider/git"
require "chef/provider/group"
require "chef/provider/http_request"
require "chef/provider/ifconfig"
-require 'chef/provider/launchd'
+require "chef/provider/launchd"
require "chef/provider/link"
require "chef/provider/log"
require "chef/provider/ohai"
diff --git a/lib/chef/resource/launchd.rb b/lib/chef/resource/launchd.rb
index 7abd9b93d8..f3c378a6a8 100644
--- a/lib/chef/resource/launchd.rb
+++ b/lib/chef/resource/launchd.rb
@@ -16,8 +16,8 @@
# limitations under the License.
#
-require 'chef/resource'
-require 'chef/provider/launchd'
+require "chef/resource"
+require "chef/provider/launchd"
class Chef
class Resource
@@ -46,12 +46,12 @@ class Chef
property :source, String
property :session_type, String
- property :type, String, default: 'daemon', coerce: proc { |type|
- type = type ? type.downcase : 'daemon'
- types = [ 'daemon', 'agent' ]
+ property :type, String, default: "daemon", coerce: proc { |type|
+ type = type ? type.downcase : "daemon"
+ types = %w{daemon agent}
unless types.include?(type)
- error_msg = 'type must be daemon or agent'
+ error_msg = "type must be daemon or agent"
raise Chef::Exceptions::ValidationFailed, error_msg
end
type
diff --git a/lib/chef/resources.rb b/lib/chef/resources.rb
index 3afa517d15..797f7b8b7e 100644
--- a/lib/chef/resources.rb
+++ b/lib/chef/resources.rb
@@ -46,7 +46,7 @@ require "chef/resource/http_request"
require "chef/resource/homebrew_package"
require "chef/resource/ifconfig"
require "chef/resource/ksh"
-require 'chef/resource/launchd'
+require "chef/resource/launchd"
require "chef/resource/link"
require "chef/resource/log"
require "chef/resource/macports_package"
diff --git a/spec/unit/provider/launchd_spec.rb b/spec/unit/provider/launchd_spec.rb
index 72a484233a..d88783b1f6 100644
--- a/spec/unit/provider/launchd_spec.rb
+++ b/spec/unit/provider/launchd_spec.rb
@@ -16,7 +16,7 @@
# limitations under the License.
#
-require 'spec_helper'
+require "spec_helper"
describe Chef::Provider::Launchd do
@@ -26,9 +26,9 @@ describe Chef::Provider::Launchd do
let(:run_context) { Chef::RunContext.new(node, {}, events) }
let(:provider) { Chef::Provider::Launchd.new(new_resource, run_context) }
- let(:label) {'call.mom.weekly'}
- let(:new_resource) { Chef::Resource::Launchd.new(label)}
- let!(:current_resource) { Chef::Resource::Launchd.new(label)}
+ let(:label) { "call.mom.weekly" }
+ let(:new_resource) { Chef::Resource::Launchd.new(label) }
+ let!(:current_resource) { Chef::Resource::Launchd.new(label) }
let(:test_plist) { String.new <<-XML }
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
@@ -52,20 +52,20 @@ describe Chef::Provider::Launchd do
XML
let(:test_hash) do {
- 'Label' => 'call.mom.weekly',
- 'Program' => '/Library/scripts/call_mom.sh',
- 'StartCalendarInterval' => {
- 'Hourly' => 10,
- 'Weekday' => 7,
+ "Label" => "call.mom.weekly",
+ "Program" => "/Library/scripts/call_mom.sh",
+ "StartCalendarInterval" => {
+ "Hourly" => 10,
+ "Weekday" => 7,
},
- 'TimeOut' => 300
+ "TimeOut" => 300
} end
before(:each) do
provider.load_current_resource
end
- it 'resource name and label should be call.mom.weekly' do
+ it "resource name and label should be call.mom.weekly" do
expect(new_resource.name).to eql(label)
expect(new_resource.label).to eql(label)
end
@@ -78,35 +78,35 @@ XML
provider.process_resource_requirements
end
- describe 'with type is set to' do
- describe 'agent' do
- it 'path should be /Library/LaunchAgents/call.mom.weekly.plist' do
- new_resource.type 'agent'
+ describe "with type is set to" do
+ describe "agent" do
+ it "path should be /Library/LaunchAgents/call.mom.weekly.plist" do
+ new_resource.type "agent"
expect(provider.gen_path_from_type).
- to eq('/Library/LaunchAgents/call.mom.weekly.plist')
+ to eq("/Library/LaunchAgents/call.mom.weekly.plist")
end
end
- describe 'daemon' do
- it 'path should be /Library/LaunchDaemons/call.mom.weekly.plist' do
+ describe "daemon" do
+ it "path should be /Library/LaunchDaemons/call.mom.weekly.plist" do
expect(provider.gen_path_from_type).
- to eq('/Library/LaunchDaemons/call.mom.weekly.plist')
+ to eq("/Library/LaunchDaemons/call.mom.weekly.plist")
end
end
end
- describe 'with a :create action and' do
- describe 'program is passed' do
- it 'should produce the test_plist from properties' do
- new_resource.program '/Library/scripts/call_mom.sh'
+ describe "with a :create action and" do
+ describe "program is passed" do
+ it "should produce the test_plist from properties" do
+ new_resource.program "/Library/scripts/call_mom.sh"
new_resource.time_out 300
- new_resource.start_calendar_interval 'Hourly' => 10, 'Weekday' => 7
+ new_resource.start_calendar_interval "Hourly" => 10, "Weekday" => 7
expect(provider.content?).to be_truthy
expect(provider.content).to eql(test_plist)
end
end
- describe 'hash is passed' do
- it 'should produce the test_plist from the hash' do
+ describe "hash is passed" do
+ it "should produce the test_plist from the hash" do
new_resource.hash test_hash
expect(provider.content?).to be_truthy
expect(provider.content).to eql(test_plist)
@@ -114,8 +114,8 @@ XML
end
end
- describe 'with an :enable action' do
- describe 'and the file has been updated' do
+ describe "with an :enable action" do
+ describe "and the file has been updated" do
before(:each) do
allow(provider).to receive(
:manage_plist).with(:create).and_return(true)
@@ -123,17 +123,17 @@ XML
:manage_service).with(:restart).and_return(true)
end
- it 'should call manage_service with a :restart action' do
+ it "should call manage_service with a :restart action" do
expect(provider.manage_service(:restart)).to be_truthy
end
- it 'works with action enable' do
+ it "works with action enable" do
expect(run_resource_setup_for_action(:enable)).to be_truthy
provider.action_enable
end
end
- describe 'and the file has not been updated' do
+ describe "and the file has not been updated" do
before(:each) do
allow(provider).to receive(
:manage_plist).with(:create).and_return(nil)
@@ -141,45 +141,45 @@ XML
:manage_service).with(:enable).and_return(true)
end
- it 'should call manage_service with a :enable action' do
- expect(provider.manage_service(:enable)).to be_truthy
+ it "should call manage_service with a :enable action" do
+ expect(provider.manage_service(:enable)).to be_truthy
end
- it 'works with action enable' do
+ it "works with action enable" do
expect(run_resource_setup_for_action(:enable)).to be_truthy
provider.action_enable
end
end
end
- describe 'with an :delete action' do
- describe 'and the ld file is present' do
+ describe "with an :delete action" do
+ describe "and the ld file is present" do
before(:each) do
allow(File).to receive(:exists?).and_return(true)
allow(provider).to receive(
:manage_service).with(:disable).and_return(true)
allow(provider).to receive(
:manage_plist).with(:delete).and_return(true)
- end
+ end
- it 'should call manage_service with a :disable action' do
- expect(provider.manage_service(:disable)).to be_truthy
+ it "should call manage_service with a :disable action" do
+ expect(provider.manage_service(:disable)).to be_truthy
end
- it 'works with action :delete' do
+ it "works with action :delete" do
expect(run_resource_setup_for_action(:delete)).to be_truthy
provider.action_delete
end
end
- describe 'and the ld file is not present' do
+ describe "and the ld file is not present" do
before(:each) do
allow(File).to receive(:exists?).and_return(false)
allow(provider).to receive(
:manage_plist).with(:delete).and_return(true)
- end
+ end
- it 'works with action :delete' do
+ it "works with action :delete" do
expect(run_resource_setup_for_action(:delete)).to be_truthy
provider.action_delete
end
diff --git a/spec/unit/resource/launchd_spec.rb b/spec/unit/resource/launchd_spec.rb
index 9076dbd84d..95febc47cf 100644
--- a/spec/unit/resource/launchd_spec.rb
+++ b/spec/unit/resource/launchd_spec.rb
@@ -1,11 +1,11 @@
#
-require 'spec_helper'
+require "spec_helper"
describe Chef::Resource::Launchd do
- @launchd = Chef::Resource::Launchd.new('io.chef.chef-client')
+ @launchd = Chef::Resource::Launchd.new("io.chef.chef-client")
let(:resource) { Chef::Resource::Launchd.new(
- 'io.chef.chef-client',
+ "io.chef.chef-client",
run_context
)}
@@ -23,10 +23,9 @@ describe Chef::Resource::Launchd do
end
it "should accept enable, disable, create, and delete as actions" do
- expect { resource.action :enable}.not_to raise_error
- expect { resource.action :disable}.not_to raise_error
- expect { resource.action :create}.not_to raise_error
- expect { resource.action :delete}.not_to raise_error
+ expect { resource.action :enable }.not_to raise_error
+ expect { resource.action :disable }.not_to raise_error
+ expect { resource.action :create }.not_to raise_error
+ expect { resource.action :delete }.not_to raise_error
end
end
-