From bb2b5f3232c47e25c4f51c68a1c415ed83643427 Mon Sep 17 00:00:00 2001 From: Lee Hambley Date: Mon, 30 Mar 2015 10:23:29 +0200 Subject: [PATCH] Revert "Issue/1404" --- features/step_definitions/assertions.rb | 12 ++++++------ features/support/remote_command_helpers.rb | 2 +- lib/capistrano/application.rb | 7 +++---- lib/capistrano/configuration/server.rb | 2 +- lib/capistrano/configuration/servers.rb | 3 +-- lib/capistrano/git.rb | 5 ++--- lib/capistrano/hg.rb | 5 ++--- lib/capistrano/scm.rb | 2 +- lib/capistrano/svn.rb | 4 ++-- lib/capistrano/tasks/console.rake | 3 +-- lib/capistrano/tasks/deploy.rake | 2 +- lib/capistrano/tasks/install.rake | 4 ++-- spec/lib/capistrano/application_spec.rb | 4 ++-- spec/lib/capistrano/configuration/filter_spec.rb | 2 +- spec/lib/capistrano/dsl/task_enhancements_spec.rb | 6 +++--- spec/support/tasks/root.rake | 2 +- 16 files changed, 30 insertions(+), 35 deletions(-) diff --git a/features/step_definitions/assertions.rb b/features/step_definitions/assertions.rb index 6f556ff1..3e54ddd3 100644 --- a/features/step_definitions/assertions.rb +++ b/features/step_definitions/assertions.rb @@ -50,26 +50,26 @@ end Then(/^the deploy\.rb file is created$/) do file = TestApp.test_app_path.join('config/deploy.rb') - expect(File.exist?(file)).to be true + expect(File.exists?(file)).to be true end Then(/^the default stage files are created$/) do staging = TestApp.test_app_path.join('config/deploy/staging.rb') production = TestApp.test_app_path.join('config/deploy/production.rb') - expect(File.exist?(staging)).to be true - expect(File.exist?(production)).to be true + expect(File.exists?(staging)).to be true + expect(File.exists?(production)).to be true end Then(/^the tasks folder is created$/) do path = TestApp.test_app_path.join('lib/capistrano/tasks') - expect(Dir.exist?(path)).to be true + expect(Dir.exists?(path)).to be true end Then(/^the specified stage files are created$/) do qa = TestApp.test_app_path.join('config/deploy/qa.rb') production = TestApp.test_app_path.join('config/deploy/production.rb') - expect(File.exist?(qa)).to be true - expect(File.exist?(production)).to be true + expect(File.exists?(qa)).to be true + expect(File.exists?(production)).to be true end Then(/^it creates the file with the remote_task prerequisite$/) do diff --git a/features/support/remote_command_helpers.rb b/features/support/remote_command_helpers.rb index 9b0c32b0..9b5232bb 100644 --- a/features/support/remote_command_helpers.rb +++ b/features/support/remote_command_helpers.rb @@ -15,7 +15,7 @@ module RemoteCommandHelpers %{[ -#{type} "#{path}" ]} end - def safely_remove_file(_path) + def safely_remove_file(path) run_vagrant_command("rm #{test_file}") rescue VagrantHelpers::VagrantSSHCommandError end end diff --git a/lib/capistrano/application.rb b/lib/capistrano/application.rb index 2792f272..caefa57a 100644 --- a/lib/capistrano/application.rb +++ b/lib/capistrano/application.rb @@ -63,8 +63,7 @@ module Capistrano def display_error_message(ex) unless options.backtrace - loc = Rake.application.find_rakefile_location - if loc + if loc = Rake.application.find_rakefile_location whitelist = (@imported.dup << loc[0]).map{|f| File.absolute_path(f, loc[1])} pattern = %r@^(?!#{whitelist.map{|p| Regexp.quote(p)}.join('|')})@ Rake.application.options.suppress_backtrace_pattern = pattern @@ -102,7 +101,7 @@ module Capistrano def version ['--version', '-V', "Display the program version.", - lambda { |_value| + lambda { |value| puts "Capistrano Version: #{Capistrano::VERSION} (Rake Version: #{RAKEVERSION})" exit } @@ -112,7 +111,7 @@ module Capistrano def dry_run ['--dry-run', '-n', "Do a dry run without executing actions", - lambda { |_value| + lambda { |value| Configuration.env.set(:sshkit_backend, SSHKit::Backend::Printer) } ] diff --git a/lib/capistrano/configuration/server.rb b/lib/capistrano/configuration/server.rb index 74c6a586..35c55d34 100644 --- a/lib/capistrano/configuration/server.rb +++ b/lib/capistrano/configuration/server.rb @@ -98,7 +98,7 @@ module Capistrano @properties[key] end - def respond_to?(method, _include_all=false) + def respond_to?(method, include_all=false) @properties.has_key?(method) end diff --git a/lib/capistrano/configuration/servers.rb b/lib/capistrano/configuration/servers.rb index 06bb84b4..7bc2fddc 100644 --- a/lib/capistrano/configuration/servers.rb +++ b/lib/capistrano/configuration/servers.rb @@ -9,8 +9,7 @@ module Capistrano def add_host(host, properties={}) new_host = Server[host] - server = servers.find { |s| s.matches? new_host } - if server + if server = servers.find { |s| s.matches? new_host } server.user = new_host.user if new_host.user server.port = new_host.port if new_host.port server.with(properties) diff --git a/lib/capistrano/git.rb b/lib/capistrano/git.rb index d01c7583..3a6727a9 100644 --- a/lib/capistrano/git.rb +++ b/lib/capistrano/git.rb @@ -8,7 +8,7 @@ class Capistrano::Git < Capistrano::SCM # def git(*args) args.unshift :git - context.execute(*args) + context.execute *args end # The Capistrano default strategy for git. You should want to use this. @@ -30,8 +30,7 @@ class Capistrano::Git < Capistrano::SCM end def release - tree = fetch(:repo_tree) - if tree + if tree = fetch(:repo_tree) tree = tree.slice %r#^/?(.*?)/?$#, 1 components = tree.split('/').size git :archive, fetch(:branch), tree, "| tar -x --strip-components #{components} -f - -C", release_path diff --git a/lib/capistrano/hg.rb b/lib/capistrano/hg.rb index d2cfed28..e7f02909 100644 --- a/lib/capistrano/hg.rb +++ b/lib/capistrano/hg.rb @@ -6,7 +6,7 @@ class Capistrano::Hg < Capistrano::SCM # execute hg in context with arguments def hg(*args) args.unshift(:hg) - context.execute(*args) + context.execute *args end module DefaultStrategy @@ -27,8 +27,7 @@ class Capistrano::Hg < Capistrano::SCM end def release - tree = fetch(:repo_tree) - if tree + if tree = fetch(:repo_tree) tree = tree.slice %r#^/?(.*?)/?$#, 1 components = tree.split('/').size hg "archive --type tgz -p . -I", tree, "--rev", fetch(:branch), "| tar -x --strip-components #{components} -f - -C", release_path diff --git a/lib/capistrano/scm.rb b/lib/capistrano/scm.rb index ccccebaa..0e755716 100644 --- a/lib/capistrano/scm.rb +++ b/lib/capistrano/scm.rb @@ -25,7 +25,7 @@ module Capistrano # Call test in context def test!(*args) - context.test(*args) + context.test *args end # The repository URL according to the context diff --git a/lib/capistrano/svn.rb b/lib/capistrano/svn.rb index 4844b31c..2d6bdc3b 100644 --- a/lib/capistrano/svn.rb +++ b/lib/capistrano/svn.rb @@ -3,13 +3,13 @@ load File.expand_path("../tasks/svn.rake", __FILE__) require 'capistrano/scm' class Capistrano::Svn < Capistrano::SCM - + # execute svn in context with arguments def svn(*args) args.unshift(:svn) args.push "--username #{fetch(:svn_username)}" if fetch(:svn_username) args.push "--password #{fetch(:svn_password)}" if fetch(:svn_password) - context.execute(*args) + context.execute *args end module DefaultStrategy diff --git a/lib/capistrano/tasks/console.rake b/lib/capistrano/tasks/console.rake index 6d7b4299..2f279224 100644 --- a/lib/capistrano/tasks/console.rake +++ b/lib/capistrano/tasks/console.rake @@ -5,8 +5,7 @@ task :console do loop do print "#{stage}> " - input = $stdin.gets - if input + if input = $stdin.gets command = input.chomp else command = 'exit' diff --git a/lib/capistrano/tasks/deploy.rake b/lib/capistrano/tasks/deploy.rake index 35188f1b..ef1af89f 100644 --- a/lib/capistrano/tasks/deploy.rake +++ b/lib/capistrano/tasks/deploy.rake @@ -59,7 +59,7 @@ namespace :deploy do desc 'Check directories of files to be linked exist in shared' task :make_linked_dirs do next unless any? :linked_files - on release_roles :all do + on release_roles :all do |host| execute :mkdir, '-p', linked_file_dirs(shared_path) end end diff --git a/lib/capistrano/tasks/install.rake b/lib/capistrano/tasks/install.rake index b351c73b..6e3818e7 100644 --- a/lib/capistrano/tasks/install.rake +++ b/lib/capistrano/tasks/install.rake @@ -18,7 +18,7 @@ task :install do entries += envs.split(',').map { |stage| {template: stage_rb, file: deploy_dir.join("#{stage}.rb")} } entries.each do |entry| - if File.exist?(entry[:file]) + if File.exists?(entry[:file]) warn "[skip] #{entry[:file]} already exists" else File.open(entry[:file], 'w+') do |f| @@ -30,7 +30,7 @@ task :install do mkdir_p tasks_dir - if File.exist?('Capfile') + if File.exists?('Capfile') warn "[skip] Capfile already exists" else FileUtils.cp(capfile, 'Capfile') diff --git a/spec/lib/capistrano/application_spec.rb b/spec/lib/capistrano/application_spec.rb index 7362e795..bb52765b 100644 --- a/spec/lib/capistrano/application_spec.rb +++ b/spec/lib/capistrano/application_spec.rb @@ -34,7 +34,7 @@ describe Capistrano::Application do end it "overrides the rake method, and sets the sshkit_backend to SSHKit::Backend::Printer" do - _out, _ = capture_io do + out, _ = capture_io do flags '--dry-run', '-n' end sshkit_backend = Capistrano::Configuration.fetch(:sshkit_backend) @@ -51,7 +51,7 @@ describe Capistrano::Application do def command_line(*options) options.each { |opt| ARGV << opt } - def subject.exit(*_args) + def subject.exit(*args) throw(:system_exit, :exit) end subject.run diff --git a/spec/lib/capistrano/configuration/filter_spec.rb b/spec/lib/capistrano/configuration/filter_spec.rb index df6060e2..65ad3f76 100644 --- a/spec/lib/capistrano/configuration/filter_spec.rb +++ b/spec/lib/capistrano/configuration/filter_spec.rb @@ -13,7 +13,7 @@ module Capistrano describe '#new' do it "won't create an invalid type of filter" do expect { - Filter.new(:zarg) + f = Filter.new(:zarg) }.to raise_error RuntimeError end diff --git a/spec/lib/capistrano/dsl/task_enhancements_spec.rb b/spec/lib/capistrano/dsl/task_enhancements_spec.rb index a14d3bf3..b2a1c69a 100644 --- a/spec/lib/capistrano/dsl/task_enhancements_spec.rb +++ b/spec/lib/capistrano/dsl/task_enhancements_spec.rb @@ -19,7 +19,7 @@ module Capistrano let(:order) { [] } let!(:task) do - Rake::Task.define_task('task', [:order]) do |_, args| + Rake::Task.define_task('task', [:order]) do |t, args| args['order'].push 'task' end end @@ -67,11 +67,11 @@ module Capistrano end it 'invokes in proper order and with arguments and block' do - task_enhancements.after('task', 'after_task_custom', :order) do + task_enhancements.after('task', 'after_task_custom', :order) do |t, args| order.push 'after_task' end - task_enhancements.before('task', 'before_task_custom', :order) do + task_enhancements.before('task', 'before_task_custom', :order) do |t, args| order.push 'before_task' end diff --git a/spec/support/tasks/root.rake b/spec/support/tasks/root.rake index bbe7c54a..c82a0f82 100644 --- a/spec/support/tasks/root.rake +++ b/spec/support/tasks/root.rake @@ -4,7 +4,7 @@ task :am_i_root do ident = capture :id, '-a' info "I am #{ident}" end - on roles(:all) do + on roles(:all) do |host| ident = capture :id, '-a' info "I am #{ident}" end