diff options
author | Hiroshi SHIBATA <[email protected]> | 2023-03-15 18:06:15 +0900 |
---|---|---|
committer | git <[email protected]> | 2023-03-16 01:59:11 +0000 |
commit | 760b8b7d2413670808499eb972abe61400fe6b46 (patch) | |
tree | c6cc680f426761b39f202ae72e705a5118573955 /lib | |
parent | 61831806030612c3a8577d88945b478262ee88f7 (diff) |
[rubygems/rubygems] Change enforce style with Layout/CaseIndentation on rubygems
https://github.com/rubygems/rubygems/commit/d4938259c4
Diffstat (limited to 'lib')
-rw-r--r-- | lib/rubygems/bundler_version_finder.rb | 4 | ||||
-rw-r--r-- | lib/rubygems/commands/setup_command.rb | 6 | ||||
-rw-r--r-- | lib/rubygems/commands/specification_command.rb | 6 | ||||
-rw-r--r-- | lib/rubygems/gem_runner.rb | 8 | ||||
-rw-r--r-- | lib/rubygems/install_update_options.rb | 6 | ||||
-rw-r--r-- | lib/rubygems/platform.rb | 74 | ||||
-rw-r--r-- | lib/rubygems/source_list.rb | 8 | ||||
-rw-r--r-- | lib/rubygems/spec_fetcher.rb | 40 | ||||
-rw-r--r-- | lib/rubygems/specification.rb | 54 | ||||
-rw-r--r-- | lib/rubygems/specification_policy.rb | 8 | ||||
-rw-r--r-- | lib/rubygems/user_interaction.rb | 20 |
11 files changed, 117 insertions, 117 deletions
diff --git a/lib/rubygems/bundler_version_finder.rb b/lib/rubygems/bundler_version_finder.rb index 5b34227d3a..cd51c37c59 100644 --- a/lib/rubygems/bundler_version_finder.rb +++ b/lib/rubygems/bundler_version_finder.rb @@ -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) diff --git a/lib/rubygems/commands/setup_command.rb b/lib/rubygems/commands/setup_command.rb index c779b7c244..5b3284382f 100644 --- a/lib/rubygems/commands/setup_command.rb +++ b/lib/rubygems/commands/setup_command.rb @@ -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 diff --git a/lib/rubygems/commands/specification_command.rb b/lib/rubygems/commands/specification_command.rb index 12004a6d56..0bb24c2415 100644 --- a/lib/rubygems/commands/specification_command.rb +++ b/lib/rubygems/commands/specification_command.rb @@ -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" diff --git a/lib/rubygems/gem_runner.rb b/lib/rubygems/gem_runner.rb index 31890a60d7..c63c177ed2 100644 --- a/lib/rubygems/gem_runner.rb +++ b/lib/rubygems/gem_runner.rb @@ -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 diff --git a/lib/rubygems/install_update_options.rb b/lib/rubygems/install_update_options.rb index 79effcf21f..d47701de10 100644 --- a/lib/rubygems/install_update_options.rb +++ b/lib/rubygems/install_update_options.rb @@ -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 diff --git a/lib/rubygems/platform.rb b/lib/rubygems/platform.rb index f4983c1153..4331831774 100644 --- a/lib/rubygems/platform.rb +++ b/lib/rubygems/platform.rb @@ -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 diff --git a/lib/rubygems/source_list.rb b/lib/rubygems/source_list.rb index 7abe796409..1e0b905f19 100644 --- a/lib/rubygems/source_list.rb +++ b/lib/rubygems/source_list.rb @@ -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) diff --git a/lib/rubygems/spec_fetcher.rb b/lib/rubygems/spec_fetcher.rb index 0d06d1f144..69050797c3 100644 --- a/lib/rubygems/spec_fetcher.rb +++ b/lib/rubygems/spec_fetcher.rb @@ -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) - - 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}" + 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 :prerelease + tuples_for(source, :prerelease) + else + raise Gem::Exception, "Unknown type - :#{type}" end rescue Gem::RemoteFetcher::FetchError => e errors << Gem::SourceFetchProblem.new(source, e) diff --git a/lib/rubygems/specification.rb b/lib/rubygems/specification.rb index f018c8ead5..9136000567 100644 --- a/lib/rubygems/specification.rb +++ b/lib/rubygems/specification.rb @@ -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 diff --git a/lib/rubygems/specification_policy.rb b/lib/rubygems/specification_policy.rb index c7e2edc2bf..bf5593a2ac 100644 --- a/lib/rubygems/specification_policy.rb +++ b/lib/rubygems/specification_policy.rb @@ -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) } diff --git a/lib/rubygems/user_interaction.rb b/lib/rubygems/user_interaction.rb index 69de05fa24..8ba1ec7e4f 100644 --- a/lib/rubygems/user_interaction.rb +++ b/lib/rubygems/user_interaction.rb @@ -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 |