1
0
Fork 0
mirror of https://github.com/capistrano/capistrano synced 2023-03-27 23:21:18 -04:00

Fix to force hash-rockets

This commit is contained in:
William Johnston 2016-02-28 17:14:50 -06:00
parent f357fb4ea7
commit d9a7b23257
22 changed files with 213 additions and 213 deletions

View file

@ -44,7 +44,7 @@ module Capistrano
end
def question
I18n.t(:question, key: key, default_value: default, scope: :capistrano)
I18n.t(:question, :key => key, :default_value => default, :scope => :capistrano)
end
def echo?

View file

@ -18,7 +18,7 @@ module Capistrano
end
def add_role(role, hosts, options={})
options_deepcopy = Marshal.dump(options.merge(roles: role))
options_deepcopy = Marshal.dump(options.merge(:roles => role))
Array(hosts).each { |host| add_host(host, Marshal.load(options_deepcopy)) }
end
@ -37,7 +37,7 @@ module Capistrano
if block_given?
yield host, role, props
else
rps << (props || {}).merge( role: role, hostname: host.hostname )
rps << (props || {}).merge( :role => role, :hostname => host.hostname )
end
end
end

View file

@ -16,7 +16,7 @@ module Capistrano
end
def t(key, options={})
I18n.t(key, options.merge(scope: :capistrano))
I18n.t(key, options.merge(:scope => :capistrano))
end
def scm
@ -30,15 +30,15 @@ module Capistrano
def revision_log_message
fetch(:revision_log_message,
t(:revision_log_message,
branch: fetch(:branch),
user: local_user,
sha: fetch(:current_revision),
release: fetch(:release_timestamp))
:branch => fetch(:branch),
:user => local_user,
:sha => fetch(:current_revision),
:release => fetch(:release_timestamp))
)
end
def rollback_log_message
t(:rollback_log_message, user: local_user, release: fetch(:rollback_timestamp))
t(:rollback_log_message, :user => local_user, :release => fetch(:rollback_timestamp))
end
def local_user

View file

@ -28,7 +28,7 @@ module Capistrano
if names.last.is_a? Hash
names.last.merge!({ :exclude => :no_release })
else
names << { exclude: :no_release }
names << { :exclude => :no_release }
end
roles(*names)
end

View file

@ -53,7 +53,7 @@ module Capistrano
end
def exit_deploy_because_of_exception(ex)
warn t(:deploy_failed, ex: ex.message)
warn t(:deploy_failed, :ex => ex.message)
invoke 'deploy:failed'
exit(false)
end

View file

