Class: Blazing::Commands
- Inherits:
-
Object
- Object
- Blazing::Commands
- Includes:
- Logger
- Defined in:
- lib/blazing/commands.rb
Class Method Summary collapse
Instance Method Summary collapse
- #goto ⇒ Object
- #init ⇒ Object
-
#initialize(options = {}) ⇒ Commands
constructor
A new instance of Commands.
- #setup ⇒ Object
- #update ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ Commands
Returns a new instance of Commands.
15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/blazing/commands.rb', line 15 def initialize( = {}) warn 'The :default Target option has been deprecated and will be ignored' if .key?(:default) @cli_options = [:cli_options] @target_name = [:target_name] @config_file = [:file] @command = [:command] @targets = [] return unless command_requires_config? @config ||= Blazing::Config.parse(@config_file) @targets = determine_targets error 'no target given or found' if @targets.empty? end |
Class Method Details
.run(command, options = {}) ⇒ Object
10 11 12 |
# File 'lib/blazing/commands.rb', line 10 def run(command, = {}) new(.merge(command: command)).send(command) end |
Instance Method Details
#goto ⇒ Object
46 47 48 49 50 51 52 53 54 55 |
# File 'lib/blazing/commands.rb', line 46 def goto # TODO: Would be nice to detect zsh and use it instead of bash? @targets.each do |target| if @cli_options[:run] system "ssh -t -t #{target.user}@#{target.host} 'cd #{target.path} && RAILS_ENV=#{target.[:rails_env]} bash --login -c \"#{@cli_options[:run]}\"'" else system "ssh -t -t #{target.user}@#{target.host} 'cd #{target.path} && RAILS_ENV=#{target.[:rails_env]} bash --login'" end end end |
#init ⇒ Object
30 31 32 33 34 35 |
# File 'lib/blazing/commands.rb', line 30 def init info "Creating an example config file in #{Blazing::DEFAULT_CONFIG_LOCATION}" info 'Customize it to your needs' create_config_directory write_config_file end |
#setup ⇒ Object
37 38 39 40 |
# File 'lib/blazing/commands.rb', line 37 def setup @targets.each(&:setup) update end |
#update ⇒ Object
42 43 44 |
# File 'lib/blazing/commands.rb', line 42 def update @targets.each(&:update) end |