capistrano-misc 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +15 -0
- data/.gitignore +26 -0
- data/.travis.yml +2 -0
- data/Appraisals +3 -0
- data/CONTRIBUTING.md +16 -0
- data/Gemfile +3 -0
- data/LICENSE +20 -0
- data/README.md +40 -0
- data/Rakefile +19 -0
- data/capistrano-misc.gemspec +26 -0
- data/gemfiles/cap_2.gemfile +7 -0
- data/gemfiles/cap_2.gemfile.lock +56 -0
- data/lib/capistrano-misc.rb +8 -0
- data/lib/capistrano-misc/misc/branch.rb +49 -0
- data/lib/capistrano-misc/misc/guard.rb +31 -0
- data/lib/capistrano-misc/misc/log.rb +23 -0
- data/lib/capistrano-misc/version.rb +14 -0
- data/spec/capistrano-misc/misc/branch_spec.rb +56 -0
- data/spec/capistrano-misc/misc/guard_spec.rb +70 -0
- data/spec/capistrano-misc/misc/log_spec.rb +28 -0
- data/spec/capistrano-misc_spec.rb +2 -0
- data/spec/spec_helper.rb +22 -0
- data/spec/support/capistrano.rb +6 -0
- metadata +156 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
---
|
|
2
|
+
!binary "U0hBMQ==":
|
|
3
|
+
metadata.gz: !binary |-
|
|
4
|
+
NzAwNjk2NDg3NzMyZjBlMmRlN2E2ZjNhMzk5Nzc5N2QzNmExNDJlZA==
|
|
5
|
+
data.tar.gz: !binary |-
|
|
6
|
+
YjkyNzZjZTc1MmZhMWYyY2I5ZWFhYzMxZjRlMDQ3M2EyOWU1MDljZQ==
|
|
7
|
+
SHA512:
|
|
8
|
+
metadata.gz: !binary |-
|
|
9
|
+
MTc2NTk0YzUwNjE4MDdhMDljNGJlYWFhOGQyMGM4ZTQzN2U3YWYwNTQyNzhh
|
|
10
|
+
NDZlOTY5MjEzOTA3NTBhN2EwY2U0MTYyYmZhY2FlNzZlNTMxOWU5YmJlYjll
|
|
11
|
+
ZjM3ZTQ0OTcyMTVmZTE2MDY0ZDk1ZWExZTI3YzA3YzhlZWJjODk=
|
|
12
|
+
data.tar.gz: !binary |-
|
|
13
|
+
YzNjZWQ4ZTdlOTI2YzllMGJlMTJlYjVlM2Y3NzVmYjk0M2NlN2ZlNTE2YmIz
|
|
14
|
+
OTNkZWMzMjBkN2IzNTYzYjBiZGZmZDI2ZjllNTcwZmI4ZjIxZDZmZDZiMGY0
|
|
15
|
+
ODEzMjk3OGNjNzc3OGQ0N2YyOTkxMGE4NTdlMGQ4NzM0Njg4YmI=
|
data/.gitignore
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
.rvmrc
|
|
2
|
+
.rspec
|
|
3
|
+
.bundle
|
|
4
|
+
.config
|
|
5
|
+
.ruby-version
|
|
6
|
+
.ruby-gemset
|
|
7
|
+
|
|
8
|
+
coverage
|
|
9
|
+
vendor
|
|
10
|
+
log
|
|
11
|
+
tmp
|
|
12
|
+
coverage
|
|
13
|
+
spec/tmp
|
|
14
|
+
spec/reports
|
|
15
|
+
|
|
16
|
+
Gemfile.lock
|
|
17
|
+
|
|
18
|
+
# YARD artifacts
|
|
19
|
+
.yardoc
|
|
20
|
+
_yardoc
|
|
21
|
+
doc/
|
|
22
|
+
|
|
23
|
+
*.gem
|
|
24
|
+
*.rbc
|
|
25
|
+
**.orig
|
|
26
|
+
**.org
|
data/.travis.yml
ADDED
data/Appraisals
ADDED
data/CONTRIBUTING.md
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
Contributor Policy
|
|
2
|
+
=================
|
|
3
|
+
|
|
4
|
+
Commit bit. If you have a commit accepted into the project then you get full git access to the repo. If I don't give you this in a timely manner just send me a message.
|
|
5
|
+
|
|
6
|
+
Testing
|
|
7
|
+
======
|
|
8
|
+
|
|
9
|
+
Please don't commit code without tests. You can bootstrap the development environment by running `bundle install`. After that, running `rake` should just work. If it doesn't then file a bug.
|
|
10
|
+
|
|
11
|
+
Versioning
|
|
12
|
+
=========
|
|
13
|
+
|
|
14
|
+
Don't bump the version in any changes you make or pull in to the project. I'll maintain rights to push the gem to rubygems.org and make releases when appropriate.
|
|
15
|
+
|
|
16
|
+
And please keep the README up to date. Thank you!
|
data/Gemfile
ADDED
data/LICENSE
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2013 dtaniwaki
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
|
6
|
+
this software and associated documentation files (the "Software"), to deal in
|
|
7
|
+
the Software without restriction, including without limitation the rights to
|
|
8
|
+
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
|
9
|
+
the Software, and to permit persons to whom the Software is furnished to do so,
|
|
10
|
+
subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
|
17
|
+
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
|
18
|
+
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
|
19
|
+
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
|
20
|
+
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
# capistrano-misc
|
|
2
|
+
|
|
3
|
+
[](https://rubygems.org/gems/capistrano-misc) [](https://travis-ci.org/dtaniwaki/capistrano-misc)
|
|
4
|
+
|
|
5
|
+
capistrano-misc provides some useful tasks for Capistrano 2.
|
|
6
|
+
|
|
7
|
+
## Installation
|
|
8
|
+
|
|
9
|
+
To your system
|
|
10
|
+
|
|
11
|
+
```ruby
|
|
12
|
+
gem install capistrano-misc
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
Or add capistrano-misc to your `Gemfile` and `bundle install`:
|
|
16
|
+
|
|
17
|
+
```ruby
|
|
18
|
+
gem 'capistrano-misc'
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
## Tasks
|
|
22
|
+
|
|
23
|
+
Execute individual tasks
|
|
24
|
+
```ruby
|
|
25
|
+
cap misc:log
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
Add callback tasks in ```config/deploy.rb```
|
|
29
|
+
```ruby
|
|
30
|
+
after 'multistage:ensure', 'misc:guard'
|
|
31
|
+
before 'deploy:update_code', 'misc:branch'
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
## Contributing
|
|
35
|
+
|
|
36
|
+
See the [contributing guide](https://github.com/dtaniwaki/capistrano-misc/blob/master/CONTRIBUTING.md).
|
|
37
|
+
|
|
38
|
+
## Copyright
|
|
39
|
+
|
|
40
|
+
Copyright (c) 2014-2014 Daisuke Taniwaki. See [LICENSE](https://github.com/dtaniwaki/capistrano-misc/blob/master/LICENSE) for details.
|
data/Rakefile
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
require 'rspec/core/rake_task'
|
|
2
|
+
require 'appraisal'
|
|
3
|
+
|
|
4
|
+
RSpec::Core::RakeTask.new(:spec)
|
|
5
|
+
|
|
6
|
+
task :default => [:all]
|
|
7
|
+
|
|
8
|
+
task :all do
|
|
9
|
+
Rake::Task['appraisal:install'].invoke
|
|
10
|
+
exec('rake appraisal spec')
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
namespace :spec do
|
|
14
|
+
desc "Execute rspec coverage"
|
|
15
|
+
task :coverage do
|
|
16
|
+
ENV['COVERAGE'] = 'true'
|
|
17
|
+
Rake::Task["spec"].execute
|
|
18
|
+
end
|
|
19
|
+
end
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
$:.push File.expand_path("../lib", __FILE__)
|
|
2
|
+
require "capistrano-misc/version"
|
|
3
|
+
|
|
4
|
+
Gem::Specification.new do |s|
|
|
5
|
+
s.name = "capistrano-misc"
|
|
6
|
+
s.version = CapistranoMisc::Version
|
|
7
|
+
s.authors = ["Daisuke Taniwaki"]
|
|
8
|
+
s.email = ["daisuketaniwaki@gmail.com"]
|
|
9
|
+
s.homepage = "https://github.com/dtaniwaki/capistrano-misc"
|
|
10
|
+
s.summary = 'Useful tasks for Capistrano'
|
|
11
|
+
s.description = 'Useful tasks for Capistrano'
|
|
12
|
+
|
|
13
|
+
s.files = `git ls-files`.split("\n")
|
|
14
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
|
15
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
|
16
|
+
s.require_paths = ["lib"]
|
|
17
|
+
s.license = "MIT"
|
|
18
|
+
|
|
19
|
+
s.add_runtime_dependency 'capistrano', "~> 2.15.0"
|
|
20
|
+
|
|
21
|
+
s.add_development_dependency 'appraisal'
|
|
22
|
+
s.add_development_dependency 'capistrano-spec'
|
|
23
|
+
s.add_development_dependency 'rspec'
|
|
24
|
+
s.add_development_dependency 'simplecov'
|
|
25
|
+
s.add_development_dependency 'rake'
|
|
26
|
+
end
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
PATH
|
|
2
|
+
remote: ../
|
|
3
|
+
specs:
|
|
4
|
+
capistrano-misc (0.0.1)
|
|
5
|
+
capistrano (~> 2.15.0)
|
|
6
|
+
|
|
7
|
+
GEM
|
|
8
|
+
remote: http://rubygems.org/
|
|
9
|
+
specs:
|
|
10
|
+
appraisal (0.5.2)
|
|
11
|
+
bundler
|
|
12
|
+
rake
|
|
13
|
+
capistrano (2.15.5)
|
|
14
|
+
highline
|
|
15
|
+
net-scp (>= 1.0.0)
|
|
16
|
+
net-sftp (>= 2.0.0)
|
|
17
|
+
net-ssh (>= 2.0.14)
|
|
18
|
+
net-ssh-gateway (>= 1.1.0)
|
|
19
|
+
capistrano-spec (0.6.3)
|
|
20
|
+
diff-lcs (1.2.5)
|
|
21
|
+
docile (1.1.3)
|
|
22
|
+
highline (1.6.20)
|
|
23
|
+
multi_json (1.8.4)
|
|
24
|
+
net-scp (1.1.2)
|
|
25
|
+
net-ssh (>= 2.6.5)
|
|
26
|
+
net-sftp (2.1.2)
|
|
27
|
+
net-ssh (>= 2.6.5)
|
|
28
|
+
net-ssh (2.8.0)
|
|
29
|
+
net-ssh-gateway (1.2.0)
|
|
30
|
+
net-ssh (>= 2.6.5)
|
|
31
|
+
rake (10.1.1)
|
|
32
|
+
rspec (2.14.1)
|
|
33
|
+
rspec-core (~> 2.14.0)
|
|
34
|
+
rspec-expectations (~> 2.14.0)
|
|
35
|
+
rspec-mocks (~> 2.14.0)
|
|
36
|
+
rspec-core (2.14.7)
|
|
37
|
+
rspec-expectations (2.14.5)
|
|
38
|
+
diff-lcs (>= 1.1.3, < 2.0)
|
|
39
|
+
rspec-mocks (2.14.5)
|
|
40
|
+
simplecov (0.8.2)
|
|
41
|
+
docile (~> 1.1.0)
|
|
42
|
+
multi_json
|
|
43
|
+
simplecov-html (~> 0.8.0)
|
|
44
|
+
simplecov-html (0.8.0)
|
|
45
|
+
|
|
46
|
+
PLATFORMS
|
|
47
|
+
ruby
|
|
48
|
+
|
|
49
|
+
DEPENDENCIES
|
|
50
|
+
appraisal
|
|
51
|
+
capistrano (~> 2.15.0)
|
|
52
|
+
capistrano-misc!
|
|
53
|
+
capistrano-spec
|
|
54
|
+
rake
|
|
55
|
+
rspec
|
|
56
|
+
simplecov
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
module CapistranoMisc::Misc
|
|
2
|
+
module Branch
|
|
3
|
+
def self.load_into(configuration)
|
|
4
|
+
configuration.load do
|
|
5
|
+
namespace :misc do
|
|
6
|
+
task :branch do
|
|
7
|
+
branch = fetch(:branch, nil)
|
|
8
|
+
next if branch.is_a?(String)
|
|
9
|
+
|
|
10
|
+
regexp = branch.is_a?(Regexp) ? branch : /.*/
|
|
11
|
+
branches = run_locally(%Q|#{scm} fetch && #{scm} branch -a|).split("\n").map{ |s| s.sub(/^[ *]*/, "") }
|
|
12
|
+
branches = branches.grep(regexp)
|
|
13
|
+
|
|
14
|
+
options = ['0: Use revision number']
|
|
15
|
+
options.concat branches.map.with_index{|revision, idx|"#{idx+1}: #{revision}"}
|
|
16
|
+
options.concat ['q: Quit']
|
|
17
|
+
while
|
|
18
|
+
s = Capistrano::CLI.ui.ask(%Q|Choose branch from \n#{options.join("\n")}\n or type tag to deploy (make sure to push the tag first): |).strip
|
|
19
|
+
if s =~ /q(uit)?/i
|
|
20
|
+
exit
|
|
21
|
+
elsif s.to_i.to_s != s
|
|
22
|
+
next
|
|
23
|
+
end
|
|
24
|
+
break
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
case idx = s.to_i
|
|
28
|
+
when 0
|
|
29
|
+
tag = Capistrano::CLI.ui.ask('Type revision or tag to deploy: ').strip
|
|
30
|
+
else
|
|
31
|
+
tag = branches[idx-1]
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
if tag.nil? || tag !~ regexp
|
|
35
|
+
logger.important "err :: The branch you specified is not allowed to deploy"
|
|
36
|
+
exit
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
set :branch, tag
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
end
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
if Capistrano::Configuration.respond_to?(:instance) && !Capistrano::Configuration.instance.nil?
|
|
48
|
+
CapistranoMisc::Misc::Branch.load_into(Capistrano::Configuration.instance)
|
|
49
|
+
end
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
module CapistranoMisc::Misc
|
|
2
|
+
module Guard
|
|
3
|
+
def self.load_into(configuration)
|
|
4
|
+
configuration.load do
|
|
5
|
+
set :guard_env, :production
|
|
6
|
+
|
|
7
|
+
namespace :misc do
|
|
8
|
+
task :guard do
|
|
9
|
+
env = self.rails_env.to_s
|
|
10
|
+
|
|
11
|
+
guard = case
|
|
12
|
+
when guard_env.is_a?(Regexp)
|
|
13
|
+
env =~ guard_env
|
|
14
|
+
else
|
|
15
|
+
[guard_env].flatten.map(&:to_sym).include?(rails_env.to_sym)
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
if guard
|
|
19
|
+
res = Capistrano::CLI.ui.ask %Q|Do you realy want to deploy to #{rails_env}, yes/no(no)?: |
|
|
20
|
+
exit unless res =~ /y(es)?/i
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
if Capistrano::Configuration.respond_to?(:instance) && !Capistrano::Configuration.instance.nil?
|
|
30
|
+
CapistranoMisc::Misc::Guard.load_into(Capistrano::Configuration.instance)
|
|
31
|
+
end
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
module CapistranoMisc::Misc
|
|
2
|
+
module Log
|
|
3
|
+
def self.load_into(configuration)
|
|
4
|
+
configuration.load do
|
|
5
|
+
namespace :misc do
|
|
6
|
+
task :log, roles: :app do
|
|
7
|
+
file = ENV['file'] || "*.log"
|
|
8
|
+
run "tail -f #{current_path}/log/#{file}" do |channel, stream, data|
|
|
9
|
+
trap("INT") { puts "Interupted!"; exit 0; }
|
|
10
|
+
puts data
|
|
11
|
+
puts
|
|
12
|
+
break if stream == :err
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
if Capistrano::Configuration.respond_to?(:instance) && !Capistrano::Configuration.instance.nil?
|
|
22
|
+
CapistranoMisc::Misc::Log.load_into(Capistrano::Configuration.instance)
|
|
23
|
+
end
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
module CapistranoMisc
|
|
2
|
+
class Version
|
|
3
|
+
MAJOR = 0 unless defined? CapistranoMisc::Version::MAJOR
|
|
4
|
+
MINOR = 0 unless defined? CapistranoMisc::Version::MINOR
|
|
5
|
+
PATCH = 1 unless defined? CapistranoMisc::Version::PATCH
|
|
6
|
+
PRE = nil unless defined? CapistranoMisc::Version::PRE
|
|
7
|
+
|
|
8
|
+
class << self
|
|
9
|
+
def to_s
|
|
10
|
+
[MAJOR, MINOR, PATCH, PRE].compact.join('.')
|
|
11
|
+
end
|
|
12
|
+
end
|
|
13
|
+
end
|
|
14
|
+
end
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
describe CapistranoMisc::Misc::Branch, 'add branch select' do
|
|
4
|
+
let :configuration do
|
|
5
|
+
configuration = Capistrano::Configuration.new
|
|
6
|
+
CapistranoMisc::Misc::Branch.load_into(configuration)
|
|
7
|
+
configuration.task('deploy:update_code') {}
|
|
8
|
+
configuration.before 'deploy:update_code', 'misc:branch'
|
|
9
|
+
configuration.stub(:scm).and_return('git')
|
|
10
|
+
configuration
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
it 'should skip select deploy branch' do
|
|
14
|
+
configuration.should_not_receive(:run_locally)
|
|
15
|
+
configuration.set :branch, 'something'
|
|
16
|
+
configuration.send('deploy:update_code')
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
it 'should let you select deploy branch' do
|
|
20
|
+
configuration.should_receive(:run_locally).and_return("branch1\nbranch2")
|
|
21
|
+
Capistrano::CLI.ui.should_receive(:ask).with("Choose branch from \n0: Use revision number\n1: branch1\n2: branch2\nq: Quit\n or type tag to deploy (make sure to push the tag first): ").and_return('1')
|
|
22
|
+
configuration.send('deploy:update_code')
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
it 'should let you select revision directly' do
|
|
26
|
+
configuration.should_receive(:run_locally).and_return("")
|
|
27
|
+
Capistrano::CLI.ui.should_receive(:ask).with("Choose branch from \n0: Use revision number\nq: Quit\n or type tag to deploy (make sure to push the tag first): ").and_return('0')
|
|
28
|
+
Capistrano::CLI.ui.should_receive(:ask).with('Type revision or tag to deploy: ').and_return('abcd')
|
|
29
|
+
configuration.send('deploy:update_code')
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
it 'should quit by typing q' do
|
|
33
|
+
configuration.should_receive(:run_locally).and_return("branch1\nbranch2")
|
|
34
|
+
Capistrano::CLI.ui.should_receive(:ask).and_return('q')
|
|
35
|
+
expect {
|
|
36
|
+
configuration.send('deploy:update_code')
|
|
37
|
+
}.to raise_error(SystemExit)
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
it 'should let you select deploy branch' do
|
|
41
|
+
configuration.should_receive(:run_locally).and_return("branch1\nbranch2")
|
|
42
|
+
Capistrano::CLI.ui.should_receive(:ask).and_return('1')
|
|
43
|
+
configuration.send('deploy:update_code')
|
|
44
|
+
configuration.branch.should == 'branch1'
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
it 'should not allow you to deploy specified revisions' do
|
|
48
|
+
configuration.set :branch, /^abc/
|
|
49
|
+
configuration.should_receive(:run_locally).and_return("abc\ndef")
|
|
50
|
+
Capistrano::CLI.ui.should_receive(:ask).with("Choose branch from \n0: Use revision number\n1: abc\nq: Quit\n or type tag to deploy (make sure to push the tag first): ").and_return('0')
|
|
51
|
+
Capistrano::CLI.ui.should_receive(:ask).with('Type revision or tag to deploy: ').and_return('def')
|
|
52
|
+
expect {
|
|
53
|
+
configuration.send('deploy:update_code')
|
|
54
|
+
}.to raise_error(SystemExit)
|
|
55
|
+
end
|
|
56
|
+
end
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
describe CapistranoMisc::Misc::Guard, 'add guard callback' do
|
|
4
|
+
let :configuration do
|
|
5
|
+
configuration = Capistrano::Configuration.new
|
|
6
|
+
CapistranoMisc::Misc::Guard.load_into(configuration)
|
|
7
|
+
configuration.task('multistage:ensure') {}
|
|
8
|
+
configuration.after 'multistage:ensure', 'misc:guard'
|
|
9
|
+
configuration
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
it 'should have default guard env' do
|
|
13
|
+
configuration.guard_env.to_s.should == 'production'
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
it 'should guard a guarded env' do
|
|
17
|
+
configuration.set :guard_env, :guard_env
|
|
18
|
+
|
|
19
|
+
configuration.set :rails_env, :guard_env
|
|
20
|
+
Capistrano::CLI.ui.should_receive(:ask).and_return('y')
|
|
21
|
+
configuration.send('multistage:ensure')
|
|
22
|
+
|
|
23
|
+
configuration.set :rails_env, :no_guard_env
|
|
24
|
+
Capistrano::CLI.ui.should_not_receive(:ask)
|
|
25
|
+
configuration.send('multistage:ensure')
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
it 'should guard multiple guarded envs' do
|
|
29
|
+
configuration.set :guard_env, [:guard_env1, :guard_env2]
|
|
30
|
+
|
|
31
|
+
configuration.set :rails_env, :guard_env1
|
|
32
|
+
Capistrano::CLI.ui.should_receive(:ask).and_return('y')
|
|
33
|
+
configuration.send('multistage:ensure')
|
|
34
|
+
|
|
35
|
+
configuration.set :rails_env, :guard_env2
|
|
36
|
+
Capistrano::CLI.ui.should_receive(:ask).and_return('y')
|
|
37
|
+
configuration.send('multistage:ensure')
|
|
38
|
+
|
|
39
|
+
configuration.set :rails_env, :no_guard_env
|
|
40
|
+
Capistrano::CLI.ui.should_not_receive(:ask)
|
|
41
|
+
configuration.send('multistage:ensure')
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
it 'should guard regexp guarded env' do
|
|
45
|
+
configuration.set :guard_env, /^guard_/
|
|
46
|
+
|
|
47
|
+
configuration.set :rails_env, :guard_env
|
|
48
|
+
Capistrano::CLI.ui.should_receive(:ask).and_return('y')
|
|
49
|
+
configuration.send('multistage:ensure')
|
|
50
|
+
|
|
51
|
+
configuration.set :rails_env, :no_guard_env
|
|
52
|
+
Capistrano::CLI.ui.should_not_receive(:ask)
|
|
53
|
+
configuration.send('multistage:ensure')
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
it 'should guard guarded env' do
|
|
57
|
+
configuration.set :guard_env, :guard_env
|
|
58
|
+
configuration.set :rails_env, :guard_env
|
|
59
|
+
|
|
60
|
+
Capistrano::CLI.ui.should_receive(:ask).and_return('n')
|
|
61
|
+
expect {
|
|
62
|
+
configuration.send('multistage:ensure')
|
|
63
|
+
}.to raise_error(SystemExit)
|
|
64
|
+
|
|
65
|
+
Capistrano::CLI.ui.should_receive(:ask).and_return('y')
|
|
66
|
+
expect {
|
|
67
|
+
configuration.send('multistage:ensure')
|
|
68
|
+
}.not_to raise_error
|
|
69
|
+
end
|
|
70
|
+
end
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
describe CapistranoMisc::Misc::Log, 'add tail task' do
|
|
4
|
+
let :configuration do
|
|
5
|
+
configuration = Capistrano::Configuration.new
|
|
6
|
+
CapistranoMisc::Misc::Log.load_into(configuration)
|
|
7
|
+
configuration.extend Capistrano::Spec::ConfigurationExtension
|
|
8
|
+
configuration.set :current_path, 'current'
|
|
9
|
+
configuration
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
before do
|
|
13
|
+
ENV['target'] = nil
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
it 'should output tail' do
|
|
17
|
+
configuration.stub_command("tail -f current/log/*.log", data: 'hit!')
|
|
18
|
+
STDOUT.should_receive(:puts).with('hit!')
|
|
19
|
+
STDOUT.should_receive(:puts).with(no_args)
|
|
20
|
+
configuration.find_and_execute_task('misc:log')
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
it 'should set target file' do
|
|
24
|
+
ENV['file'] = 'sample.txt'
|
|
25
|
+
configuration.should_receive(:run).with("tail -f current/log/sample.txt")
|
|
26
|
+
configuration.find_and_execute_task('misc:log')
|
|
27
|
+
end
|
|
28
|
+
end
|
data/spec/spec_helper.rb
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
require 'rubygems'
|
|
2
|
+
require 'bundler/setup'
|
|
3
|
+
|
|
4
|
+
if ENV["COVERAGE"]
|
|
5
|
+
require 'simplecov'
|
|
6
|
+
SimpleCov.start do
|
|
7
|
+
add_filter do |src|
|
|
8
|
+
src.filename !~ /#{File.join(root, 'lib')}\//
|
|
9
|
+
end
|
|
10
|
+
end
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
require 'capistrano'
|
|
14
|
+
Capistrano::Configuration.instance = Capistrano::Configuration.new
|
|
15
|
+
require 'capistrano-misc'
|
|
16
|
+
|
|
17
|
+
Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each{ |f| require f }
|
|
18
|
+
|
|
19
|
+
RSpec.configure do |config|
|
|
20
|
+
config.color_enabled = true
|
|
21
|
+
end
|
|
22
|
+
|
metadata
ADDED
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: capistrano-misc
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.0.1
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- Daisuke Taniwaki
|
|
8
|
+
autorequire:
|
|
9
|
+
bindir: bin
|
|
10
|
+
cert_chain: []
|
|
11
|
+
date: 2014-02-08 00:00:00.000000000 Z
|
|
12
|
+
dependencies:
|
|
13
|
+
- !ruby/object:Gem::Dependency
|
|
14
|
+
name: capistrano
|
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
|
16
|
+
requirements:
|
|
17
|
+
- - ~>
|
|
18
|
+
- !ruby/object:Gem::Version
|
|
19
|
+
version: 2.15.0
|
|
20
|
+
type: :runtime
|
|
21
|
+
prerelease: false
|
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
23
|
+
requirements:
|
|
24
|
+
- - ~>
|
|
25
|
+
- !ruby/object:Gem::Version
|
|
26
|
+
version: 2.15.0
|
|
27
|
+
- !ruby/object:Gem::Dependency
|
|
28
|
+
name: appraisal
|
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
|
30
|
+
requirements:
|
|
31
|
+
- - ! '>='
|
|
32
|
+
- !ruby/object:Gem::Version
|
|
33
|
+
version: '0'
|
|
34
|
+
type: :development
|
|
35
|
+
prerelease: false
|
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
37
|
+
requirements:
|
|
38
|
+
- - ! '>='
|
|
39
|
+
- !ruby/object:Gem::Version
|
|
40
|
+
version: '0'
|
|
41
|
+
- !ruby/object:Gem::Dependency
|
|
42
|
+
name: capistrano-spec
|
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
|
44
|
+
requirements:
|
|
45
|
+
- - ! '>='
|
|
46
|
+
- !ruby/object:Gem::Version
|
|
47
|
+
version: '0'
|
|
48
|
+
type: :development
|
|
49
|
+
prerelease: false
|
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
51
|
+
requirements:
|
|
52
|
+
- - ! '>='
|
|
53
|
+
- !ruby/object:Gem::Version
|
|
54
|
+
version: '0'
|
|
55
|
+
- !ruby/object:Gem::Dependency
|
|
56
|
+
name: rspec
|
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
|
58
|
+
requirements:
|
|
59
|
+
- - ! '>='
|
|
60
|
+
- !ruby/object:Gem::Version
|
|
61
|
+
version: '0'
|
|
62
|
+
type: :development
|
|
63
|
+
prerelease: false
|
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
65
|
+
requirements:
|
|
66
|
+
- - ! '>='
|
|
67
|
+
- !ruby/object:Gem::Version
|
|
68
|
+
version: '0'
|
|
69
|
+
- !ruby/object:Gem::Dependency
|
|
70
|
+
name: simplecov
|
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
|
72
|
+
requirements:
|
|
73
|
+
- - ! '>='
|
|
74
|
+
- !ruby/object:Gem::Version
|
|
75
|
+
version: '0'
|
|
76
|
+
type: :development
|
|
77
|
+
prerelease: false
|
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
79
|
+
requirements:
|
|
80
|
+
- - ! '>='
|
|
81
|
+
- !ruby/object:Gem::Version
|
|
82
|
+
version: '0'
|
|
83
|
+
- !ruby/object:Gem::Dependency
|
|
84
|
+
name: rake
|
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
|
86
|
+
requirements:
|
|
87
|
+
- - ! '>='
|
|
88
|
+
- !ruby/object:Gem::Version
|
|
89
|
+
version: '0'
|
|
90
|
+
type: :development
|
|
91
|
+
prerelease: false
|
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
93
|
+
requirements:
|
|
94
|
+
- - ! '>='
|
|
95
|
+
- !ruby/object:Gem::Version
|
|
96
|
+
version: '0'
|
|
97
|
+
description: Useful tasks for Capistrano
|
|
98
|
+
email:
|
|
99
|
+
- daisuketaniwaki@gmail.com
|
|
100
|
+
executables: []
|
|
101
|
+
extensions: []
|
|
102
|
+
extra_rdoc_files: []
|
|
103
|
+
files:
|
|
104
|
+
- .gitignore
|
|
105
|
+
- .travis.yml
|
|
106
|
+
- Appraisals
|
|
107
|
+
- CONTRIBUTING.md
|
|
108
|
+
- Gemfile
|
|
109
|
+
- LICENSE
|
|
110
|
+
- README.md
|
|
111
|
+
- Rakefile
|
|
112
|
+
- capistrano-misc.gemspec
|
|
113
|
+
- gemfiles/cap_2.gemfile
|
|
114
|
+
- gemfiles/cap_2.gemfile.lock
|
|
115
|
+
- lib/capistrano-misc.rb
|
|
116
|
+
- lib/capistrano-misc/misc/branch.rb
|
|
117
|
+
- lib/capistrano-misc/misc/guard.rb
|
|
118
|
+
- lib/capistrano-misc/misc/log.rb
|
|
119
|
+
- lib/capistrano-misc/version.rb
|
|
120
|
+
- spec/capistrano-misc/misc/branch_spec.rb
|
|
121
|
+
- spec/capistrano-misc/misc/guard_spec.rb
|
|
122
|
+
- spec/capistrano-misc/misc/log_spec.rb
|
|
123
|
+
- spec/capistrano-misc_spec.rb
|
|
124
|
+
- spec/spec_helper.rb
|
|
125
|
+
- spec/support/capistrano.rb
|
|
126
|
+
homepage: https://github.com/dtaniwaki/capistrano-misc
|
|
127
|
+
licenses:
|
|
128
|
+
- MIT
|
|
129
|
+
metadata: {}
|
|
130
|
+
post_install_message:
|
|
131
|
+
rdoc_options: []
|
|
132
|
+
require_paths:
|
|
133
|
+
- lib
|
|
134
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
135
|
+
requirements:
|
|
136
|
+
- - ! '>='
|
|
137
|
+
- !ruby/object:Gem::Version
|
|
138
|
+
version: '0'
|
|
139
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
140
|
+
requirements:
|
|
141
|
+
- - ! '>='
|
|
142
|
+
- !ruby/object:Gem::Version
|
|
143
|
+
version: '0'
|
|
144
|
+
requirements: []
|
|
145
|
+
rubyforge_project:
|
|
146
|
+
rubygems_version: 2.1.11
|
|
147
|
+
signing_key:
|
|
148
|
+
specification_version: 4
|
|
149
|
+
summary: Useful tasks for Capistrano
|
|
150
|
+
test_files:
|
|
151
|
+
- spec/capistrano-misc/misc/branch_spec.rb
|
|
152
|
+
- spec/capistrano-misc/misc/guard_spec.rb
|
|
153
|
+
- spec/capistrano-misc/misc/log_spec.rb
|
|
154
|
+
- spec/capistrano-misc_spec.rb
|
|
155
|
+
- spec/spec_helper.rb
|
|
156
|
+
- spec/support/capistrano.rb
|