Merge pull request #4186 from reitermarkus/compat

Clean up `compat`.
This commit is contained in:
Markus Reiter 2018-05-18 18:52:07 +02:00 committed by GitHub
commit 54270e9214
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
13 changed files with 159 additions and 128 deletions

View File

@ -1,4 +1,5 @@
module SharedEnvExtension module SharedEnvExtension
module Compat
def j1 def j1
odisabled "ENV.j1", "ENV.deparallelize" odisabled "ENV.j1", "ENV.deparallelize"
end end
@ -6,4 +7,7 @@ module SharedEnvExtension
def java_cache def java_cache
odisabled "ENV.java_cache" odisabled "ENV.java_cache"
end end
end
prepend Compat
end end

View File

@ -1,6 +1,10 @@
module Dependable module Dependable
module Compat
def run? def run?
odeprecated "Dependable#run?" odeprecated "Dependable#run?"
tags.include? :run tags.include? :run
end end
end
prepend Compat
end end

View File

@ -1,4 +1,5 @@
class String class String
module Compat
def undent def undent
odisabled "<<-EOS.undent", "<<~EOS" odisabled "<<-EOS.undent", "<<~EOS"
self self
@ -16,4 +17,7 @@ class String
# mollit anim id est laborum. # mollit anim id est laborum.
# EOS # EOS
alias undent_________________________________________________________72 undent alias undent_________________________________________________________72 undent
end
prepend Compat
end end

View File

@ -1,5 +1,9 @@
class Formula class Formula
module Compat
def rake(*) def rake(*)
odisabled "FileUtils#rake", "system \"rake\"" odisabled "FileUtils#rake", "system \"rake\""
end end
end
prepend Compat
end end

View File

@ -1,7 +1,6 @@
module Gpg module Gpg
module_function class << self
module Compat
def executable def executable
odisabled "Gpg.executable", 'which "gpg"' odisabled "Gpg.executable", 'which "gpg"'
end end
@ -10,7 +9,7 @@ module Gpg
odisabled "Gpg.available?", 'which "gpg"' odisabled "Gpg.available?", 'which "gpg"'
end end
def create_test_key(_) def create_test_key(*)
odisabled "Gpg.create_test_key" odisabled "Gpg.create_test_key"
end end
@ -18,7 +17,11 @@ module Gpg
odisabled "Gpg.cleanup_test_processes!" odisabled "Gpg.cleanup_test_processes!"
end end
def test(_) def test(*)
odisabled "Gpg.test" odisabled "Gpg.test"
end end
end
prepend Compat
end
end end

View File

@ -7,8 +7,7 @@ require "compat/hbc/dsl"
module Hbc module Hbc
class << self class << self
prepend( module Compat
Module.new do
def init def init
Cache.delete_legacy_cache Cache.delete_legacy_cache
@ -17,7 +16,8 @@ module Hbc
super super
end end
end, end
)
prepend Compat
end end
end end

View File

@ -1,7 +1,7 @@
module Hbc module Hbc
module Cache module Cache
module_function class << self
module Compat
def delete_legacy_cache def delete_legacy_cache
legacy_cache = HOMEBREW_CACHE.join("Casks") legacy_cache = HOMEBREW_CACHE.join("Casks")
return unless legacy_cache.exist? return unless legacy_cache.exist?
@ -10,4 +10,8 @@ module Hbc
FileUtils.remove_entry_secure(legacy_cache) FileUtils.remove_entry_secure(legacy_cache)
end end
end end
prepend Compat
end
end
end end

View File

@ -1,4 +1,9 @@
module CaskLoaderCompatibilityLayer module Hbc
module CaskLoader
class FromContentLoader; end
class FromPathLoader < FromContentLoader
module Compat
private private
def cask(header_token, **options, &block) def cask(header_token, **options, &block)
@ -9,14 +14,9 @@ module CaskLoaderCompatibilityLayer
super(header_token, **options, &block) super(header_token, **options, &block)
end end
end end
module Hbc prepend Compat
module CaskLoader
class FromContentLoader; end
class FromPathLoader < FromContentLoader
prepend CaskLoaderCompatibilityLayer
end end
end end
end end

View File

@ -1,7 +1,7 @@
module Hbc module Hbc
module Caskroom module Caskroom
module_function class << self
module Compat
def migrate_legacy_caskroom def migrate_legacy_caskroom
return if Hbc.caskroom.exist? return if Hbc.caskroom.exist?
@ -42,4 +42,8 @@ module Hbc
end end
end end
end end
prepend Compat
end
end
end end

View File

@ -2,22 +2,18 @@ require "cask/lib/hbc/cli/abstract_command"
module Hbc module Hbc
class CLI class CLI
module Compat
class Update < AbstractCommand class Update < AbstractCommand
def self.run(*_ignored) def self.run(*_ignored)
odeprecated "`brew cask update`", "`brew update`", disable_on: Time.utc(2017, 7, 1) odisabled "`brew cask update`", "`brew update`"
result = SystemCommand.run(HOMEBREW_BREW_FILE, args: ["update"],
print_stderr: true,
print_stdout: true)
exit result.exit_status
end end
def self.visible def self.visible
false false
end end
end
end
def self.help prepend Compat
"a synonym for 'brew update'"
end
end
end end
end end

View File

@ -1,7 +1,11 @@
module Hbc module Hbc
class DSL class DSL
module Compat
def license(*) def license(*)
odeprecated "Hbc::DSL#license" odeprecated "Hbc::DSL#license"
end end
end end
prepend Compat
end
end end

View File

@ -1,10 +1,14 @@
module OS module OS
module Mac module Mac
class << self class << self
module Compat
def release def release
odeprecated "MacOS.release", "MacOS.version" odeprecated "MacOS.release", "MacOS.version"
version version
end end
end end
prepend Compat
end
end end
end end

View File

@ -74,8 +74,8 @@ describe Hbc::CLI, :cask do
end end
end end
it "provides a help message for all commands" do it "provides a help message for all visible commands" do
described_class.command_classes.each do |command_class| described_class.command_classes.select(&:visible).each do |command_class|
expect(command_class.help).to match(/\w+/), command_class.name expect(command_class.help).to match(/\w+/), command_class.name
end end
end end