[rubygems/rubygems] Change enforce style with Layout/CaseIndentation on rubygems
https://github.com/rubygems/rubygems/commit/d4938259c4
This commit is contained in:
parent
6183180603
commit
760b8b7d24
@ -65,8 +65,8 @@ module Gem::BundlerVersionFinder
|
||||
return unless gemfile
|
||||
|
||||
lockfile = case gemfile
|
||||
when "gems.rb" then "gems.locked"
|
||||
else "#{gemfile}.lock"
|
||||
when "gems.rb" then "gems.locked"
|
||||
else "#{gemfile}.lock"
|
||||
end.dup.tap(&Gem::UNTAINT)
|
||||
|
||||
return unless File.file?(lockfile)
|
||||
|
@ -54,9 +54,9 @@ class Gem::Commands::SetupCommand < Gem::Command
|
||||
"List the documentation types you wish to",
|
||||
"generate. For example: rdoc,ri" do |value, options|
|
||||
options[:document] = case value
|
||||
when nil then %w[rdoc ri]
|
||||
when false then []
|
||||
else value
|
||||
when nil then %w[rdoc ri]
|
||||
when false then []
|
||||
else value
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -140,9 +140,9 @@ Specific fields in the specification can be extracted in YAML format:
|
||||
s = s.send field if field
|
||||
|
||||
say case options[:format]
|
||||
when :ruby then s.to_ruby
|
||||
when :marshal then Marshal.dump s
|
||||
else s.to_yaml
|
||||
when :ruby then s.to_ruby
|
||||
when :marshal then Marshal.dump s
|
||||
else s.to_yaml
|
||||
end
|
||||
|
||||
say "\n"
|
||||
|
@ -40,10 +40,10 @@ class Gem::GemRunner
|
||||
cmd.command_names.each do |command_name|
|
||||
config_args = Gem.configuration[command_name]
|
||||
config_args = case config_args
|
||||
when String
|
||||
config_args.split " "
|
||||
else
|
||||
Array(config_args)
|
||||
when String
|
||||
config_args.split " "
|
||||
else
|
||||
Array(config_args)
|
||||
end
|
||||
Gem::Command.add_specific_extra_args command_name, config_args
|
||||
end
|
||||
|
@ -35,9 +35,9 @@ module Gem::InstallUpdateOptions
|
||||
"List the documentation types you wish to",
|
||||
"generate. For example: rdoc,ri") do |value, options|
|
||||
options[:document] = case value
|
||||
when nil then %w[ri]
|
||||
when false then []
|
||||
else value
|
||||
when nil then %w[ri]
|
||||
when false then []
|
||||
else value
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -79,8 +79,8 @@ class Gem::Platform
|
||||
cpu = arch.shift
|
||||
|
||||
@cpu = case cpu
|
||||
when /i\d86/ then "x86"
|
||||
else cpu
|
||||
when /i\d86/ then "x86"
|
||||
else cpu
|
||||
end
|
||||
|
||||
if arch.length == 2 && arch.last =~ /^\d+(\.\d+)?$/ # for command-line
|
||||
@ -92,29 +92,29 @@ class Gem::Platform
|
||||
@cpu, os = nil, cpu if os.nil? # legacy jruby
|
||||
|
||||
@os, @version = case os
|
||||
when /aix(\d+)?/ then [ "aix", $1 ]
|
||||
when /cygwin/ then [ "cygwin", nil ]
|
||||
when /darwin(\d+)?/ then [ "darwin", $1 ]
|
||||
when /^macruby$/ then [ "macruby", nil ]
|
||||
when /freebsd(\d+)?/ then [ "freebsd", $1 ]
|
||||
when /^java$/, /^jruby$/ then [ "java", nil ]
|
||||
when /^java([\d.]*)/ then [ "java", $1 ]
|
||||
when /^dalvik(\d+)?$/ then [ "dalvik", $1 ]
|
||||
when /^dotnet$/ then [ "dotnet", nil ]
|
||||
when /^dotnet([\d.]*)/ then [ "dotnet", $1 ]
|
||||
when /linux-?(\w+)?/ then [ "linux", $1 ]
|
||||
when /mingw32/ then [ "mingw32", nil ]
|
||||
when /mingw-?(\w+)?/ then [ "mingw", $1 ]
|
||||
when /(mswin\d+)(\_(\d+))?/ then
|
||||
os, version = $1, $3
|
||||
@cpu = "x86" if @cpu.nil? && os =~ /32$/
|
||||
[os, version]
|
||||
when /netbsdelf/ then [ "netbsdelf", nil ]
|
||||
when /openbsd(\d+\.\d+)?/ then [ "openbsd", $1 ]
|
||||
when /solaris(\d+\.\d+)?/ then [ "solaris", $1 ]
|
||||
# test
|
||||
when /^(\w+_platform)(\d+)?/ then [ $1, $2 ]
|
||||
else [ "unknown", nil ]
|
||||
when /aix(\d+)?/ then [ "aix", $1 ]
|
||||
when /cygwin/ then [ "cygwin", nil ]
|
||||
when /darwin(\d+)?/ then [ "darwin", $1 ]
|
||||
when /^macruby$/ then [ "macruby", nil ]
|
||||
when /freebsd(\d+)?/ then [ "freebsd", $1 ]
|
||||
when /^java$/, /^jruby$/ then [ "java", nil ]
|
||||
when /^java([\d.]*)/ then [ "java", $1 ]
|
||||
when /^dalvik(\d+)?$/ then [ "dalvik", $1 ]
|
||||
when /^dotnet$/ then [ "dotnet", nil ]
|
||||
when /^dotnet([\d.]*)/ then [ "dotnet", $1 ]
|
||||
when /linux-?(\w+)?/ then [ "linux", $1 ]
|
||||
when /mingw32/ then [ "mingw32", nil ]
|
||||
when /mingw-?(\w+)?/ then [ "mingw", $1 ]
|
||||
when /(mswin\d+)(\_(\d+))?/ then
|
||||
os, version = $1, $3
|
||||
@cpu = "x86" if @cpu.nil? && os =~ /32$/
|
||||
[os, version]
|
||||
when /netbsdelf/ then [ "netbsdelf", nil ]
|
||||
when /openbsd(\d+\.\d+)?/ then [ "openbsd", $1 ]
|
||||
when /solaris(\d+\.\d+)?/ then [ "solaris", $1 ]
|
||||
# test
|
||||
when /^(\w+_platform)(\d+)?/ then [ $1, $2 ]
|
||||
else [ "unknown", nil ]
|
||||
end
|
||||
when Gem::Platform then
|
||||
@cpu = arch.cpu
|
||||
@ -209,18 +209,18 @@ class Gem::Platform
|
||||
when String then
|
||||
# This data is from http://gems.rubyforge.org/gems/yaml on 19 Aug 2007
|
||||
other = case other
|
||||
when /^i686-darwin(\d)/ then ["x86", "darwin", $1 ]
|
||||
when /^i\d86-linux/ then ["x86", "linux", nil ]
|
||||
when "java", "jruby" then [nil, "java", nil ]
|
||||
when /^dalvik(\d+)?$/ then [nil, "dalvik", $1 ]
|
||||
when /dotnet(\-(\d+\.\d+))?/ then ["universal","dotnet", $2 ]
|
||||
when /mswin32(\_(\d+))?/ then ["x86", "mswin32", $2 ]
|
||||
when /mswin64(\_(\d+))?/ then ["x64", "mswin64", $2 ]
|
||||
when "powerpc-darwin" then ["powerpc", "darwin", nil ]
|
||||
when /powerpc-darwin(\d)/ then ["powerpc", "darwin", $1 ]
|
||||
when /sparc-solaris2.8/ then ["sparc", "solaris", "2.8" ]
|
||||
when /universal-darwin(\d)/ then ["universal", "darwin", $1 ]
|
||||
else other
|
||||
when /^i686-darwin(\d)/ then ["x86", "darwin", $1 ]
|
||||
when /^i\d86-linux/ then ["x86", "linux", nil ]
|
||||
when "java", "jruby" then [nil, "java", nil ]
|
||||
when /^dalvik(\d+)?$/ then [nil, "dalvik", $1 ]
|
||||
when /dotnet(\-(\d+\.\d+))?/ then ["universal","dotnet", $2 ]
|
||||
when /mswin32(\_(\d+))?/ then ["x86", "mswin32", $2 ]
|
||||
when /mswin64(\_(\d+))?/ then ["x64", "mswin64", $2 ]
|
||||
when "powerpc-darwin" then ["powerpc", "darwin", nil ]
|
||||
when /powerpc-darwin(\d)/ then ["powerpc", "darwin", $1 ]
|
||||
when /sparc-solaris2.8/ then ["sparc", "solaris", "2.8" ]
|
||||
when /universal-darwin(\d)/ then ["universal", "darwin", $1 ]
|
||||
else other
|
||||
end
|
||||
|
||||
other = Gem::Platform.new other
|
||||
|
@ -49,10 +49,10 @@ class Gem::SourceList
|
||||
|
||||
def <<(obj)
|
||||
src = case obj
|
||||
when Gem::Source
|
||||
obj
|
||||
else
|
||||
Gem::Source.new(obj)
|
||||
when Gem::Source
|
||||
obj
|
||||
else
|
||||
Gem::Source.new(obj)
|
||||
end
|
||||
|
||||
@sources << src unless @sources.include?(src)
|
||||
|
@ -216,26 +216,26 @@ class Gem::SpecFetcher
|
||||
@sources.each_source do |source|
|
||||
begin
|
||||
names = case type
|
||||
when :latest
|
||||
tuples_for source, :latest
|
||||
when :released
|
||||
tuples_for source, :released
|
||||
when :complete
|
||||
names =
|
||||
tuples_for(source, :prerelease, true) +
|
||||
tuples_for(source, :released)
|
||||
when :latest
|
||||
tuples_for source, :latest
|
||||
when :released
|
||||
tuples_for source, :released
|
||||
when :complete
|
||||
names =
|
||||
tuples_for(source, :prerelease, true) +
|
||||
tuples_for(source, :released)
|
||||
|
||||
names.sort
|
||||
when :abs_latest
|
||||
names =
|
||||
tuples_for(source, :prerelease, true) +
|
||||
tuples_for(source, :latest)
|
||||
names.sort
|
||||
when :abs_latest
|
||||
names =
|
||||
tuples_for(source, :prerelease, true) +
|
||||
tuples_for(source, :latest)
|
||||
|
||||
names.sort
|
||||
when :prerelease
|
||||
tuples_for(source, :prerelease)
|
||||
else
|
||||
raise Gem::Exception, "Unknown type - :#{type}"
|
||||
names.sort
|
||||
when :prerelease
|
||||
tuples_for(source, :prerelease)
|
||||
else
|
||||
raise Gem::Exception, "Unknown type - :#{type}"
|
||||
end
|
||||
rescue Gem::RemoteFetcher::FetchError => e
|
||||
errors << Gem::SourceFetchProblem.new(source, e)
|
||||
|
@ -163,14 +163,14 @@ class Gem::Specification < Gem::BasicSpecification
|
||||
|
||||
@@default_value.each do |k,v|
|
||||
INITIALIZE_CODE_FOR_DEFAULTS[k] = case v
|
||||
when [], {}, true, false, nil, Numeric, Symbol
|
||||
v.inspect
|
||||
when String
|
||||
v.dump
|
||||
when Numeric
|
||||
"default_value(:#{k})"
|
||||
else
|
||||
"default_value(:#{k}).dup"
|
||||
when [], {}, true, false, nil, Numeric, Symbol
|
||||
v.inspect
|
||||
when String
|
||||
v.dump
|
||||
when Numeric
|
||||
"default_value(:#{k})"
|
||||
else
|
||||
"default_value(:#{k}).dup"
|
||||
end
|
||||
end
|
||||
|
||||
@ -1747,17 +1747,17 @@ class Gem::Specification < Gem::BasicSpecification
|
||||
# This is the cleanest, most-readable, faster-than-using-Date
|
||||
# way to do it.
|
||||
@date = case date
|
||||
when String then
|
||||
if DateTimeFormat =~ date
|
||||
Time.utc($1.to_i, $2.to_i, $3.to_i)
|
||||
else
|
||||
raise(Gem::InvalidSpecificationException,
|
||||
"invalid date format in specification: #{date.inspect}")
|
||||
end
|
||||
when Time, DateLike then
|
||||
Time.utc(date.year, date.month, date.day)
|
||||
else
|
||||
TODAY
|
||||
when String then
|
||||
if DateTimeFormat =~ date
|
||||
Time.utc($1.to_i, $2.to_i, $3.to_i)
|
||||
else
|
||||
raise(Gem::InvalidSpecificationException,
|
||||
"invalid date format in specification: #{date.inspect}")
|
||||
end
|
||||
when Time, DateLike then
|
||||
Time.utc(date.year, date.month, date.day)
|
||||
else
|
||||
TODAY
|
||||
end
|
||||
end
|
||||
|
||||
@ -1864,12 +1864,12 @@ class Gem::Specification < Gem::BasicSpecification
|
||||
coder.add "name", @name
|
||||
coder.add "version", @version
|
||||
platform = case @original_platform
|
||||
when nil, "" then
|
||||
"ruby"
|
||||
when String then
|
||||
@original_platform
|
||||
else
|
||||
@original_platform.to_s
|
||||
when nil, "" then
|
||||
"ruby"
|
||||
when String then
|
||||
@original_platform
|
||||
else
|
||||
@original_platform.to_s
|
||||
end
|
||||
coder.add "platform", platform
|
||||
|
||||
@ -2708,8 +2708,8 @@ class Gem::Specification < Gem::BasicSpecification
|
||||
default = self.default_value attribute
|
||||
|
||||
value = case default
|
||||
when Time, Numeric, Symbol, true, false, nil then default
|
||||
else default.dup
|
||||
when Time, Numeric, Symbol, true, false, nil then default
|
||||
else default.dup
|
||||
end
|
||||
|
||||
instance_variable_set "@#{attribute}", value
|
||||
|
@ -337,10 +337,10 @@ duplicate dependency on #{dep}, (#{prev.requirement}) use:
|
||||
def validate_array_attribute(field)
|
||||
val = @specification.send(field)
|
||||
klass = case field
|
||||
when :dependencies then
|
||||
Gem::Dependency
|
||||
else
|
||||
String
|
||||
when :dependencies then
|
||||
Gem::Dependency
|
||||
else
|
||||
String
|
||||
end
|
||||
|
||||
unless Array === val && val.all? {|x| x.kind_of?(klass) }
|
||||
|
@ -258,22 +258,22 @@ class Gem::StreamUI
|
||||
end
|
||||
|
||||
default_answer = case default
|
||||
when nil
|
||||
"yn"
|
||||
when true
|
||||
"Yn"
|
||||
else
|
||||
"yN"
|
||||
when nil
|
||||
"yn"
|
||||
when true
|
||||
"Yn"
|
||||
else
|
||||
"yN"
|
||||
end
|
||||
|
||||
result = nil
|
||||
|
||||
while result.nil? do
|
||||
result = case ask "#{question} [#{default_answer}]"
|
||||
when /^y/i then true
|
||||
when /^n/i then false
|
||||
when /^$/ then default
|
||||
else nil
|
||||
when /^y/i then true
|
||||
when /^n/i then false
|
||||
when /^$/ then default
|
||||
else nil
|
||||
end
|
||||
end
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user