Class: Zold::Push
- Inherits:
-
Object
- Object
- Zold::Push
- Defined in:
- lib/zold/commands/push.rb
Overview
Wallet pushing command
Instance Method Summary collapse
-
#initialize(wallet:, remotes:, log: Log::Quiet.new) ⇒ Push
constructor
A new instance of Push.
- #run(_ = []) ⇒ Object
Constructor Details
Instance Method Details
#run(_ = []) ⇒ Object
38 39 40 41 42 43 44 45 46 47 |
# File 'lib/zold/commands/push.rb', line 38 def run(_ = []) raise 'The wallet is absent' unless @wallet.exists? remote = @remotes.all[0] uri = URI("#{remote[:home]}/wallet/#{@wallet.id}") response = Http.new(uri).put(File.read(@wallet.path)) unless response.code == '200' raise "Failed to push to #{uri}: #{response.code}/#{response.}" end @log.info("The #{@wallet.id} pushed to #{uri}") end |