capistrano-compact-formatter 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +14 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +56 -0
- data/Rakefile +2 -0
- data/capistrano-compact-formatter.gemspec +25 -0
- data/lib/capistrano-compact-formatter.rb +2 -0
- data/lib/capistrano-compact-formatter/version.rb +3 -0
- data/lib/sshkit/formatter/compact.rb +74 -0
- data/sample-output.png +0 -0
- metadata +96 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 80c6060c648bcb4a580a9af765e190b9aeeaa1ed
|
4
|
+
data.tar.gz: 8d6d900c7d816e2eb3ede84c9bb27d7839019e68
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: e5685429e25b90176f518aa2a69d7f1d216506bc6d5578c622fc681b9af34dbae55dcc55c4ddc6de0cffd566f91859233d96b0829cf2c9e355a4e8bb19be94e6
|
7
|
+
data.tar.gz: 13d3d7edf1684fcd4be3b9879abd9f2c907ca5f3d462f7e425a4c23ee67e536b0b3453cb9545e84594267166788a7fb4f6ad18ae1e95e8a471f6f286e8a7b613
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2015 Miguel Palhas
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,56 @@
|
|
1
|
+
# Capistrano Compact Formatter
|
2
|
+
|
3
|
+
Custom formatter for Capistrano 3, with compact output, and opinionated according to my own needs.
|
4
|
+
|
5
|
+
I don't like the built-in formatters from sshkit. They're too verbose in debug mode, but too little verbose otherwise. Everytime an error occurred while using `set :debug, :info`, I would find myself changing it back to `:debug` to see the actual error messages.
|
6
|
+
|
7
|
+
A quick breakdown of what it does:
|
8
|
+
|
9
|
+
* no difference for each log level. I might add this in the future, but at this point, I didn't feel the need;
|
10
|
+
* each command is printed in a single line, containing a trimmed message and a success flag;
|
11
|
+
* if a command has output in stdout/stderr, it will be printed below, with a leading tab, in green/red respectively;
|
12
|
+
* conditional commands (i.e. commands with the format `[ some_bash_condition ]`) will not be printed. They return frequently return false, which would output a red failure flag. I find that misleading, since it doesn't mean the deploy failed. It's merely a condition that evaluated to false.
|
13
|
+
|
14
|
+
Sample output:
|
15
|
+
|
16
|
+
![Sample Output](sample-output.png)
|
17
|
+
|
18
|
+
## Installation
|
19
|
+
|
20
|
+
Add this line to your application's Gemfile:
|
21
|
+
|
22
|
+
```ruby
|
23
|
+
gem 'capistrano-compact-formatter'
|
24
|
+
```
|
25
|
+
|
26
|
+
Or install it yourself as:
|
27
|
+
|
28
|
+
$ gem install capistrano-compact-formatter
|
29
|
+
|
30
|
+
## Usage
|
31
|
+
|
32
|
+
And require it in your `Capfile`
|
33
|
+
|
34
|
+
```ruby
|
35
|
+
# Capfile
|
36
|
+
|
37
|
+
require 'capistrano-compact-formatter'
|
38
|
+
```
|
39
|
+
|
40
|
+
Then in your `config/deploy.rb`, specify the formatter to use:
|
41
|
+
|
42
|
+
```ruby
|
43
|
+
# config/deploy.rb
|
44
|
+
|
45
|
+
set :format, :compact
|
46
|
+
```
|
47
|
+
|
48
|
+
And you're all set!
|
49
|
+
|
50
|
+
## Contributing
|
51
|
+
|
52
|
+
1. Fork it ( https://github.com/[my-github-username]/capistrano-compact-formatter/fork )
|
53
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
54
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
55
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
56
|
+
5. Create a new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'capistrano-compact-formatter/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = 'capistrano-compact-formatter'
|
8
|
+
spec.version = CapistranoCompactFormatter::VERSION
|
9
|
+
spec.authors = ['Miguel Palhas']
|
10
|
+
spec.email = ['mpalhas@gmail.com']
|
11
|
+
spec.summary = %q{A compact formatter for capistrano 3}
|
12
|
+
spec.description = %q{A compact formatter for capistrano 3}
|
13
|
+
spec.homepage = 'https://github.com/naps62/capistrano-compact-formatter'
|
14
|
+
spec.license = 'MIT'
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0")
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ['lib']
|
20
|
+
|
21
|
+
spec.add_dependency 'sshkit', '~> 1.3'
|
22
|
+
|
23
|
+
spec.add_development_dependency 'bundler', '~> 1.7'
|
24
|
+
spec.add_development_dependency 'rake', '~> 10.0'
|
25
|
+
end
|
@@ -0,0 +1,74 @@
|
|
1
|
+
module SSHKit
|
2
|
+
module Formatter
|
3
|
+
class Compact < Abstract
|
4
|
+
CMD_LEN = 80
|
5
|
+
CMD_SPACE = 10
|
6
|
+
|
7
|
+
def initialize(*args)
|
8
|
+
super
|
9
|
+
@stdout = StringIO.new
|
10
|
+
@stderr = StringIO.new
|
11
|
+
end
|
12
|
+
|
13
|
+
def write(obj)
|
14
|
+
case obj
|
15
|
+
when SSHKit::Command then write_command(obj)
|
16
|
+
when SSHKit::LogMessage then write_log_message(obj)
|
17
|
+
else
|
18
|
+
original_output << c.black(c.on_yellow("Output formatter doesn't know how to handle #{obj.class}\n"))
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
alias :<< :write
|
23
|
+
|
24
|
+
private
|
25
|
+
|
26
|
+
def write_command(command)
|
27
|
+
return if command.to_command[0] == '['
|
28
|
+
|
29
|
+
command_start = pretty_command(command)[0..CMD_LEN-1].ljust(CMD_LEN).gsub(/[^\s]{3}$/, '...').ljust(CMD_LEN+CMD_SPACE)
|
30
|
+
|
31
|
+
if !command.started?
|
32
|
+
original_output << c.blue(command_start)
|
33
|
+
end
|
34
|
+
|
35
|
+
|
36
|
+
@stdout << formatted_stream(command.stdout)
|
37
|
+
@stderr << formatted_stream(command.stderr)
|
38
|
+
|
39
|
+
if command.finished?
|
40
|
+
original_output << c.bold { command.failure? ? c.red('failure') : c.green('success') }
|
41
|
+
original_output << "\n"
|
42
|
+
|
43
|
+
if command.failure?
|
44
|
+
original_output << c.red(command.to_command)
|
45
|
+
end
|
46
|
+
|
47
|
+
original_output << c.green(@stdout.string)
|
48
|
+
original_output << c.red(@stderr.string)
|
49
|
+
|
50
|
+
@stdout = StringIO.new
|
51
|
+
@stderr = StringIO.new
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
def write_log_message(log_message)
|
56
|
+
original_output << " #{log_message.to_s}"
|
57
|
+
end
|
58
|
+
|
59
|
+
def c
|
60
|
+
Color
|
61
|
+
end
|
62
|
+
|
63
|
+
def pretty_command(command)
|
64
|
+
"#{command.command} #{command.args.join(' ')}"
|
65
|
+
end
|
66
|
+
|
67
|
+
def formatted_stream(stream)
|
68
|
+
stream.lines.map do |line|
|
69
|
+
"\t#{line}"
|
70
|
+
end.join('\n')
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
data/sample-output.png
ADDED
Binary file
|
metadata
ADDED
@@ -0,0 +1,96 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: capistrano-compact-formatter
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Miguel Palhas
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-02-03 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: sshkit
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.3'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.3'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: bundler
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1.7'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.7'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rake
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '10.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '10.0'
|
55
|
+
description: A compact formatter for capistrano 3
|
56
|
+
email:
|
57
|
+
- mpalhas@gmail.com
|
58
|
+
executables: []
|
59
|
+
extensions: []
|
60
|
+
extra_rdoc_files: []
|
61
|
+
files:
|
62
|
+
- ".gitignore"
|
63
|
+
- Gemfile
|
64
|
+
- LICENSE.txt
|
65
|
+
- README.md
|
66
|
+
- Rakefile
|
67
|
+
- capistrano-compact-formatter.gemspec
|
68
|
+
- lib/capistrano-compact-formatter.rb
|
69
|
+
- lib/capistrano-compact-formatter/version.rb
|
70
|
+
- lib/sshkit/formatter/compact.rb
|
71
|
+
- sample-output.png
|
72
|
+
homepage: https://github.com/naps62/capistrano-compact-formatter
|
73
|
+
licenses:
|
74
|
+
- MIT
|
75
|
+
metadata: {}
|
76
|
+
post_install_message:
|
77
|
+
rdoc_options: []
|
78
|
+
require_paths:
|
79
|
+
- lib
|
80
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
81
|
+
requirements:
|
82
|
+
- - ">="
|
83
|
+
- !ruby/object:Gem::Version
|
84
|
+
version: '0'
|
85
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
requirements: []
|
91
|
+
rubyforge_project:
|
92
|
+
rubygems_version: 2.4.5
|
93
|
+
signing_key:
|
94
|
+
specification_version: 4
|
95
|
+
summary: A compact formatter for capistrano 3
|
96
|
+
test_files: []
|