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