Class: TRMNLP::Commands::Push
Instance Method Summary collapse
Methods inherited from Base
Constructor Details
This class inherits a constructor from TRMNLP::Commands::Base
Instance Method Details
#call(plugin_settings_id) ⇒ Object
9 10 11 12 13 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 |
# File 'lib/trmnlp/commands/push.rb', line 9 def call(plugin_settings_id) context.validate! raise Error, "please run `trmnlp login`" unless config.app.logged_in? plugin_settings_id ||= config.plugin.id raise Error, 'plugin ID must be specified' if plugin_settings_id.nil? unless .force print "Plugin settings on the server will be overwritten. Are you sure? (y/n) " answer = $stdin.gets.chomp.downcase raise Error, 'aborting' unless answer == 'y' || answer == 'yes' end api = APIClient.new(config) size = 0 Tempfile.create(binmode: true) do |temp_file| Zip::File.open(temp_file.path, Zip::File::CREATE) do |zip_file| paths.src_files.each do |file| zip_file.add(File.basename(file), file) end end api.post_plugin_setting_archive(plugin_settings_id, temp_file.path) size = File.size(temp_file.path) end puts "Uploaded plugin (#{size} bytes)" end |