lib/gemsmith/rake/publisher.rb in gemsmith-9.6.0 vs lib/gemsmith/rake/publisher.rb in gemsmith-10.0.0
- old
+ new
@@ -7,16 +7,18 @@
require "gemsmith/cli"
module Gemsmith
module Rake
# Provides gem release functionality. Meant to be wrapped in Rake tasks.
+ # :reek:TooManyInstanceVariables
class Publisher
def self.gem_spec_path
String Dir["#{Dir.pwd}/*.gemspec"].first
end
# rubocop:disable Metrics/ParameterLists
+ # :reek:LongParameterList
def initialize gem_spec: Gemsmith::Gem::Specification.new(self.class.gem_spec_path),
gem_config: Gemsmith::CLI.configuration.to_h,
credentials: Gemsmith::Credentials,
publisher: Milestoner::Publisher.new,
shell: Bundler::UI::Shell.new,
@@ -30,15 +32,14 @@
@kernel = kernel
end
# rubocop:disable Metrics/AbcSize
def push
- creds = credentials.new key: gem_spec.allowed_push_key.to_sym,
- url: gem_spec.allowed_push_host
+ creds = credentials.new key: gem_spec.allowed_push_key.to_sym, url: gem_host
creds.create
- options = %(--key "#{translate_key creds.key}" --host "#{gem_spec.allowed_push_host}")
+ options = %(--key "#{translate_key creds.key}" --host "#{gem_host}")
status = kernel.system %(gem push "pkg/#{gem_spec.package_file_name}" #{options})
process_push status
end
def publish
@@ -54,19 +55,24 @@
private
attr_reader :gem_spec, :gem_config, :credentials, :publisher, :shell, :kernel
+ def gem_host
+ gem_spec.allowed_push_host
+ end
+
def translate_key key
key == credentials.default_key ? :rubygems : key
end
def process_push status
+ package = gem_spec.package_file_name
+
if status
- shell.confirm "Pushed #{gem_spec.package_file_name} to #{gem_spec.allowed_push_host}."
+ shell.confirm "Pushed #{package} to #{gem_host}."
else
- shell.error "Failed pushing #{gem_spec.package_file_name} to " \
- "#{gem_spec.allowed_push_host}. " \
+ shell.error "Failed pushing #{package} to #{gem_host}. " \
"Check gemspec and gem credential settings."
end
status
end