Class: BaseCommands::BaseDSLCommands
- Inherits:
-
Object
- Object
- BaseCommands::BaseDSLCommands
- Defined in:
- lib/dsl/commands/base_commands.rb
Direct Known Subclasses
Instance Method Summary collapse
- #execute ⇒ Object
- #path(path) ⇒ Object (also: #path_to_s3cmd)
- #save_script(filename) ⇒ Object
- #send_block_command ⇒ Object
Instance Method Details
#execute ⇒ Object
50 51 52 53 |
# File 'lib/dsl/commands/base_commands.rb', line 50 def execute @execute = true self end |
#path(path) ⇒ Object Also known as: path_to_s3cmd
8 9 10 11 |
# File 'lib/dsl/commands/base_commands.rb', line 8 def path(path) @commands[:path] = path self end |
#save_script(filename) ⇒ Object
45 46 47 48 |
# File 'lib/dsl/commands/base_commands.rb', line 45 def save_script(filename) @save = filename self end |
#send_block_command ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/dsl/commands/base_commands.rb', line 14 def send_block_command @send_block_command = if @commands.include? :path @commands[:path] @commands.delete(:path) else @path.empty? ? 's3cmd' : @path end @commands.each do |key, value| @send_block_command += " #{key} '#{value}'" end @send_block_command.gsub!(/\'/, '').strip! `#{@send_block_command}` if @execute if @save File.open(@save, 'w') do |file| file.write( <<-EOF.unindent_heredoc #!/usr/bin/env bash ##{@name} ##{Time.now} #{@send_block_command} EOF ) end end @send_block_command end |