summaryrefslogtreecommitdiff
path: root/lib/rubygems/commands
diff options
context:
space:
mode:
authorhsbt <hsbt@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-08-27 10:05:04 +0000
committerhsbt <hsbt@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-08-27 10:05:04 +0000
commit85d461456c154d7b4a72b20369e0d65d7880ce02 (patch)
tree21e1be2c786c8040a426841768e046fb4dc365b1 /lib/rubygems/commands
parent3a83ba90c35833bab757998def36cfe872dec461 (diff)
Merge master branch from rubygems upstream.
* It's preparation to release RubyGems 3.0.0.beta2 and Ruby 2.6.0 preview 3. * https://github.com/rubygems/rubygems/compare/v3.0.0.beta1...fad2eb15a282b19dfcb4b48bc95b8b39ebb4511f git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64555 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib/rubygems/commands')
-rw-r--r--lib/rubygems/commands/build_command.rb6
-rw-r--r--lib/rubygems/commands/cert_command.rb2
-rw-r--r--lib/rubygems/commands/cleanup_command.rb10
-rw-r--r--lib/rubygems/commands/install_command.rb7
-rw-r--r--lib/rubygems/commands/open_command.rb6
-rw-r--r--lib/rubygems/commands/pristine_command.rb9
-rw-r--r--lib/rubygems/commands/push_command.rb39
-rw-r--r--lib/rubygems/commands/setup_command.rb6
-rw-r--r--lib/rubygems/commands/signin_command.rb2
-rw-r--r--lib/rubygems/commands/uninstall_command.rb2
10 files changed, 78 insertions, 11 deletions
diff --git a/lib/rubygems/commands/build_command.rb b/lib/rubygems/commands/build_command.rb
index 0ba24e5ea3..f1d700349f 100644
--- a/lib/rubygems/commands/build_command.rb
+++ b/lib/rubygems/commands/build_command.rb
@@ -10,6 +10,10 @@ class Gem::Commands::BuildCommand < Gem::Command
add_option '--force', 'skip validation of the spec' do |value, options|
options[:force] = true
end
+
+ add_option '--strict', 'consider warnings as errors when validating the spec' do |value, options|
+ options[:strict] = true
+ end
end
def arguments # :nodoc:
@@ -51,7 +55,7 @@ with gem spec:
spec = Gem::Specification.load File.basename(gemspec)
if spec then
- Gem::Package.build spec, options[:force]
+ Gem::Package.build spec, options[:force], options[:strict]
else
alert_error "Error loading gemspec. Aborting."
terminate_interaction 1
diff --git a/lib/rubygems/commands/cert_command.rb b/lib/rubygems/commands/cert_command.rb
index 5542262a50..aa26f340ff 100644
--- a/lib/rubygems/commands/cert_command.rb
+++ b/lib/rubygems/commands/cert_command.rb
@@ -87,7 +87,7 @@ class Gem::Commands::CertCommand < Gem::Command
add_option('-d', '--days NUMBER_OF_DAYS',
'Days before the certificate expires') do |days, options|
- options[:expiration_length_days] = days.to_i
+ options[:expiration_length_days] = days.to_i
end
end
diff --git a/lib/rubygems/commands/cleanup_command.rb b/lib/rubygems/commands/cleanup_command.rb
index 79c23c840d..fe85deddda 100644
--- a/lib/rubygems/commands/cleanup_command.rb
+++ b/lib/rubygems/commands/cleanup_command.rb
@@ -22,6 +22,12 @@ class Gem::Commands::CleanupCommand < Gem::Command
options[:check_dev] = value
end
+ add_option('--[no-]user-install',
+ 'Cleanup in user\'s home directory instead',
+ 'of GEM_HOME.') do |value, options|
+ options[:user_install] = value
+ end
+
@candidate_gems = nil
@default_gems = []
@full = nil
@@ -124,8 +130,10 @@ If no gems are named all gems in GEM_HOME are cleaned.
spec.default_gem?
}
+ uninstall_from = options[:user_install] ? Gem.user_dir : @original_home
+
gems_to_cleanup = gems_to_cleanup.select { |spec|
- spec.base_dir == @original_home
+ spec.base_dir == uninstall_from
}
@default_gems += default_gems
diff --git a/lib/rubygems/commands/install_command.rb b/lib/rubygems/commands/install_command.rb
index c6abf9cd7c..9fe131c290 100644
--- a/lib/rubygems/commands/install_command.rb
+++ b/lib/rubygems/commands/install_command.rb
@@ -117,6 +117,13 @@ to write the specification by hand. For example:
some_extension_gem (1.0)
$
+Command Alias
+==========================
+
+You can use `i` command instead of `install`.
+
+ $ gem i GEMNAME
+
EOF
end
diff --git a/lib/rubygems/commands/open_command.rb b/lib/rubygems/commands/open_command.rb
index 059635e835..fdac19dc1f 100644
--- a/lib/rubygems/commands/open_command.rb
+++ b/lib/rubygems/commands/open_command.rb
@@ -60,8 +60,14 @@ class Gem::Commands::OpenCommand < Gem::Command
def open_gem name
spec = spec_for name
+
return false unless spec
+ if spec.default_gem?
+ say "'#{name}' is a default gem and can't be opened."
+ return false
+ end
+
open_editor(spec.full_gem_path)
end
diff --git a/lib/rubygems/commands/pristine_command.rb b/lib/rubygems/commands/pristine_command.rb
index 817e752266..575c344130 100644
--- a/lib/rubygems/commands/pristine_command.rb
+++ b/lib/rubygems/commands/pristine_command.rb
@@ -46,6 +46,12 @@ class Gem::Commands::PristineCommand < Gem::Command
options[:env_shebang] = value
end
+ add_option('-n', '--bindir DIR',
+ 'Directory where executables are',
+ 'located') do |value, options|
+ options[:bin_dir] = File.expand_path(value)
+ end
+
add_version_option('restore to', 'pristine condition')
end
@@ -160,12 +166,15 @@ extensions will be restored.
install_defaults.to_s['--env-shebang']
end
+ bin_dir = options[:bin_dir] if options[:bin_dir]
+
installer_options = {
:wrappers => true,
:force => true,
:install_dir => spec.base_dir,
:env_shebang => env_shebang,
:build_args => spec.build_args,
+ :bin_dir => bin_dir
}
if options[:only_executables] then
diff --git a/lib/rubygems/commands/push_command.rb b/lib/rubygems/commands/push_command.rb
index 613c4e6ddf..83c7131afc 100644
--- a/lib/rubygems/commands/push_command.rb
+++ b/lib/rubygems/commands/push_command.rb
@@ -29,6 +29,8 @@ command. For further discussion see the help for the yank command.
def initialize
super 'push', 'Push a gem up to the gem server', :host => self.host
+ @user_defined_host = false
+
add_proxy_option
add_key_option
@@ -36,20 +38,41 @@ command. For further discussion see the help for the yank command.
'Push to another gemcutter-compatible host',
' (e.g. https://rubygems.org)') do |value, options|
options[:host] = value
+ @user_defined_host = true
end
@host = nil
end
def execute
- @host = options[:host]
+ gem_name = get_one_gem_name
+ default_gem_server, push_host = get_hosts_for(gem_name)
+
+ default_host = nil
+ user_defined_host = nil
+
+ if @user_defined_host
+ user_defined_host = options[:host]
+ else
+ default_host = options[:host]
+ end
+
+ @host = if user_defined_host
+ user_defined_host
+ elsif default_gem_server
+ default_gem_server
+ elsif push_host
+ push_host
+ else
+ default_host
+ end
sign_in @host
- send_gem get_one_gem_name
+ send_gem(gem_name)
end
- def send_gem name
+ def send_gem(name)
args = [:post, "api/v1/gems"]
latest_rubygems_version = Gem.latest_rubygems_version
@@ -100,5 +123,15 @@ You can upgrade or downgrade to the latest release version with:
with_response response
end
+ private
+
+ def get_hosts_for(name)
+ gem_metadata = Gem::Package.new(name).spec.metadata
+
+ [
+ gem_metadata["default_gem_server"],
+ gem_metadata["allowed_push_host"]
+ ]
+ end
end
diff --git a/lib/rubygems/commands/setup_command.rb b/lib/rubygems/commands/setup_command.rb
index fc87063fe3..281108ea1f 100644
--- a/lib/rubygems/commands/setup_command.rb
+++ b/lib/rubygems/commands/setup_command.rb
@@ -84,7 +84,7 @@ class Gem::Commands::SetupCommand < Gem::Command
add_option '--[no-]regenerate-binstubs',
'Regenerate gem binstubs' do |value, options|
- options[:regenerate_binstubs] = value
+ options[:regenerate_binstubs] = value
end
add_option('-E', '--[no-]env-shebang',
@@ -468,8 +468,8 @@ By default, this RubyGems will install gem as:
(prefix == RbConfig::CONFIG['libdir'] or
# this one is important
prefix == File.join(RbConfig::CONFIG['libdir'], 'ruby')) then
- lib_dir = RbConfig::CONFIG[site_or_vendor]
- bin_dir = RbConfig::CONFIG['bindir']
+ lib_dir = RbConfig::CONFIG[site_or_vendor]
+ bin_dir = RbConfig::CONFIG['bindir']
else
lib_dir = File.join prefix, 'lib'
bin_dir = File.join prefix, 'bin'
diff --git a/lib/rubygems/commands/signin_command.rb b/lib/rubygems/commands/signin_command.rb
index 6556db5a89..a48c32b52e 100644
--- a/lib/rubygems/commands/signin_command.rb
+++ b/lib/rubygems/commands/signin_command.rb
@@ -10,7 +10,7 @@ class Gem::Commands::SigninCommand < Gem::Command
'It defaults to https://rubygems.org'
add_option('--host HOST', 'Push to another gemcutter-compatible host') do |value, options|
- options[:host] = value
+ options[:host] = value
end
end
diff --git a/lib/rubygems/commands/uninstall_command.rb b/lib/rubygems/commands/uninstall_command.rb
index 55a052284a..1ddc12c737 100644
--- a/lib/rubygems/commands/uninstall_command.rb
+++ b/lib/rubygems/commands/uninstall_command.rb
@@ -48,7 +48,7 @@ class Gem::Commands::UninstallCommand < Gem::Command
end
add_option('-n', '--bindir DIR',
- 'Directory to remove binaries from') do |value, options|
+ 'Directory to remove executables from') do |value, options|
options[:bin_dir] = File.expand_path(value)
end