diff --git a/CHANGELOG.md b/CHANGELOG.md index ed1d8e7..5721bcc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,9 @@ ## Unreleased ### Changed -- switched connection part to _capistrano-interactive_ +- switched connection part to _sshkit-interactive_ +- allow setting rails environment separately deployment environment +- allow setting user to run rails console separately from ssh user ## 1.0.2 (2015-12-06) ### Fixed diff --git a/README.md b/README.md index 6afbf01..10d6afb 100644 --- a/README.md +++ b/README.md @@ -43,6 +43,20 @@ You can also start a sandbox session: $ cap production rails:console sandbox=1 +## Options + +### Rails environment + +```ruby +set :console_env, :production +``` + +### User + +```ruby +set :console_user, :appuser +``` + ## Contributing diff --git a/capistrano-rails-console.gemspec b/capistrano-rails-console.gemspec index 64ab029..19ca091 100644 --- a/capistrano-rails-console.gemspec +++ b/capistrano-rails-console.gemspec @@ -18,12 +18,9 @@ Gem::Specification.new do |spec| spec.test_files = spec.files.grep(%r{^(test|spec|features)/}) spec.require_paths = ['lib'] - spec.add_dependency 'capistrano', '>= 3.1.0', '< 4.0.0' - spec.add_dependency 'capistrano-interactive', '~> 0.2.0' - - spec.add_dependency 'sshkit', '>= 1.4' + spec.add_dependency 'capistrano', '>= 3.5.0', '< 4.0.0' + spec.add_dependency 'sshkit-interactive', '~> 0.2.0' spec.add_development_dependency 'bundler' spec.add_development_dependency 'rake' - spec.add_development_dependency 'yard' end diff --git a/lib/capistrano-rails-console.rb b/lib/capistrano-rails-console.rb index e69de29..d995f5a 100644 --- a/lib/capistrano-rails-console.rb +++ b/lib/capistrano-rails-console.rb @@ -0,0 +1 @@ +require 'capistrano/rails/console' diff --git a/lib/capistrano/rails/console/remote.rb b/lib/capistrano/rails/console/remote.rb index 8a333dd..f9c8d94 100644 --- a/lib/capistrano/rails/console/remote.rb +++ b/lib/capistrano/rails/console/remote.rb @@ -1,3 +1,3 @@ -require 'capistrano/interactive' +require 'sshkit/interactive' load File.expand_path('../tasks/remote.cap', __FILE__) diff --git a/lib/capistrano/rails/console/tasks/remote.cap b/lib/capistrano/rails/console/tasks/remote.cap index 51a8512..579fd12 100644 --- a/lib/capistrano/rails/console/tasks/remote.cap +++ b/lib/capistrano/rails/console/tasks/remote.cap @@ -4,7 +4,8 @@ namespace :load do set :rvm_map_bins, fetch(:rvm_map_bins, []).push(:rails) # Default values - set :console_env, -> { fetch(:rails_env, fetch(:stage, 'production')) } + set :console_env, -> { fetch(:rails_env, fetch(:stage, 'production')) } + set :console_user, -> { fetch(:app_user, nil) } end end @@ -14,9 +15,11 @@ namespace :rails do args = [] args << '--sandbox' if ENV.key?('sandbox') || ENV.key?('s') - on primary(:app) do + run_interactively primary(:app) do within current_path do - interact(:rails, :console, fetch(:console_env), *args) + as user: fetch(:console_user) do + execute(:rails, :console, fetch(:console_env), *args) + end end end end diff --git a/lib/capistrano/rails/console/version.rb b/lib/capistrano/rails/console/version.rb index 31d09dc..d51d55a 100644 --- a/lib/capistrano/rails/console/version.rb +++ b/lib/capistrano/rails/console/version.rb @@ -5,7 +5,7 @@ module Capistrano # Console module Console # Gem version - VERSION = '1.1.0' + VERSION = '2.0.0' end end end