Skip to content

Commit

Permalink
FC005: Avoid repetition of resource declarations.
Browse files Browse the repository at this point in the history
  • Loading branch information
fnichol committed May 15, 2012
1 parent 1ec5629 commit 4885040
Showing 1 changed file with 10 additions and 38 deletions.
48 changes: 10 additions & 38 deletions providers/global_gem.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,43 +25,15 @@ def load_current_resource
@rvm_env = ::RVM::ChefUserEnvironment.new(new_resource.user)
end

action :install do
# add gem entry into global.gems
update_global_gems_file :create

# install gem in all rubies in global gemsets
installed_rubies.each do |rubie|
gem_package_wrapper :install, "#{rubie}@global"
end
end

action :upgrade do
# add gem entry into global.gems
update_global_gems_file :create

# upgrade gem in all rubies in global gemsets
installed_rubies.each do |rubie|
gem_package_wrapper :upgrade, "#{rubie}@global"
end
end

action :remove do
# remove gem entry from global.gems
update_global_gems_file :remove

# remove gem in all rubies in global gemsets
installed_rubies.each do |rubie|
gem_package_wrapper :remove, "#{rubie}@global"
end
end

action :purge do
# remove gem entry from global.gems
update_global_gems_file :remove

# remove gem in all rubies in global gemsets
installed_rubies.each do |rubie|
gem_package_wrapper :purge, "#{rubie}@global"
[:install, :upgrade, :remove, :purge].each do |exec_action|
action exec_action do
# add gem entry into global.gems
update_global_gems_file exec_action

# install gem in all rubies in global gemsets
installed_rubies.each do |rubie|
gem_package_wrapper exec_action, "#{rubie}@global"
end
end
end

Expand Down Expand Up @@ -103,7 +75,7 @@ def update_global_gems_file(exec_action)
"#{node['rvm']['root_path']}/gemsets/global.gems"
end

if exec_action == :create
if [:install, :upgrade].include?(exec_action)
e = execute "Add #{gem} to #{global_gems_file}" do
if new_resource.user
user new_resource.user
Expand Down

0 comments on commit 4885040

Please sign in to comment.