@ -1,37 +1,37 @@
require 'i18n'
en = {
starting: 'Starting',
capified: 'Capified',
start: 'Start',
update: 'Update',
finalize: 'Finalise',
finishing: 'Finishing',
finished: 'Finished',
stage_not_set: 'Stage not set, please call something such as `cap production deploy`, where production is a stage you have defined.',
written_file: 'create %{file}',
question: 'Please enter %{key} (%{default_value}): ',
keeping_releases: 'Keeping %{keep_releases} of %{releases} deployed releases on %{host}',
no_old_releases: 'No old releases (keeping newest %{keep_releases}) on %{host}',
linked_file_does_not_exist: 'linked file %{file} does not exist on %{host}',
cannot_rollback: 'There are no older releases to rollback to',
mirror_exists: 'The repository mirror is at %{at}',
revision_log_message: 'Branch %{branch} (at %{sha}) deployed as release %{release} by %{user}',
rollback_log_message: '%{user} rolled back to release %{release}',
deploy_failed: 'The deploy has failed with an error: %{ex}',
console: {
welcome: 'capistrano console - enter command to execute on %{stage}',
bye: 'bye'
:starting => 'Starting',
:capified => 'Capified',
:start => 'Start',
:update => 'Update',
:finalize => 'Finalise',
:finishing => 'Finishing',
:finished => 'Finished',
:stage_not_set => 'Stage not set, please call something such as `cap production deploy`, where production is a stage you have defined.',
:written_file => 'create %{file}',
:question => 'Please enter %{key} (%{default_value}): ',
:keeping_releases => 'Keeping %{keep_releases} of %{releases} deployed releases on %{host}',
:no_old_releases => 'No old releases (keeping newest %{keep_releases}) on %{host}',
:linked_file_does_not_exist => 'linked file %{file} does not exist on %{host}',
:cannot_rollback => 'There are no older releases to rollback to',
:mirror_exists => 'The repository mirror is at %{at}',
:revision_log_message => 'Branch %{branch} (at %{sha}) deployed as release %{release} by %{user}',
:rollback_log_message => '%{user} rolled back to release %{release}',
:deploy_failed => 'The deploy has failed with an error: %{ex}',
:console => {
:welcome => 'capistrano console - enter command to execute on %{stage}',
:bye => 'bye'
},
error: {
user: {
does_not_exist: 'User %{user} does not exists',
cannot_switch: 'Cannot switch to user %{user}'
:error => {
:user => {
:does_not_exist => 'User %{user} does not exists',
:cannot_switch => 'Cannot switch to user %{user}'
}
}
}
I18n.backend.store_translations(:en, { capistrano: en })
I18n.backend.store_translations(:en, { :capistrano => en })
if I18n.respond_to?(:enforce_available_locales=)
I18n.enforce_available_locales = true

View file

@ -37,7 +37,7 @@ class Capistrano::Plugin < Rake::TaskLib
# skipped, if you want full control over when and how the plugin's tasks are
# executed. Simply pass `hooks:false` to opt out.
#
def initialize(hooks:true)
def initialize(hooks: true)
define_tasks
register_hooks if hooks
task "load:defaults" do

View file

@ -1,7 +1,7 @@
desc 'Execute remote commands'
task :console do
stage = fetch(:stage)
puts I18n.t('console.welcome', scope: :capistrano, stage: stage)
puts I18n.t('console.welcome', :scope => :capistrano, :stage => stage)
loop do
print "#{stage}> "

View file

@ -92,7 +92,7 @@ namespace :deploy do
on release_roles :all do |host|
linked_files(shared_path).each do |file|
unless test "[ -f #{file} ]"
error t(:linked_file_does_not_exist, file: file, host: host)
error t(:linked_file_does_not_exist, :file => file, :host => host)
exit 1
end
end
@ -160,7 +160,7 @@ namespace :deploy do
on release_roles :all do |host|
releases = capture(:ls, '-xtr', releases_path).split
if releases.count >= fetch(:keep_releases)
info t(:keeping_releases, host: host.to_s, keep_releases: fetch(:keep_releases), releases: releases.count)
info t(:keeping_releases, :host => host.to_s, :keep_releases => fetch(:keep_releases), :releases => releases.count)
directories = (releases - releases.last(fetch(:keep_releases)))
if directories.any?
directories_str = directories.map do |release|
@ -168,7 +168,7 @@ namespace :deploy do
end.join(" ")
execute :rm, '-rf', directories_str
else
info t(:no_old_releases, host: host.to_s, keep_releases: fetch(:keep_releases))
info t(:no_old_releases, :host => host.to_s, :keep_releases => fetch(:keep_releases))
end
end
end

View file

@ -65,4 +65,4 @@ task :deploy do
invoke "deploy:#{task}"
end
end
task default: :deploy
task :default => :deploy

View file

@ -6,8 +6,8 @@ namespace :git do
set :git_environmental_variables, ->() {
{
git_askpass: "/bin/echo",
git_ssh: "#{fetch(:tmp_dir)}/#{fetch(:application)}/git-ssh.sh"
:git_askpass => "/bin/echo",
:git_ssh => "#{fetch(:tmp_dir)}/#{fetch(:application)}/git-ssh.sh"
}
}
@ -21,7 +21,7 @@ namespace :git do
end
desc 'Check that the repository is reachable'
task check: :'git:wrapper' do
task :check => :'git:wrapper' do
fetch(:branch)
on release_roles :all do
with fetch(:git_environmental_variables) do
@ -31,10 +31,10 @@ namespace :git do
end
desc 'Clone the repo to the cache'
task clone: :'git:wrapper' do
task :clone => :'git:wrapper' do
on release_roles :all do
if strategy.test
info t(:mirror_exists, at: repo_path)
info t(:mirror_exists, :at => repo_path)
else
within deploy_path do
with fetch(:git_environmental_variables) do
@ -46,7 +46,7 @@ namespace :git do
end
desc 'Update the repo mirror to reflect the origin state'
task update: :'git:clone' do
task :update => :'git:clone' do
on release_roles :all do
within repo_path do
with fetch(:git_environmental_variables) do
@ -57,7 +57,7 @@ namespace :git do
end
desc 'Copy repo to releases'
task create_release: :'git:update' do
task :create_release => :'git:update' do
on release_roles :all do
with fetch(:git_environmental_variables) do
within repo_path do

View file

@ -14,7 +14,7 @@ namespace :hg do
task :clone do
on release_roles :all do
if strategy.test
info t(:mirror_exists, at: repo_path)
info t(:mirror_exists, :at => repo_path)
else
within deploy_path do
strategy.clone

View file

@ -14,8 +14,8 @@ task :install do
mkdir_p deploy_dir
entries = [{template: deploy_rb, file: config_dir.join('deploy.rb')}]
entries += envs.split(',').map { |stage| {template: stage_rb, file: deploy_dir.join("#{stage}.rb")} }
entries = [{:template => deploy_rb, :file => config_dir.join('deploy.rb')}]
entries += envs.split(',').map { |stage| {:template => stage_rb, :file => deploy_dir.join("#{stage}.rb")} }
entries.each do |entry|
if File.exist?(entry[:file])
@ -23,7 +23,7 @@ task :install do
else
File.open(entry[:file], 'w+') do |f|
f.write(ERB.new(File.read(entry[:template])).result(binding))
puts I18n.t(:written_file, scope: :capistrano, file: entry[:file])
puts I18n.t(:written_file, :scope => :capistrano, :file => entry[:file])
end
end
end
@ -34,9 +34,9 @@ task :install do
warn "[skip] Capfile already exists"
else
FileUtils.cp(capfile, 'Capfile')
puts I18n.t(:written_file, scope: :capistrano, file: 'Capfile')
puts I18n.t(:written_file, :scope => :capistrano, :file => 'Capfile')
end
puts I18n.t :capified, scope: :capistrano
puts I18n.t :capified, :scope => :capistrano
end

View file

@ -14,7 +14,7 @@ namespace :svn do
task :clone do
on release_roles :all do
if strategy.test
info t(:mirror_exists, at: repo_path)
info t(:mirror_exists, :at => repo_path)
else
within deploy_path do
strategy.clone

View file

@ -11,11 +11,11 @@ describe Capistrano::DSL do
describe 'setting and fetching hosts' do
describe 'when defining a host using the `server` syntax' do
before do
dsl.server 'example1.com', roles: %w{web}, active: true
dsl.server 'example2.com', roles: %w{web}
dsl.server 'example3.com', roles: %w{app web}, active: true
dsl.server 'example4.com', roles: %w{app}, primary: true
dsl.server 'example5.com', roles: %w{db}, no_release: true, active:true
dsl.server 'example1.com', :roles => %w{web}, :active => true
dsl.server 'example2.com', :roles => %w{web}
dsl.server 'example3.com', :roles => %w{app web}, :active => true
dsl.server 'example4.com', :roles => %w{app}, :primary => true
dsl.server 'example5.com', :roles => %w{db}, :no_release => true, :active => true
end
describe 'fetching all servers' do
@ -37,7 +37,7 @@ describe Capistrano::DSL do
end
context 'with property filter options' do
subject { dsl.release_roles(:all, filter: :active) }
subject { dsl.release_roles(:all, :filter => :active) }
it 'returns all release servers that match the property filter' do
expect(subject.map(&:hostname)).to eq %w{example1.com example3.com}
@ -48,7 +48,7 @@ describe Capistrano::DSL do
describe 'fetching servers by multiple roles' do
it "does not confuse the last role with options" do
expect(dsl.roles(:app, :web).count).to eq 4
expect(dsl.roles(:app, :web, filter: :active).count).to eq 2
expect(dsl.roles(:app, :web, :filter => :active).count).to eq 2
end
end
@ -69,7 +69,7 @@ describe Capistrano::DSL do
end
describe 'fetching filtered servers by role' do
subject { dsl.roles(:app, filter: :active) }
subject { dsl.roles(:app, :filter => :active) }
it 'returns the servers' do
expect(subject.map(&:hostname)).to eq %w{example3.com}
@ -77,7 +77,7 @@ describe Capistrano::DSL do
end
describe 'fetching selected servers by role' do
subject { dsl.roles(:app, select: :active) }
subject { dsl.roles(:app, :select => :active) }
it 'returns the servers' do
expect(subject.map(&:hostname)).to eq %w{example3.com}
@ -103,7 +103,7 @@ describe Capistrano::DSL do
describe 'setting an internal host filter' do
subject { dsl.roles(:app) }
it 'is ignored' do
dsl.set :filter, { host: 'example3.com' }
dsl.set :filter, { :host => 'example3.com' }
expect(subject.map(&:hostname)).to eq(['example3.com', 'example4.com'])
end
end
@ -111,7 +111,7 @@ describe Capistrano::DSL do
describe 'setting an internal role filter' do
subject { dsl.roles(:app) }
it 'ignores it' do
dsl.set :filter, { role: :web }
dsl.set :filter, { :role => :web }
expect(subject.map(&:hostname)).to eq(['example3.com','example4.com'])
end
end
@ -119,7 +119,7 @@ describe Capistrano::DSL do
describe 'setting an internal host and role filter' do
subject { dsl.roles(:app) }
it 'ignores it' do
dsl.set :filter, { role: :web, host: 'example1.com' }
dsl.set :filter, { :role => :web, :host => 'example1.com' }
expect(subject.map(&:hostname)).to eq(['example3.com','example4.com'])
end
end
@ -127,7 +127,7 @@ describe Capistrano::DSL do
describe 'setting an internal regexp host filter' do
subject { dsl.roles(:all) }
it 'is ignored' do
dsl.set :filter, { host: /1/ }
dsl.set :filter, { :host => /1/ }
expect(subject.map(&:hostname)).to eq(%w{example1.com example2.com example3.com example4.com example5.com})
end
end
@ -135,7 +135,7 @@ describe Capistrano::DSL do
describe 'setting an internal hosts filter' do
subject { dsl.roles(:app) }
it 'is ignored' do
dsl.set :filter, { hosts: 'example3.com' }
dsl.set :filter, { :hosts => 'example3.com' }
expect(subject.map(&:hostname)).to eq(['example3.com', 'example4.com'])
end
end
@ -143,7 +143,7 @@ describe Capistrano::DSL do
describe 'setting an internal roles filter' do
subject { dsl.roles(:app) }
it 'ignores it' do
dsl.set :filter, { roles: :web }
dsl.set :filter, { :roles => :web }
expect(subject.map(&:hostname)).to eq(['example3.com','example4.com'])
end
end
@ -151,7 +151,7 @@ describe Capistrano::DSL do
describe 'setting an internal hosts and roles filter' do
subject { dsl.roles(:app) }
it 'ignores it' do
dsl.set :filter, { roles: :web, hosts: 'example1.com' }
dsl.set :filter, { :roles => :web, :hosts => 'example1.com' }
expect(subject.map(&:hostname)).to eq(['example3.com','example4.com'])
end
end
@ -159,7 +159,7 @@ describe Capistrano::DSL do
describe 'setting an internal regexp hosts filter' do
subject { dsl.roles(:all) }
it 'is ignored' do
dsl.set :filter, { hosts: /1/ }
dsl.set :filter, { :hosts => /1/ }
expect(subject.map(&:hostname)).to eq(%w{example1.com example2.com example3.com example4.com example5.com})
end
end
@ -177,11 +177,11 @@ describe Capistrano::DSL do
describe 'when defining hosts using the `role` syntax' do
before do
dsl.role :web, %w{example1.com example2.com example3.com}
dsl.role :web, %w{example1.com}, active: true
dsl.role :web, %w{example1.com}, :active => true
dsl.role :app, %w{example3.com example4.com}
dsl.role :app, %w{example3.com}, active: true
dsl.role :app, %w{example4.com}, primary: true
dsl.role :db, %w{example5.com}, no_release: true
dsl.role :app, %w{example3.com}, :active => true
dsl.role :app, %w{example4.com}, :primary => true
dsl.role :db, %w{example5.com}, :no_release => true
end
describe 'fetching all servers' do
@ -203,7 +203,7 @@ describe Capistrano::DSL do
end
context 'with filter options' do
subject { dsl.release_roles(:all, filter: :active) }
subject { dsl.release_roles(:all, :filter => :active) }
it 'returns all release servers that match the filter' do
expect(subject.map(&:hostname)).to eq %w{example1.com example3.com}
@ -229,7 +229,7 @@ describe Capistrano::DSL do
end
describe 'fetching filtered servers by role' do
subject { dsl.roles(:app, filter: :active) }
subject { dsl.roles(:app, :filter => :active) }
it 'returns the servers' do
expect(subject.map(&:hostname)).to eq %w{example3.com}
@ -237,7 +237,7 @@ describe Capistrano::DSL do
end
describe 'fetching selected servers by role' do
subject { dsl.roles(:app, select: :active) }
subject { dsl.roles(:app, :select => :active) }
it 'returns the servers' do
expect(subject.map(&:hostname)).to eq %w{example3.com}
@ -265,9 +265,9 @@ describe Capistrano::DSL do
describe 'when defining a host using a combination of the `server` and `role` syntax' do
before do
dsl.server 'db@example1.com:1234', roles: %w{db}, active: true
dsl.server 'root@example1.com:1234', roles: %w{web}, active: true
dsl.server 'example1.com:5678', roles: %w{web}, active: true
dsl.server 'db@example1.com:1234', :roles => %w{db}, :active => true
dsl.server 'root@example1.com:1234', :roles => %w{web}, :active => true
dsl.server 'example1.com:5678', :roles => %w{web}, :active => true
dsl.role :app, %w{deployer@example1.com:1234}
dsl.role :app, %w{example1.com:5678}
end
@ -301,14 +301,14 @@ describe Capistrano::DSL do
describe "using the :user property" do
it "takes precedence over in the host string" do
dsl.server 'db@example1.com:1234', roles: %w{db}, active: true, user: 'brian'
dsl.server 'db@example1.com:1234', :roles => %w{db}, :active => true, :user => 'brian'
expect(subject).to eq("brian@example1.com:1234")
end
end
describe "using the :port property" do
it "takes precedence over in the host string" do
dsl.server 'db@example1.com:9090', roles: %w{db}, active: true, port: 1234
dsl.server 'db@example1.com:9090', :roles => %w{db}, :active => true, :port => 1234
expect(subject).to eq("db@example1.com:1234")
end
end
@ -425,7 +425,7 @@ describe Capistrano::DSL do
describe 'configuration SSHKit' do
let(:config) { SSHKit.config }
let(:backend) { SSHKit.config.backend.config }
let(:default_env) { { rails_env: :production } }
let(:default_env) { { :rails_env => :production } }
before do
dsl.set(:format, :dot)
@ -434,9 +434,9 @@ describe Capistrano::DSL do
dsl.set(:pty, true)
dsl.set(:connection_timeout, 10)
dsl.set(:ssh_options, {
keys: %w(/home/user/.ssh/id_rsa),
forward_agent: false,
auth_methods: %w(publickey password)
:keys => %w(/home/user/.ssh/id_rsa),
:forward_agent => false,
:auth_methods => %w(publickey password)
})
dsl.configure_backend
end
@ -474,11 +474,11 @@ describe Capistrano::DSL do
describe "when passed server objects" do
before do
dsl.server 'example1.com', roles: %w{web}, active: true
dsl.server 'example2.com', roles: %w{web}
dsl.server 'example3.com', roles: %w{app web}, active: true
dsl.server 'example4.com', roles: %w{app}, primary: true
dsl.server 'example5.com', roles: %w{db}, no_release: true
dsl.server 'example1.com', :roles => %w{web}, :active => true
dsl.server 'example2.com', :roles => %w{web}
dsl.server 'example3.com', :roles => %w{app web}, :active => true
dsl.server 'example4.com', :roles => %w{app}, :primary => true
dsl.server 'example5.com', :roles => %w{db}, :no_release => true
@coordinator = mock('coordinator')
@coordinator.expects(:each).returns(nil)
ENV.delete 'ROLES'
@ -489,14 +489,14 @@ describe Capistrano::DSL do
hosts = dsl.roles(:web)
all = dsl.roles(:all)
SSHKit::Coordinator.expects(:new).with(hosts).returns(@coordinator)
dsl.set :filter, { role: 'web' }
dsl.set :filter, { :role => 'web' }
dsl.on(all)
end
it 'filters by host and role from the :filter variable' do
all = dsl.roles(:all)
SSHKit::Coordinator.expects(:new).with([]).returns(@coordinator)
dsl.set :filter, { role: 'db', host: 'example3.com' }
dsl.set :filter, { :role => 'db', :host => 'example3.com' }
dsl.on(all)
end
@ -504,14 +504,14 @@ describe Capistrano::DSL do
hosts = dsl.roles(:web)
all = dsl.roles(:all)
SSHKit::Coordinator.expects(:new).with(hosts).returns(@coordinator)
dsl.set :filter, { roles: 'web' }
dsl.set :filter, { :roles => 'web' }
dsl.on(all)
end
it 'filters by hosts and roles from the :filter variable' do
all = dsl.roles(:all)
SSHKit::Coordinator.expects(:new).with([]).returns(@coordinator)
dsl.set :filter, { roles: 'db', hosts: 'example3.com' }
dsl.set :filter, { :roles => 'db', :hosts => 'example3.com' }
dsl.on(all)
end
@ -551,37 +551,37 @@ describe Capistrano::DSL do
end
it "selects nothing when a role filter is present" do
dsl.set :filter, { role: 'web' }
dsl.set :filter, { :role => 'web' }
SSHKit::Coordinator.expects(:new).with([]).returns(@coordinator)
dsl.on('my.server')
end
it "selects using the string when a host filter is present" do
dsl.set :filter, { host: 'server.local' }
dsl.set :filter, { :host => 'server.local' }
SSHKit::Coordinator.expects(:new).with(['server.local']).returns(@coordinator)
dsl.on('server.local')
end
it "doesn't select when a host filter is present that doesn't match" do
dsl.set :filter, { host: 'ruby.local' }
dsl.set :filter, { :host => 'ruby.local' }
SSHKit::Coordinator.expects(:new).with([]).returns(@coordinator)
dsl.on('server.local')
end
it "selects nothing when a roles filter is present" do
dsl.set :filter, { roles: 'web' }
dsl.set :filter, { :roles => 'web' }
SSHKit::Coordinator.expects(:new).with([]).returns(@coordinator)
dsl.on('my.server')
end
it "selects using the string when a hosts filter is present" do
dsl.set :filter, { hosts: 'server.local' }
dsl.set :filter, { :hosts => 'server.local' }
SSHKit::Coordinator.expects(:new).with(['server.local']).returns(@coordinator)
dsl.on('server.local')
end
it "doesn't select when a hosts filter is present that doesn't match" do
dsl.set :filter, { hosts: 'ruby.local' }
dsl.set :filter, { :hosts => 'ruby.local' }
SSHKit::Coordinator.expects(:new).with([]).returns(@coordinator)
dsl.on('server.local')
end
@ -593,26 +593,26 @@ describe Capistrano::DSL do
describe 'role_properties()' do
before do
dsl.role :redis, %w[example1.com example2.com], redis: { port: 6379, type: :slave }
dsl.server 'example1.com', roles: %w{web}, active: true, web: { port: 80 }
dsl.server 'example2.com', roles: %w{web redis}, web: { port: 81 }, redis: { type: :master }
dsl.server 'example3.com', roles: %w{app}, primary: true
dsl.role :redis, %w[example1.com example2.com], :redis => { :port => 6379, :type => :slave }
dsl.server 'example1.com', :roles => %w{web}, :active => true, :web => { :port => 80 }
dsl.server 'example2.com', :roles => %w{web redis}, :web => { :port => 81 }, :redis => { :type => :master }
dsl.server 'example3.com', :roles => %w{app}, :primary => true
end
it 'retrieves properties for a single role as a set' do
rps = dsl.role_properties(:app)
expect(rps).to eq(Set[{ hostname: 'example3.com', role: :app}])
expect(rps).to eq(Set[{ :hostname => 'example3.com', :role => :app}])
end
it 'retrieves properties for multiple roles as a set' do
rps = dsl.role_properties(:app, :web)
expect(rps).to eq(Set[{ hostname: 'example3.com', role: :app},{ hostname: 'example1.com', role: :web, port: 80},{ hostname: 'example2.com', role: :web, port: 81}])
expect(rps).to eq(Set[{ :hostname => 'example3.com', :role => :app},{ :hostname => 'example1.com', :role => :web, :port => 80},{ :hostname => 'example2.com', :role => :web, :port => 81}])
end
it 'yields the properties for a single role' do
recipient = mock('recipient')
recipient.expects(:doit).with('example1.com', :redis, { port: 6379, type: :slave})
recipient.expects(:doit).with('example2.com', :redis, { port: 6379, type: :master})
recipient.expects(:doit).with('example1.com', :redis, { :port => 6379, :type => :slave})
recipient.expects(:doit).with('example2.com', :redis, { :port => 6379, :type => :master})
dsl.role_properties(:redis) do |host, role, props|
recipient.doit(host, role, props)
end
@ -620,8 +620,8 @@ describe Capistrano::DSL do
it 'yields the properties for multiple roles' do
recipient = mock('recipient')
recipient.expects(:doit).with('example1.com', :redis, { port: 6379, type: :slave})
recipient.expects(:doit).with('example2.com', :redis, { port: 6379, type: :master})
recipient.expects(:doit).with('example1.com', :redis, { :port => 6379, :type => :slave})
recipient.expects(:doit).with('example2.com', :redis, { :port => 6379, :type => :master})
recipient.expects(:doit).with('example3.com', :app, nil)
dsl.role_properties(:redis, :app) do |host, role, props|
recipient.doit(host, role, props)
@ -630,10 +630,10 @@ describe Capistrano::DSL do
it 'yields the merged properties for multiple roles' do
recipient = mock('recipient')
recipient.expects(:doit).with('example1.com', :redis, { port: 6379, type: :slave})
recipient.expects(:doit).with('example2.com', :redis, { port: 6379, type: :master})
recipient.expects(:doit).with('example1.com', :web, { port: 80 })
recipient.expects(:doit).with('example2.com', :web, { port: 81 })
recipient.expects(:doit).with('example1.com', :redis, { :port => 6379, :type => :slave})
recipient.expects(:doit).with('example2.com', :redis, { :port => 6379, :type => :master})
recipient.expects(:doit).with('example1.com', :web, { :port => 80 })
recipient.expects(:doit).with('example2.com', :web, { :port => 81 })
dsl.role_properties(:redis, :web) do |host, role, props|
recipient.doit(host, role, props)
end
@ -641,9 +641,9 @@ describe Capistrano::DSL do
it 'honours a property filter before yielding' do
recipient = mock('recipient')
recipient.expects(:doit).with('example1.com', :redis, { port: 6379, type: :slave})
recipient.expects(:doit).with('example1.com', :web, { port: 80 })
dsl.role_properties(:redis, :web, select: :active) do |host, role, props|
recipient.expects(:doit).with('example1.com', :redis, { :port => 6379, :type => :slave})
recipient.expects(:doit).with('example1.com', :web, { :port => 80 })
dsl.role_properties(:redis, :web, :select => :active) do |host, role, props|
recipient.doit(host, role, props)
end
end

View file

@ -6,7 +6,7 @@ module Capistrano
describe Question do
let(:question) { Question.new(key, default, options) }
let(:question_without_echo) { Question.new(key, default, echo: false) }
let(:question_without_echo) { Question.new(key, default, :echo => false) }
let(:default) { :default }
let(:key) { :branch }
let(:options) { nil }

View file

@ -81,7 +81,7 @@ module Capistrano
end
context 'properties contains roles' do
let(:properties) { {roles: [:clouds]} }
let(:properties) { {:roles => [:clouds]} }
it 'adds the roles' do
expect(server.roles.first).to eq :clouds
@ -89,7 +89,7 @@ module Capistrano
end
context 'properties contains user' do
let(:properties) { {user: 'tomc'} }
let(:properties) { {:user => 'tomc'} }
it 'sets the user' do
expect(server.user).to eq 'tomc'
@ -101,7 +101,7 @@ module Capistrano
end
context 'properties contains port' do
let(:properties) { {port: 2222} }
let(:properties) { {:port => 2222} }
it 'sets the port' do
expect(server.port).to eq 2222
@ -109,7 +109,7 @@ module Capistrano
end
context 'properties contains key' do
let(:properties) { {key: '/key'} }
let(:properties) { {:key => '/key'} }
it 'adds the key' do
expect(server.keys).to include '/key'
@ -117,7 +117,7 @@ module Capistrano
end
context 'properties contains password' do
let(:properties) { {password: 'supersecret'} }
let(:properties) { {:password => 'supersecret'} }
it 'adds the key' do
expect(server.password).to eq 'supersecret'
@ -125,7 +125,7 @@ module Capistrano
end
context 'new properties' do
let(:properties) { { webscales: 5 } }
let(:properties) { { :webscales => 5 } }
it 'adds the properties' do
expect(server.properties.webscales).to eq 5
@ -133,7 +133,7 @@ module Capistrano
end
context 'existing properties' do
let(:properties) { { webscales: 6 } }
let(:properties) { { :webscales => 6 } }
it 'keeps the existing properties' do
expect(server.properties.webscales).to eq 6
@ -160,46 +160,46 @@ module Capistrano
context 'value matches server property' do
context 'with :filter' do
let(:options) { { filter: :active }}
let(:options) { { :filter => :active }}
it { expect(subject).to be_truthy }
end
context 'with :select' do
let(:options) { { select: :active }}
let(:options) { { :select => :active }}
it { expect(subject).to be_truthy }
end
context 'with :exclude' do
let(:options) { { exclude: :active }}
let(:options) { { :exclude => :active }}
it { expect(subject).to be_falsey }
end
end
context 'value does not match server properly' do
context 'with :active true' do
let(:options) { { active: true }}
let(:options) { { :active => true }}
it { expect(subject).to be_truthy }
end
context 'with :active false' do
let(:options) { { active: false }}
let(:options) { { :active => false }}
it { expect(subject).to be_falsey }
end
end
context 'value does not match server properly' do
context 'with :filter' do
let(:options) { { filter: :inactive }}
let(:options) { { :filter => :inactive }}
it { expect(subject).to be_falsey }
end
context 'with :select' do
let(:options) { { select: :inactive }}
let(:options) { { :select => :inactive }}
it { expect(subject).to be_falsey }
end
context 'with :exclude' do
let(:options) { { exclude: :inactive }}
let(:options) { { :exclude => :inactive }}
it { expect(subject).to be_truthy }
end
end
@ -207,12 +207,12 @@ module Capistrano
context 'key is a property' do
context 'with :active true' do
let(:options) { { active: true }}
let(:options) { { :active => true }}
it { expect(subject).to be_truthy }
end
context 'with :active false' do
let(:options) { { active: false }}
let(:options) { { :active => false }}
it { expect(subject).to be_falsey }
end
end
@ -221,17 +221,17 @@ module Capistrano
context 'value matches server property' do
context 'with :filter' do
let(:options) { { filter: ->(s) { s.properties.active } } }
let(:options) { { :filter => ->(s) { s.properties.active } } }
it { expect(subject).to be_truthy }
end
context 'with :select' do
let(:options) { { select: ->(s) { s.properties.active } } }
let(:options) { { :select => ->(s) { s.properties.active } } }
it { expect(subject).to be_truthy }
end
context 'with :exclude' do
let(:options) { { exclude: ->(s) { s.properties.active } } }
let(:options) { { :exclude => ->(s) { s.properties.active } } }
it { expect(subject).to be_falsey }
end
@ -239,17 +239,17 @@ module Capistrano
context 'value does not match server properly' do
context 'with :filter' do
let(:options) { { filter: ->(s) { s.properties.inactive } } }
let(:options) { { :filter => ->(s) { s.properties.inactive } } }
it { expect(subject).to be_falsey }
end
context 'with :select' do
let(:options) { { select: ->(s) { s.properties.inactive } } }
let(:options) { { :select => ->(s) { s.properties.inactive } } }
it { expect(subject).to be_falsey }
end
context 'with :exclude' do
let(:options) { { exclude: ->(s) { s.properties.inactive } } }
let(:options) { { :exclude => ->(s) { s.properties.inactive } } }
it { expect(subject).to be_truthy }
end
@ -272,11 +272,11 @@ module Capistrano
context 'custom' do
let(:properties) do
{ ssh_options: {
user: 'another_user',
keys: %w(/home/another_user/.ssh/id_rsa),
forward_agent: false,
auth_methods: %w(publickey password) } }
{ :ssh_options => {
:user => 'another_user',
:keys => %w(/home/another_user/.ssh/id_rsa),
:forward_agent => false,
:auth_methods => %w(publickey password) } }
end
before do

View file

@ -19,8 +19,8 @@ module Capistrano
end
it 'handles de-duplification within roles with users' do
servers.add_role(:app, %w{1}, user: 'nick')
servers.add_role(:app, %w{1}, user: 'fred')
servers.add_role(:app, %w{1}, :user => 'nick')
servers.add_role(:app, %w{1}, :user => 'fred')
expect(servers.count).to eq 1
end
@ -35,12 +35,12 @@ module Capistrano
end
it 'creates distinct server properties' do
servers.add_role(:db, %w{1 2}, db: { port: 1234 } )
servers.add_host('1', db: { master: true })
servers.add_role(:db, %w{1 2}, :db => { :port => 1234 } )
servers.add_host('1', :db => { :master => true })
expect(servers.count).to eq(2)
expect(servers.roles_for([:db]).count).to eq 2
expect(servers.find(){|s| s.hostname == '1'}.properties.db).to eq({ port: 1234, master: true })
expect(servers.find(){|s| s.hostname == '2'}.properties.db).to eq({ port: 1234 })
expect(servers.find(){|s| s.hostname == '1'}.properties.db).to eq({ :port => 1234, :master => true })
expect(servers.find(){|s| s.hostname == '2'}.properties.db).to eq({ :port => 1234 })
end
end
@ -84,14 +84,14 @@ module Capistrano
it 'takes the first server with the primary have the primary flag' do
servers.add_role(:app, %w{1 2})
servers.add_host('2', primary: true)
servers.add_host('2', :primary => true)
expect(servers.fetch_primary(:app).hostname).to eq('2')
end
it 'ignores any on_filters' do
Configuration.env.set :filter, { host: '1'}
Configuration.env.set :filter, { :host => '1'}
servers.add_role(:app, %w{1 2})
servers.add_host('2', primary: true)
servers.add_host('2', :primary => true)
expect(servers.fetch_primary(:app).hostname).to eq('2')
end
end
@ -122,7 +122,7 @@ module Capistrano
describe 'adding a server' do
before do
servers.add_host('1', roles: [:app, 'web'], test: :value)
servers.add_host('1', :roles => [:app, 'web'], :test => :value)
end
it 'can create a server with properties' do
@ -133,26 +133,26 @@ module Capistrano
end
it 'can accept multiple servers with the same hostname but different ports or users' do
servers.add_host('1', roles: [:app, 'web'], test: :value, port: 12)
servers.add_host('1', roles: [:app, 'web'], test: :value, port: 34)
servers.add_host('1', roles: [:app, 'web'], test: :value, user: 'root')
servers.add_host('1', roles: [:app, 'web'], test: :value, user: 'deployer')
servers.add_host('1', roles: [:app, 'web'], test: :value, user: 'root', port: 34)
servers.add_host('1', roles: [:app, 'web'], test: :value, user: 'deployer', port: 34)
servers.add_host('1', roles: [:app, 'web'], test: :value, user: 'deployer', port: 56)
servers.add_host('1', :roles => [:app, 'web'], :test => :value, :port => 12)
servers.add_host('1', :roles => [:app, 'web'], :test => :value, :port => 34)
servers.add_host('1', :roles => [:app, 'web'], :test => :value, :user => 'root')
servers.add_host('1', :roles => [:app, 'web'], :test => :value, :user => 'deployer')
servers.add_host('1', :roles => [:app, 'web'], :test => :value, :user => 'root', :port => 34)
servers.add_host('1', :roles => [:app, 'web'], :test => :value, :user => 'deployer', :port => 34)
servers.add_host('1', :roles => [:app, 'web'], :test => :value, :user => 'deployer', :port => 56)
expect(servers.count).to eq(5)
end
describe "with a :user property" do
it 'sets the server ssh username' do
servers.add_host('1', roles: [:app, 'web'], user: 'nick')
servers.add_host('1', :roles => [:app, 'web'], :user => 'nick')
expect(servers.count).to eq(1)
expect(servers.roles_for([:all]).first.user).to eq 'nick'
end
it 'overwrites the value of a user specified in the hostname' do
servers.add_host('brian@1', roles: [:app, 'web'], user: 'nick')
servers.add_host('brian@1', :roles => [:app, 'web'], :user => 'nick')
expect(servers.count).to eq(1)
expect(servers.roles_for([:all]).first.user).to eq 'nick'
end
@ -160,47 +160,47 @@ module Capistrano
end
it 'overwrites the value of a previously defined scalar property' do
servers.add_host('1', roles: [:app, 'web'], test: :volatile)
servers.add_host('1', :roles => [:app, 'web'], :test => :volatile)
expect(servers.count).to eq(1)
expect(servers.roles_for([:all]).first.properties.test).to eq :volatile
end
it 'merges previously defined hash properties' do
servers.add_host('1', roles: [:b], db: { port: 1234 })
servers.add_host('1', roles: [:b], db: { master: true })
servers.add_host('1', :roles => [:b], :db => { :port => 1234 })
servers.add_host('1', :roles => [:b], :db => { :master => true })
expect(servers.count).to eq(1)
expect(servers.roles_for([:b]).first.properties.db).to eq({ port: 1234, master: true })
expect(servers.roles_for([:b]).first.properties.db).to eq({ :port => 1234, :master => true })
end
it 'concatenates previously defined array properties' do
servers.add_host('1', roles: [:b], steps: [1,3,5])
servers.add_host('1', roles: [:b], steps: [1,9])
servers.add_host('1', :roles => [:b], :steps => [1,3,5])
servers.add_host('1', :roles => [:b], :steps => [1,9])
expect(servers.count).to eq(1)
expect(servers.roles_for([:b]).first.properties.steps).to eq([1,3,5,1,9])
end
it 'merges previously defined set properties' do
servers.add_host('1', roles: [:b], endpoints: Set[123,333])
servers.add_host('1', roles: [:b], endpoints: Set[222,333])
servers.add_host('1', :roles => [:b], :endpoints => Set[123,333])
servers.add_host('1', :roles => [:b], :endpoints => Set[222,333])
expect(servers.count).to eq(1)
expect(servers.roles_for([:b]).first.properties.endpoints).to eq(Set[123,222,333])
end
it 'adds array property value only ones for a new host' do
servers.add_host('2', roles: [:array_test], array_property: [1,2])
servers.add_host('2', :roles => [:array_test], :array_property => [1,2])
expect(servers.roles_for([:array_test]).first.properties.array_property).to eq [1,2]
end
it 'updates roles when custom user defined' do
servers.add_host('1', roles: ['foo'], user: 'custom')
servers.add_host('1', roles: ['bar'], user: 'custom')
servers.add_host('1', :roles => ['foo'], :user => 'custom')
servers.add_host('1', :roles => ['bar'], :user => 'custom')
expect(servers.roles_for([:foo]).first.hostname).to eq '1'
expect(servers.roles_for([:bar]).first.hostname).to eq '1'
end
it 'updates roles when custom port defined' do
servers.add_host('1', roles: ['foo'], port: 1234)
servers.add_host('1', roles: ['bar'], port: 1234)
servers.add_host('1', :roles => ['foo'], :port => 1234)
servers.add_host('1', :roles => ['bar'], :port => 1234)
expect(servers.roles_for([:foo]).first.hostname).to eq '1'
expect(servers.roles_for([:bar]).first.hostname).to eq '1'
end
@ -210,32 +210,32 @@ module Capistrano
describe 'selecting roles' do
before do
servers.add_host('1', roles: :app, active: true)
servers.add_host('2', roles: :app)
servers.add_host('1', :roles => :app, :active => true)
servers.add_host('2', :roles => :app)
end
it 'is empty if the filter would remove all matching hosts' do
expect(servers.roles_for([:app, select: :inactive])).to be_empty
expect(servers.roles_for([:app, :select => :inactive])).to be_empty
end
it 'can filter hosts by properties on the host object using symbol as shorthand' do
expect(servers.roles_for([:app, filter: :active]).length).to eq 1
expect(servers.roles_for([:app, :filter => :active]).length).to eq 1
end
it 'can select hosts by properties on the host object using symbol as shorthand' do
expect(servers.roles_for([:app, select: :active]).length).to eq 1
expect(servers.roles_for([:app, :select => :active]).length).to eq 1
end
it 'can filter hosts by properties on the host using a regular proc' do
expect(servers.roles_for([:app, filter: ->(h) { h.properties.active }]).length).to eq 1
expect(servers.roles_for([:app, :filter => ->(h) { h.properties.active }]).length).to eq 1
end
it 'can select hosts by properties on the host using a regular proc' do
expect(servers.roles_for([:app, select: ->(h) { h.properties.active }]).length).to eq 1
expect(servers.roles_for([:app, :select => ->(h) { h.properties.active }]).length).to eq 1
end
it 'is empty if the regular proc filter would remove all matching hosts' do
expect(servers.roles_for([:app, select: ->(h) { h.properties.inactive }])).to be_empty
expect(servers.roles_for([:app, :select => ->(h) { h.properties.inactive }])).to be_empty
end
end
@ -243,27 +243,27 @@ module Capistrano
describe 'excluding by property' do
before do
servers.add_host('1', roles: :app, active: true)
servers.add_host('2', roles: :app, active: true, no_release: true)
servers.add_host('1', :roles => :app, :active => true)
servers.add_host('2', :roles => :app, :active => true, :no_release => true)
end
it 'is empty if the filter would remove all matching hosts' do
hosts = servers.roles_for([:app, exclude: :active])
hosts = servers.roles_for([:app, :exclude => :active])
expect(hosts.map(&:hostname)).to be_empty
end
it 'returns the servers without the attributes specified' do
hosts = servers.roles_for([:app, exclude: :no_release])
hosts = servers.roles_for([:app, :exclude => :no_release])
expect(hosts.map(&:hostname)).to eq %w{1}
end
it 'can exclude hosts by properties on the host using a regular proc' do
hosts = servers.roles_for([:app, exclude: ->(h) { h.properties.no_release }])
hosts = servers.roles_for([:app, :exclude => ->(h) { h.properties.no_release }])
expect(hosts.map(&:hostname)).to eq %w{1}
end
it 'is empty if the regular proc filter would remove all matching hosts' do
hosts = servers.roles_for([:app, exclude: ->(h) { h.properties.active }])
hosts = servers.roles_for([:app, :exclude => ->(h) { h.properties.active }])
expect(hosts.map(&:hostname)).to be_empty
end
@ -272,11 +272,11 @@ module Capistrano
describe 'filtering roles internally' do
before do
servers.add_host('1', roles: :app, active: true)
servers.add_host('2', roles: :app)
servers.add_host('3', roles: :web)
servers.add_host('4', roles: :web)
servers.add_host('5', roles: :db)
servers.add_host('1', :roles => :app, :active => true)
servers.add_host('2', :roles => :app)
servers.add_host('3', :roles => :web)
servers.add_host('4', :roles => :web)
servers.add_host('5', :roles => :db)
end
subject { servers.roles_for(roles).map(&:hostname) }

View file

@ -7,7 +7,7 @@ module Capistrano
describe '.new' do
it 'accepts initial hash' do
configuration = described_class.new(custom: 'value')
configuration = described_class.new(:custom => 'value')
expect(configuration.fetch(:custom)).to eq('value')
end
end
@ -262,10 +262,10 @@ module Capistrano
it 'merges them with the :ssh_options variable' do
config.set :format, :pretty
config.set :log_level, :debug
config.set :ssh_options, { user: 'albert' }
SSHKit::Backend::Netssh.configure do |ssh| ssh.ssh_options = { password: 'einstein' } end
config.set :ssh_options, { :user => 'albert' }
SSHKit::Backend::Netssh.configure do |ssh| ssh.ssh_options = { :password => 'einstein' } end
config.configure_backend
expect(config.backend.config.backend.config.ssh_options).to eq({ user: 'albert', password: 'einstein' })
expect(config.backend.config.backend.config.ssh_options).to eq({ :user => 'albert', :password => 'einstein' })
end
end
end

View file

@ -12,11 +12,11 @@ module Capistrano
describe '#t' do
before do
I18n.expects(:t).with(:phrase, {count: 2, scope: :capistrano})
I18n.expects(:t).with(:phrase, {:count => 2, :scope => :capistrano})
end
it 'delegates to I18n' do
dsl.t(:phrase, count: 2)
dsl.t(:phrase, :count => 2)
end
end

View file

@ -5,16 +5,16 @@ Vagrant.configure("2") do |config|
config.ssh.insert_key = false
[:app].each_with_index do |role, i|
config.vm.define(role, primary: true) do |primary|
config.vm.define(role, :primary => true) do |primary|
primary.vm.define role
primary.vm.box = 'hashicorp/precise64'
primary.vm.network "forwarded_port", guest: 22, host: "222#{i}".to_i
primary.vm.provision :shell, inline: 'sudo apt-get -y install git-core'
primary.vm.network "forwarded_port", :guest => 22, :host => "222#{i}".to_i
primary.vm.provision :shell, :inline => 'sudo apt-get -y install git-core'
vagrantkey = open("https://raw.githubusercontent.com/mitchellh/vagrant/master/keys/vagrant.pub", "r",&:read)
primary.vm.provision :shell,
inline: <<-INLINE
:inline => <<-INLINE
install -d -m 700 /root/.ssh
echo -e "#{vagrantkey}" > /root/.ssh/authorized_keys
chmod 0600 /root/.ssh/authorized_keys

View file

@ -4,7 +4,7 @@ namespace :deploy do
end
end
remote_file 'config/database.yml' => '/tmp/database.yml', roles: :all
remote_file 'config/database.yml' => '/tmp/database.yml', :roles => :all
file '/tmp/database.yml' do |t|
sh "touch #{t.name}"