capistrano-misc 0.0.4 → 0.0.5

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 CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- NzBhNGE1NjA0Zjc5ZjM2YzI4MDA1NzU1MTcwOTBmZGFhMDY0OGU4MQ==
4
+ YmRhMDE5NDg4ZWM2NzlkY2M4NTRjNjU3YTIxY2UwZTVmM2FhMmZmZg==
5
5
  data.tar.gz: !binary |-
6
- MTY3NDgzYTZmNWMxYzI5NTg4OWE4YzRhMWRiNzZiYzcyNGUyNDlhOQ==
6
+ MzYxZTU4NjRiMjZmZWQ0MGM3NmVjMThkMjQwOTc3ZWQ2MzE2YTAwNw==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- OGVjZmM2ZWMyMTA3Mzg2OTEwN2ZkMWEyZTVmNDgwODE4OTBmNmI5Y2QyNTNh
10
- OTQ0YTBiZDljZDUyMzE3ZDgwNGNkMGFiZTE0ZTk1NWM1NzExMmIxNzE4NDU2
11
- MjFlNjBhYzNjNjEwNGFlOGFlMDY5OWJjYzA0NDBmOTMwMjA3NGQ=
9
+ N2ZjMmNjZDU1OWJmOGM3ZmJiYWZmNjc5ZTIwYjliYWQzOThmM2QwMGQxZDY5
10
+ YThlNDExYTA1YTg1ZTgyYmNmYzZlZGNkZDE2YWNjNTg3MmM2OWEzMzA1ZTlh
11
+ YTliM2Q1OGMyNTEzNmMyZmYwODViMTgyYjc4NTYzZmI4Y2VmNDA=
12
12
  data.tar.gz: !binary |-
13
- NDY4OTcxNTI3YmJkMTZkMDY4NWNjNzQ5MmUwOTgzMjYxYmIzYTIzMzFkYTE5
14
- N2ZkYTUzMjZhMDIwMjRhMzZiYWE0YzkxYzU2MDI0M2M1MjFkZjgyYjE0ZjE4
15
- NTZiZWQ1MTk3NWU1OGI2ZTllZGE1MDVmMDhhNWMzYjc0ZTQ1ZGY=
13
+ ZWQwMzhmMGNlYTFhNTZkYjZiOTM3YjQ2NGFhZTUzMDFmOWRmYzllMjAwZjUz
14
+ YmM2ZDZhN2FhM2Q4NmE2ZGNmNzI2MTU5OTc5YjViYjE1N2Q5MzM3NWY0MzRk
15
+ MjAyYzRlODQ4OTg1NzQ3YTQyYjVlNThkYjNlZDk4Njk3YzA1Zjg=
data/README.md CHANGED
@@ -22,13 +22,16 @@ require 'capistrano-misc'
22
22
 
23
23
  Execute tasks
24
24
  ```ruby
25
- cap misc:log
25
+ cap misc:tailf
26
26
  ```
27
27
 
28
28
  Add task hooks
29
29
  ```ruby
30
30
  after 'multistage:ensure', 'misc:guard'
31
+ set :guard_env, [:production, :beta] # default :production
32
+
31
33
  before 'deploy:update_code', 'misc:branch'
34
+ set :branch, /upstream.*\/master$/ # default all
32
35
  ```
33
36
 
34
37
  ## Contributing
@@ -3,6 +3,7 @@ module CapistranoMisc::Misc
3
3
  def self.load_into(configuration)
4
4
  configuration.load do
5
5
  namespace :misc do
6
+ desc 'Select branch to deploy from console'
6
7
  task :branch do
7
8
  branch = fetch(:branch, nil)
8
9
  next if branch.is_a?(String)
@@ -5,6 +5,7 @@ module CapistranoMisc::Misc
5
5
  set :guard_env, :production
6
6
 
7
7
  namespace :misc do
8
+ desc 'Guard specified env from accidentally execution'
8
9
  task :guard do
9
10
  env = self.rails_env.to_s
10
11
 
@@ -1,11 +1,14 @@
1
1
  module CapistranoMisc::Misc
2
- module Log
2
+ module Tailf
3
3
  def self.load_into(configuration)
4
4
  configuration.load do
