Class: Consist::Commands::Upload
- Inherits:
-
Object
- Object
- Consist::Commands::Upload
- Includes:
- Erbable
- Defined in:
- lib/consist/commands/upload.rb
Instance Method Summary collapse
-
#initialize(command) ⇒ Upload
constructor
A new instance of Upload.
- #perform!(executor) ⇒ Object
- #upload(executor, local_path, remote_path) ⇒ Object
- #upload_defined_file(executor, contents, remote_path) ⇒ Object
Methods included from Erbable
Constructor Details
#initialize(command) ⇒ Upload
Returns a new instance of Upload.
8 9 10 |
# File 'lib/consist/commands/upload.rb', line 8 def initialize(command) @command = command end |
Instance Method Details
#perform!(executor) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/consist/commands/upload.rb', line 12 def perform!(executor) # rubocop:disable Style/ClassEqualityComparison if @command[:local_file].class == Symbol puts "---> Uploading defined file #{@command[:local_file]}" target_file = Consist.files.detect { |f| f[:id] == @command[:local_file] } raise "\n\nNo declared file of ID `#{@command[:local_file]}`" unless target_file contents = StringIO.new(erb_template(target_file[:contents])) upload_defined_file(executor, contents, @command[:remote_path]) else local_path = File.("../steps/#{@id}/#{@command[:local_file]}", __dir__) upload(executor, local_path, @command[:remote_path]) end # rubocop:enable Style/ClassEqualityComparison end |
#upload(executor, local_path, remote_path) ⇒ Object
28 29 30 |
# File 'lib/consist/commands/upload.rb', line 28 def upload(executor, local_path, remote_path) executor.send(:upload!, local_path, remote_path, interaction_handler: Consist::Commands::StreamLogger.new) end |
#upload_defined_file(executor, contents, remote_path) ⇒ Object
32 33 34 |
# File 'lib/consist/commands/upload.rb', line 32 def upload_defined_file(executor, contents, remote_path) executor.upload! contents, remote_path, interaction_handler: Consist::Commands::StreamLogger.new end |