diff --git a/lib/deploygate/api/v1/push.rb b/lib/deploygate/api/v1/push.rb index 824b26f..7fdb699 100644 --- a/lib/deploygate/api/v1/push.rb +++ b/lib/deploygate/api/v1/push.rb @@ -10,15 +10,16 @@ class << self # @param [String] target_user # @param [String] token # @param [String] message + # @param [String] distribution_key # @param [Boolean] disable_notify # @yield Upload process block # @return [Hash] - def upload(file_path, target_user, token, message, disable_notify = false, &process_block) + def upload(file_path, target_user, token, message, distribution_key, disable_notify = false, &process_block) res = nil open(file_path) do |file| res = Base.new(token).post( sprintf(ENDPOINT, target_user), - { :file => file , :message => message, :disable_notify => disable_notify ? 'yes' : 'no' }) { process_block.call unless process_block.nil? } + { :file => file , :message => message, :distribution_key => distribution_key, :disable_notify => disable_notify ? 'yes' : 'no' }) { process_block.call unless process_block.nil? } end upload_results = { diff --git a/lib/deploygate/command_builder.rb b/lib/deploygate/command_builder.rb index e4db604..3cb2925 100644 --- a/lib/deploygate/command_builder.rb +++ b/lib/deploygate/command_builder.rb @@ -29,6 +29,7 @@ def run c.description = 'upload to deploygate' c.option '--message STRING', String, 'release message' c.option '--user STRING', String, 'owner name or group name' + c.option '--distribution-key STRING', String, 'update distribution key' c.option '--open', 'open browser (OSX only)' c.option '--disable_notify', 'disable notify via email (iOS app only)' c.action do |args, options| diff --git a/lib/deploygate/commands/deploy/push.rb b/lib/deploygate/commands/deploy/push.rb index 6433246..a8bccb9 100644 --- a/lib/deploygate/commands/deploy/push.rb +++ b/lib/deploygate/commands/deploy/push.rb @@ -16,16 +16,17 @@ def upload(args, options) session = DeployGate::Session.new() end - message = options.message - owner = options.user || session.name - open = options.open - disable_notify = options.disable_notify - file_path = args.first + message = options.message + owner = options.user || session.name + distribution_key = options.distribution_key + open = options.open + disable_notify = options.disable_notify + file_path = args.first data = nil print "Uploading to #{owner}.." begin - data = DeployGate::Deploy.push(file_path, owner, message, disable_notify) { + data = DeployGate::Deploy.push(file_path, owner, message, distribution_key, disable_notify) { print '.' sleep 0.2 } diff --git a/lib/deploygate/deploy.rb b/lib/deploygate/deploy.rb index 86a1302..e4f9075 100644 --- a/lib/deploygate/deploy.rb +++ b/lib/deploygate/deploy.rb @@ -12,10 +12,11 @@ class << self # @param [String] file_path # @param [String] target_user # @param [String] message + # @param [String] distribution_key # @param [Boolean] disable_notify # @yield Upload process block # @return [Hash] - def push(file_path, target_user, message, disable_notify = false, &process_block) + def push(file_path, target_user, message, distribution_key, disable_notify = false, &process_block) raise NotFileExistError, 'Target file is not found' if file_path.nil? || !File.exist?(file_path) session = DeployGate::Session.new() @@ -23,7 +24,7 @@ def push(file_path, target_user, message, disable_notify = false, &process_block token = session.token - data = API::V1::Push.upload(file_path, target_user, token, message, disable_notify) { process_block.call unless process_block.nil? } + data = API::V1::Push.upload(file_path, target_user, token, message, distribution_key || '', disable_notify) { process_block.call unless process_block.nil? } raise UploadError, data[:message] if data[:error] data diff --git a/lib/deploygate/version.rb b/lib/deploygate/version.rb index d4c6557..c539d95 100644 --- a/lib/deploygate/version.rb +++ b/lib/deploygate/version.rb @@ -1,3 +1,3 @@ module DeployGate - VERSION = "0.0.5" + VERSION = "0.0.6" end diff --git a/spec/deploygate/api/v1/push_spec.rb b/spec/deploygate/api/v1/push_spec.rb index 34e2389..22a4293 100644 --- a/spec/deploygate/api/v1/push_spec.rb +++ b/spec/deploygate/api/v1/push_spec.rb @@ -21,7 +21,7 @@ to_return(:body => response.to_json) call_process_block = false - results = DeployGate::API::V1::Push.upload(test_file_path, target_user, token, message) + results = DeployGate::API::V1::Push.upload(test_file_path, target_user, token, message, '') expect(results).to eq ({ :error => response[:error], :message => response[:because], @@ -46,7 +46,7 @@ with(:headers => { 'AUTHORIZATION' => token }). to_return(:body => response.to_json) - results = DeployGate::API::V1::Push.upload(test_file_path, target_user, token, message) + results = DeployGate::API::V1::Push.upload(test_file_path, target_user, token, message, '') expect(results).to eq ({:error => response[:error], :message => response[:because]}) end end diff --git a/spec/deploygate/deploy_spec.rb b/spec/deploygate/deploy_spec.rb index 5b24a19..99c9de1 100644 --- a/spec/deploygate/deploy_spec.rb +++ b/spec/deploygate/deploy_spec.rb @@ -5,13 +5,13 @@ allow_any_instance_of(DeployGate::Session).to receive(:login?) { false } expect { - DeployGate::Deploy.push(test_file_path, 'test', 'message') + DeployGate::Deploy.push(test_file_path, 'test', 'message', nil) }.to raise_error DeployGate::Deploy::NotLoginError end it "NotFileExistError" do expect { - DeployGate::Deploy.push('no_file_path', 'test', 'message') + DeployGate::Deploy.push('no_file_path', 'test', 'message', nil) }.to raise_error DeployGate::Deploy::NotFileExistError end @@ -20,7 +20,7 @@ allow(DeployGate::API::V1::Push).to receive(:upload).and_return({:error => true, :message => 'error message'}) expect { - DeployGate::Deploy.push(test_file_path, 'test', 'message') + DeployGate::Deploy.push(test_file_path, 'test', 'message', nil) }.to raise_error DeployGate::Deploy::UploadError end end @@ -31,7 +31,7 @@ allow_any_instance_of(DeployGate::Session).to receive(:login?) { true } expect { - DeployGate::Deploy.push(test_file_path, 'test', 'message') + DeployGate::Deploy.push(test_file_path, 'test', 'message', nil) }.not_to raise_error end end