3a516de9 by Jeff Balicki

Drop files from .gitignore

1 parent 1907bd8c
Showing 1000 changed files with 0 additions and 3151 deletions

Too many changes to show.

To preserve performance only 1000 of 1000+ files are displayed.

No preview for this file type
DB_HOST=127.0.0.1
DB_NAME=commonwell_broker
DB_USER=root
DB_PASS=jeff518862
merchant_id = "376299332"
api_id = "bdE8c883e75941978540fab06b857C7B"
external_payment_client_id = "i3dgneUrHPXFyfDQWCyueNmNcI5uh441"
external_payment_client_secret = "0TtB9dgxvXZYSk7QjI8Ib15Q29Bl-wZYHjW-V1O3vrxAa$
external_payment_audience = "https://cmig-dev-payment-service.insurcloud.ca/"
external_payment = "https://api-dev03.nonprod.cmig.insurcloud.ca/payment-online$
external_payment_token = "https://insurcloud-dev.auth0.com/oauth/token"
\ No newline at end of file
No preview for this file type
<?php
// autoload.php @generated by Composer
require_once __DIR__ . '/composer/autoload_real.php';
return ComposerAutoloaderInitc870c977e69b00574a49c4be5d77a175::getLoader();
#!/usr/bin/env ruby
#
# This file was generated by RubyGems.
#
# The application 'bundler' is installed as part of a gem, and
# this file is here to facilitate running it.
#
require 'rubygems'
version = ">= 0.a"
str = ARGV.first
if str
str = str.b[/\A_(.*)_\z/, 1]
if str and Gem::Version.correct?(str)
version = str
ENV['BUNDLER_VERSION'] = str
ARGV.shift
end
end
if Gem.respond_to?(:activate_bin_path)
load Gem.activate_bin_path('bundler', 'bundle', version)
else
gem "bundler", version
load Gem.bin_path("bundler", "bundle", version)
end
#!/usr/bin/env ruby
#
# This file was generated by RubyGems.
#
# The application 'bundler' is installed as part of a gem, and
# this file is here to facilitate running it.
#
require 'rubygems'
version = ">= 0.a"
str = ARGV.first
if str
str = str.b[/\A_(.*)_\z/, 1]
if str and Gem::Version.correct?(str)
version = str
ENV['BUNDLER_VERSION'] = str
ARGV.shift
end
end
if Gem.respond_to?(:activate_bin_path)
load Gem.activate_bin_path('bundler', 'bundler', version)
else
gem "bundler", version
load Gem.bin_path("bundler", "bundler", version)
end
#!/usr/bin/env ruby
#
# This file was generated by RubyGems.
#
# The application 'capistrano' is installed as part of a gem, and
# this file is here to facilitate running it.
#
require 'rubygems'
Gem.use_gemdeps
version = ">= 0.a"
str = ARGV.first
if str
str = str.b[/\A_(.*)_\z/, 1]
if str and Gem::Version.correct?(str)
version = str
ARGV.shift
end
end
if Gem.respond_to?(:activate_bin_path)
load Gem.activate_bin_path('capistrano', 'cap', version)
else
gem "capistrano", version
load Gem.bin_path("capistrano", "cap", version)
end
#!/usr/bin/env ruby
#
# This file was generated by RubyGems.
#
# The application 'capistrano' is installed as part of a gem, and
# this file is here to facilitate running it.
#
require 'rubygems'
Gem.use_gemdeps
version = ">= 0.a"
str = ARGV.first
if str
str = str.b[/\A_(.*)_\z/, 1]
if str and Gem::Version.correct?(str)
version = str
ARGV.shift
end
end
if Gem.respond_to?(:activate_bin_path)
load Gem.activate_bin_path('capistrano', 'capify', version)
else
gem "capistrano", version
load Gem.bin_path("capistrano", "capify", version)
end
#!/usr/bin/env ruby
#
# This file was generated by RubyGems.
#
# The application 'rake' is installed as part of a gem, and
# this file is here to facilitate running it.
#
require 'rubygems'
Gem.use_gemdeps
version = ">= 0.a"
str = ARGV.first
if str
str = str.b[/\A_(.*)_\z/, 1]
if str and Gem::Version.correct?(str)
version = str
ARGV.shift
end
end
if Gem.respond_to?(:activate_bin_path)
load Gem.activate_bin_path('rake', 'rake', version)
else
gem "rake", version
load Gem.bin_path("rake", "rake", version)
end
/.bundle/
/.yardoc
/Gemfile.lock
/_yardoc/
/coverage/
/doc/
/log/
/pkg/
/spec/reports/
/tmp/
*.bundle
*.so
*.o
*.a
mkmf.log
AllCops:
DisplayCopNames: true
DisplayStyleGuide: true
TargetRubyVersion: 1.9
Exclude:
- "*.gemspec"
Metrics/AbcSize:
Exclude:
- "test/**/*"
Metrics/MethodLength:
Exclude:
- "test/**/*"
Metrics/ClassLength:
Exclude:
- "test/**/*"
Style/BarePercentLiterals:
EnforcedStyle: percent_q
Style/ClassAndModuleChildren:
Enabled: false
Style/Documentation:
Enabled: false
Style/DoubleNegation:
Enabled: false
Style/HashSyntax:
EnforcedStyle: hash_rockets
Style/SpaceAroundEqualsInParameterDefault:
EnforcedStyle: no_space
Style/StringLiterals:
EnforcedStyle: double_quotes
Style/TrivialAccessors:
AllowPredicates: true
language: ruby
rvm:
- 1.9
- 2.0
- 2.1
- 2.2
- 2.3.1
- 2.4.0
env:
- sshkit="master"
- sshkit="= 1.7.1"
- sshkit="= 1.6.1"
matrix:
exclude:
# Older versions of SSHKit don't work with Ruby 2.4, so skip those
- rvm: 2.4.0
env: sshkit="= 1.7.1"
- rvm: 2.4.0
env: sshkit="= 1.6.1"
include:
# Run Danger only once, on 2.4.0
- rvm: 2.4.0
script: bundle exec danger
before_install: gem install bundler --conservative --version '~> 1.13.7'
# Airbrussh Change Log
All notable changes to this project will be documented in this file. This project adheres to [Semantic Versioning][Semver].
## [Unreleased]
* Your contribution here!
## [1.3.0][] (2017-06-16)
* [#109](https://github.com/mattbrictson/airbrussh/pull/109): Add configurable task prefix - [@gondalez](https://github.com/gondalez)
## [1.2.0][] (2017-04-14)
* [#95](https://github.com/mattbrictson/airbrussh/pull/95): colorize LogMessage label on WARN level and above - [@klyonrad](https://github.com/klyonrad)
* [#106](https://github.com/mattbrictson/airbrussh/pull/106): Remove the `log_file` parameter from the `CommandFormatter#exit_message` method; it was unused - [@mattbrictson](https://github.com/mattbrictson)
## [1.1.2][] (2017-01-02)
* Add Ruby 2.4.0 to testing matrix and fix Ruby 2.4 deprecation warnings
## [1.1.1][] (2016-09-09)
* When a Capistrano deploy fails and the error log is dumped to the console,
Airbrussh no longer truncates the error output. This ensures that important
troubleshooting information is not lost.
[#91](https://github.com/mattbrictson/airbrussh/issues/91)
## [1.1.0][] (2016-07-26)
* Use default color for info messages.
When using the `gray` color on some implementation of the `solarized`
theme the text is not visible. The `solarized` theme is popular and
bugs have been reported about missed error messages, so this patch
switches these messages to the default color.
(see [#84](https://github.com/mattbrictson/airbrussh/issues/84))
## [1.0.2][] (2016-05-13)
* Fix a crash that can happen in certain multi-server deployments when
Capistrano's `invoke` is used to switch Rake tasks in the middle of SSHKit
execution ([#78](https://github.com/mattbrictson/airbrussh/issues/78),
[#80](https://github.com/mattbrictson/airbrussh/pull/80))
## [1.0.1][] (2016-03-21)
* Fix support for fake TTYs reporting a 0 width console like Ruby's PTY library [#76](https://github.com/mattbrictson/airbrussh/pull/76)
## [1.0.0][] (2016-02-27)
* No changes since 1.0.0.beta1.
## [1.0.0.beta1][] (2015-12-27)
Breaking Changes:
* None
Added:
* Airbrussh can now be configured with an options Hash passed to the
`Airbrussh::Formatter` constructor. This is in order to standardize how all
SSHKit formatters are configured
(see [SSHKit #308](https://github.com/capistrano/sshkit/pull/308)).
## [0.8.0][] (2015-11-20)
* Airbrussh now displays the correct user@host output in the following edge-cases:
* Inside an SSHKit `as(:user => "...")` block
* When a user is specified using `set :ssh_options, :user => "..."` ([see #65](https://github.com/mattbrictson/airbrussh/issues/65))
## [0.7.0][] (2015-08-08)
Fixes:
* Handle truncation of raw/non-UTF8 output without crashing ([#57](https://github.com/mattbrictson/airbrussh/issues/57))
Other changes:
* Re-implement the "tail log on deploy failure" feature in pure Ruby ([#59](https://github.com/mattbrictson/airbrussh/issues/59))
* Code of contact added to the project
* Tests now run on Windows ([#55](https://github.com/mattbrictson/airbrussh/issues/55))
## [0.6.0][] (2015-07-10)
This is another release with mostly behind-the-scenes changes. If you notice any differences in Airbrussh's behavior in this version, [please report an issue](https://github.com/mattbrictson/airbrussh/issues).
Other changes:
* Bundler 1.10 is now required to build and test airbrussh (this doesn't affect users of airbrussh at all).
* If the directory containing the log file doesn't exist, Airbrussh will now attempt to create it using `FileUtils.mkdir_p` ([#30](https://github.com/mattbrictson/airbrussh/issues/30))
* By default Airbrussh now always prints `Using airbrussh format.` when it starts up. In previous versions, a bug caused this message to sometimes not be shown. To change or disable this message, set the `banner` configuration option as explained in the README.
## [0.5.1][] (2015-06-24)
* Fix `NameError: uninitialized constant Airbrussh::SimpleDelegator`
## [0.5.0][] (2015-06-24)
There are no changes to the actual behavior and feature set of Airbrussh in this release.
There are, however, many behind-the-scenes changes and improvements to overall code quality. This release also adds support for upcoming versions of SSHKit.
* Added Rubocop enforcement to Travis
* Added Code Climate and Coveralls checks (see badges in the README)
* Airbrussh now has good test coverage, and is tested by Travis against a matrix of Ruby and SSHKit versions ([@robd](https://github.com/robd))
* Changes to support the new SSHKit formatter API, as introduced in [SSHKit #257](https://github.com/capistrano/sshkit/pull/257) ([@robd](https://github.com/robd))
* `Airbrussh.reset` has been removed
* Airbrussh now has its own ANSI color code; it no longer relies on a third-party gem (i.e. `colorize`)
## [0.4.1][] (2015-05-06)
* Fix `Marshal.dump` warnings by removing `deep_copy` workaround that it is no longer needed for the latest SSHKit ([#10](https://github.com/mattbrictson/airbrussh/issues/10)).
## [0.4.0][] (2015-05-03)
* Changes to ensure compatibility with the upcoming version of SSHKit ([ec3122b](https://github.com/mattbrictson/airbrussh/commit/ec3122b101de53f2304723da842d5c8b6f70f4f3)).
* Explicitly specify UTF-8 encoding for source files, for Ruby 1.9.3 compatibility ([#9](https://github.com/mattbrictson/airbrussh/issues/9)).
## [0.3.0][] (2015-03-28)
* New `config.banner` option allows startup message to be disabled or changed (suggestion from [@justindowning](https://github.com/justindowning))
* New `config.command_output` option gives full control of whether airbrussh shows or hides the stderr and stdout data received from remote commands; see the usage section of the README for further explanation (suggestion from [@carlesso](https://github.com/carlesso))
## [0.2.1][] (2015-03-02)
* Un-pin SSHKit dependency now that SSHKit 1.7.1 has been released.
## [0.2.0][] (2015-03-02)
* Pin SSHKit dependency at `~> 1.6.1` to avoid a [bug in 1.7.0](https://github.com/capistrano/sshkit/issues/226) that causes command exit statuses to be omitted from the log.
## 0.0.1 (2015-02-19)
* Initial release
[Semver]: http://semver.org
[Unreleased]: https://github.com/mattbrictson/airbrussh/compare/v1.3.0...HEAD
[1.3.0]: https://github.com/mattbrictson/airbrussh/compare/v1.2.0...v1.3.0
[1.2.0]: https://github.com/mattbrictson/airbrussh/compare/v1.1.2...v1.2.0
[1.1.2]: https://github.com/mattbrictson/airbrussh/compare/v1.1.1...v1.1.2
[1.1.1]: https://github.com/mattbrictson/airbrussh/compare/v1.1.0...v1.1.1
[1.1.0]: https://github.com/mattbrictson/airbrussh/compare/v1.0.2...v1.1.0
[1.0.2]: https://github.com/mattbrictson/airbrussh/compare/v1.0.1...v1.0.2
[1.0.1]: https://github.com/mattbrictson/airbrussh/compare/v1.0.0...v1.0.1
[1.0.0]: https://github.com/mattbrictson/airbrussh/compare/v1.0.0.beta1...v1.0.0
[1.0.0.beta1]: https://github.com/mattbrictson/airbrussh/compare/v0.8.0...v1.0.0.beta1
[0.8.0]: https://github.com/mattbrictson/airbrussh/compare/v0.7.0...v0.8.0
[0.7.0]: https://github.com/mattbrictson/airbrussh/compare/v0.6.0...v0.7.0
[0.6.0]: https://github.com/mattbrictson/airbrussh/compare/v0.5.1...v0.6.0
[0.5.1]: https://github.com/mattbrictson/airbrussh/compare/v0.5.0...v0.5.1
[0.5.0]: https://github.com/mattbrictson/airbrussh/compare/v0.4.1...v0.5.0
[0.4.1]: https://github.com/mattbrictson/airbrussh/compare/v0.4.0...v0.4.1
[0.4.0]: https://github.com/mattbrictson/airbrussh/compare/v0.3.0...v0.4.0
[0.3.0]: https://github.com/mattbrictson/airbrussh/compare/v0.2.1...v0.3.0
[0.2.1]: https://github.com/mattbrictson/airbrussh/compare/v0.2.0...v0.2.1
[0.2.0]: https://github.com/mattbrictson/airbrussh/compare/v0.0.1...v0.2.0
Contributor Code of Conduct
As contributors and maintainers of this project, we pledge to respect all
people who contribute through reporting issues, posting feature requests,
updating documentation, submitting pull requests or patches, and other
activities.
We are committed to making participation in this project a harassment-free
experience for everyone, regardless of level of experience, gender, gender
identity and expression, sexual orientation, disability, personal appearance,
body size, race, ethnicity, age, or religion.
Examples of unacceptable behavior by participants include the use of sexual
language or imagery, derogatory comments or personal attacks, trolling, public
or private harassment, insults, or other unprofessional conduct.
Project maintainers have the right and responsibility to remove, edit, or
reject comments, commits, code, wiki edits, issues, and other contributions
that are not aligned to this Code of Conduct. Project maintainers who do not
follow the Code of Conduct may be removed from the project team.
This code of conduct applies both within project spaces and in public spaces
when an individual is representing the project or its community.
Instances of abusive, harassing, or otherwise unacceptable behavior may be
reported by opening an issue or contacting one or more of the project
maintainers.
This Code of Conduct is adapted from the Contributor Covenant
(http://contributor-covenant.org), version 1.1.0, available at
http://contributor-covenant.org/version/1/1/0/
# Contributing to airbrussh
Have a feature idea, bug fix, or refactoring suggestion? Contributions are welcome!
## Pull requests
1. Check [Issues][] to see if your contribution has already been discussed and/or implemented.
2. If not, open an issue to discuss your contribution. I won't accept all changes and do not want to waste your time.
3. Once you have the :thumbsup:, fork the repo, make your changes, and open a PR.
4. Don't forget to add your contribution and credit yourself in `CHANGELOG.md`!
## Coding guidelines
* This project has a coding style enforced by [RuboCop][]. Use hash rockets and double-quoted strings, and otherwise try to follow the [Ruby style guide][style].
* Writing tests is strongly encouraged! This project uses Minitest.
## Getting started
Note that Bundler 1.10 is required for development. Run `gem update bundler` to get the latest version.
After checking out the airbrussh repo, run `bin/setup` to install dependencies. Run `rake` to execute airbrussh's tests and RuboCop checks.
Airbrussh is designed to work against multiple versions of SSHKit and Ruby. In order to test this, we use the environment variable `sshkit` in order to run the tests against a specific version. The combinations of sshkit and ruby we support are specified in [.travis.yml](.travis.yml). To test all the versions locally, there is a `test_all.rb` bin file. This installs the gems and runs the tests for each sshkit version in [.travis.yml](.travis.yml). *Note: this will update your `Gemfile.lock` as each SSHKit gem version is installed. The gem version is restored to the default when the script exits.*
A Guardfile is also present, so if you'd like to use Guard to do a TDD workflow, then:
1. Run `bundle install --with extras` to get the optional guard dependencies
2. Run `guard` to monitor the filesystem and automatically run tests as you work
[Issues]: https://github.com/mattbrictson/airbrussh/issues
[RuboCop]: https://github.com/bbatsov/rubocop
[style]: https://github.com/bbatsov/ruby-style-guide
danger.import_dangerfile(github: "capistrano/danger")
source "https://rubygems.org"
# Specify your gem's dependencies in airbrussh.gemspec
gemspec
# Optional development dependencies; requires bundler >= 1.10.
# Note that these gems assume a Ruby 2.2 environment. Install them using:
#
# bundle install --with extras
#
group :extras, :optional => true do
gem "chandler"
gem "guard", ">= 2.2.2"
gem "guard-minitest"
gem "rb-fsevent"
gem "terminal-notifier-guard"
end
# Danger is used by Travis, but only for Ruby 2.0+
gem "danger", "~> 4.3" unless RUBY_VERSION == "1.9.3"
if (sshkit_version = ENV["sshkit"])
requirement = begin
Gem::Dependency.new("sshkit", sshkit_version).requirement
rescue ArgumentError
user, branch =
if sshkit_version.include?("#")
sshkit_version.split("#")
else
["capistrano", sshkit_version]
end
{ :github => "#{user}/sshkit", :branch => branch }
end
gem "sshkit", requirement
end
# json 2.0+ is not compatible with Ruby 1.9, so pin at older version.
gem "json", "~> 1.8" if RUBY_VERSION == "1.9.3"
# net-ssh 3.0+ is not compatible with Ruby 1.9, so pin at older version.
gem "net-ssh", "~> 2.8" if RUBY_VERSION == "1.9.3"
# term-ansicolor 1.4.0+ is not compatible with Ruby 1.9, so pin older version.
gem "term-ansicolor", "~> 1.3.2" if RUBY_VERSION == "1.9.3"
# tins 1.7.0+ is not compatible with Ruby 1.9, so pin at older version.
gem "tins", "~> 1.6.0" if RUBY_VERSION == "1.9.3"
guard :minitest do
# with Minitest::Unit
watch(%r{^test/(.*)\/?(.*)_test\.rb$})
watch(%r{^lib/(.*/)?([^/]+)\.rb$}) { |m| "test/#{m[1]}#{m[2]}_test.rb" }
watch(%r{^test/minitest_helper\.rb$}) { "test" }
end
The MIT License (MIT)
Copyright (c) 2016 Matt Brictson
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.
# Airbrussh
[![Gem Version](https://badge.fury.io/rb/airbrussh.svg)](http://badge.fury.io/rb/airbrussh)
[![Build Status](https://travis-ci.org/mattbrictson/airbrussh.svg?branch=master)](https://travis-ci.org/mattbrictson/airbrussh)
[![Build status](https://ci.appveyor.com/api/projects/status/h052rlq54sne3md6/branch/master?svg=true)](https://ci.appveyor.com/project/mattbrictson/airbrussh/branch/master)
[![Code Climate](https://codeclimate.com/github/mattbrictson/airbrussh/badges/gpa.svg)](https://codeclimate.com/github/mattbrictson/airbrussh)
[![Coverage Status](https://coveralls.io/repos/mattbrictson/airbrussh/badge.svg?branch=master)](https://coveralls.io/r/mattbrictson/airbrussh?branch=master)
Airbrussh is a concise log formatter for Capistrano and SSHKit. It displays well-formatted, useful log output that is easy to read. Airbrussh also saves Capistrano's verbose output to a separate log file just in case you need additional details for troubleshooting.
**As of April 2016, Airbrussh is bundled with Capistrano 3.5, and is Capistrano's default formatter! There is nothing additional to install or enable.** Continue reading to learn more about Airbrussh's features and configuration options.
If you aren't yet using Capistrano 3.5 (or wish to use Airbrussh with SSHKit directly), refer to the [advanced/legacy usage](#advancedlegacy-usage) section for installation instructions.
![Sample output](https://raw.github.com/mattbrictson/airbrussh/master/demo.gif)
For more details on how exactly Airbrussh affects Capistrano's output and the reasoning behind it, check out the blog post: [Introducing Airbrussh](https://mattbrictson.com/airbrussh).
-----
* [Usage](#usage)
* [Configuration](#configuration)
* [FAQ](#faq)
* [Advanced/legacy usage](#advancedlegacy-usage)
## Usage
Airbrussh is enabled by default in Capistrano 3.5 and newer. To manually enable Airbrussh (for example, when upgrading an existing project), set the Capistrano format like this:
```ruby
# In deploy.rb
set :format, :airbrussh
```
### What's displayed
When you run a Capistrano command, Airbrussh provides the following information in its output:
![Sample output](https://raw.github.com/mattbrictson/airbrussh/master/formatting.png)
* Name of Capistrano task being executed
* When each task started (minutes:seconds elapsed since the deploy began)
* The SSH command-line strings that are executed; for Capistrano tasks that involve running multiple commands, the numeric prefix indicates the command in the sequence, starting from `01`
* Stdout and stderr output from each command
* The duration of each command execution, per server
### What's *not* displayed
For brevity, Airbrussh does not show *everything* that Capistrano is doing. For example, it will omit Capistrano's `test` commands, which can be noisy and confusing. Airbrussh also hides things like environment variables, as well as `cd` and `env` invocations. To see a full audit of Capistrano's execution, including *exactly* what commands were run on each server, look at `log/capistrano.log`.
## Configuration
You can customize many aspects of Airbrussh's output. In Capistrano 3.5 and newer, this is done via the `:format_options` variable, like this:
```ruby
# Pass options to Airbrussh
set :format_options, color: false, truncate: 80
```
Here are the options you can use, and their effects (note that the defaults may be different depending on where Airbrussh is used; these are the defaults used by Capistrano 3.5):
|Option|Default|Usage|
|---|---|---|
|`banner`|`nil`|Provide a string (e.g. "Capistrano started!") that will be printed when Capistrano starts up.|
|`color`|`:auto`|Use `true` or `false` to enable or disable ansi color. If set to `:auto`, Airbrussh automatically uses color based on whether the output is a TTY, or if the SSHKIT_COLOR environment variable is set.|
|`command_output`|`true`|Set to `:stdout`, `:stderr`, or `true` to display the SSH output received via stdout, stderr, or both, respectively. Set to `false` to not show any SSH output, for a minimal look.|
|`log_file`|`log/capistrano.log`|Capistrano's verbose output is saved to this file to facilitate debugging. Set to `nil` to disable completely.|
|`truncate`|`:auto`|Set to a number (e.g. 80) to truncate the width of the output to that many characters, or `false` to disable truncation. If `:auto`, output is automatically truncated to the width of the terminal window, if it can be determined.|
|`task_prefix`|`nil`|A string to prefix to task output. Handy for output collapsing like [buildkite](https://buildkite.com/docs/builds/managing-log-output)'s `---` prefix|
## FAQ
**Airbrussh is not displaying the output of my commands! For example, I run `tail` in one of my capistrano tasks and airbrussh doesn't show anything. How do I fix this?**
Make sure Airbrussh is configured to show SSH output.
```ruby
set :format_options, command_output: true
```
**I haven't upgraded to Capistrano 3.5 yet. Can I still use Airbrussh?**
Yes! Capistrano 3.4.x is also supported. Refer to the [advanced/legacy usage](#advancedlegacy-usage) section for installation instructions.
**Does Airbrussh work with Capistrano 2?**
No, Capistrano 3 is required. We recommend Capistrano 3.4.0 or higher. Capistrano 3.5.0 and higher have Airbrussh enabled by default, with no installation needed.
**Does Airbrussh work with JRuby?**
JRuby is not officially supported or tested, but may work. You must disable automatic truncation to work around a known bug in the JRuby 9.0 standard library. See [#62](https://github.com/mattbrictson/airbrussh/issues/62) for more details.
```ruby
set :format_options, truncate: false
```
**I have a question that’s not answered here or elsewhere in the README.**
Please [open a GitHub issue](https://github.com/mattbrictson/airbrussh/issues/new) and we’ll be happy to help!
## Advanced/legacy usage
Although Airbrussh is built into Capistrano 3.5.0 and higher, it is also available as a plug-in for older versions. Airbrussh has been tested with MRI 1.9+, Capistrano 3.4.0+, and SSHKit 1.6.1+.
### Capistrano 3.4.x
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"
```
**Important:** explicitly setting Capistrano's `:format` option in your deploy.rb will override airbrussh. Remove this line if you have it:
```ruby
# Remove this
set :format, :pretty
```
Capistrano 3.4.x doesn't have the `:format_options` configuration system, so you will need to configure Airbrussh using this technique:
```ruby
Airbrussh.configure do |config|
config.color = false
config.command_output = true
# etc.
end
```
Refer to the [configuration](#configuration) section above for the list of supported options.
### SSHKit
If you are using SSHKit directly (i.e. without Capistrano), you can use Airbrussh like this:
```ruby
require "airbrussh"
SSHKit.config.output = Airbrussh::Formatter.new($stdout)
# You can also pass configuration options like this
SSHKit.config.output = Airbrussh::Formatter.new($stdout, color: false)
```
## History
Airbrussh started life as custom logging code within the [capistrano-mb][] 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`. In February 2016, Airbrussh was added as the default formatter in Capistrano 3.5.0.
## Roadmap
Airbrussh now has a stable feature set, excellent test coverage, is being used for production deployments, and has reached 1.0.0! If you have ideas for improvements to Airbrussh, please open a [GitHub issue](https://github.com/mattbrictson/airbrussh/issues/new).
## Contributing
Contributions are welcome! Read [CONTRIBUTING.md](CONTRIBUTING.md) to get started.
[capistrano-mb]: https://github.com/mattbrictson/capistrano-mb
require "bundler/gem_tasks"
require "rake/testtask"
Rake::TestTask.new(:test) do |t|
t.libs << "test"
t.libs << "lib"
t.test_files = FileList["test/**/*_test.rb"]
end
require "rubocop/rake_task"
RuboCop::RakeTask.new
# rubocop:disable Lint/HandleExceptions
begin
require "chandler/tasks"
rescue LoadError
end
task "release:rubygem_push" => "chandler:push" if defined?(Chandler)
task :default => [:test, :rubocop]
# Capistrano 3.5 upgrade guide for existing Airbrussh users
If you have been using Airbrussh with Capistrano, and are upgrading to Capistrano 3.5, then this guide is for you.
## What changed?
* Airbrussh is built into Capistrano starting with Capistrano 3.5.0, and is enabled by default.
* Capistrano 3.5 initializes Airbrussh with a default configuration that is different than Airbrussh+Capistrano 3.4.0.
* In Capistrano 3.5, `set :format_options, ...` is now the preferred mechanism for configuring Airbrussh.
## How to upgrade
1. Remove `gem "airbrussh"` from your Gemfile. Airbrussh is now included automatically by Capistrano.
2. Likewise, remove `require "capistrano/airbrussh"` from your Capfile. Capistrano now does this internally.
3. Remove `Airbrussh.configure do ... end` from your deploy.rb and replace with `set :format_options, ...` (see below).
## New configuration system
In Capistrano 3.5, Airbrussh is configured by assigning a configuration Hash to the `:format_options` variable. Here is a comparison of the old and new syntaxes:
```ruby
# Old syntax
Airbrussh.configure do |config|
config.color = false
end
# New syntax
set :format_options, color: false
```
Although the syntax is different, the names of the configuration keys have not changed.
## New defaults
Capistrano 3.5.0 changes Airbrussh defaults as follows:
* `banner: false`
* `command_output: true`
Therefore, after upgrading to Capistrano 3.5.0, you may notice Airbrussh's output has changed and become more verbose. To restore the defaults to what you were used to in older versions, do this:
```ruby
set :format_options, banner: :auto, command_output: false
```
## Trouble?
If you have any Airbrussh-related trouble with the upgrade, please [open an issue](https://github.com/mattbrictson/airbrussh/issues).
# 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 = "A replacement log formatter for SSHKit that makes "\
"Capistrano output much easier on the eyes. Just add "\
"Airbrussh 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").reject { |f| f.match(%r{^(test|spec|features)/}) }
spec.bindir = "exe"
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
spec.require_paths = ["lib"]
spec.add_dependency "sshkit", [">= 1.6.1", "!= 1.7.0"]
spec.add_development_dependency "bundler", "~> 1.10"
spec.add_development_dependency "coveralls", "~> 0.8.15"
spec.add_development_dependency "rake", "~> 12.0"
spec.add_development_dependency "minitest", "~> 5.10"
spec.add_development_dependency "minitest-reporters", "~> 1.1"
spec.add_development_dependency "mocha", "~> 1.2"
spec.add_development_dependency "rubocop", "~> 0.41.2"
end
version: '{build}'
skip_tags: true
environment:
matrix:
- ruby_version: "23"
- ruby_version: "23-x64"
install:
- SET PATH=C:\Ruby%ruby_version%\bin;%PATH%
- gem install bundler --no-document --conservative --version 1.10.5
- bundle install --retry=3
test_script:
- bundle exec rake
build: off
#!/usr/bin/env ruby
require "bundler/setup"
require "airbrussh"
# You can add fixtures and/or initialization code here to make experimenting
# with your gem easier. You can also use a different console, if you like.
# (If you use this, don't forget to add pry to your Gemfile!)
# require "pry"
# Pry.start
require "irb"
IRB.start
#!/bin/bash
set -euo pipefail
IFS=$'\n\t'
bundle install
# Do any other automated setup that you need to do here
#!/usr/bin/env ruby
require "yaml"
require "English"
ruby24 = Gem::Version.new(RUBY_VERSION) >= Gem::Version.new("2.4.0")
YAML.load_file(".travis.yml")["env"].each do |sshkit_version|
# Older versions of SSHKit don't work with Ruby 2.4, so skip those
next if ruby24 && sshkit_version !~ /master/
puts "\e[0;34;49m== Running tests against #{sshkit_version} ==\e[0m"
output = `#{sshkit_version} bundle update`
raise "bundle update failed: #{output}" unless $CHILD_STATUS.success?
system("#{sshkit_version} bundle exec rake test")
end
system("bundle exec rake rubocop")
at_exit do
puts "\e[0;34;49m== Resetting sshkit ==\e[0m"
system("bundle update")
end
require "airbrussh/configuration"
require "airbrussh/formatter"
require "airbrussh/version"
module Airbrussh
def self.configuration(options={})
return options if options.is_a?(::Airbrussh::Configuration)
@configuration ||= Configuration.new
@configuration.apply_options(options)
end
def self.configure
yield(configuration)
end
end
require "airbrussh/capistrano/tasks"
tasks = Airbrussh::Capistrano::Tasks.new(self)
# Hook into Capistrano's init process to set the formatter
namespace :load do
task :defaults do
tasks.load_defaults
end
end
# Capistrano failure hook
namespace :deploy do
task :failed do
tasks.deploy_failed
end
end
require "airbrussh"
require "airbrussh/colors"
require "airbrussh/console"
require "forwardable"
require "shellwords"
module Airbrussh
module Capistrano
# Encapsulates the rake behavior that integrates Airbrussh into Capistrano.
# This class allows us to easily test the behavior using a mock to stand in
# for the Capistrano DSL.
#
# See airbrussh/capistrano.rb to see how this class is used.
#
class Tasks
extend Forwardable
def_delegators :dsl, :set, :env
def_delegators :config, :log_file
include Airbrussh::Colors
def initialize(dsl, stderr=$stderr, config=Airbrussh.configuration)
@dsl = dsl
@stderr = stderr
@config = config
configure
warn_if_missing_dsl
end
# Behavior for the rake load:defaults task.
def load_defaults
require "sshkit/formatter/airbrussh"
set :format, :airbrussh
end
# Behavior for the rake deploy:failed task.
def deploy_failed
return unless airbrussh_is_being_used?
return if log_file.nil?
error_line
error_line(red("** DEPLOY FAILED"))
error_line(yellow("** Refer to #{log_file} for details. "\
"Here are the last 20 lines:"))
error_line
error_line(tail_log_file)
end
private
attr_reader :dsl, :stderr, :config
# Change airbrussh's default configuration to be more appropriate for
# capistrano.
def configure
config.log_file = "log/capistrano.log"
config.monkey_patch_rake = true
end
# Verify that capistrano and rake DSLs are present
def warn_if_missing_dsl
return if %w(set namespace task).all? { |m| dsl.respond_to?(m, true) }
error_line(
red("WARNING: airbrussh/capistrano must be loaded by Capistrano in "\
"order to work.\nRequire this gem within your application's "\
"Capfile, as described here:\n"\
"https://github.com/mattbrictson/airbrussh#installation")
)
end
def err_console
@err_console ||= begin
# Ensure we do not truncate the error output
err_config = config.dup
err_config.truncate = false
Airbrussh::Console.new(stderr, err_config)
end
end
def error_line(line="\n")
line.each_line(&err_console.method(:print_line))
end
# Returns a String containing the last 20 lines of the log file. Since
# this method uses a fixed-size buffer, fewer than 20 lines may be
# returned in cases where the lines are extremely long.
def tail_log_file
open(log_file) do |file|
file.seek(-[8192, file.size].min, IO::SEEK_END)
file.readlines.last(20).join
end
end
def airbrussh_is_being_used?
# Obtain the current formatter from the SSHKit backend
output = env.backend.config.output
output.is_a?(Airbrussh::Formatter)
end
end
end
end
module Airbrussh
# Very basic support for ANSI color, so that we don't have to rely on
# any external dependencies.
module Colors
ANSI_CODES = {
:red => 31,
:green => 32,
:yellow => 33,
:blue => 34,
:gray => 90
}.freeze
# Define red, green, blue, etc. methods that return a copy of the
# String that is wrapped in the corresponding ANSI color escape
# sequence.
ANSI_CODES.each do |name, code|
define_method(name) do |string|
"\e[0;#{code};49m#{string}\e[0m"
end
module_function(name)
end
end
end
# encoding: UTF-8
require "airbrussh/colors"
require "delegate"
# rubocop:disable Style/AsciiComments
module Airbrussh
# Decorates an SSHKit Command to add string output helpers and the
# command's position within currently executing rake task:
#
# * position - zero-based position of this command in the list of
# all commands that have been run in the current rake task; in
# some cases this could be nil
class CommandFormatter < SimpleDelegator
include Airbrussh::Colors
def initialize(command, position)
super(command)
@position = position
end
# Prefixes the line with the command number and removes the newline.
#
# format_output("hello\n") # => "01 hello"
#
def format_output(line)
"#{number} #{line.chomp}"
end
# Returns the abbreviated command (in yellow) with the number prefix.
#
# start_message # => "01 echo hello"
#
def start_message
"#{number} #{yellow(abbreviated)}"
end
# Returns a green (success) or red (failure) message depending on the
# exit status.
#
# exit_message # => "✔ 01 user@host 0.084s"
# exit_message # => "✘ 01 user@host 0.084s"
#
def exit_message
message = if failure?
red(failure_message)
else
green(success_message)
end
message << " #{runtime}"
end
private
def user_at_host
user_str = host.user || (host.ssh_options || {})[:user]
host_str = host.hostname
[user_str, host_str].compact.join("@")
end
def runtime
format("%5.3fs", super)
end
def abbreviated
to_s.sub(%r{^/usr/bin/env }, "")
end
def number
format("%02d", @position.to_i + 1)
end
def success_message
"✔ #{number} #{user_at_host}"
end
def failure_message
"✘ #{number} #{user_at_host}"
end
end
end
require "airbrussh/colors"
require "airbrussh/console_formatter"
require "airbrussh/log_file_formatter"
module Airbrussh
class Configuration
attr_accessor :log_file, :monkey_patch_rake, :color, :truncate, :banner,
:command_output, :task_prefix
def initialize
self.log_file = nil
self.monkey_patch_rake = false
self.color = :auto
self.truncate = :auto
self.banner = :auto
self.command_output = false
self.task_prefix = nil
end
def apply_options(options)
return self if options.nil?
options.each do |key, value|
if respond_to?(writer = "#{key}=")
public_send(writer, value)
else
warn_unrecognized_key(key)
end
end
self
end
def banner_message
return nil unless banner
return banner unless banner == :auto
msg = "Using airbrussh format."
if log_file
msg << "\n"
msg << "Verbose output is being written to #{Colors.blue(log_file)}."
end
msg
end
# This returns an array of formatters appropriate for the configuration.
# Depending on whether a log file is configured, this could be just the
# Airbrussh:ConsoleFormatter, or that plus the LogFileFormatter.
def formatters(io)
fmts = [Airbrussh::ConsoleFormatter.new(io, self)]
fmts.unshift(Airbrussh::LogFileFormatter.new(log_file)) if log_file
fmts
end
def show_command_output?(sym)
command_output == true || Array(command_output).include?(sym)
end
private
def warn_unrecognized_key(key)
$stderr.puts("Ignoring unrecognized Airbrussh option: #{key}")
end
end
end
# encoding: UTF-8
require "io/console"
module Airbrussh
# Helper class that wraps an IO object and provides methods for truncating
# output, assuming the IO object represents a console window.
#
# This is useful for writing log messages that will typically show up on
# an ANSI color-capable console. When a console is not present (e.g. when
# running on a CI server) the output will gracefully degrade.
class Console
attr_reader :output, :config
def initialize(output, config=Airbrussh.configuration)
@output = output
@config = config
end
# Writes to the IO after first truncating the output to fit the console
# width. If the underlying IO is not a TTY, ANSI colors are removed from
# the output. A newline is always added. Color output can be forced by
# setting the SSHKIT_COLOR environment variable.
def print_line(obj="")
string = obj.to_s
string = truncate_to_console_width(string) if console_width
string = strip_ascii_color(string) unless color_enabled?
write(string + "\n")
output.flush
end
# Writes directly through to the IO with no truncation or color logic.
# No newline is added.
def write(string)
output.write(string || "")
end
alias << write
def truncate_to_console_width(string)
string = (string || "").rstrip
ellipsis = utf8_supported?(string) ? "…" : "..."
width = console_width
if strip_ascii_color(string).length > width
width -= ellipsis.length
string.chop! while strip_ascii_color(string).length > width
string << "#{ellipsis}\e[0m"
else
string
end
end
def strip_ascii_color(string)
(string || "").gsub(/\033\[[0-9;]*m/, "")
end
def console_width
width = case (truncate = config.truncate)
when :auto
IO.console.winsize.last if @output.tty?
when Integer
truncate
end
width if width.to_i > 0
end
private
def color_enabled?
case config.color
when true
true
when :auto
ENV["SSHKIT_COLOR"] || @output.tty?
else
false
end
end
def utf8_supported?(string)
string.encode("UTF-8").valid_encoding?
rescue Encoding::UndefinedConversionError
false
end
end
end
require "airbrussh/colors"
require "airbrussh/command_formatter"
require "airbrussh/console"
require "airbrussh/rake/context"
require "sshkit"
module Airbrussh
class ConsoleFormatter < SSHKit::Formatter::Abstract
include Airbrussh::Colors
extend Forwardable
attr_reader :config, :context
def_delegators :context, :current_task_name, :register_new_command
def initialize(io, config=Airbrussh.configuration)
super(io)
@config = config
@context = Airbrussh::Rake::Context.new(config)
@console = Airbrussh::Console.new(original_output, config)
write_banner
end
def write_banner
print_line(config.banner_message) if config.banner_message
end
def log_command_start(command)
return if debug?(command)
first_execution = register_new_command(command)
command = decorate(command)
print_task_if_changed
print_indented_line(command.start_message) if first_execution
end
def log_command_data(command, stream_type, string)
return if debug?(command)
return unless config.show_command_output?(stream_type)
command = decorate(command)
string.each_line do |line|
print_indented_line(command.format_output(line))
end
end
def log_command_exit(command)
return if debug?(command)
command = decorate(command)
print_indented_line(command.exit_message, -2)
end
def write(obj)
case obj
when SSHKit::Command
log_command_start(obj)
log_and_clear_command_output(obj, :stderr)
log_and_clear_command_output(obj, :stdout)
log_command_exit(obj) if obj.finished?
when SSHKit::LogMessage
write_log_message(obj)
end
end
alias << write
private
attr_accessor :last_printed_task
def write_log_message(log_message)
return if debug?(log_message)
print_task_if_changed
print_indented_line(format_log_message(log_message))
end
def format_log_message(log_message)
case log_message.verbosity
when SSHKit::Logger::WARN
"#{yellow('WARN')} #{log_message}"
when SSHKit::Logger::ERROR
"#{red('ERROR')} #{log_message}"
when SSHKit::Logger::FATAL
"#{red('FATAL')} #{log_message}"
else
log_message.to_s
end
end
# For SSHKit versions up to and including 1.7.1, the stdout and stderr
# output was available as attributes on the Command. Print the data for
# the specified command and stream if enabled and clear the stream.
# (see Airbrussh::Configuration#command_output).
def log_and_clear_command_output(command, stream)
output = command.public_send(stream)
log_command_data(command, stream, output)
command.public_send("#{stream}=", "")
end
def print_task_if_changed
return if current_task_name.nil?
return if current_task_name == last_printed_task
self.last_printed_task = current_task_name
print_line("#{config.task_prefix}#{clock} #{blue(current_task_name)}")
end
def clock
@start_at ||= Time.now
duration = Time.now - @start_at
minutes = (duration / 60).to_i
seconds = (duration - minutes * 60).to_i
format("%02d:%02d", minutes, seconds)
end
def debug?(obj)
obj.verbosity <= SSHKit::Logger::DEBUG
end
def decorate(command)
Airbrussh::CommandFormatter.new(command, @context.position(command))
end
def print_line(string)
@console.print_line(string)
end
def print_indented_line(string, offset=0)
indent = " " * (6 + offset)
print_line([indent, string].join)
end
end
end
require "sshkit"
module Airbrussh
# This class quacks like an SSHKit::Formatter, but when any formatting
# methods are called, it simply forwards them to one more more concrete
# formatters. This allows us to split out the responsibilities of
# ConsoleFormatter and LogFileFormatter into two separate classes, with
# DelegatingFormatter forwarding the logging messages to both at once.
#
class DelegatingFormatter
FORWARD_METHODS = %w(
fatal error warn info debug log
log_command_start log_command_data log_command_exit
).freeze
DUP_AND_FORWARD_METHODS = %w(<< write).freeze
attr_reader :formatters
def initialize(formatters)
@formatters = formatters
end
FORWARD_METHODS.each do |method|
define_method(method) do |*args|
formatters.map { |f| f.public_send(method, *args) }.last
end
end
# For versions of SSHKit up to and including 1.7.1, the LogfileFormatter
# and ConsoleFormatter (and all of SSHKit's built in formatters) clear
# the stdout and stderr data in the command obj. Therefore, ensure only
# one of the formatters (the last one) gets the original command. This is
# also the formatter whose return value is passed to the caller.
#
DUP_AND_FORWARD_METHODS.each do |method|
define_method(method) do |command_or_log_message|
formatters[0...-1].each do |f|
f.public_send(method, command_or_log_message.dup)
end
formatters.last.public_send(method, command_or_log_message)
end
end
end
end
require "airbrussh"
require "airbrussh/delegating_formatter"
# This is the formatter class that conforms to the SSHKit Formatter API and
# provides the airbrussh functionality to SSHKit. Note however that this class
# doesn't do much by itself; instead, it delegates to the ConsoleFormatter
# and (optionally) the LogFileFormatter, which handle the bulk of the logic.
#
module Airbrussh
class Formatter < Airbrussh::DelegatingFormatter
def initialize(io, options_or_config_object={})
config = ::Airbrussh.configuration(options_or_config_object)
# Delegate to ConsoleFormatter and (optionally) LogFileFormatter,
# based on the configuration.
super(config.formatters(io))
end
end
end
require "delegate"
require "fileutils"
require "logger"
require "sshkit"
module Airbrussh
# A Pretty formatter that sends its output to a specified log file path.
# LogFileFormatter takes care of creating the file (and its parent
# directory) if it does not already exist, opens it for appending, and writes
# a delimiter message. The file is automatically rotated if it reaches 20 MB.
#
class LogFileFormatter < SimpleDelegator
attr_reader :path
def initialize(path, formatter_class=SSHKit::Formatter::Pretty)
@path = path
ensure_directory_exists if path.is_a?(String)
super(formatter_class.new(log_file_io))
write_delimiter
end
private
def write_delimiter
delimiter = []
delimiter << "-" * 75
delimiter << "START #{Time.now} cap #{ARGV.join(' ')}"
delimiter << "-" * 75
delimiter.each do |line|
write(SSHKit::LogMessage.new(SSHKit::Logger::INFO, line))
end
end
def ensure_directory_exists
FileUtils.mkdir_p(File.dirname(path))
end
def log_file_io
@io ||= ::Logger.new(path, 1, 20_971_520)
end
end
end
require "rake"
module Airbrussh
module Rake
# Maintains information about what Rake task is currently being invoked,
# in order to be able to decorate SSHKit commands with additional
# context-sensitive information. Works via a monkey patch to Rake::Task,
# which can be disabled via by setting
# Airbrussh.configuration.monkey_patch_rake = false.
#
# Note that this class is not thread-safe. Normally this is not a problem,
# but some Capistrano users are known to use `invoke` to switch the Rake
# task in the middle of an SSHKit thread, which causes Context to get very
# confused. It such scenarios Context is not reliable and may return `nil`
# for the `position` of a command.
#
class Context
def initialize(config=Airbrussh.configuration)
@history = []
@enabled = config.monkey_patch_rake
self.class.install_monkey_patch if enabled?
end
# Returns the name of the currently-executing rake task, if it can be
# determined. If monkey patching is disabled, this will be nil.
def current_task_name
return nil unless enabled?
self.class.current_task_name
end
# Update the context when a new command starts by:
# * Clearing the command history if the rake task has changed
# * Recording the command in the history
#
# Returns whether or not this command was the first execution
# of this command in the current rake task
def register_new_command(command)
reset_history_if_task_changed
first_execution = !history.include?(command.to_s)
history << command.to_s
history.uniq!
first_execution
end
# The zero-based position of the specified command in the current rake
# task. May be `nil` in certain multi-threaded scenarios, so be careful!
def position(command)
history.index(command.to_s)
end
class << self
attr_accessor :current_task_name
def install_monkey_patch
return if ::Rake::Task.instance_methods.include?(:_airbrussh_execute)
::Rake::Task.class_exec do
alias_method :_airbrussh_execute, :execute
def execute(args=nil) # rubocop:disable Lint/NestedMethodDefinition
::Airbrussh::Rake::Context.current_task_name = name.to_s
_airbrussh_execute(args)
end
end
end
end
private
attr_reader :history
attr_accessor :last_task_name
def reset_history_if_task_changed
history.clear if last_task_name != current_task_name
self.last_task_name = current_task_name
end
def enabled?
@enabled
end
end
end
end
# frozen_string_literal: true
module Airbrussh
VERSION = "1.3.0".freeze
end
require "airbrussh/formatter"
# Capistrano's formatter configuration requires that the formatter class
# be in the SSHKit::Formatter namespace. So we declare
# SSHKit::Formatter::Airbrussh that simply functions as an alias for
# Airbrussh::Formatter.
module SSHKit
module Formatter
class Airbrussh < Airbrussh::Formatter
end
end
end
---
engines:
duplication:
enabled: true
config:
languages:
- ruby
fixme:
enabled: true
rubocop:
enabled: false
ratings:
paths:
- "**.rb"
- "bin/*"
- "exe/*"
exclude_paths:
- bundler.gemspec
- "*.md"
- lib/bundler/ssl_certs/*.pem
- lib/bundler/vendor/**/*
- lib/bundler/templates/**/*.tt
- man/*
- spec/**/*
- Rakefile
# Please do not submit patches for including directives to ignore IDE/editor
# generated files. Use a global gitignore as described in
# https://help.github.com/articles/ignoring-files and find useful gitignore
# samples at https://github.com/github/gitignore
# files created by running the specs
/tmp/
# gems built by `rake build`
/pkg/
# output from ronn
/lib/bundler/man/
man/*
!man/*.ronn
# rspec failure tracking
.rspec_status
--format documentation
--color
--warnings
inherit_from:
- .rubocop_todo.yml
AllCops:
TargetRubyVersion: 1.9
Exclude:
- tmp/**/*
- lib/bundler/vendor/**/*
DisplayCopNames: true
# Lint
# They are idiomatic
Lint/AssignmentInCondition:
Enabled: false
Lint/EndAlignment:
EnforcedStyleAlignWith: variable
AutoCorrect: true
Lint/UnusedMethodArgument:
Enabled: false
# Style
Style/AccessModifierIndentation:
EnforcedStyle: outdent
Style/Alias:
EnforcedStyle: prefer_alias_method
Style/AlignParameters:
EnforcedStyle: with_fixed_indentation
Style/FrozenStringLiteralComment:
EnforcedStyle: always
Style/MultilineBlockChain:
Enabled: false
Style/MultilineOperationIndentation:
EnforcedStyle: indented
Style/PerlBackrefs:
Enabled: false
Style/SingleLineBlockParams:
Enabled: false
Style/SpaceInsideBlockBraces:
SpaceBeforeBlockParameters: false
Style/TrivialAccessors:
Enabled: false
# We adopted raise instead of fail.
Style/SignalException:
EnforcedStyle: only_raise
Style/StringLiterals:
EnforcedStyle: double_quotes
Style/StringLiteralsInInterpolation:
EnforcedStyle: double_quotes
# Having these make it easier to *not* forget to add one when adding a new
# value and you can simply copy the previous line.
Style/TrailingCommaInLiteral:
EnforcedStyleForMultiline: comma
Style/TrailingUnderscoreVariable:
Enabled: false
# `String.new` is preferred style with enabled frozen string literal
Style/EmptyLiteral:
Enabled: false
# 1.8.7 support
Style/HashSyntax:
EnforcedStyle: hash_rockets
Style/Lambda:
Enabled: false
Style/DotPosition:
EnforcedStyle: trailing
Style/EachWithObject:
Enabled: false
Style/SpecialGlobalVars:
Enabled: false
Style/TrailingCommaInArguments:
Enabled: false
Performance/FlatMap:
Enabled: false
# Metrics
# We've chosen to use Rubocop only for style, and not for complexity or quality checks.
Metrics/ClassLength:
Enabled: false
Metrics/ModuleLength:
Enabled: false
Metrics/MethodLength:
Enabled: false
Metrics/BlockNesting:
Enabled: false
Metrics/AbcSize:
Enabled: false
Metrics/CyclomaticComplexity:
Enabled: false
Metrics/ParameterLists:
Enabled: false
Metrics/BlockLength:
Enabled: false
# It will be obvious which code is complex, Rubocop should only lint simple
# rules for us.
Metrics/PerceivedComplexity:
Enabled: false
language: ruby
script: rake spec:travis
before_script:
- travis_retry rake spec:travis:deps
- travis_retry rake man:build
- travis_retry rake spec:rubygems:clone_rubygems_$RGV
branches:
only:
- master
- auto
- /.+-dev$/
- /.+-stable$/
notifications:
slack:
on_success: change
on_failure: always
rooms:
- secure: JxBi7DDJGkIF/7f/FSN/HUHpvV4EKfQccZHTPd1b2pNJn3GXo6u+tNVbAw2WjxYzPyPQI3ZcYBCU9SEXp/i7VmG8uMzh8Kyildw+miSKYKVb90uYqcsXWzbxwyNBgJLvyDkzST45H5lgnyAicee3WkFes/WDZikIajbH7ztdb04=
addons:
code_climate:
repo_token:
secure: "TrzIv116JLGUxm6PAUskCYrv8KTDguncKROVwbnjVPKTGDAgoDderd8JUdDEXrKoZ9qGLD2TPYKExt9/QDl71E+qHdWnVqWv4HKCUk2P9z/VLKzHuggOUBkCXiJUhjywUieCJhI3N92bfq2EjSBbu2/OFHqWOjLQ+QCooTEBjv8="
rvm:
- 2.4.1
- 2.3.4
- 2.2.7
- 2.1.10
- 2.0.0
- 1.9.3
- 1.8.7
# Rubygems versions MUST be available as rake tasks
# see Rakefile:125 for the list of possible RGV values
env:
# We need to know if changes to rubygems will break bundler on release
- RGV=master
# Test the latest rubygems release with all of our supported rubies
- RGV=v2.6.8
matrix:
include:
# Ruby 2.4, Rubygems 2.6.8 and up
# Ruby 2.3, Rubygems 2.5.1 and up
- rvm: 2.2.6
env: RGV=v2.5.2
# Ruby 2.2, Rubygems 2.4.5 and up
- rvm: 2.2.6
env: RGV=v2.4.8
# Ruby 2.1, Rubygems 2.2.2 and up
- rvm: 2.1.10
env: RGV=v2.2.5
# Ruby 2.0.0, Rubygems 2.0.0 and up
- rvm: 2.0.0
env: RGV=v2.2.5
- rvm: 2.0.0
env: RGV=v2.1.11
- rvm: 2.0.0
env: RGV=v2.0.14
# Ruby 1.9.3, Rubygems 1.5.3 and up
- rvm: 1.9.3
env: RGV=v2.2.5
- rvm: 1.9.3
env: RGV=v2.1.11
- rvm: 1.9.3
env: RGV=v2.0.14
- rvm: 1.9.3
env: RGV=v1.8.29
- rvm: 1.9.3
env: RGV=v1.7.2
- rvm: 1.9.3
env: RGV=v1.6.2
- rvm: 1.9.3
env: RGV=v1.5.3
# Ruby 1.8.7, Rubygems 1.3.6 and up
- rvm: 1.8.7
env: RGV=v2.2.5
# ALLOWED FAILURES
# since the great Travis image outage, frequent random segfaults :'(
- rvm: 1.8.7
env: RGV=v2.0.14
- rvm: 1.8.7
env: RGV=v1.8.29
- rvm: 1.8.7
env: RGV=v1.7.2
- rvm: 1.8.7
env: RGV=v1.6.2
- rvm: 1.8.7
env: RGV=v1.5.3
- rvm: 1.8.7
env: RGV=v1.4.2
- rvm: 1.8.7
env: RGV=v1.3.7
- rvm: 1.8.7
env: RGV=v1.3.6
# Ruby-head (we want to know how we're doing, but not fail the build)
- rvm: ruby-head
env: RGV=master
allow_failures:
- rvm: 1.8.7
env: RGV=v2.0.14
- rvm: 1.8.7
env: RGV=v1.8.29
- rvm: 1.8.7
env: RGV=v1.7.2
- rvm: 1.8.7
env: RGV=v1.6.2
- rvm: 1.8.7
env: RGV=v1.5.3
- rvm: 1.8.7
env: RGV=v1.4.2
- rvm: 1.8.7
env: RGV=v1.3.7
- rvm: 1.8.7
env: RGV=v1.3.6
- rvm: ruby-head
env: RGV=master
This diff could not be displayed because it is too large.
# Bundler Code of Conduct
The Bundler project strongly values contributors from anywhere, regardless of level of experience, gender, gender identity and expression, sexual orientation, disability, physical appearance, body size, race, ethnicity, age, religion, or nationality. As a result, the Bundler team has agreed to and enforces this code of conduct in order to provide a harassment-free experience for everyone who participates in the development of Bundler.
### Summary
Harassment in code and discussion or violation of physical boundaries is completely unacceptable anywhere in the Bundler project’s codebases, issue trackers, chat rooms, mailing lists, meetups, and any other events. Violators will be warned and then blocked or banned by the core team at or before the 3rd violation.
### In detail
Harassment includes offensive verbal comments related to level of experience, gender, gender identity and expression, sexual orientation, disability, physical appearance, body size, race, ethnicity, age, religion, nationality, the use of sexualized language or imagery, deliberate intimidation, stalking, sustained disruption, and unwelcome sexual attention.
Individuals asked to stop any harassing behavior are expected to comply immediately.
Maintainers, including the core team, are also subject to the anti-harassment policy.
If anyone engages in abusive, harassing, or otherwise unacceptable behavior, including maintainers, we may take appropriate action, up to and including warning the offender, deletion of comments, removal from the project’s codebase and communication systems, and escalation to GitHub support.
If you are being harassed, notice that someone else is being harassed, or have any other concerns, please contact a member of [the core team](http://bundler.io/contributors.html) or [email the core team](mailto:team@bundler.io) immediately.
We expect everyone to follow these rules anywhere in the Bundler project’s codebases, issue trackers, IRC channel, group chat, and mailing lists.
This code of conduct applies both within project spaces and in public spaces when an individual is representing the project or its community.
Finally, don't forget that it is human to make mistakes! We all do. Let’s work together to help each other, resolve issues, and learn from the mistakes that we will all inevitably make from time to time.
### Thanks
Thanks to the [JSConf Code of Conduct](http://jsconf.com/codeofconduct.html) and [Fedora Code of Conduct](http://fedoraproject.org/code-of-conduct) for inspiration and ideas. Additional thanks to [Contributor Covenant](http://contributor-covenant.org) for the [default code of conduct](https://github.com/bundler/bundler/blob/master/lib/bundler/templates/newgem/CODE_OF_CONDUCT.md.tt) included in generated gems.
### License
<p class="license" xmlns:dct="http://purl.org/dc/terms/" xmlns:vcard="http://www.w3.org/2001/vcard-rdf/3.0#">
To the extent possible under law, <a rel="dct:publisher" href="http://bundler.io">The Bundler Team</a> has waived all copyright and related or neighboring rights to the <span property="dct:title">Bundler Code of Conduct</span>. This work is published from the <span property="vcard:Country" datatype="dct:ISO3166" content="US" about="http://bundler.io">United States.</span>
<br>
<br>
<a rel="license" href="http://creativecommons.org/publicdomain/zero/1.0/">
<img src="http://i.creativecommons.org/p/zero/1.0/88x31.png" style="border-style: none;" alt="CC0">
</a>
</p>
# Contributing to Bundler
Welcome to Bundler! We are so happy that you're here. We know it can be daunting to joining a new open source project, so here's a quick overview of what you can expect from this documentation.
Bundler welcomes contributions from *everyone*. While contributing, please follow the project [code of conduct](http://bundler.io/conduct.html), so that everyone can be included.
## Quick start
Some guides you might find useful:
* [Submitting pull requests](doc/development/PULL_REQUESTS.md)
* [Filing an issue](doc/contributing/ISSUES.md)
* [Bug triage](doc/contributing/BUG_TRIAGE.md)
## Comprehensive guides
Not finding what you're looking for? More comprehensive guides are [available here](doc/README.md).
Portions copyright (c) 2010 Andre Arko
Portions copyright (c) 2009 Engine Yard
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.
[![Version ](https://img.shields.io/gem/v/bundler.svg?style=flat)](https://rubygems.org/gems/bundler)
[![Build Status](https://img.shields.io/travis/bundler/bundler/master.svg?style=flat)](https://travis-ci.org/bundler/bundler)
[![Code Climate](https://img.shields.io/codeclimate/github/bundler/bundler.svg?style=flat)](https://codeclimate.com/github/bundler/bundler)
[![Inline docs ](http://inch-ci.org/github/bundler/bundler.svg?style=flat)](http://inch-ci.org/github/bundler/bundler)
# Bundler: a gem to bundle gems
Bundler makes sure Ruby applications run the same code on every machine.
It does this by managing the gems that the application depends on. Given a list of gems, it can automatically download and install those gems, as well as any other gems needed by the gems that are listed. Before installing gems, it checks the versions of every gem to make sure that they are compatible, and can all be loaded at the same time. After the gems have been installed, Bundler can help you update some or all of them when new versions become available. Finally, it records the exact versions that have been installed, so that others can install the exact same gems.
### Installation and usage
To install:
```
gem install bundler
```
Bundler is most commonly used to manage your application's dependencies. To use it for this:
```
bundle init
echo 'gem "rspec"' >> Gemfile
bundle install
bundle exec rspec
```
See [bundler.io](http://bundler.io) for the full documentation.
### Troubleshooting
For help with common problems, see [TROUBLESHOOTING](doc/TROUBLESHOOTING.md).
Still stuck? Try [filing an issue](doc/contributing/ISSUES.md).
### Supporting
<a href="https://rubytogether.org/"><img src="https://rubytogether.org/images/rubies.svg" width=200></a><br/>
Bundler is maintained by <a href="https://rubytogether.org/">Ruby Together</a>, a grassroots initiative committed to supporting the critical Ruby infrastructure you rely on. Contribute today <a href="https://rubytogether.org/developers">as an individual</a> or even better, <a href="https://rubytogether.org/companies">as a company</a>, and ensure that Bundler, RubyGems, and other shared tooling is around for years to come.
### Other questions
To see what has changed in recent versions of Bundler, see the [CHANGELOG](CHANGELOG.md).
To get in touch with the Bundler core team and other Bundler users, please see [getting help](doc/contributing/GETTING_HELP.md).
### Contributing
If you'd like to contribute to Bundler, that's awesome, and we <3 you. There's a guide to contributing to Bundler (both code and general help) over in [our documentation section](doc/README.md).
### Code of Conduct
Everyone interacting in the Bundler project’s codebases, issue trackers, chat rooms, and mailing lists is expected to follow the [Bundler code of conduct](https://github.com/bundler/bundler/blob/master/CODE_OF_CONDUCT.md).
#!/usr/bin/env ruby
# frozen_string_literal: true
load File.expand_path("../with_rubygems", __FILE__) if ENV["RGV"]
require "rubygems"
bundler_spec = Gem::Specification.load(File.expand_path("../../bundler.gemspec", __FILE__))
bundler_spec.dependencies.each do |dep|
begin
gem dep.name, dep.requirement
rescue Gem::LoadError => e
$stderr.puts "#{e.message} (#{e.class})"
end
end
Gem.finish_resolve if Gem.respond_to?(:finish_resolve)
load Gem.bin_path("rake", "rake")
#!/usr/bin/env ruby
# frozen_string_literal: true
load File.expand_path("../with_rubygems", __FILE__) if ENV["RGV"]
require "rubygems"
bundler_spec = Gem::Specification.load(File.expand_path("../../bundler.gemspec", __FILE__))
bundler_spec.dependencies.each do |dep|
gem dep.name, dep.requirement
end
Gem.finish_resolve if Gem.respond_to?(:finish_resolve)
load Gem.bin_path("rspec-core", "rspec")
#!/usr/bin/env ruby
# frozen_string_literal: true
load File.expand_path("../with_rubygems", __FILE__) if ENV["RGV"]
require "rubygems"
bundler_spec = Gem::Specification.load(File.expand_path("../../bundler.gemspec", __FILE__))
bundler_spec.dependencies.each do |dep|
gem dep.name, dep.requirement
end
gem "rubocop", "= 0.48.0"
Gem.finish_resolve if Gem.respond_to?(:finish_resolve)
load Gem.bin_path("rubocop", "rubocop")
#!/usr/bin/env ruby
# frozen_string_literal: true
require "pathname"
def run(*cmd)
return if system(*cmd)
raise "Running `#{cmd.join(" ")}` failed"
end
version = ENV.delete("RGV")
rubygems_path = Pathname.new(__FILE__).join("../../tmp/rubygems").expand_path
unless rubygems_path.directory?
rubygems_path.parent.mkpath unless rubygems_path.directory?
run("git", "clone", "https://github.com/rubygems/rubygems.git", rubygems_path.to_s)
end
Dir.chdir(rubygems_path) do
version = "v#{version}" if version =~ /\A\d/
run("git", "checkout", version, "--quiet")
end if version
rubygems_lib = rubygems_path + "lib"
ENV["RUBYOPT"] = %(-I#{rubygems_lib} #{ENV["RUBYOPT"]})
if $0 != __FILE__
ARGV.unshift($0)
elsif cmd = ARGV.first
possible_dirs = [
Pathname.new(__FILE__) + "..",
Pathname.new(__FILE__) + "../../exe",
rubygems_path + "bin",
]
cmd = possible_dirs.map do |dir|
dir.join(cmd).expand_path
end.find(&:file?)
ARGV[0] = cmd.to_s if cmd
end
exec(*ARGV)
# coding: utf-8
# frozen_string_literal: true
lib = File.expand_path("../lib/", __FILE__)
$:.unshift lib unless $:.include?(lib)
require "bundler/version"
Gem::Specification.new do |s|
s.name = "bundler"
s.version = Bundler::VERSION
s.license = "MIT"
s.authors = [
"André Arko", "Samuel Giddins", "Chris Morris", "James Wen", "Tim Moore",
"André Medeiros", "Jessica Lynn Suttles", "Terence Lee", "Carl Lerche",
"Yehuda Katz"
]
s.email = ["team@bundler.io"]
s.homepage = "http://bundler.io"
s.summary = "The best way to manage your application's dependencies"
s.description = "Bundler manages an application's dependencies through its entire life, across many machines, systematically and repeatably"
if s.respond_to?(:metadata=)
s.metadata = {
"bug_tracker_uri" => "http://github.com/bundler/bundler/issues",
"changelog_uri" => "https://github.com/bundler/bundler/blob/master/CHANGELOG.md",
"homepage_uri" => "https://bundler.io/",
"source_code_uri" => "http://github.com/bundler/bundler/",
}
end
s.required_ruby_version = ">= 1.8.7"
s.required_rubygems_version = ">= 1.3.6"
s.add_development_dependency "automatiek", "~> 0.1.0"
s.add_development_dependency "mustache", "0.99.6"
s.add_development_dependency "rake", "~> 10.0"
s.add_development_dependency "rdiscount", "~> 2.2"
s.add_development_dependency "ronn", "~> 0.7.3"
s.add_development_dependency "rspec", "~> 3.5"
s.files = `git ls-files -z`.split("\x0").reject {|f| f.match(%r{^(test|spec|features)/}) }
# we don't check in man pages, but we need to ship them because
# we use them to generate the long-form help for each command.
s.files += Dir.glob("man/**/*")
s.bindir = "exe"
s.executables = %w(bundle bundler)
s.require_paths = ["lib"]
end
# Docs: Contributing and developing Bundler
_If you're looking for documentation on how to use Bundler: visit [bundler.io](http://bundler.io/), or run `bundle help` from the command line. You may also be interested in [troubleshooting common issues](TROUBLESHOOTING.md) found when using Bundler._
Bundler welcomes contributions from *everyone*. While contributing, please follow the project [code of conduct](http://bundler.io/conduct.html), so that everyone can be included.
If you'd like to help make Bundler better, you totally rock! Thanks for helping us make Bundler better.
## Contributing
* [Overview & getting started](contributing/README.md)
* [How you can help: your first contributions!](contributing/HOW_YOU_CAN_HELP.md)
* [Bug triage](contributing/BUG_TRIAGE.md)
* [Getting help](contributing/GETTING_HELP.md)
* [Filing issues](contributing/ISSUES.md)
* [Community](contributing/COMMUNITY.md)
## Development
* [Overview](development/README.md)
* [Development setup](development/SETUP.md)
* [Submitting pull requests](development/PULL_REQUESTS.md)
* [Adding new features](development/NEW_FEATURES.md)
* [Releasing Bundler](development/RELEASING.md)
## Documentation
* [Overview](documentation/README.md)
* [Writing docs for man pages](documentation/WRITING.md)
* [Documentation vision](documentation/VISION.md)
# Troubleshooting common issues
Stuck using Bundler? Browse these common issues before [filing a new issue](contributing/ISSUES.md).
## Permission denied when installing bundler
Certain operating systems such as MacOS and Ubuntu have versions of Ruby that require elevated privileges to install gems.
ERROR: While executing gem ... (Gem::FilePermissionError)
You don't have write permissions for the /Library/Ruby/Gems/2.0.0 directory.
There are multiple ways to solve this issue. You can install bundler with elevated privilges using `sudo` or `su`.
sudo gem install bundler
If you cannot elevated your privileges or do not want to globally install Bundler, you can use the `--user-install` option.
gem install bundler --user-install
This will install Bundler into your home directory. Note that you will need to append `~/.gem/ruby/<ruby version>/bin` to your `$PATH` variable to use `bundle`.
## Heroku errors
Please open a ticket with [Heroku](https://www.heroku.com) if you're having trouble deploying. They have a professional support team who can help you resolve Heroku issues far better than the Bundler team can. If the problem that you are having turns out to be a bug in Bundler itself, [Heroku support](https://www.heroku.com/support) can get the exact details to us.
## Other problems
First, figure out exactly what it is that you're trying to do (see [XY Problem](http://xyproblem.info/)). Then, go to the [Bundler documentation website](http://bundler.io) and see if we have instructions on how to do that.
Second, check [the compatibility
list](http://bundler.io/compatibility.html), and make sure that the version of Bundler that you are using works with the versions of Ruby and Rubygems that you are using. To see your versions:
# Bundler version
bundle -v
# Ruby version
ruby -v
# Rubygems version
gem -v
If these instructions don't work, or you can't find any appropriate instructions, you can try these troubleshooting steps:
# Remove user-specific gems and git repos
rm -rf ~/.bundle/ ~/.gem/bundler/ ~/.gems/cache/bundler/
# Remove system-wide git repos and git checkouts
rm -rf $GEM_HOME/bundler/ $GEM_HOME/cache/bundler/
# Remove project-specific settings
rm -rf .bundle/
# Remove project-specific cached gems and repos
rm -rf vendor/cache/
# Remove the saved resolve of the Gemfile
rm -rf Gemfile.lock
# Uninstall the rubygems-bundler and open_gem gems
rvm gemset use global # if using rvm
gem uninstall rubygems-bundler open_gem
# Try to install one more time
bundle install
# Bug triage
Triaging is the work of processing tickets that have been opened by users. Common tasks include verifying bugs, categorizing tickets, and ensuring there's enough information to reproduce the bug for anyone who wants to try to fix it.
We've created an [issues guide](ISSUES.md) to walk users through the process of how to report an issue with the Bundler project. We also have a [troubleshooting guide](../TROUBLESHOOTING.md) to diagnose common problems.
Not every ticket will be a bug in Bundler's code, but open tickets usually mean that the there is something we could improve to help that user. Sometimes that means writing additional documentation or making error messages clearer.
## Triaging existing issues
When you're looking at a ticket, here are the main questions to ask:
* Can I reproduce this bug myself?
* Are the steps to reproduce the bug clearly documented in the ticket?
* Which versions of Bundler (1.1.x, 1.2.x, git, etc.) manifest this bug?
* Which operating systems (OS X, Windows, Ubuntu, CentOS, etc.) manifest this bug?
* Which rubies (MRI, JRuby, Rubinius, etc.) and which versions (1.8.7, 1.9.3, etc.) have this bug?
If you can't reproduce the issue, chances are good that the bug has been fixed already (hurrah!). That's a good time to post to the ticket explaining what you did and how it worked.
If you can reproduce an issue, you're well on your way to fixing it. :)
## Fixing your triaged bug
Everyone is welcome and encouraged to fix any open bug, improve an error message or add documentation. If you have a fix or an improvement to a ticket that you would like to contribute, we have a small guide to help:
1. Discuss the fix on the existing issue. Coordinating with everyone else saves duplicate work and serves as a great way to get suggestions and ideas if you need any.
2. Base your commits on the correct branch. Bugfixes for 1.x versions of Bundler should be based on the matching 1-x-stable branch.
3. Review the [pull request guide](../development/PULL_REQUESTS.md).
4. Commit the code with at least one test covering your changes to a named branch in your fork.
5. Put a line in the [CHANGELOG](../../CHANGELOG.md) summarizing your changes under the next release under the “Bugfixes” heading.
6. Send us a [pull request](https://help.github.com/articles/using-pull-requests) from your bugfix branch.
## Duplicates!
Finally, the ticket may be a duplicate of another older ticket. If you notice a ticket is a duplicate, simply comment on the ticket noting the original ticket’s number. For example, you could say “This is a duplicate of issue #42, and can be closed”.
# Community
Community is an important part of all we do. If you’d like to be part of the Bundler community, you can jump right in and start helping make Bundler better for everyone who uses it.
It would be tremendously helpful to have more people answering questions about Bundler (and often simply about [Rubygems](https://github.com/rubygems/rubygems) or Ruby itself) in our [issue tracker](https://github.com/bundler/bundler/issues) or on [Stack Overflow](http://stackoverflow.com/questions/tagged/bundler).
Additional documentation and explanation is always helpful, too. If you have any suggestions for the Bundler website [bundler.io](http://bundler.io), we would absolutely love it if you opened an issue or pull request on the [bundler-site](https://github.com/bundler/bundler-site) repository.
Sharing your experiences and discoveries by writing them up is a valuable way to help others who have similar problems or experiences in the future. You can write a blog post, create an example and commit it to GitHub, take screenshots, or make videos.
Publishing examples of how Bundler is used helps everyone, and we’ve discovered that people already use it in ways that we never imagined when we were writing it. If you’re still not sure what to write about, there are also several projects doing interesting things based on Bundler. They could probably use publicity too.
Finally, all contributors to the Bundler project must agree to the contributor [code of conduct](http://bundler.io/conduct.html). By participating in this project you agree to abide by its terms.
# Getting help
If you have any questions after reading the documentation for contributing, please feel free to contact either [@indirect](https://github.com/indirect), [@segiddins](https://github.com/segiddins), or [@RochesterinNYC](https://github.com/RochesterinNYC). They are all happy to provide help working through your first bug fix or thinking through the problem you’re trying to resolve.
The best ways to get in touch are:
* [Bundler Slack](https://bundler.slack.com).
* Not a member of the Slack? Join the Bundler team slack [here](http://slack.bundler.io/)!
* [Bundler mailing list](http://groups.google.com/group/ruby-bundler)
You may also find our guide on [filing issues](ISSUES.md) to be helpful as well!
# How you can help: your first commits!
If you’re interested in contributing to Bundler, that’s awesome! We’d love your help.
If at any point you get stuck, here's how to [get in touch with the Bundler team for help](GETTING_HELP.md).
## First contribution suggestions
We track [small bugs and features](https://github.com/bundler/bundler/labels/contribution%3A%20small) so that anyone who wants to help can start with something that's not too overwhelming.
Generally, great ways to get started helping out with Bundler are:
- using prerelease versions (run `gem install bundler --pre`)
- [reporting bugs you encounter or suggesting new features](https://github.com/bundler/bundler/issues/new)
- see our [issues guide](ISSUES.md) for help on filing issues
- see the [new features documentation](../development/NEW_FEATURES.md) for more
- adding to or editing [the Bundler documentation website](http://bundler.io) and [Bundler man pages](http://bundler.io/man/bundle.1.html)
- [checking issues for completeness](BUG_TRIAGE.md)
- closing issues that are not complete
- adding a failing test for reproducible [reported bugs](https://github.com/bundler/bundler/issues)
- reviewing [pull requests](https://github.com/bundler/bundler/pulls) and suggesting improvements
- improving existing code, including suggestions from [PullReview](https://www.pullreview.com/github/bundler/bundler/reviews/master) or [CodeClimate](https://codeclimate.com/github/bundler/bundler)
- writing code (no patch is too small! fix typos or bad whitespace)
- get started setting up your dev environment with [these instructions](../development/DEVELOPMENT_SETUP.md)
- backfilling [unit tests](https://github.com/bundler/bundler/tree/master/spec/bundler) for modules that lack [coverage](https://codeclimate.com/github/bundler/bundler/coverage)
If nothing on those lists looks good, [talk to us](http://slack.bundler.io/), and we'll figure out what you can help with. We can absolutely use your help, no matter what level of programming skill you have at the moment.
# Filing Issues: a guide
So! You're having problems with Bundler. This file is here to help. If you're running into an error, try reading the rest of this file for help. If you can't figure out how to solve your problem, there are also instructions on how to report a bug.
Before filing an issue, check our [troubleshooting guide](../TROUBLESHOOTING.md) for quick fixes to common issues.
## Documentation
Instructions for common Bundler uses can be found on the [Bundler documentation site](http://bundler.io/).
Detailed information about each Bundler command, including help with common problems, can be found in the [Bundler man pages](http://bundler.io/man/bundle.1.html) or [Bundler Command Line Reference](http://bundler.io/v1.11/commands.html).
## Reporting unresolved problems
Check our [troubleshooting common issues guide](../TROUBLESHOOTING.md) and see if your issues is resolved using the steps provided.
Hopefully the troubleshooting steps above resolved your problem! If things still aren't working the way you expect them to, please let us know so that we can diagnose and hopefully fix the problem you're having.
**The best way to report a bug is by providing a reproduction script.** See these examples:
* [Git environment variables causing install to fail.](https://gist.github.com/xaviershay/6207550)
* [Multiple gems in a repository cannot be updated independently.](https://gist.github.com/xaviershay/6295889)
A half working script with comments for the parts you were unable to automate is still appreciated.
If you are unable to do that, please include the following information in your report:
- What you're trying to accomplish
- The command you ran
- What you expected to happen
- What actually happened
- The exception backtrace(s), if any
- Everything output by running `bundle env`
If your version of Bundler does not have the `bundle env` command, then please include:
- Your `Gemfile`
- Your `Gemfile.lock`
- Your Bundler configuration settings (run `bundle config`)
- What version of bundler you are using (run `bundle -v`)
- What version of Ruby you are using (run `ruby -v`)
- What version of Rubygems you are using (run `gem -v`)
- Whether you are using RVM, and if so what version (run `rvm -v`)
- Whether you have the `rubygems-bundler` gem, which can break gem executables (run `gem list rubygems-bundler`)
- Whether you have the `open_gem` gem, which can cause rake activation conflicts (run `gem list open_gem`)
If you have either `rubygems-bundler` or `open_gem` installed, please try removing them and then following the troubleshooting steps above before opening a new ticket.
[Create a gist](https://gist.github.com) containing all of that information, then visit the [Bundler issue tracker](https://github.com/bundler/bundler/issues) and [create a ticket](https://github.com/bundler/bundler/issues/new) describing your problem and linking to your gist.
Thanks for reporting issues and helping make Bundler better!
# Contributing to Bundler
Welcome to Bundler! We are so happy that you're here. We know it can be daunting to joining a new open source project, so here's a quick overview of what you can expect from this documentation.
*Something missing?* Send us a [pull request](../development/PULL_REQUESTS.md)!
**Recommended first steps**
- Join us in the Bundler slack! Generate an invite [here](http://slack.bundler.io/)
- *If you're interested in helping with code:*
- Get a quick overview of our [development process](../development/README.md)
- [Setup your machine for development](../development/SETUP.md)
- Checkout [How you can help: your first contributions!](HOW_YOU_CAN_HELP.md) for a list of suggestions to get started
- *If you're interested in helping with documentation:*
- Read up on [how documentation works for Bundler](../documentation/README.md)
- Learn about our [documentation vision](../documentation/VISION.md)
You can start learning about Bundler by reading [the documentation](http://bundler.io). If you want, you can also read a (lengthy) explanation of [why Bundler exists and what it does](http://bundler.io/rationale.html).
##[How you can help: your first contributions!](HOW_YOU_CAN_HELP.md)
A detailed overview of how to get started contributing to Bundler, including a long list of suggestions for your first project.
##[Bug triage](BUG_TRIAGE.md)
Want to take a stab at processing issues? Start here.
##[Getting help](GETTING_HELP.md)
How to get in touch with folks who can help when you're stuck. Don't worry! This happens to all of us. We're really nice, we promise.
##[Filing issues](ISSUES.md)
We see a lot of issues in the Bundler repo! Use this guide to file informative, actionable issues.
##[Community](COMMUNITY.md)
Learn more about our goals for the Bundler community and the ways you can help us build better together.
# Adding New Features
If you would like to add a new feature to Bundler, please follow these steps:
1. [Create an issue](https://github.com/bundler/bundler/issues/new) with the [`feature-request` label](https://github.com/bundler/bundler/labels/type:%20feature-request) to discuss your feature.
2. Base your commits on the master branch, since we follow [SemVer](http://semver.org) and don't add new features to old releases.
3. Commit the code and at least one test covering your changes to a feature branch in your fork.
4. Send us a [pull request](PULL_REQUESTS.md) from your feature branch.
If you don't hear back immediately, don’t get discouraged! We all have day jobs, but we respond to most tickets within a day or two.
# Submitting Pull Requests
Before you submit a pull request, please remember to do the following:
1. Check your code format and style
2. Run the test suite
3. Use a meaningful commit message without tags
## Code formatting
Make sure the code formatting and styling adheres to the guidelines. We use RuboCop for this. Lack of formatting adherence will result in automatic Travis build failures.
$ bin/rubocop -a
## Tests
Prior to submitting your PR, please run the test suite:
$ bin/rspec
If you are unable to run the entire test suite, please run the unit test suite and at least the integration specs related to the command or domain of Bundler that your code changes relate to.
Ex. For a pull request that changes something with `bundle update`, you might run:
$ bin/rspec spec/bundler
$ bin/rspec spec/commands/update_spec.rb
## Commit messages
Please ensure that the commit messages included in the pull request __do not__ have the following:
- `@tag` GitHub user or team references (ex. `@indirect` or `@bundler/core`)
- `#id` references to issues or pull requests (ex. `#43` or `bundler/bundler-site#12`)
If you want to use these mechanisms, please instead include them in the pull request description. This prevents multiple notifications or references being created on commit rebases or pull request/branch force pushes.
Additionally, do not use `[ci skip]` or `[skip ci]` mechanisms in your pull request titles/descriptions or commit messages. Every potential commit and pull request should run through Bundler's CI system. This applies to all changes/commits (ex. even a change to just documentation or the removal of a comment).
## CHANGELOG.md
Don't forget to add your changes into the CHANGELOG! If you're submitting documentation, note the changes under the "Documentation" heading.
# Development
So, you're ready to start contributing to Bundler! You've come to the right place. Here you'll find an overview of how to work on Bundler locally and a description of the process from code to release.
##[Development setup](SETUP.md)
Guidelines for setting up your local development environment.
##[Submitting pull requests](PULL_REQUESTS.md)
An overview of our preferred PR process, including how to run the test suite and what to expect when you submit code for review.
##[Adding new features](NEW_FEATURES.md)
Guidelines for proposing and writing new features for Bundler.
##[Releasing Bundler](RELEASING.md)
A broad-strokes overview of the release process adhered to by the Bundler core team.
# Releasing
_Release process documentation is in progress, see [PR 5252](https://github.com/bundler/bundler/pull/5252)._
## Beta testing
Early releases require heavy testing, especially across various system setups. We :heart: testers, and are big fans of anyone who can run `gem install bundler --pre` and try out upcoming releases in their development and staging environments.
There may not always be prereleases or beta versions of Bundler. The Bundler team will tweet from the [@bundlerio account](http://twitter.com/bundlerio) when a prerelease or beta version becomes available. You are also always welcome to try checking out master and building a gem yourself if you want to try out the latest changes.
# Development setup
Bundler doesn't use a Gemfile to list development dependencies, because when we tried it we couldn't tell if we were awake or it was just another level of dreams. To work on Bundler, you'll probably want to do a couple of things.
1. Install `groff-base` and `graphviz` packages using your package manager, e.g for ubuntu
$ sudo apt-get install graphviz groff-base -y
and for OS X (with brew installed)
$ brew install graphviz homebrew/dupes/groff
2. Install Bundler's development dependencies
$ bin/rake spec:deps
3. Run the test suite, to make sure things are working
$ bin/rake spec
4. Set up a shell alias to run Bundler from your clone, e.g. a Bash alias:
$ alias dbundle='BUNDLE_TRAMPOLINE_DISABLE=1 ruby -I /path/to/bundler/lib /path/to/bundler/exe/bundle'
The `BUNDLE_TRAMPOLINE_DISABLE` environment variable ensures that the version of Bundler in `/path/to/bundler/lib` will be used. Without that environment setting, Bundler will automatically download, install, and run the version of Bundler listed in `Gemfile.lock`. With that set up, you can test changes you've made to Bundler by running `dbundle`, without interfering with the regular `bundle` command.
## Debugging with `pry`
To dive into the code with Pry: `RUBYOPT=-rpry dbundle` to require pry and then run commands.
# Documentation
Code needs explanation, and sometimes those who know the code well have trouble explaining it to someone just getting into it. Because of that, we welcome documentation suggestions and patches from everyone, especially if they are brand new to using Bundler.
Currently, Bundler has two main sources of documentation:
1. built-in `help` (including usage information and man pages)
2. [Bundler documentation site](http://bundler.io)
If you have a suggestion or proposed change for [bundler.io](http://bundler.io), please open an issue or send a pull request to the [bundler-site](https://github.com/bundler/bundler-site) repository.
Not sure where to write documentation? In general, follow these guidelines:
* For an explanation of a specific Bundler command (ex: `bundle clean`): make changes to the man pages
* For longer explanations or usage guides (ex: "Using Bundler with Rails"): create new documentation within the [bundler-site](https://github.com/bundler/bundler-site) repository
If you are unsure where to begin, ping [@feministy](https://github.com/feministy) or [@indirect](https://github.com/indirect) in the Bundler Slack ([get an invite here](../contributing/GETTING_HELP.md)).
## [Writing docs for man pages)](WRITING.md)
If you’d like to submit a patch to the man pages, you're in the right place! Details on editing and previewing changes to man pages can be found here.
## [Documentation vision](VISION.md)
Just like Bundler, we have a grand plan (really, a wish list of sorts) for Bundler documentation. Preview our hopes and dreams for our documentation here.
## Translations
We don't currently have any translations, but please reach out to us if you would like to help get this going.
# Documentation vision
Currently, documentation for using Bundler is spread across two places:
1. built-in `help` (including usage information and man pages)
2. [Bundler documentation site](http://bundler.io)
Additional documentation about using Bundler to publish gems can also be found on the [RubyGems guides](http://guides.rubygems.org/).
## Goals
Bundler documentation should provide users with assistance:
1. Installing Bundler
2. Using Bundler to manage an application's dependencies
3. Using Bundler to create, package, and publish gems
Our goal is to provide three types of documentation:
* High level overviews that provide topical guidance
* Step-by-step tutorials
* Command-specific reference material for the CLI
Additionally, this documentation should be readily available in a logical place and easy to follow.
Someday, we'd like to create deep-dive reference material about the inner workings of Bundler. However, while this is part of our overall vision for Bundler documentation, it is not the focus of our current work.
# Writing docs for man pages
A primary source of help for Bundler users are the man pages: the output printed when you run `bundle help` (or `bundler help`). These pages can be a little tricky to format and preview, but are pretty straightforward once you get the hang of it.
_Note: `bundler` and `bundle` may be used interchangeably in the CLI. This guide uses `bundle` because it's cuter._
## What goes in man pages?
We use man pages for Bundler commands used in the CLI (command line interface). They can vary in length from large (see `bundle install`) to very short (see `bundle clean`).
To see a list of commands available in the Bundler CLI, type:
$ bundle help
Our goal is to have a man page for every command.
Don't see a man page for a command? Make a new page and send us a PR! We also welcome edits to existing pages.
## Creating a new man page
To create a new man page, simply create a new `.ronn` file in the `man/` directory.
For example: to create a man page for the command `bundle cookies` (not a real command, sadly), I would create a file `man/bundle-cookies.ronn` and add my documentation there.
## Formatting
Our man pages use ronn formatting, a combination of Markdown and standard man page conventions. It can be a little weird getting used to it at first, especially if you've used Markdown a lot.
[The ronn guide formatting guide](https://rtomayko.github.io/ronn/ronn.7.html) provides a good overview of the common types of formatting.
In general, make your page look like the other pages: utilize sections like `##OPTIONS` and formatting like code blocks and definition lists where appropriate.
If you're not sure if the formatting looks right, that's ok! Make a pull request with what you've got and we'll take a peek.
## Previewing
To preview your changes as they will print out for Bundler users, you'll need to run a series of commands:
```
$ rake spec:deps
$ rake man:build
$ man man/bundle-cookies.1
```
If you make more changes to `bundle-cookies.ronn`, you'll need to run the `rake man:build` again before previewing.
## Testing
We have tests for our documentation! The most important test file to run before you make your pull request is the one for the `help` command and another for documentation quality.
```
$ rspec ./spec/commands/help_spec.rb
$ rspec ./spec/quality_spec.rb
```
#!/usr/bin/env ruby
# frozen_string_literal: true
# Exit cleanly from an early interrupt
Signal.trap("INT") do
Bundler.ui.debug("\n#{caller.join("\n")}") if defined?(Bundler)
exit 1
end
update = "update".start_with?(ARGV.first || " ") && ARGV.find {|a| a.start_with?("--bundler") }
update &&= update =~ /--bundler(?:=(.+))?/ && $1 || "> 0.a"
ENV["BUNDLER_VERSION"] = update if update
require "bundler/postit_trampoline"
require "bundler"
# Check if an older version of bundler is installed
$LOAD_PATH.each do |path|
next unless path =~ %r{/bundler-0\.(\d+)} && $1.to_i < 9
err = String.new
err << "Looks like you have a version of bundler that's older than 0.9.\n"
err << "Please remove your old versions.\n"
err << "An easy way to do this is by running `gem cleanup bundler`."
abort(err)
end
require "bundler/friendly_errors"
Bundler.with_friendly_errors do
require "bundler/cli"
# Allow any command to use --help flag to show help for that command
help_flags = %w(--help -h)
help_flag_used = ARGV.any? {|a| help_flags.include? a }
args = help_flag_used ? Bundler::CLI.reformatted_help_args(ARGV) : ARGV
Bundler::CLI.start(args, :debug => true)
end
#!/usr/bin/env ruby
# frozen_string_literal: true
Signal.trap("INT") { exit 1 }
require "bundler/errors"
require "bundler/ruby_version"
require "bundler/ruby_dsl"
require "bundler/shared_helpers"
module Bundler
class Dsl
include RubyDsl
attr_accessor :ruby_version
def initialize
@ruby_version = nil
end
def eval_gemfile(gemfile, contents = nil)
contents ||= File.open(gemfile, "rb", &:read)
instance_eval(contents, gemfile.to_s, 1)
rescue SyntaxError => e
bt = e.message.split("\n")[1..-1]
raise GemfileError, ["Gemfile syntax error:", *bt].join("\n")
rescue ScriptError, RegexpError, NameError, ArgumentError => e
e.backtrace[0] = "#{e.backtrace[0]}: #{e.message} (#{e.class})"
STDERR.puts e.backtrace.join("\n ")
raise GemfileError, "There was an error in your Gemfile," \
" and Bundler cannot continue."
end
def source(source, options = {})
end
def gem(name, *args)
end
def group(*args)
end
end
end
Bundler::SharedHelpers.major_deprecation("the bundle_ruby executable has been removed in favor of `bundle platform --ruby`")
dsl = Bundler::Dsl.new
begin
dsl.eval_gemfile(Bundler::SharedHelpers.default_gemfile)
ruby_version = dsl.ruby_version
if ruby_version
puts ruby_version
else
puts "No ruby version specified"
end
rescue Bundler::GemfileError => e
puts e.message
exit(-1)
end
#!/usr/bin/env ruby
# frozen_string_literal: true
load File.expand_path("../bundle", __FILE__)
# frozen_string_literal: true
# Capistrano task for Bundler.
#
# Add "require 'bundler/capistrano'" in your Capistrano deploy.rb, and
# Bundler will be activated after each new deployment.
require "bundler/deployment"
require "capistrano/version"
if defined?(Capistrano::Version) && Gem::Version.new(Capistrano::Version).release >= Gem::Version.new("3.0")
raise "For Capistrano 3.x integration, please use http://github.com/capistrano/bundler"
end
Capistrano::Configuration.instance(:must_exist).load do
before "deploy:finalize_update", "bundle:install"
Bundler::Deployment.define_task(self, :task, :except => { :no_release => true })
set :rake, lambda { "#{fetch(:bundle_cmd, "bundle")} exec rake" }
end
# frozen_string_literal: true
require "bundler/cli/common"
module Bundler
class CLI::Add
def initialize(options, gem_name)
@gem_name = gem_name
@options = options
@options[:group] = @options[:group].split(",").map(&:strip) if !@options[:group].nil? && !@options[:group].empty?
end
def run
version = @options[:version].nil? ? nil : @options[:version].split(",").map(&:strip)
unless version.nil?
version.each do |v|
raise InvalidOption, "Invalid gem requirement pattern '#{v}'" unless Gem::Requirement::PATTERN =~ v.to_s
end
end
dependency = Bundler::Dependency.new(@gem_name, version, @options)
Injector.inject([dependency], :conservative_versioning => @options[:version].nil?) # Perform conservative versioning only when version is not specified
Installer.install(Bundler.root, Bundler.definition)
end
end
end
# frozen_string_literal: true
require "bundler/cli/common"
module Bundler
class CLI::Binstubs
attr_reader :options, :gems
def initialize(options, gems)
@options = options
@gems = gems
end
def run
Bundler.definition.validate_runtime!
Bundler.settings[:bin] = options["path"] if options["path"]
Bundler.settings[:bin] = nil if options["path"] && options["path"].empty?
installer = Installer.new(Bundler.root, Bundler.definition)
if gems.empty?
Bundler.ui.error "`bundle binstubs` needs at least one gem to run."
exit 1
end
gems.each do |gem_name|
spec = Bundler.definition.specs.find {|s| s.name == gem_name }
unless spec
raise GemNotFound, Bundler::CLI::Common.gem_not_found_message(
gem_name, Bundler.definition.specs
)
end
if spec.name == "bundler"
Bundler.ui.warn "Sorry, Bundler can only be run via Rubygems."
elsif options[:standalone]
installer.generate_standalone_bundler_executable_stubs(spec)
else
installer.generate_bundler_executable_stubs(spec, :force => options[:force], :binstubs_cmd => true)
end
end
end
end
end
# frozen_string_literal: true
module Bundler
class CLI::Cache
attr_reader :options
def initialize(options)
@options = options
end
def run
Bundler.definition.validate_runtime!
Bundler.definition.resolve_with_cache!
setup_cache_all
Bundler.settings[:cache_all_platforms] = options["all-platforms"] if options.key?("all-platforms")
Bundler.load.cache
Bundler.settings[:no_prune] = true if options["no-prune"]
Bundler.load.lock
rescue GemNotFound => e
Bundler.ui.error(e.message)
Bundler.ui.warn "Run `bundle install` to install missing gems."
exit 1
end
private
def setup_cache_all
Bundler.settings[:cache_all] = options[:all] if options.key?("all")
if Bundler.definition.has_local_dependencies? && !Bundler.settings[:cache_all]
Bundler.ui.warn "Your Gemfile contains path and git dependencies. If you want " \
"to package them as well, please pass the --all flag. This will be the default " \
"on Bundler 2.0."
end
end
end
end
# frozen_string_literal: true
module Bundler
class CLI::Check
attr_reader :options
def initialize(options)
@options = options
end
def run
if options[:path]
Bundler.settings[:path] = File.expand_path(options[:path])
Bundler.settings[:disable_shared_gems] = true
end
begin
definition = Bundler.definition
definition.validate_runtime!
not_installed = definition.missing_specs
rescue GemNotFound, VersionConflict
Bundler.ui.error "Bundler can't satisfy your Gemfile's dependencies."
Bundler.ui.warn "Install missing gems with `bundle install`."
exit 1
end
if not_installed.any?
Bundler.ui.error "The following gems are missing"
not_installed.each {|s| Bundler.ui.error " * #{s.name} (#{s.version})" }
Bundler.ui.warn "Install missing gems with `bundle install`"
exit 1
elsif !Bundler.default_lockfile.file? && Bundler.settings[:frozen]
Bundler.ui.error "This bundle has been frozen, but there is no #{Bundler.default_lockfile.relative_path_from(SharedHelpers.pwd)} present"
exit 1
else
Bundler.load.lock(:preserve_unknown_sections => true) unless options[:"dry-run"]
Bundler.ui.info "The Gemfile's dependencies are satisfied"
end
end
end
end
# frozen_string_literal: true
module Bundler
class CLI::Clean
attr_reader :options
def initialize(options)
@options = options
end
def run
require_path_or_force unless options[:"dry-run"]
Bundler.load.clean(options[:"dry-run"])
end
protected
def require_path_or_force
if !Bundler.settings[:path] && !options[:force]
Bundler.ui.error "Cleaning all the gems on your system is dangerous! " \
"If you're sure you want to remove every system gem not in this " \
"bundle, run `bundle clean --force`."
exit 1
end
end
end
end
# frozen_string_literal: true
module Bundler
module CLI::Common
def self.output_post_install_messages(messages)
return if Bundler.settings["ignore_messages"]
messages.to_a.each do |name, msg|
print_post_install_message(name, msg) unless Bundler.settings["ignore_messages.#{name}"]
end
end
def self.print_post_install_message(name, msg)
Bundler.ui.confirm "Post-install message from #{name}:"
Bundler.ui.info msg
end
def self.output_without_groups_message
return unless Bundler.settings.without.any?
Bundler.ui.confirm without_groups_message
end
def self.without_groups_message
groups = Bundler.settings.without
group_list = [groups[0...-1].join(", "), groups[-1..-1]].
reject {|s| s.to_s.empty? }.join(" and ")
group_str = (groups.size == 1) ? "group" : "groups"
"Gems in the #{group_str} #{group_list} were not installed."
end
def self.select_spec(name, regex_match = nil)
specs = []
regexp = Regexp.new(name) if regex_match
Bundler.definition.specs.each do |spec|
return spec if spec.name == name
specs << spec if regexp && spec.name =~ regexp
end
case specs.count
when 0
raise GemNotFound, gem_not_found_message(name, Bundler.definition.dependencies)
when 1
specs.first
else
ask_for_spec_from(specs)
end
rescue RegexpError
raise GemNotFound, gem_not_found_message(name, Bundler.definition.dependencies)
end
def self.ask_for_spec_from(specs)
if !$stdout.tty? && ENV["BUNDLE_SPEC_RUN"].nil?
raise GemNotFound, gem_not_found_message(name, Bundler.definition.dependencies)
end
specs.each_with_index do |spec, index|
Bundler.ui.info "#{index.succ} : #{spec.name}", true
end
Bundler.ui.info "0 : - exit -", true
num = Bundler.ui.ask("> ").to_i
num > 0 ? specs[num - 1] : nil
end
def self.gem_not_found_message(missing_gem_name, alternatives)
require "bundler/similarity_detector"
message = "Could not find gem '#{missing_gem_name}'."
alternate_names = alternatives.map {|a| a.respond_to?(:name) ? a.name : a }
suggestions = SimilarityDetector.new(alternate_names).similar_word_list(missing_gem_name)
message += "\nDid you mean #{suggestions}?" if suggestions
message
end
def self.ensure_all_gems_in_lockfile!(names, locked_gems = Bundler.locked_gems)
locked_names = locked_gems.specs.map(&:name)
names.-(locked_names).each do |g|
raise GemNotFound, gem_not_found_message(g, locked_names)
end
end
def self.configure_gem_version_promoter(definition, options)
patch_level = patch_level_options(options)
raise InvalidOption, "Provide only one of the following options: #{patch_level.join(", ")}" unless patch_level.length <= 1
definition.gem_version_promoter.tap do |gvp|
gvp.level = patch_level.first || :major
gvp.strict = options[:strict] || options["update-strict"]
end
end
def self.patch_level_options(options)
[:major, :minor, :patch].select {|v| options.keys.include?(v.to_s) }
end
end
end
# frozen_string_literal: true
module Bundler
class CLI::Config
attr_reader :name, :options, :scope, :thor
attr_accessor :args
def initialize(options, args, thor)
@options = options
@args = args
@thor = thor
@name = peek = args.shift
@scope = "global"
return unless peek && peek.start_with?("--")
@name = args.shift
@scope = peek[2..-1]
end
def run
unless name
confirm_all
return
end
unless valid_scope?(scope)
Bundler.ui.error "Invalid scope --#{scope} given. Please use --local or --global."
exit 1
end
if scope == "delete"
Bundler.settings.set_local(name, nil)
Bundler.settings.set_global(name, nil)
return
end
if args.empty?
if options[:parseable]
if value = Bundler.settings[name]
Bundler.ui.info("#{name}=#{value}")
end
return
end
confirm(name)
return
end
Bundler.ui.info(message) if message
Bundler.settings.send("set_#{scope}", name, new_value)
end
private
def confirm_all
if @options[:parseable]
thor.with_padding do
Bundler.settings.all.each do |setting|
val = Bundler.settings[setting]
Bundler.ui.info "#{setting}=#{val}"
end
end
else
Bundler.ui.confirm "Settings are listed in order of priority. The top value will be used.\n"
Bundler.settings.all.each do |setting|
Bundler.ui.confirm "#{setting}"
show_pretty_values_for(setting)
Bundler.ui.confirm ""
end
end
end
def confirm(name)
Bundler.ui.confirm "Settings for `#{name}` in order of priority. The top value will be used"
show_pretty_values_for(name)
end
def new_value
pathname = Pathname.new(args.join(" "))
if name.start_with?("local.") && pathname.directory?
pathname.expand_path.to_s
else
args.join(" ")
end
end
def message
locations = Bundler.settings.locations(name)
if @options[:parseable]
"#{name}=#{new_value}" if new_value
elsif scope == "global"
if locations[:local]
"Your application has set #{name} to #{locations[:local].inspect}. " \
"This will override the global value you are currently setting"
elsif locations[:env]
"You have a bundler environment variable for #{name} set to " \
"#{locations[:env].inspect}. This will take precedence over the global value you are setting"
elsif locations[:global] && locations[:global] != args.join(" ")
"You are replacing the current global value of #{name}, which is currently " \
"#{locations[:global].inspect}"
end
elsif scope == "local" && locations[:local] != args.join(" ")
"You are replacing the current local value of #{name}, which is currently " \
"#{locations[:local].inspect}"
end
end
def show_pretty_values_for(setting)
thor.with_padding do
Bundler.settings.pretty_values_for(setting).each do |line|
Bundler.ui.info line
end
end
end
def valid_scope?(scope)
%w(delete local global).include?(scope)
end
end
end