From 6b6a0317a732a4cb27ea33a067a6417f6aab0723 Mon Sep 17 00:00:00 2001 From: Matt Brictson Date: Thu, 19 Feb 2015 19:45:30 -0800 Subject: [PATCH] Initial commit --- .gitignore | 14 ++++++ .travis.yml | 3 ++ Gemfile | 4 ++ LICENSE.txt | 22 +++++++++ README.md | 98 ++++++++++++++++++++++++++++++++++++++++ Rakefile | 8 ++++ airbrussh.gemspec | 28 ++++++++++++ lib/airbrussh.rb | 5 ++ lib/airbrussh/version.rb | 3 ++ test/minitest_helper.rb | 11 +++++ test/test_airbrussh.rb | 11 +++++ 11 files changed, 207 insertions(+) create mode 100644 .gitignore create mode 100644 .travis.yml create mode 100644 Gemfile create mode 100644 LICENSE.txt create mode 100644 README.md create mode 100644 Rakefile create mode 100644 airbrussh.gemspec create mode 100644 lib/airbrussh.rb create mode 100644 lib/airbrussh/version.rb create mode 100644 test/minitest_helper.rb create mode 100644 test/test_airbrussh.rb diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..ae3fdc2 --- /dev/null +++ b/.gitignore @@ -0,0 +1,14 @@ +/.bundle/ +/.yardoc +/Gemfile.lock +/_yardoc/ +/coverage/ +/doc/ +/pkg/ +/spec/reports/ +/tmp/ +*.bundle +*.so +*.o +*.a +mkmf.log diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..457cdc9 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,3 @@ +language: ruby +rvm: + - 2.2.0 diff --git a/Gemfile b/Gemfile new file mode 100644 index 0000000..79e4700 --- /dev/null +++ b/Gemfile @@ -0,0 +1,4 @@ +source "https://rubygems.org" + +# Specify your gem's dependencies in airbrussh.gemspec +gemspec diff --git a/LICENSE.txt b/LICENSE.txt new file mode 100644 index 0000000..54b6742 --- /dev/null +++ b/LICENSE.txt @@ -0,0 +1,22 @@ +Copyright (c) 2015 Matt Brictson + +MIT License + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +"Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/README.md b/README.md new file mode 100644 index 0000000..5d73d16 --- /dev/null +++ b/README.md @@ -0,0 +1,98 @@ +# Airbrussh + +**Airbrussh is a replacement log formatter for SSHKit that makes your Capistrano output much easier on the eyes.** Just add it to your Capfile and enjoy concise, useful log output that is easy to read. + +And don't worry: airbrussh saves Capistrano's default verbose output to a separate log file just in case you still need it for troubleshooting. + +*TODO: animated GIF of airbrusshed output goes here!* + +## Installation + +Add this line to your application's Gemfile: + +```ruby +gem "airbrussh", :require => false +``` + +And then execute: + + $ bundle + +Finally, add this line to your application's Capfile: + +```ruby +require "airbrussh/capistrano" +``` + +## Usage + +Airbrussh automatically replaces the default Capistrano log formatter, so there is nothing more you have to do. Just run `cap` as normal and enjoy the prettier output! + +**Advanced:** Airbrussh can be configured by calling `Airbrussh.configure` in your `deploy.rb` file. You can do stage-specific configuration in e.g. `deploy/production.rb` as well. Here are the available options: + +```ruby +Airbrussh.configure do |config| + # Capistrano's default, un-airbrusshed output is saved to a file to + # facilitate debugging. To disable this entirely: + # config.log_file = nil + # You can also provide an IO object: + # config.log_file = $stderr + # Default: + config.log_file = "log/capistrano.log" + + # Airbrussh patches Rake so it can access the name of the currently executing + # task. Set this to false if monkey patching is causing issues. + # Default: + config.monkey_patch_rake = true + + # Ansi colors will be used in the output automatically based on whether the + # output is a TTY, or if the SSHKIT_COLOR environment variable is set. + # To disable color always: + # config.color = false + # Default: + config.color = :auto + + # Output is automatically truncated to the width of the terminal window, if + # possible. If the width of the terminal can't be determined, no truncation + # is performed. To truncate to a fixed with: + # config.truncate = 80 + # Or to disable truncation entirely: + # config.truncate = false + # Default: + config.truncate = :auto +end +``` + +## Usage outside of Capistrano + +If you are using SSHKit directly, you can use Airbrussh without the Capistrano magic: + +```ruby +require "airbrussh" +SSHKit.config.output = Airbrussh::Formatter.new +``` + +When Capistrano is not present, Airbrussh uses a slightly different default configuration: + +```ruby +Airbrussh.configure do |config| + config.log_file = nil + config.monkey_patch_rake = false + config.color = :auto + config.truncate = :auto +end +``` + +## History + +Airbrussh started life as custom logging code within the [capistrano-fiftyfive][] collection of opinionated Capistrano recipes. In February 2015, the logging code was refactored into a standalone gem with its own configuration and documentation, and renamed `airbrussh`. Now anyone can using SSHKit or Capistrano can safely plug it into their projects! + +## Contributing + +1. Fork it ( https://github.com/[my-github-username]/airbrussh/fork ) +2. Create your feature branch (`git checkout -b my-new-feature`) +3. Commit your changes (`git commit -am 'Add some feature'`) +4. Push to the branch (`git push origin my-new-feature`) +5. Create a new Pull Request + +[capistrano-fiftyfive]: https://github.com/mattbrictson/capistrano-fiftyfive diff --git a/Rakefile b/Rakefile new file mode 100644 index 0000000..60eb08b --- /dev/null +++ b/Rakefile @@ -0,0 +1,8 @@ +require "bundler/gem_tasks" +require "rake/testtask" + +Rake::TestTask.new(:test) do |t| + t.libs << "test" +end + +task :default => :test diff --git a/airbrussh.gemspec b/airbrussh.gemspec new file mode 100644 index 0000000..306a242 --- /dev/null +++ b/airbrussh.gemspec @@ -0,0 +1,28 @@ +# coding: utf-8 +lib = File.expand_path("../lib", __FILE__) +$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) +require "airbrussh/version" + +Gem::Specification.new do |spec| + spec.name = "airbrussh" + spec.version = Airbrussh::VERSION + spec.authors = ["Matt Brictson"] + spec.email = ["airbrussh@mattbrictson.com"] + spec.summary = "Airbrussh pretties up your SSHKit and Capistrano output" + spec.description = "Airbrussh is a replacement log formatter for SSHKit "\ + "that makes your Capistrano output much easier on the "\ + "eyes. Just add it to your Capfile and enjoy concise, "\ + "useful log output that is easy to read." + spec.homepage = "https://github.com/mattbrictson/airbrussh" + spec.license = "MIT" + + spec.files = `git ls-files -z`.split("\x0") + spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) } + spec.test_files = spec.files.grep(%r{^(test|spec|features)/}) + spec.require_paths = ["lib"] + + spec.add_development_dependency "bundler", "~> 1.7" + spec.add_development_dependency "rake", "~> 10.0" + spec.add_development_dependency "minitest" + spec.add_development_dependency "minitest-reporters" +end diff --git a/lib/airbrussh.rb b/lib/airbrussh.rb new file mode 100644 index 0000000..99c4bb6 --- /dev/null +++ b/lib/airbrussh.rb @@ -0,0 +1,5 @@ +require "airbrussh/version" + +module Airbrussh + # Your code goes here... +end diff --git a/lib/airbrussh/version.rb b/lib/airbrussh/version.rb new file mode 100644 index 0000000..e001155 --- /dev/null +++ b/lib/airbrussh/version.rb @@ -0,0 +1,3 @@ +module Airbrussh + VERSION = "0.0.1" +end diff --git a/test/minitest_helper.rb b/test/minitest_helper.rb new file mode 100644 index 0000000..6195ac8 --- /dev/null +++ b/test/minitest_helper.rb @@ -0,0 +1,11 @@ +$LOAD_PATH.unshift File.expand_path("../../lib", __FILE__) +require "airbrussh" + +require "minitest/autorun" +require "minitest/reporters" + +Minitest::Reporters.use!( + Minitest::Reporters::ProgressReporter.new, + ENV, + Minitest.backtrace_filter +) diff --git a/test/test_airbrussh.rb b/test/test_airbrussh.rb new file mode 100644 index 0000000..ece1664 --- /dev/null +++ b/test/test_airbrussh.rb @@ -0,0 +1,11 @@ +require "minitest_helper" + +class TestAirbrussh < MiniTest::Unit::TestCase + def test_that_it_has_a_version_number + refute_nil ::Airbrussh::VERSION + end + + def test_it_does_something_useful + assert false + end +end