From d6f66e416b3950d945379dfd72b12a4556716704 Mon Sep 17 00:00:00 2001 From: Tim Smith Date: Sun, 17 Jul 2016 21:02:44 -0700 Subject: [PATCH] Update copyrights and resolve cookstyle warnings Signed-off-by: Tim Smith --- attributes/default.rb | 2 +- .../chef_provider_package_rbenvrubygems.rb | 2 +- libraries/chef_rbenv_mixin.rb | 2 +- libraries/chef_rbenv_recipe_helpers.rb | 22 +++++++++---------- libraries/chef_rbenv_script_helpers.rb | 8 +++---- providers/ruby.rb | 4 +++- providers/script.rb | 5 +++-- recipes/default.rb | 2 +- recipes/system_install.rb | 2 +- recipes/user_install.rb | 2 +- resources/gem.rb | 2 +- resources/global.rb | 2 +- resources/rehash.rb | 2 +- resources/ruby.rb | 2 +- resources/script.rb | 2 +- 15 files changed, 32 insertions(+), 29 deletions(-) diff --git a/attributes/default.rb b/attributes/default.rb index 1f1e6105..9cb97f17 100644 --- a/attributes/default.rb +++ b/attributes/default.rb @@ -4,7 +4,7 @@ # # Author:: Fletcher Nichol # -# Copyright 2011, Fletcher Nichol +# Copyright 2011-2016, Fletcher Nichol # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/libraries/chef_provider_package_rbenvrubygems.rb b/libraries/chef_provider_package_rbenvrubygems.rb index 5d940755..82202524 100644 --- a/libraries/chef_provider_package_rbenvrubygems.rb +++ b/libraries/chef_provider_package_rbenvrubygems.rb @@ -4,7 +4,7 @@ # # Author:: Fletcher Nichol # -# Copyright 2011, Fletcher Nichol +# Copyright 2011-2016, Fletcher Nichol # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/libraries/chef_rbenv_mixin.rb b/libraries/chef_rbenv_mixin.rb index 808511d9..faf39019 100644 --- a/libraries/chef_rbenv_mixin.rb +++ b/libraries/chef_rbenv_mixin.rb @@ -4,7 +4,7 @@ # # Author:: Fletcher Nichol # -# Copyright 2011, Fletcher Nichol +# Copyright 2011-2016, Fletcher Nichol # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/libraries/chef_rbenv_recipe_helpers.rb b/libraries/chef_rbenv_recipe_helpers.rb index 206127a2..31e04edb 100644 --- a/libraries/chef_rbenv_recipe_helpers.rb +++ b/libraries/chef_rbenv_recipe_helpers.rb @@ -4,7 +4,7 @@ # # Author:: Fletcher Nichol # -# Copyright 2011, Fletcher Nichol +# Copyright 2011-2016, Fletcher Nichol # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -51,11 +51,11 @@ def install_or_upgrade_rbenv(opts = {}) private def git_deploy_rbenv(opts) - if opts[:upgrade_strategy] == 'none' - git_exec_action = :checkout - else - git_exec_action = :sync - end + git_exec_action = if opts[:upgrade_strategy] == 'none' + :checkout + else + :sync + end git opts[:rbenv_prefix] do repository opts[:git_url] @@ -89,11 +89,11 @@ def git_deploy_rbenv(opts) def initialize_rbenv(opts) prefix = opts[:rbenv_prefix] - if opts[:user] - init_env = { 'USER' => opts[:user], 'HOME' => opts[:home_dir] } - else - init_env = {} - end + init_env = if opts[:user] + { 'USER' => opts[:user], 'HOME' => opts[:home_dir] } + else + {} + end bash "Initialize rbenv (#{opts[:user] || 'system'})" do code %(PATH="#{prefix}/bin:$PATH" rbenv init -) diff --git a/libraries/chef_rbenv_script_helpers.rb b/libraries/chef_rbenv_script_helpers.rb index 25d51e95..31d8e209 100644 --- a/libraries/chef_rbenv_script_helpers.rb +++ b/libraries/chef_rbenv_script_helpers.rb @@ -4,7 +4,7 @@ # # Author:: Fletcher Nichol # -# Copyright 2011, Fletcher Nichol +# Copyright 2011-2016, Fletcher Nichol # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -62,16 +62,16 @@ def set_updated end # Execute the supplied block of code as the given user. - def run_as_user(username, &block) + def run_as_user(username) if username user = Etc.getpwnam(username) Process.fork do Process.uid = user.uid - block.call + yield end Process.wait else - block.call + yield end end end diff --git a/providers/ruby.rb b/providers/ruby.rb index 80ee64d1..4f85e908 100644 --- a/providers/ruby.rb +++ b/providers/ruby.rb @@ -4,7 +4,7 @@ # # Author:: Fletcher Nichol # -# Copyright 2011, Fletcher Nichol +# Copyright 2011-2016, Fletcher Nichol # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -19,6 +19,8 @@ # limitations under the License. # +use_inline_resources + provides :rbenv_ruby include Chef::Rbenv::ScriptHelpers diff --git a/providers/script.rb b/providers/script.rb index f6e05c9c..8960e878 100644 --- a/providers/script.rb +++ b/providers/script.rb @@ -70,11 +70,12 @@ def build_script_environment script_env.merge!(new_resource.environment) if new_resource.environment if new_resource.path - script_env.merge!('PATH' => "#{new_resource.path.join(':')}:#{ENV['PATH']}") + script_env['PATH'] = "#{new_resource.path.join(':')}:#{ENV['PATH']}" end if new_resource.user - script_env.merge!('USER' => new_resource.user, 'HOME' => user_home) + script_env['USER'] = new_resource.user + script_env['HOME'] = user_home end script_env diff --git a/recipes/default.rb b/recipes/default.rb index 466ed58d..7daf164b 100644 --- a/recipes/default.rb +++ b/recipes/default.rb @@ -2,7 +2,7 @@ # Cookbook Name:: ruby_rbenv # Recipe:: default # -# Copyright 2011, Fletcher Nichol +# Copyright 2011-2016, Fletcher Nichol # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/recipes/system_install.rb b/recipes/system_install.rb index 046442f4..057f8594 100644 --- a/recipes/system_install.rb +++ b/recipes/system_install.rb @@ -2,7 +2,7 @@ # Cookbook Name:: ruby_rbenv # Recipe:: system_install # -# Copyright 2011, Fletcher Nichol +# Copyright 2011-2016, Fletcher Nichol # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/recipes/user_install.rb b/recipes/user_install.rb index b162eab8..30451af1 100644 --- a/recipes/user_install.rb +++ b/recipes/user_install.rb @@ -2,7 +2,7 @@ # Cookbook Name:: ruby_rbenv # Recipe:: user_install # -# Copyright 2011, Fletcher Nichol +# Copyright 2011-2016, Fletcher Nichol # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/resources/gem.rb b/resources/gem.rb index d8717ca6..d40eeaea 100644 --- a/resources/gem.rb +++ b/resources/gem.rb @@ -4,7 +4,7 @@ # # Author:: Fletcher Nichol # -# Copyright 2011, Fletcher Nichol +# Copyright 2011-2016, Fletcher Nichol # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/resources/global.rb b/resources/global.rb index 2c077407..1e298e62 100644 --- a/resources/global.rb +++ b/resources/global.rb @@ -4,7 +4,7 @@ # # Author:: Fletcher Nichol # -# Copyright 2011, Fletcher Nichol +# Copyright 2011-2016, Fletcher Nichol # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/resources/rehash.rb b/resources/rehash.rb index b67895e7..110b3ff9 100644 --- a/resources/rehash.rb +++ b/resources/rehash.rb @@ -4,7 +4,7 @@ # # Author:: Fletcher Nichol # -# Copyright 2011, Fletcher Nichol +# Copyright 2011-2016, Fletcher Nichol # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/resources/ruby.rb b/resources/ruby.rb index 61dd13d3..f775caf7 100644 --- a/resources/ruby.rb +++ b/resources/ruby.rb @@ -4,7 +4,7 @@ # # Author:: Fletcher Nichol # -# Copyright 2011, Fletcher Nichol +# Copyright 2011-2016, Fletcher Nichol # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/resources/script.rb b/resources/script.rb index 774c2781..b1333d98 100644 --- a/resources/script.rb +++ b/resources/script.rb @@ -4,7 +4,7 @@ # # Author:: Fletcher Nichol # -# Copyright 2011, Fletcher Nichol +# Copyright 2011-2016, Fletcher Nichol # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License.