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.
- #list ⇒ Object
- #recipes ⇒ Object
- #setup ⇒ Object
- #update ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ Commands
14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/blazing/commands.rb', line 14 def initialize( = {}) warn 'The :default Target option has been deprecated and will be ignored' if .has_key?(:default) = [:options] # that stinks! TODO: clean up options handling. @target_name = [:target_name] @config_file = [:file] @command = [:command] @targets = [] if command_requires_config? @config ||= Config.parse(@config_file) @targets = determine_targets error 'no target given or found' if @targets.empty? end end |
Class Method Details
.run(command, options = {}) ⇒ Object
9 10 11 |
# File 'lib/blazing/commands.rb', line 9 def run(command, = {}) self.new(.merge({ :command => command })).send(command) end |
Instance Method Details
#goto ⇒ Object
49 50 51 52 53 54 55 56 57 58 |
# File 'lib/blazing/commands.rb', line 49 def goto # TODO: Would be nice to detect zsh and use it instead of bash? @targets.each do |target| if [:run] system "ssh -t -t #{target.user}@#{target.host} 'cd #{target.path} && RAILS_ENV=#{target.options[:rails_env]} bash --login -c \"#{@cli_options[:run]}\"'" else system "ssh -t -t #{target.user}@#{target.host} 'cd #{target.path} && RAILS_ENV=#{target.options[:rails_env]} bash --login'" end end end |
#init ⇒ Object
29 30 31 32 33 34 |
# File 'lib/blazing/commands.rb', line 29 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 |
#list ⇒ Object
60 61 62 |
# File 'lib/blazing/commands.rb', line 60 def list Blazing::Recipe.pretty_list end |
#recipes ⇒ Object
45 46 47 |
# File 'lib/blazing/commands.rb', line 45 def recipes @config.recipes.each { |recipe| recipe.run({:target_name => @target_name}) } end |
#setup ⇒ Object
36 37 38 39 |
# File 'lib/blazing/commands.rb', line 36 def setup @targets.each { |target| target.setup } update end |
#update ⇒ Object
41 42 43 |
# File 'lib/blazing/commands.rb', line 41 def update @targets.each { |target| target.update } end |