Class: TRMNLP::Commands::Pull
Instance Method Summary collapse
Methods inherited from Base
Constructor Details
This class inherits a constructor from TRMNLP::Commands::Base
Instance Method Details
#call ⇒ 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/pull.rb', line 9 def call context.validate! authenticate! plugin_settings_id = .id || config.plugin.id raise Error, 'plugin ID must be specified' if plugin_settings_id.nil? unless .force answer = prompt("Local plugin files will be overwritten. Are you sure? (y/n) ").downcase raise Error, 'aborting' unless answer == 'y' || answer == 'yes' end api = APIClient.new(config) tempfile = api.get_plugin_setting_archive(plugin_settings_id) size = 0 begin Zip::File.open(tempfile.path) do |zip_file| zip_file.each do |entry| dest_path = paths.src_dir.join(entry.name) dest_path.dirname.mkpath zip_file.extract(entry, dest_path) { true } # overwrite existing end end size = File.size(tempfile.path) ensure tempfile.close end puts "Downloaded plugin (#{size} bytes)" end |