From 58db95c1d23b8269dffd654afb0b8b12b46a51ce Mon Sep 17 00:00:00 2001 From: Markus Reiter Date: Fri, 19 May 2017 21:13:08 +0200 Subject: Refactor `CLI::Cat`. --- Library/Homebrew/cask/lib/hbc/cli/base.rb | 4 ++++ Library/Homebrew/cask/lib/hbc/cli/cat.rb | 6 +++++- 2 files changed, 9 insertions(+), 1 deletion(-) (limited to 'Library') diff --git a/Library/Homebrew/cask/lib/hbc/cli/base.rb b/Library/Homebrew/cask/lib/hbc/cli/base.rb index 3301cad91..1ad347de3 100644 --- a/Library/Homebrew/cask/lib/hbc/cli/base.rb +++ b/Library/Homebrew/cask/lib/hbc/cli/base.rb @@ -20,6 +20,10 @@ module Hbc def self.needs_init? false end + + def initialize(*args) + @args = args + end end end end diff --git a/Library/Homebrew/cask/lib/hbc/cli/cat.rb b/Library/Homebrew/cask/lib/hbc/cli/cat.rb index 52f6e0eab..774b96e89 100644 --- a/Library/Homebrew/cask/lib/hbc/cli/cat.rb +++ b/Library/Homebrew/cask/lib/hbc/cli/cat.rb @@ -2,7 +2,11 @@ module Hbc class CLI class Cat < Base def self.run(*args) - cask_tokens = cask_tokens_from(args) + new(*args).run + end + + def run + cask_tokens = self.class.cask_tokens_from(@args) raise CaskUnspecifiedError if cask_tokens.empty? # only respects the first argument cask_token = cask_tokens.first.sub(/\.rb$/i, "") -- cgit v1.2.3