5
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|
6
+ desc 'tailf in all the servers'
7
+ task :tailf, roles: :app do
8
+ file = ENV['tailf_file'] || fetch(:tailf_file, nil) || "*.log"
9
+ dir = fetch(:tailf_dir, "#{current_path}/log")
10
+ path = File.join(dir, file)
11
+ run "tail -f #{path}" do |channel, stream, data|
9
12
  trap("INT") { puts "Interupted!"; exit 0; }
10
13
  puts data
11
14
  puts
@@ -19,5 +22,5 @@ module CapistranoMisc::Misc
19
22
  end
20
23
 
21
24
  if Capistrano::Configuration.respond_to?(:instance) && !Capistrano::Configuration.instance.nil?
22
- CapistranoMisc::Misc::Log.load_into(Capistrano::Configuration.instance)
25
+ CapistranoMisc::Misc::Tailf.load_into(Capistrano::Configuration.instance)
23
26
  end
@@ -2,7 +2,7 @@ module CapistranoMisc
2
2
  class Version
3
3
  MAJOR = 0 unless defined? CapistranoMisc::Version::MAJOR
4
4
  MINOR = 0 unless defined? CapistranoMisc::Version::MINOR
5
- PATCH = 4 unless defined? CapistranoMisc::Version::PATCH
5
+ PATCH = 5 unless defined? CapistranoMisc::Version::PATCH
6
6
  PRE = nil unless defined? CapistranoMisc::Version::PRE
7
7
 
8
8
  class << self
@@ -0,0 +1,40 @@
1
+ require 'spec_helper'
2
+
3
+ describe CapistranoMisc::Misc::Tailf, 'add tail task' do
4
+ let :configuration do
5
+ configuration = Capistrano::Configuration.new
6
+ CapistranoMisc::Misc::Tailf.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['tailf_file'] = 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:tailf')
21
+ end
22
+
23
+ it 'should set target file by argv' do
24
+ ENV['tailf_file'] = 'sample.txt'
25
+ configuration.should_receive(:run).with("tail -f current/log/sample.txt")
26
+ configuration.find_and_execute_task('misc:tailf')
27
+ end
28
+
29
+ it 'should set target file by set variable' do
30
+ configuration.should_receive(:run).with("tail -f current/log/sample.out")
31
+ configuration.set :tailf_file, 'sample.out'
32
+ configuration.find_and_execute_task('misc:tailf')
33
+ end
34
+
35
+ it 'should set log dir' do
36
+ configuration.should_receive(:run).with("tail -f /glog/*.log")
37
+ configuration.set :tailf_dir, '/glog'
38
+ configuration.find_and_execute_task('misc:tailf')
39
+ end
40
+ end
data/spec/spec_helper.rb CHANGED
@@ -18,5 +18,8 @@ Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each{ |f| require f }
18
18
 
19
19
  RSpec.configure do |config|
20
20
  config.color_enabled = true
21
+ config.before :each do
22
+ configuration.logger = Capistrano::Logger.new(:output => '/dev/null')
23
+ end
21
24
  end
22
25
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: capistrano-misc
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daisuke Taniwaki
@@ -100,11 +100,11 @@ files:
100
100
  - lib/capistrano-misc.rb
101
101
  - lib/capistrano-misc/misc/branch.rb
102
102
  - lib/capistrano-misc/misc/guard.rb
103
- - lib/capistrano-misc/misc/log.rb
103
+ - lib/capistrano-misc/misc/tailf.rb
104
104
  - lib/capistrano-misc/version.rb
105
105
  - spec/capistrano-misc/misc/branch_spec.rb
106
106
  - spec/capistrano-misc/misc/guard_spec.rb
107
- - spec/capistrano-misc/misc/log_spec.rb
107
+ - spec/capistrano-misc/misc/tailf_spec.rb
108
108
  - spec/capistrano-misc_spec.rb
109
109
  - spec/spec_helper.rb
110
110
  - spec/support/capistrano.rb
@@ -135,7 +135,7 @@ summary: Useful tasks for Capistrano
135
135
  test_files:
136
136
  - spec/capistrano-misc/misc/branch_spec.rb
137
137
  - spec/capistrano-misc/misc/guard_spec.rb
138
- - spec/capistrano-misc/misc/log_spec.rb
138
+ - spec/capistrano-misc/misc/tailf_spec.rb
139
139
  - spec/capistrano-misc_spec.rb
140
140
  - spec/spec_helper.rb
141
141
  - spec/support/capistrano.rb
@@ -1,28 +0,0 @@
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