capistrano-migeorge-formatter 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 9e55b1e99f1892613a7dd515ce4aec7e3927e067
4
+ data.tar.gz: 6213d6168b1ff3607d969d6eab0bdcef82bc52e9
5
+ SHA512:
6
+ metadata.gz: 6ff906bf36d33222b24b56f6849aefc983a31a11b9f95bad086a7d9c0c42e8bdf8619bbd5a7137cb252914b05e33adccb326a07b7349fa19060a057f429396d0
7
+ data.tar.gz: 69730dcbcb4a901b5f603cb8ba15d3ddbb4d3f8f2efde0ccc60a01ecafb228f260f9aec7d83cf5b8e4c9adfe889c973075288fe87fbe64888b5e23537d781cf2
data/.gitignore ADDED
@@ -0,0 +1,14 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ *.bundle
11
+ *.so
12
+ *.o
13
+ *.a
14
+ mkmf.log
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in capistrano-compact-formatter.gemspec
4
+ gemspec
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 MiGeorge 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 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-migeorge-formatter'
24
+ ```
25
+
26
+ Or install it yourself as:
27
+
28
+ $ gem install capistrano-migeorge-formatter
29
+
30
+ ## Usage
31
+
32
+ And require it in your `Capfile`
33
+
34
+ ```ruby
35
+ # Capfile
36
+
37
+ require 'capistrano-migeorge-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,2 @@
1
+ require 'bundler/gem_tasks'
2
+
@@ -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-migeorge-formatter/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = 'capistrano-migeorge-formatter'
8
+ spec.version = CapistranoMigeorgeFormatter::VERSION
9
+ spec.authors = ['Miguel Palhas', 'Mike George']
10
+ spec.email = ['mike@tallduck.com']
11
+ spec.summary = %q{A compact custom formatter for capistrano 3}
12
+ spec.description = %q{A compact custom formatter for capistrano 3}
13
+ spec.homepage = 'https://github.com/migeorge/capistrano-migeorge-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,2 @@
1
+ require 'capistrano-migeorge-formatter/version'
2
+ require 'sshkit/formatter/compact'
@@ -0,0 +1,3 @@
1
+ module CapistranoMigeorgeFormatter
2
+ VERSION = '0.0.2'
3
+ 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('\u2717') : c.green('\u2713') }
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 << "\n-> #{log_message.to_s}\n"
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,97 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: capistrano-migeorge-formatter
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.2
5
+ platform: ruby
6
+ authors:
7
+ - Miguel Palhas
8
+ - Mike George
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2015-05-05 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: sshkit
16
+ requirement: !ruby/object:Gem::Requirement
17
+ requirements:
18
+ - - "~>"
19
+ - !ruby/object:Gem::Version
20
+ version: '1.3'
21
+ type: :runtime
22
+ prerelease: false
23
+ version_requirements: !ruby/object:Gem::Requirement
24
+ requirements:
25
+ - - "~>"
26
+ - !ruby/object:Gem::Version
27
+ version: '1.3'
28
+ - !ruby/object:Gem::Dependency
29
+ name: bundler
30
+ requirement: !ruby/object:Gem::Requirement
31
+ requirements:
32
+ - - "~>"
33
+ - !ruby/object:Gem::Version
34
+ version: '1.7'
35
+ type: :development
36
+ prerelease: false
37
+ version_requirements: !ruby/object:Gem::Requirement
38
+ requirements:
39
+ - - "~>"
40
+ - !ruby/object:Gem::Version
41
+ version: '1.7'
42
+ - !ruby/object:Gem::Dependency
43
+ name: rake
44
+ requirement: !ruby/object:Gem::Requirement
45
+ requirements:
46
+ - - "~>"
47
+ - !ruby/object:Gem::Version
48
+ version: '10.0'
49
+ type: :development
50
+ prerelease: false
51
+ version_requirements: !ruby/object:Gem::Requirement
52
+ requirements:
53
+ - - "~>"
54
+ - !ruby/object:Gem::Version
55
+ version: '10.0'
56
+ description: A compact custom formatter for capistrano 3
57
+ email:
58
+ - mike@tallduck.com
59
+ executables: []
60
+ extensions: []
61
+ extra_rdoc_files: []
62
+ files:
63
+ - ".gitignore"
64
+ - Gemfile
65
+ - LICENSE.txt
66
+ - README.md
67
+ - Rakefile
68
+ - capistrano-migeorge-formatter.gemspec
69
+ - lib/capistrano-migeorge-formatter.rb
70
+ - lib/capistrano-migeorge-formatter/version.rb
71
+ - lib/sshkit/formatter/compact.rb
72
+ - sample-output.png
73
+ homepage: https://github.com/migeorge/capistrano-migeorge-formatter
74
+ licenses:
75
+ - MIT
76
+ metadata: {}
77
+ post_install_message:
78
+ rdoc_options: []
79
+ require_paths:
80
+ - lib
81
+ required_ruby_version: !ruby/object:Gem::Requirement
82
+ requirements:
83
+ - - ">="
84
+ - !ruby/object:Gem::Version
85
+ version: '0'
86
+ required_rubygems_version: !ruby/object:Gem::Requirement
87
+ requirements:
88
+ - - ">="
89
+ - !ruby/object:Gem::Version
90
+ version: '0'
91
+ requirements: []
92
+ rubyforge_project:
93
+ rubygems_version: 2.4.5
94
+ signing_key:
95
+ specification_version: 4
96
+ summary: A compact custom formatter for capistrano 3
97
+ test_files: []