diff options
| author | Markus Reiter | 2016-09-24 13:52:43 +0200 |
|---|---|---|
| committer | Markus Reiter | 2016-09-24 16:00:58 +0200 |
| commit | b86c8efb79b3ed835d552c4d7416640ef10caf21 (patch) | |
| tree | 7e1edc8a8f339e4d2781f43576d40c9c79aebcdc /Library/Homebrew/cask/lib/hbc/cli/internal_dump.rb | |
| parent | 687f0fcf721c8e36f32570ed72d0988a6eaf986f (diff) | |
| download | brew-b86c8efb79b3ed835d552c4d7416640ef10caf21.tar.bz2 | |
Cask: Use nested classes and modules.
Diffstat (limited to 'Library/Homebrew/cask/lib/hbc/cli/internal_dump.rb')
| -rw-r--r-- | Library/Homebrew/cask/lib/hbc/cli/internal_dump.rb | 52 |
1 files changed, 28 insertions, 24 deletions
diff --git a/Library/Homebrew/cask/lib/hbc/cli/internal_dump.rb b/Library/Homebrew/cask/lib/hbc/cli/internal_dump.rb index 1bccf610d..af1494e5f 100644 --- a/Library/Homebrew/cask/lib/hbc/cli/internal_dump.rb +++ b/Library/Homebrew/cask/lib/hbc/cli/internal_dump.rb @@ -1,30 +1,34 @@ -class Hbc::CLI::InternalDump < Hbc::CLI::InternalUseBase - def self.run(*arguments) - cask_tokens = cask_tokens_from(arguments) - raise Hbc::CaskUnspecifiedError if cask_tokens.empty? - retval = dump_casks(*cask_tokens) - # retval is ternary: true/false/nil +module Hbc + class CLI + class InternalDump < InternalUseBase + def self.run(*arguments) + cask_tokens = cask_tokens_from(arguments) + raise CaskUnspecifiedError if cask_tokens.empty? + retval = dump_casks(*cask_tokens) + # retval is ternary: true/false/nil - raise Hbc::CaskError, "nothing to dump" if retval.nil? - raise Hbc::CaskError, "dump incomplete" unless retval - end + raise CaskError, "nothing to dump" if retval.nil? + raise CaskError, "dump incomplete" unless retval + end - def self.dump_casks(*cask_tokens) - Hbc.debug = true # Yuck. At the moment this is the only way to make dumps visible - count = 0 - cask_tokens.each do |cask_token| - begin - cask = Hbc.load(cask_token) - count += 1 - cask.dumpcask - rescue StandardError => e - opoo "#{cask_token} was not found or would not load: #{e}" + def self.dump_casks(*cask_tokens) + Hbc.debug = true # Yuck. At the moment this is the only way to make dumps visible + count = 0 + cask_tokens.each do |cask_token| + begin + cask = Hbc.load(cask_token) + count += 1 + cask.dumpcask + rescue StandardError => e + opoo "#{cask_token} was not found or would not load: #{e}" + end + end + count.zero? ? nil : count == cask_tokens.length end - end - count.zero? ? nil : count == cask_tokens.length - end - def self.help - "Dump the given Cask in YAML format" + def self.help + "Dump the given Cask in YAML format" + end + end end end |
