From f48857d24657c2cf9c8d01c781ba270cff52c8a0 Mon Sep 17 00:00:00 2001 From: Markus Reiter Date: Fri, 3 Feb 2017 11:54:38 +0100 Subject: Use constants for RuboCop version. --- Library/Homebrew/cask/lib/hbc/cli/style.rb | 4 +--- Library/Homebrew/cmd/style.rb | 2 +- Library/Homebrew/config.rb | 4 ++++ 3 files changed, 6 insertions(+), 4 deletions(-) (limited to 'Library') diff --git a/Library/Homebrew/cask/lib/hbc/cli/style.rb b/Library/Homebrew/cask/lib/hbc/cli/style.rb index cdcc135b8..d3e44382d 100644 --- a/Library/Homebrew/cask/lib/hbc/cli/style.rb +++ b/Library/Homebrew/cask/lib/hbc/cli/style.rb @@ -23,12 +23,10 @@ module Hbc $CHILD_STATUS.success? end - RUBOCOP_CASK_VERSION = "~> 0.10.6".freeze - def install_rubocop Utils.capture_stderr do begin - Homebrew.install_gem_setup_path! "rubocop-cask", RUBOCOP_CASK_VERSION, "rubocop" + Homebrew.install_gem_setup_path! "rubocop-cask", HOMEBREW_RUBOCOP_CASK_VERSION, "rubocop" rescue SystemExit raise CaskError, Tty.strip_ansi($stderr.string).chomp.sub(/\AError: /, "") end diff --git a/Library/Homebrew/cmd/style.rb b/Library/Homebrew/cmd/style.rb index 586c6da6b..3d12561c1 100644 --- a/Library/Homebrew/cmd/style.rb +++ b/Library/Homebrew/cmd/style.rb @@ -47,7 +47,7 @@ module Homebrew def check_style_impl(files, output_type, options = {}) fix = options[:fix] - Homebrew.install_gem_setup_path! "rubocop", "0.47.1" + Homebrew.install_gem_setup_path! "rubocop", HOMEBREW_RUBOCOP_VERSION args = %w[ --force-exclusion diff --git a/Library/Homebrew/config.rb b/Library/Homebrew/config.rb index 38d7c8043..9831b0af8 100644 --- a/Library/Homebrew/config.rb +++ b/Library/Homebrew/config.rb @@ -48,3 +48,7 @@ end # Load path used by standalone scripts to access the Homebrew code base HOMEBREW_LOAD_PATH = HOMEBREW_LIBRARY_PATH + +# RuboCop version used for `brew style` and `brew cask style` +HOMEBREW_RUBOCOP_VERSION = "0.47.1".freeze +HOMEBREW_RUBOCOP_CASK_VERSION = "~> 0.10.6".freeze # has to be updated when RuboCop version changes -- cgit v1.2.3 From e70d28cba1b42c555f025b7beb13f67d2df5a067 Mon Sep 17 00:00:00 2001 From: Markus Reiter Date: Fri, 3 Feb 2017 14:05:07 +0100 Subject: Add test to check if `rubocop-cask` version is is outdated. --- Library/Homebrew/cask/spec/cask/cli/style_spec.rb | 16 ++++++++++++++++ Library/Homebrew/config.rb | 6 ++---- Library/Homebrew/constants.rb | 3 +++ Library/Homebrew/test/support/lib/config.rb | 2 ++ 4 files changed, 23 insertions(+), 4 deletions(-) create mode 100644 Library/Homebrew/constants.rb (limited to 'Library') diff --git a/Library/Homebrew/cask/spec/cask/cli/style_spec.rb b/Library/Homebrew/cask/spec/cask/cli/style_spec.rb index b0d34576a..106bfbb44 100644 --- a/Library/Homebrew/cask/spec/cask/cli/style_spec.rb +++ b/Library/Homebrew/cask/spec/cask/cli/style_spec.rb @@ -1,4 +1,6 @@ require "English" +require "open3" +require "rubygems" describe Hbc::CLI::Style do let(:args) { [] } @@ -77,6 +79,20 @@ describe Hbc::CLI::Style do expect { subject }.to raise_error(Hbc::CaskError) end end + + context "version" do + it "matches `HOMEBREW_RUBOCOP_VERSION`" do + stdout, status = Open3.capture2("gem", "dependency", "rubocop-cask", "--version", HOMEBREW_RUBOCOP_CASK_VERSION, "--pipe", "--remote") + + expect(status).to be_a_success + + requirement = Gem::Requirement.new(stdout.scan(/rubocop --version '(.*)'/).flatten.first) + version = Gem::Version.new(HOMEBREW_RUBOCOP_VERSION) + + expect(requirement).not_to be_none + expect(requirement).to be_satisfied_by(version) + end + end end describe "#cask_paths" do diff --git a/Library/Homebrew/config.rb b/Library/Homebrew/config.rb index 9831b0af8..30b7bc6c9 100644 --- a/Library/Homebrew/config.rb +++ b/Library/Homebrew/config.rb @@ -2,6 +2,8 @@ unless ENV["HOMEBREW_BREW_FILE"] raise "HOMEBREW_BREW_FILE was not exported! Please call bin/brew directly!" end +require "constants" + # Path to `bin/brew` main executable in HOMEBREW_PREFIX HOMEBREW_BREW_FILE = Pathname.new(ENV["HOMEBREW_BREW_FILE"]) @@ -48,7 +50,3 @@ end # Load path used by standalone scripts to access the Homebrew code base HOMEBREW_LOAD_PATH = HOMEBREW_LIBRARY_PATH - -# RuboCop version used for `brew style` and `brew cask style` -HOMEBREW_RUBOCOP_VERSION = "0.47.1".freeze -HOMEBREW_RUBOCOP_CASK_VERSION = "~> 0.10.6".freeze # has to be updated when RuboCop version changes diff --git a/Library/Homebrew/constants.rb b/Library/Homebrew/constants.rb new file mode 100644 index 000000000..033a24dd0 --- /dev/null +++ b/Library/Homebrew/constants.rb @@ -0,0 +1,3 @@ +# RuboCop version used for `brew style` and `brew cask style` +HOMEBREW_RUBOCOP_VERSION = "0.47.1".freeze +HOMEBREW_RUBOCOP_CASK_VERSION = "~> 0.10.6".freeze # has to be updated when RuboCop version changes diff --git a/Library/Homebrew/test/support/lib/config.rb b/Library/Homebrew/test/support/lib/config.rb index fb5c210fe..3a0a76722 100644 --- a/Library/Homebrew/test/support/lib/config.rb +++ b/Library/Homebrew/test/support/lib/config.rb @@ -2,6 +2,8 @@ unless ENV["HOMEBREW_BREW_FILE"] raise "HOMEBREW_BREW_FILE was not exported! Please call bin/brew directly!" end +require "constants" + require "tmpdir" require "pathname" -- cgit v1.2.3 From fd7616b8939e87423ab1785a0c0f17a44c92e571 Mon Sep 17 00:00:00 2001 From: Markus Reiter Date: Sun, 12 Feb 2017 23:07:06 +0100 Subject: Update `rubocop-cask` to 0.11.0. --- Library/Homebrew/constants.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Library') diff --git a/Library/Homebrew/constants.rb b/Library/Homebrew/constants.rb index 033a24dd0..660cad7a3 100644 --- a/Library/Homebrew/constants.rb +++ b/Library/Homebrew/constants.rb @@ -1,3 +1,3 @@ # RuboCop version used for `brew style` and `brew cask style` HOMEBREW_RUBOCOP_VERSION = "0.47.1".freeze -HOMEBREW_RUBOCOP_CASK_VERSION = "~> 0.10.6".freeze # has to be updated when RuboCop version changes +HOMEBREW_RUBOCOP_CASK_VERSION = "~> 0.11.0".freeze # has to be updated when RuboCop version changes -- cgit v1.2.3