Skip to content

Commit

Permalink
Fix Rubocop warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
sethvargo committed Sep 25, 2013
1 parent 6aa207c commit 74b497a
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 61 deletions.
116 changes: 56 additions & 60 deletions providers/plugin.rb
Original file line number Diff line number Diff line change
Expand Up @@ -58,77 +58,73 @@ def load_current_resource
end
end


private

def current_version
current_version = nil
manifest_file = ::File.join(plugins_dir, @current_resource.name, 'META-INF', 'MANIFEST.MF')
if ::File.exist?(manifest_file)
manifest = IO.read(manifest_file)
if manifest =~ /^Plugin-Version:\s*(.+)$/
current_version = $1.strip
def current_version
current_version = nil
manifest_file = ::File.join(plugins_dir, @current_resource.name, 'META-INF', 'MANIFEST.MF')
if ::File.exist?(manifest_file)
manifest = IO.read(manifest_file)
current_version = manifest.match(/^Plugin-Version:\s*(.+)$/).strip
end
current_version
end
current_version
end

def plugin_exists?
::File.exists?(plugin_file_path)
end
def plugin_exists?
::File.exists?(plugin_file_path)
end

def plugin_dir_path
::File.join(plugins_dir, @new_resource.name)
end
def plugin_dir_path
::File.join(plugins_dir, @new_resource.name)
end

def plugin_file_path
::File.join(plugins_dir, "#{@new_resource.name}.jpi")
end
def plugin_file_path
::File.join(plugins_dir, "#{@new_resource.name}.jpi")
end

def plugins_dir
::File.join(node['jenkins']['server']['home'], 'plugins')
end
def plugins_dir
::File.join(node['jenkins']['server']['home'], 'plugins')
end

def do_install_plugin
plugin_url = @new_resource.url

# Plugins installed from the Jenkins Update Center are written to disk with
# the `*.jpi` extension. Although plugins downloaded from the Jenkins Mirror
# have an `*.hpi` extension we will save the plugins with a `*.jpi` extension
# to match Update Center's behavior.
remote_file plugin_file_path do
source plugin_url
owner node['jenkins']['server']['user']
group node['jenkins']['server']['group']
backup false
action :create
notifies :restart, 'service[jenkins'
notifies :create, 'ruby_block[block_until_operational'
end

def do_install_plugin
plugin_url = @new_resource.url

# Plugins installed from the Jenkins Update Center are written to disk with
# the `*.jpi` extension. Although plugins downloaded from the Jenkins Mirror
# have an `*.hpi` extension we will save the plugins with a `*.jpi` extension
# to match Update Center's behavior.
remote_file plugin_file_path do
source plugin_url
owner node['jenkins']['server']['user']
group node['jenkins']['server']['group']
backup false
action :create
notifies :restart, "service[jenkins]"
notifies :create, "ruby_block[block_until_operational]"
end
file "#{plugin_file_path}.pinned" do
action :create_if_missing
owner node['jenkins']['server']['user']
group node['jenkins']['server']['group']
file "#{plugin_file_path}.pinned" do
action :create_if_missing
owner node['jenkins']['server']['user']
group node['jenkins']['server']['group']
end
end
end

def do_upgrade_plugin
do_install_plugin
end

def do_remove_plugin
file plugin_file_path do
action :delete
backup false
notifies :restart, "service[jenkins]"
notifies :create, "ruby_block[block_until_operational]"
def do_upgrade_plugin
do_install_plugin
end

directory plugin_dir_path do
action :delete
recursive true
notifies :restart, "service[jenkins]"
notifies :create, "ruby_block[block_until_operational]"
def do_remove_plugin
file plugin_file_path do
action :delete
backup false
notifies :restart, 'service[jenkins]'
notifies :create, 'ruby_block[block_until_operational]'
end

directory plugin_dir_path do
action :delete
recursive true
notifies :restart, 'service[jenkins]'
notifies :create, 'ruby_block[block_until_operational]'
end
end
end
2 changes: 1 addition & 1 deletion resources/plugin.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@

# If url isn't specified, a default URL based on the plugin name and version is returned
def url(arg = nil)
if arg.nil? and @url.nil?
if arg.nil? && @url.nil?
"#{node['jenkins']['mirror']}/plugins/#{name}/#{version}/#{name}.hpi"
else
set_or_return(:url, arg, :kind_of => String)
Expand Down

0 comments on commit 74b497a

Please sign in to comment.