diff --git a/brew-cask.rb b/brew-cask.rb index 6c40f03456..5ba2231aa3 100644 --- a/brew-cask.rb +++ b/brew-cask.rb @@ -1,8 +1,15 @@ -require Pathname(__FILE__).realpath.dirname.join("lib", "cask", "version") +begin + require Pathname(__FILE__).realpath.dirname.join("lib", "hbc", "version") +rescue + # todo: transitional, defensive, should not be needed. + # remove the begin/rescue logic after 1 Feb 2015 + require Pathname(__FILE__).realpath.dirname.join("lib", "cask", "version") + HBC_VERSION = HOMEBREW_CASK_VERSION +end class BrewCask < Formula homepage "https://github.com/caskroom/homebrew-cask/" - url "https://github.com/caskroom/homebrew-cask.git", :tag => "v#{HOMEBREW_CASK_VERSION}" + url "https://github.com/caskroom/homebrew-cask.git", :tag => "v#{HBC_VERSION}" head "https://github.com/caskroom/homebrew-cask.git", :branch => "master" skip_clean "bin" diff --git a/developer/bin/bump_version b/developer/bin/bump_version index ae822b1c4f..f8ac818884 100755 --- a/developer/bin/bump_version +++ b/developer/bin/bump_version @@ -14,9 +14,9 @@ require 'rubygems' ### configurable constants ### -VERSION_FILE = 'lib/cask/version.rb' +VERSION_FILE = 'lib/hbc/version.rb' VERSION_PAT = %r[\d+\.\d+\.\d+]i -VERSION_CONSTANT_NAME = 'HOMEBREW_CASK_VERSION' +VERSION_CONSTANT_NAME = 'HBC_VERSION' ### ### methods diff --git a/doc/releasing.md b/doc/releasing.md index 00c707ad7e..b2fffe4f16 100644 --- a/doc/releasing.md +++ b/doc/releasing.md @@ -69,7 +69,7 @@ changelog. $ export NEW_RELEASE_TAG="$(./developer/bin/get_release_tag -next -patch)"; echo "$NEW_RELEASE_TAG" ``` 7. Make sure the value in `$NEW_RELEASE_TAG` is what you want. -8. Bump the `HOMEBREW_CASK_VERSION` string which is stored in the file +8. Bump the `HBC_VERSION` string which is stored in the file `lib/cask/version.rb`: ```bash diff --git a/lib/brew-cask-cmd.rb b/lib/brew-cask-cmd.rb index 80eb46bcd7..19d648c351 100644 --- a/lib/brew-cask-cmd.rb +++ b/lib/brew-cask-cmd.rb @@ -13,7 +13,7 @@ $LOAD_PATH.unshift(File.expand_path('..', Pathname.new(__FILE__).realpath)) # todo remove internal Homebrew dependencies and remove this line require 'vendor/homebrew-fork/global' -require 'cask' +require 'hbc' -Cask::CLI.process(ARGV) +Hbc::CLI.process(ARGV) exit 0 diff --git a/lib/cask/artifact.rb b/lib/cask/artifact.rb deleted file mode 100644 index fa94d4f834..0000000000 --- a/lib/cask/artifact.rb +++ /dev/null @@ -1,68 +0,0 @@ -module Cask::Artifact; end - -require 'cask/artifact/base' -require 'cask/artifact/uninstall_base' -require 'cask/artifact/symlinked' -require 'cask/artifact/hardlinked' - -require 'cask/artifact/app' -require 'cask/artifact/artifact' # generic 'artifact' stanza -require 'cask/artifact/binary' -require 'cask/artifact/colorpicker' -require 'cask/artifact/font' -require 'cask/artifact/input_method' -require 'cask/artifact/installer' -require 'cask/artifact/internet_plugin' -require 'cask/artifact/nested_container' -require 'cask/artifact/pkg' -require 'cask/artifact/postflight_block' -require 'cask/artifact/preflight_block' -require 'cask/artifact/prefpane' -require 'cask/artifact/qlplugin' -require 'cask/artifact/screen_saver' -require 'cask/artifact/service' -require 'cask/artifact/stage_only' -require 'cask/artifact/suite' -require 'cask/artifact/uninstall' -require 'cask/artifact/widget' -require 'cask/artifact/zap' - -module Cask::Artifact - # - # NOTE: order is important here, since we want to extract nested containers - # before we handle any other artifacts - # - def self.artifacts - [ - Cask::Artifact::PreflightBlock, - Cask::Artifact::NestedContainer, - Cask::Artifact::Installer, - Cask::Artifact::App, - Cask::Artifact::Suite, - Cask::Artifact::Artifact, # generic 'artifact' stanza - Cask::Artifact::Colorpicker, - Cask::Artifact::Pkg, - Cask::Artifact::Prefpane, - Cask::Artifact::Qlplugin, - Cask::Artifact::Font, - Cask::Artifact::Widget, - Cask::Artifact::Service, - Cask::Artifact::StageOnly, - Cask::Artifact::Binary, - Cask::Artifact::InputMethod, - Cask::Artifact::InternetPlugin, - Cask::Artifact::ScreenSaver, - Cask::Artifact::Uninstall, - Cask::Artifact::PostflightBlock, - Cask::Artifact::Zap, - ] - end - - def self.for_cask(cask) - odebug "Determining which artifacts are present in Cask #{cask}" - artifacts.select do |artifact| - odebug "Checking for artifact class #{artifact}" - artifact.me?(cask) - end - end -end diff --git a/lib/cask/artifact/app.rb b/lib/cask/artifact/app.rb deleted file mode 100644 index 01effd5ec4..0000000000 --- a/lib/cask/artifact/app.rb +++ /dev/null @@ -1,2 +0,0 @@ -class Cask::Artifact::App < Cask::Artifact::Symlinked -end diff --git a/lib/cask/artifact/binary.rb b/lib/cask/artifact/binary.rb deleted file mode 100644 index f09b2de7b5..0000000000 --- a/lib/cask/artifact/binary.rb +++ /dev/null @@ -1,5 +0,0 @@ -class Cask::Artifact::Binary < Cask::Artifact::Symlinked - def install_phase - super unless Cask.no_binaries - end -end diff --git a/lib/cask/artifact/colorpicker.rb b/lib/cask/artifact/colorpicker.rb deleted file mode 100644 index f339f91c40..0000000000 --- a/lib/cask/artifact/colorpicker.rb +++ /dev/null @@ -1,2 +0,0 @@ -class Cask::Artifact::Colorpicker < Cask::Artifact::Symlinked -end diff --git a/lib/cask/artifact/font.rb b/lib/cask/artifact/font.rb deleted file mode 100644 index 3410dcfa5b..0000000000 --- a/lib/cask/artifact/font.rb +++ /dev/null @@ -1,2 +0,0 @@ -class Cask::Artifact::Font < Cask::Artifact::Hardlinked -end diff --git a/lib/cask/artifact/input_method.rb b/lib/cask/artifact/input_method.rb deleted file mode 100644 index 9295a5beb7..0000000000 --- a/lib/cask/artifact/input_method.rb +++ /dev/null @@ -1,2 +0,0 @@ -class Cask::Artifact::InputMethod < Cask::Artifact::Symlinked -end diff --git a/lib/cask/artifact/internet_plugin.rb b/lib/cask/artifact/internet_plugin.rb deleted file mode 100644 index 4368a7244a..0000000000 --- a/lib/cask/artifact/internet_plugin.rb +++ /dev/null @@ -1,3 +0,0 @@ -class Cask::Artifact::InternetPlugin < Cask::Artifact::Symlinked - -end diff --git a/lib/cask/artifact/screen_saver.rb b/lib/cask/artifact/screen_saver.rb deleted file mode 100644 index 0c6a438a7b..0000000000 --- a/lib/cask/artifact/screen_saver.rb +++ /dev/null @@ -1,3 +0,0 @@ -class Cask::Artifact::ScreenSaver < Cask::Artifact::Symlinked - -end diff --git a/lib/cask/artifact/service.rb b/lib/cask/artifact/service.rb deleted file mode 100644 index c42934162d..0000000000 --- a/lib/cask/artifact/service.rb +++ /dev/null @@ -1,2 +0,0 @@ -class Cask::Artifact::Service < Cask::Artifact::Symlinked -end diff --git a/lib/cask/artifact/uninstall.rb b/lib/cask/artifact/uninstall.rb deleted file mode 100644 index 09fbf0176e..0000000000 --- a/lib/cask/artifact/uninstall.rb +++ /dev/null @@ -1,2 +0,0 @@ -class Cask::Artifact::Uninstall < Cask::Artifact::UninstallBase -end diff --git a/lib/cask/artifact/widget.rb b/lib/cask/artifact/widget.rb deleted file mode 100644 index 9f49edbbf3..0000000000 --- a/lib/cask/artifact/widget.rb +++ /dev/null @@ -1,2 +0,0 @@ -class Cask::Artifact::Widget < Cask::Artifact::Symlinked -end diff --git a/lib/cask/cli/uninstall.rb b/lib/cask/cli/uninstall.rb deleted file mode 100644 index c6fdefca00..0000000000 --- a/lib/cask/cli/uninstall.rb +++ /dev/null @@ -1,17 +0,0 @@ -class Cask::CLI::Uninstall < Cask::CLI::Base - def self.run(*args) - cask_tokens = cask_tokens_from(args) - raise CaskUnspecifiedError if cask_tokens.empty? - force = args.include? '--force' - cask_tokens.each do |cask_token| - odebug "Uninstalling Cask #{cask_token}" - cask = Cask.load(cask_token) - raise CaskNotInstalledError.new(cask) unless cask.installed? or force - Cask::Installer.new(cask).uninstall(force) - end - end - - def self.help - "uninstalls the given Cask" - end -end diff --git a/lib/cask/container.rb b/lib/cask/container.rb deleted file mode 100644 index e04613b842..0000000000 --- a/lib/cask/container.rb +++ /dev/null @@ -1,62 +0,0 @@ -class Cask::Container; end - -require 'cask/container/base' -require 'cask/container/air' -require 'cask/container/bzip2' -require 'cask/container/cab' -require 'cask/container/criteria' -require 'cask/container/dmg' -require 'cask/container/generic_unar' -require 'cask/container/gzip' -require 'cask/container/naked' -require 'cask/container/otf' -require 'cask/container/pkg' -require 'cask/container/seven_zip' -require 'cask/container/sit' -require 'cask/container/tar' -require 'cask/container/ttf' -require 'cask/container/rar' -require 'cask/container/xar' -require 'cask/container/zip' - -class Cask::Container - def self.autodetect_containers - [ - Cask::Container::Pkg, - Cask::Container::Ttf, - Cask::Container::Otf, - Cask::Container::Air, - Cask::Container::Cab, - Cask::Container::Dmg, - Cask::Container::SevenZip, - Cask::Container::Sit, - Cask::Container::Tar, # or compressed tar - Cask::Container::Rar, - Cask::Container::Zip, - Cask::Container::Bzip2, - Cask::Container::Gzip, # pure gzip, not tar/gzip - Cask::Container::Xar, - ] - # for explicit use only (never autodetected): - # Cask::Container::Naked - # Cask::Container::GenericUnar - end - - def self.for_path(path, command) - odebug "Determining which containers to use based on filetype" - criteria = Cask::Container::Criteria.new(path, command) - autodetect_containers.find do |c| - odebug "Checking container class #{c}" - c.me?(criteria) - end - end - - def self.from_type(type) - odebug "Determining which containers to use based on 'container :type'" - begin - Cask::Container.const_get(type.to_s.split('_').map(&:capitalize).join) - rescue NameError - false - end - end -end diff --git a/lib/cask/dsl/preflight.rb b/lib/cask/dsl/preflight.rb deleted file mode 100644 index 1375a79723..0000000000 --- a/lib/cask/dsl/preflight.rb +++ /dev/null @@ -1,6 +0,0 @@ -class Cask::DSL::Preflight < Cask::DSL::Base - def method_missing(method, *args) - Cask::Utils.method_missing_message(method, @cask.to_s, 'preflight') - return nil - end -end diff --git a/lib/cask/dsl/uninstall_postflight.rb b/lib/cask/dsl/uninstall_postflight.rb deleted file mode 100644 index 13fab81d6e..0000000000 --- a/lib/cask/dsl/uninstall_postflight.rb +++ /dev/null @@ -1,6 +0,0 @@ -class Cask::DSL::UninstallPostflight < Cask::DSL::Base - def method_missing(method, *args) - Cask::Utils.method_missing_message(method, @cask.to_s, 'uninstall_postflight') - return nil - end -end diff --git a/lib/cask/dsl/uninstall_preflight.rb b/lib/cask/dsl/uninstall_preflight.rb deleted file mode 100644 index e7acb0ac06..0000000000 --- a/lib/cask/dsl/uninstall_preflight.rb +++ /dev/null @@ -1,10 +0,0 @@ -require 'cask/staged' - -class Cask::DSL::UninstallPreflight < Cask::DSL::Base - include Cask::Staged - - def method_missing(method, *args) - Cask::Utils.method_missing_message(method, @cask.to_s, 'uninstall_preflight') - return nil - end -end diff --git a/lib/cask/extend.rb b/lib/cask/extend.rb deleted file mode 100644 index ffebb062ed..0000000000 --- a/lib/cask/extend.rb +++ /dev/null @@ -1,4 +0,0 @@ -# monkeypatching -require 'cask/extend/hash' -require 'cask/extend/string' -require 'cask/extend/pathname' diff --git a/lib/cask/hardware.rb b/lib/cask/hardware.rb deleted file mode 100644 index 760fa46594..0000000000 --- a/lib/cask/hardware.rb +++ /dev/null @@ -1,3 +0,0 @@ -module Cask::Hardware; end - -require 'cask/hardware/cpu' diff --git a/lib/cask/source.rb b/lib/cask/source.rb deleted file mode 100644 index 9ffbdce358..0000000000 --- a/lib/cask/source.rb +++ /dev/null @@ -1,36 +0,0 @@ -module Cask::Source; end - -require 'cask/source/gone' -require 'cask/source/path_slash_required' -require 'cask/source/path_slash_optional' -require 'cask/source/tapped_qualified' -require 'cask/source/untapped_qualified' -require 'cask/source/tapped' -require 'cask/source/uri' - -module Cask::Source - def self.sources - [ - Cask::Source::URI, - Cask::Source::PathSlashRequired, - Cask::Source::TappedQualified, - Cask::Source::UntappedQualified, - Cask::Source::Tapped, - Cask::Source::PathSlashOptional, - Cask::Source::Gone, - ] - end - - def self.for_query(query) - odebug "Translating '#{query}' into a valid Cask source" - source = sources.find do |s| - odebug "Testing source class #{s}" - s.me?(query) - end - raise CaskUnavailableError.new(query) unless source - odebug "Success! Using source class #{source}" - resolved_cask_source = source.new(query) - odebug "Resolved Cask URI or file source to '#{resolved_cask_source}'" - resolved_cask_source - end -end diff --git a/lib/cask/source/path_slash_optional.rb b/lib/cask/source/path_slash_optional.rb deleted file mode 100644 index cb2346a5c0..0000000000 --- a/lib/cask/source/path_slash_optional.rb +++ /dev/null @@ -1,8 +0,0 @@ -require 'cask/source/path_base' - -class Cask::Source::PathSlashOptional < Cask::Source::PathBase - def self.me?(query) - path = self.path_for_query(query) - path.exist? - end -end diff --git a/lib/cask/source/tapped_qualified.rb b/lib/cask/source/tapped_qualified.rb deleted file mode 100644 index 1b2d35d757..0000000000 --- a/lib/cask/source/tapped_qualified.rb +++ /dev/null @@ -1,14 +0,0 @@ -require 'cask/source/tapped' - -class Cask::Source::TappedQualified < Cask::Source::Tapped - def self.me?(query) - !!Cask::QualifiedToken::parse(query) and path_for_query(query).exist? - end - - def self.path_for_query(query) - user, repo, token = Cask::QualifiedToken::parse(query) - token.sub!(/\.rb$/i,'') - tap = "#{user}/homebrew-#{repo}" - Cask.tapspath.join(tap, 'Casks', "#{token}.rb") - end -end diff --git a/lib/cask/source/untapped_qualified.rb b/lib/cask/source/untapped_qualified.rb deleted file mode 100644 index e207f64727..0000000000 --- a/lib/cask/source/untapped_qualified.rb +++ /dev/null @@ -1,17 +0,0 @@ -require 'cask/source/tapped_qualified' - -class Cask::Source::UntappedQualified < Cask::Source::TappedQualified - def self.path_for_query(query) - user, repo, token = Cask::QualifiedToken::parse(query) - token.sub!(/\.rb$/i,'') - tap = "#{user}/homebrew-#{repo}" - unless Cask.tapspath.join(tap).exist? - ohai "Adding new tap '#{tap}'" - result = Cask::SystemCommand.run!(HOMEBREW_BREW_FILE, - :args => ['tap', "#{user}/#{repo}"]) - puts result.stdout - $stderr.puts result.stderr - end - Cask.tapspath.join(tap, 'Casks', "#{token}.rb") - end -end diff --git a/lib/cask/version.rb b/lib/cask/version.rb deleted file mode 100644 index 03f8a7bf39..0000000000 --- a/lib/cask/version.rb +++ /dev/null @@ -1 +0,0 @@ -HOMEBREW_CASK_VERSION = '0.51.1' diff --git a/lib/cask.rb b/lib/hbc.rb similarity index 75% rename from lib/cask.rb rename to lib/hbc.rb index 1b064f2975..5bba1abd9d 100644 --- a/lib/cask.rb +++ b/lib/hbc.rb @@ -1,56 +1,56 @@ HOMEBREW_CACHE_CASKS = HOMEBREW_CACHE.join('Casks') -class Cask; end +class Hbc; end # todo remove internal Homebrew dependencies and remove this line require 'vendor/homebrew-fork/download_strategy' -require 'cask/extend' -require 'cask/artifact' -require 'cask/audit' -require 'cask/auditor' -require 'cask/without_source' -require 'cask/checkable' -require 'cask/cli' -require 'cask/cask_dependencies' -require 'cask/caveats' -require 'cask/container' -require 'cask/download' -require 'cask/download_strategy' -require 'cask/dsl' -require 'cask/exceptions' -require 'cask/fetcher' -require 'cask/hardware' -require 'cask/installer' -require 'cask/locations' -require 'cask/macos' -require 'cask/options' -require 'cask/pkg' -require 'cask/pretty_listing' -require 'cask/qualified_token' -require 'cask/scopes' -require 'cask/source' -require 'cask/staged' -require 'cask/system_command' -require 'cask/topological_hash' -require 'cask/underscore_supporting_uri' -require 'cask/url' -require 'cask/url_checker' -require 'cask/utils' -require 'cask/version' +require 'hbc/extend' +require 'hbc/artifact' +require 'hbc/audit' +require 'hbc/auditor' +require 'hbc/without_source' +require 'hbc/checkable' +require 'hbc/cli' +require 'hbc/cask_dependencies' +require 'hbc/caveats' +require 'hbc/container' +require 'hbc/download' +require 'hbc/download_strategy' +require 'hbc/dsl' +require 'hbc/exceptions' +require 'hbc/fetcher' +require 'hbc/hardware' +require 'hbc/installer' +require 'hbc/locations' +require 'hbc/macos' +require 'hbc/options' +require 'hbc/pkg' +require 'hbc/pretty_listing' +require 'hbc/qualified_token' +require 'hbc/scopes' +require 'hbc/source' +require 'hbc/staged' +require 'hbc/system_command' +require 'hbc/topological_hash' +require 'hbc/underscore_supporting_uri' +require 'hbc/url' +require 'hbc/url_checker' +require 'hbc/utils' +require 'hbc/version' require 'vendor/plist' -class Cask - include Cask::DSL - include Cask::Locations - include Cask::Scopes - include Cask::Options - include Cask::Utils +class Hbc + include Hbc::DSL + include Hbc::Locations + include Hbc::Scopes + include Hbc::Options + include Hbc::Utils # todo: restrict visibility of this to the DSL - ::MacOS = Cask::MacOS - ::Hardware = Cask::Hardware + ::MacOS = Hbc::MacOS + ::Hardware = Hbc::Hardware def self.init # todo: Creating directories should be deferred until needed. @@ -85,7 +85,7 @@ class Cask def self.load(query) odebug 'Loading Cask definitions' - cask = Cask::Source.for_query(query).load + cask = Hbc::Source.for_query(query).load cask.dumpcask cask end @@ -134,7 +134,7 @@ class Cask def metadata_path(timestamp=:latest, create=false) return nil unless metadata_versioned_container_path.respond_to?(:join) if create and timestamp == :latest - raise CaskError.new('Cannot create metadata path when timestamp is :latest') + raise Hbc::CaskError.new('Cannot create metadata path when timestamp is :latest') end if timestamp == :latest path = Pathname.glob(metadata_versioned_container_path.join('*')).sort.last @@ -152,10 +152,10 @@ class Cask def metadata_subdir(leaf, timestamp=:latest, create=false) if create and timestamp == :latest - raise CaskError.new('Cannot create metadata subdir when timestamp is :latest') + raise Hbc::CaskError.new('Cannot create metadata subdir when timestamp is :latest') end unless leaf.respond_to?(:length) and leaf.length > 0 - raise CaskError.new('Cannot create metadata subdir for empty leaf') + raise Hbc::CaskError.new('Cannot create metadata subdir for empty leaf') end parent = metadata_path(timestamp, create) return nil unless parent.respond_to?(:join) diff --git a/lib/hbc/artifact.rb b/lib/hbc/artifact.rb new file mode 100644 index 0000000000..62d835b9bb --- /dev/null +++ b/lib/hbc/artifact.rb @@ -0,0 +1,68 @@ +module Hbc::Artifact; end + +require 'hbc/artifact/base' +require 'hbc/artifact/uninstall_base' +require 'hbc/artifact/symlinked' +require 'hbc/artifact/hardlinked' + +require 'hbc/artifact/app' +require 'hbc/artifact/artifact' # generic 'artifact' stanza +require 'hbc/artifact/binary' +require 'hbc/artifact/colorpicker' +require 'hbc/artifact/font' +require 'hbc/artifact/input_method' +require 'hbc/artifact/installer' +require 'hbc/artifact/internet_plugin' +require 'hbc/artifact/nested_container' +require 'hbc/artifact/pkg' +require 'hbc/artifact/postflight_block' +require 'hbc/artifact/preflight_block' +require 'hbc/artifact/prefpane' +require 'hbc/artifact/qlplugin' +require 'hbc/artifact/screen_saver' +require 'hbc/artifact/service' +require 'hbc/artifact/stage_only' +require 'hbc/artifact/suite' +require 'hbc/artifact/uninstall' +require 'hbc/artifact/widget' +require 'hbc/artifact/zap' + +module Hbc::Artifact + # + # NOTE: order is important here, since we want to extract nested containers + # before we handle any other artifacts + # + def self.artifacts + [ + Hbc::Artifact::PreflightBlock, + Hbc::Artifact::NestedContainer, + Hbc::Artifact::Installer, + Hbc::Artifact::App, + Hbc::Artifact::Suite, + Hbc::Artifact::Artifact, # generic 'artifact' stanza + Hbc::Artifact::Colorpicker, + Hbc::Artifact::Pkg, + Hbc::Artifact::Prefpane, + Hbc::Artifact::Qlplugin, + Hbc::Artifact::Font, + Hbc::Artifact::Widget, + Hbc::Artifact::Service, + Hbc::Artifact::StageOnly, + Hbc::Artifact::Binary, + Hbc::Artifact::InputMethod, + Hbc::Artifact::InternetPlugin, + Hbc::Artifact::ScreenSaver, + Hbc::Artifact::Uninstall, + Hbc::Artifact::PostflightBlock, + Hbc::Artifact::Zap, + ] + end + + def self.for_cask(cask) + odebug "Determining which artifacts are present in Cask #{cask}" + artifacts.select do |artifact| + odebug "Checking for artifact class #{artifact}" + artifact.me?(cask) + end + end +end diff --git a/lib/hbc/artifact/app.rb b/lib/hbc/artifact/app.rb new file mode 100644 index 0000000000..9bb6a02371 --- /dev/null +++ b/lib/hbc/artifact/app.rb @@ -0,0 +1,2 @@ +class Hbc::Artifact::App < Hbc::Artifact::Symlinked +end diff --git a/lib/cask/artifact/artifact.rb b/lib/hbc/artifact/artifact.rb similarity index 66% rename from lib/cask/artifact/artifact.rb rename to lib/hbc/artifact/artifact.rb index 40d2c2225b..086fbfa0cc 100644 --- a/lib/cask/artifact/artifact.rb +++ b/lib/hbc/artifact/artifact.rb @@ -1,4 +1,4 @@ -class Cask::Artifact::Artifact < Cask::Artifact::Symlinked +class Hbc::Artifact::Artifact < Hbc::Artifact::Symlinked def self.artifact_english_name 'Generic artifact' end diff --git a/lib/cask/artifact/base.rb b/lib/hbc/artifact/base.rb similarity index 96% rename from lib/cask/artifact/base.rb rename to lib/hbc/artifact/base.rb index f0a2566417..b9beab8be9 100644 --- a/lib/cask/artifact/base.rb +++ b/lib/hbc/artifact/base.rb @@ -1,4 +1,4 @@ -class Cask::Artifact::Base +class Hbc::Artifact::Base def self.artifact_name @artifact_name ||= self.name.sub(%r{^.*:}, '').gsub(%r{(.)([A-Z])}, '\1_\2').downcase @@ -76,7 +76,7 @@ class Cask::Artifact::Base {} end - def initialize(cask, command=Cask::SystemCommand) + def initialize(cask, command=Hbc::SystemCommand) @cask = cask @command = command end diff --git a/lib/hbc/artifact/binary.rb b/lib/hbc/artifact/binary.rb new file mode 100644 index 0000000000..babc0117a1 --- /dev/null +++ b/lib/hbc/artifact/binary.rb @@ -0,0 +1,5 @@ +class Hbc::Artifact::Binary < Hbc::Artifact::Symlinked + def install_phase + super unless Hbc.no_binaries + end +end diff --git a/lib/hbc/artifact/colorpicker.rb b/lib/hbc/artifact/colorpicker.rb new file mode 100644 index 0000000000..0f432e9c21 --- /dev/null +++ b/lib/hbc/artifact/colorpicker.rb @@ -0,0 +1,2 @@ +class Hbc::Artifact::Colorpicker < Hbc::Artifact::Symlinked +end diff --git a/lib/hbc/artifact/font.rb b/lib/hbc/artifact/font.rb new file mode 100644 index 0000000000..5ed7beb2e0 --- /dev/null +++ b/lib/hbc/artifact/font.rb @@ -0,0 +1,2 @@ +class Hbc::Artifact::Font < Hbc::Artifact::Hardlinked +end diff --git a/lib/cask/artifact/hardlinked.rb b/lib/hbc/artifact/hardlinked.rb similarity index 90% rename from lib/cask/artifact/hardlinked.rb rename to lib/hbc/artifact/hardlinked.rb index 09aeb4e261..8b96c55442 100644 --- a/lib/cask/artifact/hardlinked.rb +++ b/lib/hbc/artifact/hardlinked.rb @@ -1,4 +1,4 @@ -class Cask::Artifact::Hardlinked < Cask::Artifact::Symlinked +class Hbc::Artifact::Hardlinked < Hbc::Artifact::Symlinked def self.islink?(path) return false unless path.respond_to?(:stat) path.stat.nlink > 1 diff --git a/lib/hbc/artifact/input_method.rb b/lib/hbc/artifact/input_method.rb new file mode 100644 index 0000000000..f4e1185d7a --- /dev/null +++ b/lib/hbc/artifact/input_method.rb @@ -0,0 +1,2 @@ +class Hbc::Artifact::InputMethod < Hbc::Artifact::Symlinked +end diff --git a/lib/cask/artifact/installer.rb b/lib/hbc/artifact/installer.rb similarity index 88% rename from lib/cask/artifact/installer.rb rename to lib/hbc/artifact/installer.rb index d486d8f69b..522cc9d9d7 100644 --- a/lib/cask/artifact/installer.rb +++ b/lib/hbc/artifact/installer.rb @@ -1,4 +1,4 @@ -class Cask::Artifact::Installer < Cask::Artifact::Base +class Hbc::Artifact::Installer < Hbc::Artifact::Base # todo: for backward compatibility, removeme def install @@ -28,7 +28,7 @@ class Cask::Artifact::Installer < Cask::Artifact::Base {:print_stdout => true} ) ohai "Running #{self.class.artifact_dsl_key} script #{executable}" - raise CaskInvalidError.new(@cask, "#{self.class.artifact_dsl_key} missing executable") if executable.nil? + raise Hbc::CaskInvalidError.new(@cask, "#{self.class.artifact_dsl_key} missing executable") if executable.nil? @command.run(@cask.staged_path.join(executable), script_arguments) end end diff --git a/lib/hbc/artifact/internet_plugin.rb b/lib/hbc/artifact/internet_plugin.rb new file mode 100644 index 0000000000..cc8f810aaf --- /dev/null +++ b/lib/hbc/artifact/internet_plugin.rb @@ -0,0 +1,3 @@ +class Hbc::Artifact::InternetPlugin < Hbc::Artifact::Symlinked + +end diff --git a/lib/cask/artifact/nested_container.rb b/lib/hbc/artifact/nested_container.rb similarity index 68% rename from lib/cask/artifact/nested_container.rb rename to lib/hbc/artifact/nested_container.rb index 8f16f2f2af..c1464ff3b9 100644 --- a/lib/cask/artifact/nested_container.rb +++ b/lib/hbc/artifact/nested_container.rb @@ -1,4 +1,4 @@ -class Cask::Artifact::NestedContainer < Cask::Artifact::Base +class Hbc::Artifact::NestedContainer < Hbc::Artifact::Base def install_phase @cask.artifacts[:nested_container].each { |container| extract(container) } end @@ -9,9 +9,9 @@ class Cask::Artifact::NestedContainer < Cask::Artifact::Base def extract(container_relative_path) source = @cask.staged_path.join(container_relative_path) - container = Cask::Container.for_path(source, @command) + container = Hbc::Container.for_path(source, @command) unless container - raise CaskError.new "Aw dang, could not identify nested container at '#{source}'" + raise Hbc::CaskError.new "Aw dang, could not identify nested container at '#{source}'" end ohai "Extracting nested container #{source.basename}" container.new(@cask, source, @command).extract diff --git a/lib/cask/artifact/pkg.rb b/lib/hbc/artifact/pkg.rb similarity index 86% rename from lib/cask/artifact/pkg.rb rename to lib/hbc/artifact/pkg.rb index 659a347f8e..778f191104 100644 --- a/lib/cask/artifact/pkg.rb +++ b/lib/hbc/artifact/pkg.rb @@ -1,4 +1,4 @@ -class Cask::Artifact::Pkg < Cask::Artifact::Base +class Hbc::Artifact::Pkg < Hbc::Artifact::Base def self.artifact_dsl_key :pkg end @@ -14,7 +14,7 @@ class Cask::Artifact::Pkg < Cask::Artifact::Base end raise if pkg_description.nil? rescue StandardError => e - raise CaskInvalidError.new(@cask, 'Bad pkg stanza') + raise Hbc::CaskInvalidError.new(@cask, 'Bad pkg stanza') end end @@ -40,13 +40,13 @@ class Cask::Artifact::Pkg < Cask::Artifact::Base ohai "Package installers may write to any location; options such as --appdir are ignored." source = @cask.staged_path.join(pkg_relative_path) unless source.exist? - raise CaskError.new "pkg source file not found: '#{source}'" + raise Hbc::CaskError.new "pkg source file not found: '#{source}'" end args = [ '-pkg', source, '-target', '/' ] - args << '-verboseR' if Cask.verbose + args << '-verboseR' if Hbc.verbose args << '-allowUntrusted' if pkg_install_opts :allow_untrusted @command.run!('/usr/sbin/installer', {:sudo => true, :args => args, :print_stdout => true}) end diff --git a/lib/cask/artifact/postflight_block.rb b/lib/hbc/artifact/postflight_block.rb similarity index 61% rename from lib/cask/artifact/postflight_block.rb rename to lib/hbc/artifact/postflight_block.rb index 0567bb31b2..1d88ffda32 100644 --- a/lib/cask/artifact/postflight_block.rb +++ b/lib/hbc/artifact/postflight_block.rb @@ -1,4 +1,4 @@ -class Cask::Artifact::PostflightBlock < Cask::Artifact::Base +class Hbc::Artifact::PostflightBlock < Hbc::Artifact::Base def self.me?(cask) cask.artifacts[:postflight].any? || cask.artifacts[:uninstall_postflight].any? @@ -6,13 +6,13 @@ class Cask::Artifact::PostflightBlock < Cask::Artifact::Base def install_phase @cask.artifacts[:postflight].each do |block| - Cask::DSL::Postflight.new(@cask).instance_eval &block + Hbc::DSL::Postflight.new(@cask).instance_eval &block end end def uninstall_phase @cask.artifacts[:uninstall_postflight].each do |block| - Cask::DSL::UninstallPostflight.new(@cask).instance_eval &block + Hbc::DSL::UninstallPostflight.new(@cask).instance_eval &block end end end diff --git a/lib/cask/artifact/preflight_block.rb b/lib/hbc/artifact/preflight_block.rb similarity index 61% rename from lib/cask/artifact/preflight_block.rb rename to lib/hbc/artifact/preflight_block.rb index a09ea4499e..9ff65ea2c8 100644 --- a/lib/cask/artifact/preflight_block.rb +++ b/lib/hbc/artifact/preflight_block.rb @@ -1,4 +1,4 @@ -class Cask::Artifact::PreflightBlock < Cask::Artifact::Base +class Hbc::Artifact::PreflightBlock < Hbc::Artifact::Base def self.me?(cask) cask.artifacts[:preflight].any? || cask.artifacts[:uninstall_preflight].any? @@ -6,13 +6,13 @@ class Cask::Artifact::PreflightBlock < Cask::Artifact::Base def install_phase @cask.artifacts[:preflight].each do |block| - Cask::DSL::Preflight.new(@cask).instance_eval &block + Hbc::DSL::Preflight.new(@cask).instance_eval &block end end def uninstall_phase @cask.artifacts[:uninstall_preflight].each do |block| - Cask::DSL::UninstallPreflight.new(@cask).instance_eval &block + Hbc::DSL::UninstallPreflight.new(@cask).instance_eval &block end end end diff --git a/lib/cask/artifact/prefpane.rb b/lib/hbc/artifact/prefpane.rb similarity index 52% rename from lib/cask/artifact/prefpane.rb rename to lib/hbc/artifact/prefpane.rb index 757df86e0d..9ad2527c35 100644 --- a/lib/cask/artifact/prefpane.rb +++ b/lib/hbc/artifact/prefpane.rb @@ -1,4 +1,4 @@ -class Cask::Artifact::Prefpane < Cask::Artifact::Symlinked +class Hbc::Artifact::Prefpane < Hbc::Artifact::Symlinked def self.artifact_english_name 'Preference Pane' end diff --git a/lib/cask/artifact/qlplugin.rb b/lib/hbc/artifact/qlplugin.rb similarity index 82% rename from lib/cask/artifact/qlplugin.rb rename to lib/hbc/artifact/qlplugin.rb index e8f13892da..a146184766 100644 --- a/lib/cask/artifact/qlplugin.rb +++ b/lib/hbc/artifact/qlplugin.rb @@ -1,4 +1,4 @@ -class Cask::Artifact::Qlplugin < Cask::Artifact::Symlinked +class Hbc::Artifact::Qlplugin < Hbc::Artifact::Symlinked def self.artifact_english_name 'QuickLook Plugin' end diff --git a/lib/hbc/artifact/screen_saver.rb b/lib/hbc/artifact/screen_saver.rb new file mode 100644 index 0000000000..0c37bc5c53 --- /dev/null +++ b/lib/hbc/artifact/screen_saver.rb @@ -0,0 +1,3 @@ +class Hbc::Artifact::ScreenSaver < Hbc::Artifact::Symlinked + +end diff --git a/lib/hbc/artifact/service.rb b/lib/hbc/artifact/service.rb new file mode 100644 index 0000000000..5240f5df5b --- /dev/null +++ b/lib/hbc/artifact/service.rb @@ -0,0 +1,2 @@ +class Hbc::Artifact::Service < Hbc::Artifact::Symlinked +end diff --git a/lib/cask/artifact/stage_only.rb b/lib/hbc/artifact/stage_only.rb similarity index 72% rename from lib/cask/artifact/stage_only.rb rename to lib/hbc/artifact/stage_only.rb index b1f0d6a0a8..de16090f39 100644 --- a/lib/cask/artifact/stage_only.rb +++ b/lib/hbc/artifact/stage_only.rb @@ -1,4 +1,4 @@ -class Cask::Artifact::StageOnly < Cask::Artifact::Base +class Hbc::Artifact::StageOnly < Hbc::Artifact::Base def self.artifact_dsl_key :stage_only end diff --git a/lib/cask/artifact/suite.rb b/lib/hbc/artifact/suite.rb similarity index 65% rename from lib/cask/artifact/suite.rb rename to lib/hbc/artifact/suite.rb index 36cd53dbcd..26959d7059 100644 --- a/lib/cask/artifact/suite.rb +++ b/lib/hbc/artifact/suite.rb @@ -1,4 +1,4 @@ -class Cask::Artifact::Suite < Cask::Artifact::Symlinked +class Hbc::Artifact::Suite < Hbc::Artifact::Symlinked def self.artifact_english_name 'App Suite' end diff --git a/lib/cask/artifact/symlinked.rb b/lib/hbc/artifact/symlinked.rb similarity index 88% rename from lib/cask/artifact/symlinked.rb rename to lib/hbc/artifact/symlinked.rb index 04d46a4656..bcaa1a334f 100644 --- a/lib/cask/artifact/symlinked.rb +++ b/lib/hbc/artifact/symlinked.rb @@ -1,4 +1,4 @@ -class Cask::Artifact::Symlinked < Cask::Artifact::Base +class Hbc::Artifact::Symlinked < Hbc::Artifact::Base def self.islink?(path) path.symlink? end @@ -46,14 +46,14 @@ class Cask::Artifact::Symlinked < Cask::Artifact::Base def load_specification(artifact_spec) source_string, target_hash = artifact_spec - raise CaskInvalidError if source_string.nil? + raise Hbc::CaskInvalidError if source_string.nil? @source = @cask.staged_path.join(source_string) if target_hash - raise CaskInvalidError unless target_hash.respond_to?(:keys) + raise Hbc::CaskInvalidError unless target_hash.respond_to?(:keys) target_hash.assert_valid_keys(:target) - @target = Cask.send(self.class.artifact_dirmethod).join(target_hash[:target]) + @target = Hbc.send(self.class.artifact_dirmethod).join(target_hash[:target]) else - @target = Cask.send(self.class.artifact_dirmethod).join(source.basename) + @target = Hbc.send(self.class.artifact_dirmethod).join(source.basename) end end @@ -98,7 +98,7 @@ class Cask::Artifact::Symlinked < Cask::Artifact::Base return false end unless source.exist? - raise CaskError.new "It seems the #{self.class.link_type_english_name.downcase} source is not there: '#{source}'" + raise Hbc::CaskError.new "It seems the #{self.class.link_type_english_name.downcase} source is not there: '#{source}'" end true end diff --git a/lib/hbc/artifact/uninstall.rb b/lib/hbc/artifact/uninstall.rb new file mode 100644 index 0000000000..89cea43b88 --- /dev/null +++ b/lib/hbc/artifact/uninstall.rb @@ -0,0 +1,2 @@ +class Hbc::Artifact::Uninstall < Hbc::Artifact::UninstallBase +end diff --git a/lib/cask/artifact/uninstall_base.rb b/lib/hbc/artifact/uninstall_base.rb similarity index 97% rename from lib/cask/artifact/uninstall_base.rb rename to lib/hbc/artifact/uninstall_base.rb index b5e76f9a1e..62473b0392 100644 --- a/lib/cask/artifact/uninstall_base.rb +++ b/lib/hbc/artifact/uninstall_base.rb @@ -1,6 +1,6 @@ require 'set' -class Cask::Artifact::UninstallBase < Cask::Artifact::Base +class Hbc::Artifact::UninstallBase < Hbc::Artifact::Base # todo: 500 is also hardcoded in cask/pkg.rb, but much of # that logic is probably in the wrong location @@ -198,7 +198,7 @@ class Cask::Artifact::UninstallBase < Cask::Artifact::Base :early_script) ohai "Running uninstall script #{executable}" - raise CaskInvalidError.new(@cask, "#{stanza} :early_script without :executable") if executable.nil? + raise Hbc::CaskInvalidError.new(@cask, "#{stanza} :early_script without :executable") if executable.nil? @command.run(@cask.staged_path.join(executable), script_arguments) sleep 1 end @@ -234,7 +234,7 @@ class Cask::Artifact::UninstallBase < Cask::Artifact::Base # :signal should come after :quit so it can be used as a backup when :quit fails directives_set.select{ |h| h.key?(:signal) }.each do |directives| Array(directives[:signal]).flatten.each_slice(2) do |pair| - raise CaskInvalidError.new(@cask, "Each #{stanza} :signal must have 2 elements.") unless pair.length == 2 + raise Hbc::CaskInvalidError.new(@cask, "Each #{stanza} :signal must have 2 elements.") unless pair.length == 2 signal, id = pair ohai "Signalling '#{signal}' to application ID '#{id}'" pid_string = @command.run!('/usr/bin/osascript', :args => ['-e', %Q{tell application "System Events" to get the unix id of every process whose bundle identifier is "#{id}"}], :sudo => true).stdout @@ -274,7 +274,7 @@ class Cask::Artifact::UninstallBase < Cask::Artifact::Base {:must_succeed => true}, {:sudo => true, :print_stdout => true}, :script) - raise CaskInvalidError.new(@cask, "#{stanza} :script without :executable.") if executable.nil? + raise Hbc::CaskInvalidError.new(@cask, "#{stanza} :script without :executable.") if executable.nil? @command.run(@cask.staged_path.join(executable), script_arguments) sleep 1 end @@ -282,7 +282,7 @@ class Cask::Artifact::UninstallBase < Cask::Artifact::Base directives_set.select{ |h| h.key?(:pkgutil) }.each do |directives| ohai "Removing files from pkgutil Bill-of-Materials" Array(directives[:pkgutil]).each do |regexp| - pkgs = Cask::Pkg.all_matching(regexp, @command) + pkgs = Hbc::Pkg.all_matching(regexp, @command) pkgs.each(&:uninstall) end end diff --git a/lib/hbc/artifact/widget.rb b/lib/hbc/artifact/widget.rb new file mode 100644 index 0000000000..00325fb66c --- /dev/null +++ b/lib/hbc/artifact/widget.rb @@ -0,0 +1,2 @@ +class Hbc::Artifact::Widget < Hbc::Artifact::Symlinked +end diff --git a/lib/cask/artifact/zap.rb b/lib/hbc/artifact/zap.rb similarity index 84% rename from lib/cask/artifact/zap.rb rename to lib/hbc/artifact/zap.rb index c07a24f5e2..c7b9611cb0 100644 --- a/lib/cask/artifact/zap.rb +++ b/lib/hbc/artifact/zap.rb @@ -1,4 +1,4 @@ -class Cask::Artifact::Zap < Cask::Artifact::UninstallBase +class Hbc::Artifact::Zap < Hbc::Artifact::UninstallBase def install_phase odebug "Nothing to do. The zap artifact has no install phase." end diff --git a/lib/cask/audit.rb b/lib/hbc/audit.rb similarity index 96% rename from lib/cask/audit.rb rename to lib/hbc/audit.rb index 539a4a435e..ab73ff9fe3 100644 --- a/lib/cask/audit.rb +++ b/lib/hbc/audit.rb @@ -1,10 +1,10 @@ -require 'cask/checkable' -require 'cask/download' +require 'hbc/checkable' +require 'hbc/download' -class Cask::Audit +class Hbc::Audit attr_reader :cask - include Cask::Checkable + include Hbc::Checkable def initialize(cask) @cask = cask diff --git a/lib/cask/auditor.rb b/lib/hbc/auditor.rb similarity index 63% rename from lib/cask/auditor.rb rename to lib/hbc/auditor.rb index a90ed631f0..ac9620f53a 100644 --- a/lib/cask/auditor.rb +++ b/lib/hbc/auditor.rb @@ -1,9 +1,9 @@ -class Cask::Auditor +class Hbc::Auditor def self.audit(cask, options = {}) - audit = Cask::Audit.new(cask) + audit = Hbc::Audit.new(cask) retval = if options.fetch(:audit_download, false) - audit.run!(Cask::Download.new(cask)) + audit.run!(Hbc::Download.new(cask)) else audit.run! end diff --git a/lib/cask/cask_dependencies.rb b/lib/hbc/cask_dependencies.rb similarity index 73% rename from lib/cask/cask_dependencies.rb rename to lib/hbc/cask_dependencies.rb index 6e3f4d13d1..d311f75971 100644 --- a/lib/cask/cask_dependencies.rb +++ b/lib/hbc/cask_dependencies.rb @@ -1,6 +1,6 @@ -require 'cask/topological_hash' +require 'hbc/topological_hash' -class Cask::CaskDependencies +class Hbc::CaskDependencies attr_reader :cask, :graph, :sorted def initialize(cask) @@ -14,7 +14,7 @@ class Cask::CaskDependencies walk = lambda do |acc, deps| deps.each do |dep| unless acc.key?(dep) - succs = deps_in.call Cask.load(dep) + succs = deps_in.call Hbc.load(dep) acc[dep] = succs walk.call(acc, succs) end @@ -23,14 +23,14 @@ class Cask::CaskDependencies end graphed = walk.call({}, @cask.depends_on.cask) - TopologicalHash[graphed] + Hbc::TopologicalHash[graphed] end def sort begin sorted = @graph.tsort rescue TSort::Cyclic - raise CaskCyclicCaskDependencyError.new(@cask.token) + raise Hbc::CaskCyclicCaskDependencyError.new(@cask.token) end end end diff --git a/lib/cask/caveats.rb b/lib/hbc/caveats.rb similarity index 93% rename from lib/cask/caveats.rb rename to lib/hbc/caveats.rb index 110a9ced38..5495b40e3a 100644 --- a/lib/cask/caveats.rb +++ b/lib/hbc/caveats.rb @@ -1,14 +1,14 @@ -class Cask::Caveats +class Hbc::Caveats def initialize(block) @block = block end def eval_and_print(cask) - Cask::CaveatsDSL.new(cask, @block) + Hbc::CaveatsDSL.new(cask, @block) end end -class Cask::CaveatsDSL +class Hbc::CaveatsDSL # constructor; implicitly renders caveat text by evaluating # block in the context of the DSL def initialize(cask, block) @@ -93,7 +93,7 @@ class Cask::CaveatsDSL end def method_missing(method, *args) - Cask::Utils.method_missing_message(method, @cask.to_s, 'caveats') + Hbc::Utils.method_missing_message(method, @cask.to_s, 'caveats') return nil end end diff --git a/lib/cask/checkable.rb b/lib/hbc/checkable.rb similarity index 97% rename from lib/cask/checkable.rb rename to lib/hbc/checkable.rb index 481b62f629..e174a0de0b 100644 --- a/lib/cask/checkable.rb +++ b/lib/hbc/checkable.rb @@ -1,4 +1,4 @@ -module Cask::Checkable +module Hbc::Checkable def errors Array(@errors) end diff --git a/lib/cask/cli.rb b/lib/hbc/cli.rb similarity index 73% rename from lib/cask/cli.rb rename to lib/hbc/cli.rb index 98113685a3..7b870e297a 100644 --- a/lib/cask/cli.rb +++ b/lib/hbc/cli.rb @@ -1,33 +1,33 @@ -class Cask::CLI; end +class Hbc::CLI; end require 'optparse' require 'shellwords' -require 'cask/cli/base' -require 'cask/cli/alfred' -require 'cask/cli/audit' -require 'cask/cli/cat' -require 'cask/cli/cleanup' -require 'cask/cli/create' -require 'cask/cli/doctor' -require 'cask/cli/edit' -require 'cask/cli/fetch' -require 'cask/cli/home' -require 'cask/cli/info' -require 'cask/cli/install' -require 'cask/cli/list' -require 'cask/cli/search' -require 'cask/cli/uninstall' -require 'cask/cli/update' -require 'cask/cli/zap' +require 'hbc/cli/base' +require 'hbc/cli/alfred' +require 'hbc/cli/audit' +require 'hbc/cli/cat' +require 'hbc/cli/cleanup' +require 'hbc/cli/create' +require 'hbc/cli/doctor' +require 'hbc/cli/edit' +require 'hbc/cli/fetch' +require 'hbc/cli/home' +require 'hbc/cli/info' +require 'hbc/cli/install' +require 'hbc/cli/list' +require 'hbc/cli/search' +require 'hbc/cli/uninstall' +require 'hbc/cli/update' +require 'hbc/cli/zap' -require 'cask/cli/internal_use_base' -require 'cask/cli/internal_checkurl' -require 'cask/cli/internal_dump' -require 'cask/cli/internal_help' -require 'cask/cli/internal_stanza' +require 'hbc/cli/internal_use_base' +require 'hbc/cli/internal_checkurl' +require 'hbc/cli/internal_dump' +require 'hbc/cli/internal_help' +require 'hbc/cli/internal_stanza' -class Cask::CLI +class Hbc::CLI ALIASES = { 'ls' => 'list', @@ -48,8 +48,8 @@ class Cask::CLI } def self.command_classes - @@command_classes ||= Cask::CLI.constants. - map { |sym| Cask::CLI.const_get sym }. + @@command_classes ||= Hbc::CLI.constants. + map { |sym| Hbc::CLI.const_get sym }. select { |sym| sym.respond_to?(:run) } end @@ -77,7 +77,7 @@ class Cask::CLI if command.respond_to?(:run) # usual case: built-in command verb command.run(*rest) - elsif require? Cask::Utils.which("brewcask-#{command}.rb").to_s + elsif require? Hbc::Utils.which("brewcask-#{command}.rb").to_s # external command as Ruby library on PATH, Homebrew-style exit 0 elsif command.to_s.include?('/') and require? command.to_s @@ -85,7 +85,7 @@ class Cask::CLI # for development and troubleshooting sym = Pathname.new(command.to_s).basename('.rb').to_s.capitalize klass = begin - Cask::CLI.const_get(sym) + Hbc::CLI.const_get(sym) rescue NameError => e nil end @@ -96,7 +96,7 @@ class Cask::CLI # other Ruby libraries must do everything via "require" exit 0 end - elsif Cask::Utils.which "brewcask-#{command}" + elsif Hbc::Utils.which "brewcask-#{command}" # arbitrary external executable on PATH, Homebrew-style exec "brewcask-#{command}", *ARGV[1..-1] elsif Pathname.new(command.to_s).executable? and @@ -107,23 +107,23 @@ class Cask::CLI exec command, *ARGV[1..-1] else # failure - Cask::CLI::NullCommand.new(command).run + Hbc::CLI::NullCommand.new(command).run end end def self.process(arguments) command_string, *rest = *arguments rest = process_options(rest) - Cask.init + Hbc.init command = lookup_command(command_string) run_command(command, *rest) - rescue CaskError, CaskSha256MismatchError => e + rescue Hbc::CaskError, Hbc::CaskSha256MismatchError => e onoe e - $stderr.puts e.backtrace if Cask.debug + $stderr.puts e.backtrace if Hbc.debug exit 1 rescue StandardError, ScriptError, NoMemoryError => e onoe e - puts Cask::Utils.error_message_with_suggestions + puts Hbc::Utils.error_message_with_suggestions puts e.backtrace exit 1 end @@ -151,53 +151,53 @@ class Cask::CLI # If you modify these arguments, please update USAGE.md @parser ||= OptionParser.new do |opts| opts.on("--caskroom=MANDATORY") do |v| - Cask.caskroom = Pathname(v).expand_path + Hbc.caskroom = Pathname(v).expand_path end opts.on("--appdir=MANDATORY") do |v| - Cask.appdir = Pathname(v).expand_path + Hbc.appdir = Pathname(v).expand_path end opts.on("--colorpickerdir=MANDATORY") do |v| - Cask.colorpickerdir = Pathname(v).expand_path + Hbc.colorpickerdir = Pathname(v).expand_path end opts.on("--prefpanedir=MANDATORY") do |v| - Cask.prefpanedir = Pathname(v).expand_path + Hbc.prefpanedir = Pathname(v).expand_path end opts.on("--qlplugindir=MANDATORY") do |v| - Cask.qlplugindir = Pathname(v).expand_path + Hbc.qlplugindir = Pathname(v).expand_path end opts.on("--fontdir=MANDATORY") do |v| - Cask.fontdir = Pathname(v).expand_path + Hbc.fontdir = Pathname(v).expand_path end opts.on("--widgetdir=MANDATORY") do |v| - Cask.widgetdir = Pathname(v).expand_path + Hbc.widgetdir = Pathname(v).expand_path end opts.on("--servicedir=MANDATORY") do |v| - Cask.servicedir = Pathname(v).expand_path + Hbc.servicedir = Pathname(v).expand_path end opts.on("--binarydir=MANDATORY") do |v| - Cask.binarydir = Pathname(v).expand_path + Hbc.binarydir = Pathname(v).expand_path end opts.on("--input_methoddir=MANDATORY") do |v| - Cask.input_methoddir = Pathname(v).expand_path + Hbc.input_methoddir = Pathname(v).expand_path end opts.on("--internet_plugindir=MANDATORY") do |v| - Cask.internet_plugindir = Pathname(v).expand_path + Hbc.internet_plugindir = Pathname(v).expand_path end opts.on("--screen_saverdir=MANDATORY") do |v| - Cask.screen_saverdir = Pathname(v).expand_path + Hbc.screen_saverdir = Pathname(v).expand_path end opts.on("--no-binaries") do |v| - Cask.no_binaries = true + Hbc.no_binaries = true end opts.on("--debug") do |v| - Cask.debug = true + Hbc.debug = true end opts.on("--verbose") do |v| - Cask.verbose = true + Hbc.verbose = true end opts.on("--outdated") do |v| - Cask.outdated = true + Hbc.outdated = true end end end @@ -213,15 +213,15 @@ class Cask::CLI remaining << head retry rescue OptionParser::MissingArgument - raise CaskError.new("The option '#{head}' requires an argument") + raise Hbc::CaskError.new("The option '#{head}' requires an argument") rescue OptionParser::AmbiguousOption - raise CaskError.new( + raise Hbc::CaskError.new( "There is more than one possible option that starts with '#{head}'") end end # for compat with Homebrew, not certain if this is desirable - Cask.verbose = true if !ENV['VERBOSE'].nil? or !ENV['HOMEBREW_VERBOSE'].nil? + Hbc.verbose = true if !ENV['VERBOSE'].nil? or !ENV['HOMEBREW_VERBOSE'].nil? remaining end @@ -233,7 +233,7 @@ class Cask::CLI def run(*args) if args.include?('--version') or @attempted_verb == '--version' - puts HOMEBREW_CASK_VERSION + puts HBC_VERSION else purpose if @attempted_verb and @attempted_verb != "help" @@ -254,10 +254,10 @@ class Cask::CLI end def usage - max_command_len = Cask::CLI.commands.map(&:length).max + max_command_len = Hbc::CLI.commands.map(&:length).max puts "Commands:\n\n" - Cask::CLI.command_classes.each do |klass| + Hbc::CLI.command_classes.each do |klass| next unless klass.visible puts " #{klass.command_name.ljust(max_command_len)} #{_help_for(klass)}" end diff --git a/lib/cask/cli/alfred.rb b/lib/hbc/cli/alfred.rb similarity index 92% rename from lib/cask/cli/alfred.rb rename to lib/hbc/cli/alfred.rb index d53591e855..0298221fda 100644 --- a/lib/cask/cli/alfred.rb +++ b/lib/hbc/cli/alfred.rb @@ -1,6 +1,6 @@ require 'rubygems' -class Cask::CLI::Alfred < Cask::CLI::Base +class Hbc::CLI::Alfred < Hbc::CLI::Base DEFAULT_SCOPES = [ '/Applications', '/Applications/Xcode.app/Contents/Applications', @@ -26,7 +26,7 @@ class Cask::CLI::Alfred < Cask::CLI::Base if args.length > 1 && args.last.is_a?(Class) @system_command = args.last else - @system_command = Cask::SystemCommand + @system_command = Hbc::SystemCommand end case subcommand @@ -47,7 +47,7 @@ class Cask::CLI::Alfred < Cask::CLI::Base opoo "Could not find Alfred 2 preferences. Alfred 2 is probably not installed." end if alfred_localprefs? and localprefs_scopes_files.size < 1 - raise CaskError.new "Alfred 2.4+ detected, but local preferences file not found. Try running Alfred first." + raise Hbc::CaskError.new "Alfred 2.4+ detected, but local preferences file not found. Try running Alfred first." end alfred_2_installed? end @@ -59,7 +59,7 @@ class Cask::CLI::Alfred < Cask::CLI::Base opoo "Alfred appears to be already linked. Updating defaults anyway." end odebug 'Linking Alfred scopes' - save_alfred_scopes(linked? ? alfred_scopes : alfred_scopes + [ Cask.caskroom.to_s ]) + save_alfred_scopes(linked? ? alfred_scopes : alfred_scopes + [ Hbc.caskroom.to_s ]) ohai "Successfully linked Alfred to homebrew-cask." end @@ -70,7 +70,7 @@ class Cask::CLI::Alfred < Cask::CLI::Base opoo "Alfred appears to be already unlinked. Updating defaults anyway." end odebug 'Unlinking Alfred scopes' - save_alfred_scopes(alfred_scopes.reject { |x| x == Cask.caskroom.to_s }) + save_alfred_scopes(alfred_scopes.reject { |x| x == Hbc.caskroom.to_s }) ohai "Successfully unlinked Alfred from homebrew-cask." end @@ -95,7 +95,7 @@ class Cask::CLI::Alfred < Cask::CLI::Base begin # reset the version every time when running under the test harness # todo: I don't know the right way to detect that; using const_get - Cask.const_get(:FakeSystemCommand) + Hbc.const_get(:FakeSystemCommand) @alfred_version = nil rescue StandardError => e end @@ -117,7 +117,7 @@ class Cask::CLI::Alfred < Cask::CLI::Base end def self.linked? - alfred_scopes.include?(Cask.caskroom.to_s) + alfred_scopes.include?(Hbc.caskroom.to_s) end # output looks like this: @@ -163,7 +163,7 @@ class Cask::CLI::Alfred < Cask::CLI::Base def self.alfred_file_preference(files, key, value=nil) unless files and files.length > 0 - raise CaskError.new "Required 'files' argument empty" + raise Hbc::CaskError.new "Required 'files' argument empty" end Array(files).map do |file| if value diff --git a/lib/cask/cli/audit.rb b/lib/hbc/cli/audit.rb similarity index 75% rename from lib/cask/cli/audit.rb rename to lib/hbc/cli/audit.rb index 31f57b223f..63adf62e1e 100644 --- a/lib/cask/cli/audit.rb +++ b/lib/hbc/cli/audit.rb @@ -1,15 +1,15 @@ -class Cask::CLI::Audit < Cask::CLI::Base +class Hbc::CLI::Audit < Hbc::CLI::Base def self.help 'verifies installability of Casks' end def self.run(*args) - retval = new(args, Cask::Auditor).run + retval = new(args, Hbc::Auditor).run # retval is ternary: true/false/nil if retval.nil? - raise CaskError.new("audit failed") + raise Hbc::CaskError.new("audit failed") elsif ! retval - raise CaskError.new("some audits failed") + raise Hbc::CaskError.new("some audits failed") end end @@ -37,9 +37,9 @@ class Cask::CLI::Audit < Cask::CLI::Base def casks_to_audit if cask_tokens.empty? - Cask.all + Hbc.all else - cask_tokens.map { |token| Cask.load(token) } + cask_tokens.map { |token| Hbc.load(token) } end end diff --git a/lib/cask/cli/base.rb b/lib/hbc/cli/base.rb similarity index 93% rename from lib/cask/cli/base.rb rename to lib/hbc/cli/base.rb index b0856d8e00..e44ae3af64 100644 --- a/lib/cask/cli/base.rb +++ b/lib/hbc/cli/base.rb @@ -1,4 +1,4 @@ -class Cask::CLI::Base +class Hbc::CLI::Base def self.command_name @command_name ||= self.name.sub(%r{^.*:}, '').gsub(%r{(.)([A-Z])}, '\1_\2').downcase end diff --git a/lib/cask/cli/cat.rb b/lib/hbc/cli/cat.rb similarity index 58% rename from lib/cask/cli/cat.rb rename to lib/hbc/cli/cat.rb index eb87f64e89..935984bfed 100644 --- a/lib/cask/cli/cat.rb +++ b/lib/hbc/cli/cat.rb @@ -1,11 +1,11 @@ -class Cask::CLI::Cat < Cask::CLI::Base +class Hbc::CLI::Cat < Hbc::CLI::Base def self.run(*args) cask_tokens = cask_tokens_from(args) - raise CaskUnspecifiedError if cask_tokens.empty? + raise Hbc::CaskUnspecifiedError if cask_tokens.empty? # only respects the first argument cask_token = cask_tokens.first.sub(/\.rb$/i, '') - cask_path = Cask.path(cask_token) - raise CaskUnavailableError, cask_token.to_s unless cask_path.exist? + cask_path = Hbc.path(cask_token) + raise Hbc::CaskUnavailableError, cask_token.to_s unless cask_path.exist? puts File.open(cask_path) { |f| f.read } end diff --git a/lib/cask/cli/cleanup.rb b/lib/hbc/cli/cleanup.rb similarity index 92% rename from lib/cask/cli/cleanup.rb rename to lib/hbc/cli/cleanup.rb index 4e5568758c..588939d2e9 100644 --- a/lib/cask/cli/cleanup.rb +++ b/lib/hbc/cli/cleanup.rb @@ -1,4 +1,4 @@ -class Cask::CLI::Cleanup < Cask::CLI::Base +class Hbc::CLI::Cleanup < Hbc::CLI::Base OUTDATED_DAYS = 10 OUTDATED_TIMESTAMP = Time.now - (60 * 60 * 24 * OUTDATED_DAYS) @@ -66,9 +66,9 @@ class Cask::CLI::Cleanup < Cask::CLI::Base def self.remove_all_cache_files message = "Removing cached downloads" - message.concat " older than #{OUTDATED_DAYS} days old" if Cask.outdated + message.concat " older than #{OUTDATED_DAYS} days old" if Hbc.outdated ohai message - to_delete = all_cache_files(Cask.outdated) + to_delete = all_cache_files(Hbc.outdated) puts "Nothing to do" unless to_delete.count > 0 to_delete.each do |item| puts item diff --git a/lib/cask/cli/create.rb b/lib/hbc/cli/create.rb similarity index 79% rename from lib/cask/cli/create.rb rename to lib/hbc/cli/create.rb index ebc9b2c517..713e030f5b 100644 --- a/lib/cask/cli/create.rb +++ b/lib/hbc/cli/create.rb @@ -1,13 +1,13 @@ -class Cask::CLI::Create < Cask::CLI::Base +class Hbc::CLI::Create < Hbc::CLI::Base def self.run(*args) cask_tokens = cask_tokens_from(args) - raise CaskUnspecifiedError if cask_tokens.empty? + raise Hbc::CaskUnspecifiedError if cask_tokens.empty? cask_token = cask_tokens.first.sub(/\.rb$/i,'') - cask_path = Cask.path(cask_token) + cask_path = Hbc.path(cask_token) odebug "Creating Cask #{cask_token}" if cask_path.exist? - raise CaskAlreadyCreatedError.new cask_token + raise Hbc::CaskAlreadyCreatedError.new cask_token end File.open(cask_path, 'w') do |f| diff --git a/lib/cask/cli/doctor.rb b/lib/hbc/cli/doctor.rb similarity index 93% rename from lib/cask/cli/doctor.rb rename to lib/hbc/cli/doctor.rb index d15ba83417..99bfc28183 100644 --- a/lib/cask/cli/doctor.rb +++ b/lib/hbc/cli/doctor.rb @@ -1,4 +1,4 @@ -class Cask::CLI::Doctor < Cask::CLI::Base +class Hbc::CLI::Doctor < Hbc::CLI::Base def self.run ohai 'OS X Release:', render_with_none_as_error( MACOS_RELEASE ) ohai 'OS X Point Release:', render_with_none_as_error( MACOS_POINT_RELEASE ) @@ -11,9 +11,9 @@ class Cask::CLI::Doctor < Cask::CLI::Base ohai 'Homebrew Cellar Path:', render_with_none_as_error( homebrew_cellar ) ohai 'Homebrew Repository Path:', render_with_none_as_error( homebrew_repository ) ohai 'Homebrew Origin:', render_with_none_as_error( homebrew_origin ) - ohai 'Homebrew-cask Version:', render_with_none_as_error( HOMEBREW_CASK_VERSION ) - ohai 'Homebrew-cask Install Location:', render_install_location( HOMEBREW_CASK_VERSION ) - ohai 'Homebrew-cask Staging Location:', render_staging_location( Cask.caskroom ) + ohai 'Homebrew-cask Version:', render_with_none_as_error( HBC_VERSION ) + ohai 'Homebrew-cask Install Location:', render_install_location( HBC_VERSION ) + ohai 'Homebrew-cask Staging Location:', render_staging_location( Hbc.caskroom ) ohai 'Homebrew-cask Cached Downloads:', render_cached_downloads ohai 'Homebrew-cask Default Tap Path:', render_tap_paths( fq_default_tap ) ohai 'Homebrew-cask Alternate Cask Taps:', render_tap_paths( alt_taps ) @@ -37,7 +37,7 @@ class Cask::CLI::Doctor < Cask::CLI::Base return @fq_default_tap if @fq_default_tap @fq_default_tap = notfound_string begin - @fq_default_tap = homebrew_repository.join 'Library', 'Taps', Cask.default_tap + @fq_default_tap = homebrew_repository.join 'Library', 'Taps', Hbc.default_tap rescue StandardError; end @fq_default_tap end @@ -66,7 +66,7 @@ class Cask::CLI::Doctor < Cask::CLI::Base homebrew_origin = notfound_string begin Dir.chdir(homebrew_repository) do - homebrew_origin = Cask::SystemCommand.run('git', + homebrew_origin = Hbc::SystemCommand.run('git', :args => %w{config --get remote.origin.url}, :print_stderr => false).stdout.strip end @@ -104,7 +104,7 @@ class Cask::CLI::Doctor < Cask::CLI::Base return @homebrew_constants[name] if @homebrew_constants.key?(name) @homebrew_constants[name] = notfound_string begin - @homebrew_constants[name] = Cask::SystemCommand.run!(HOMEBREW_BREW_FILE, + @homebrew_constants[name] = Hbc::SystemCommand.run!(HOMEBREW_BREW_FILE, :args => [ "--#{name}" ], :print_stderr => false).stdout.strip if @homebrew_constants[name] !~ %r{\S} @@ -206,20 +206,20 @@ class Cask::CLI::Doctor < Cask::CLI::Base return "#{none_string} #{error_string}" end copy = Array.new(paths) - unless Cask::Utils.file_is_descendant(copy[0], homebrew_cellar) + unless Hbc::Utils.file_is_descendant(copy[0], homebrew_cellar) copy[0] = "#{copy[0]} #{error_string %Q{error: should be descendant of Homebrew Cellar}}" end copy.map! do |elt| - elt = (homebrew_libdir and Cask::Utils.file_is_descendant(elt, homebrew_libdir)) ? + elt = (homebrew_libdir and Hbc::Utils.file_is_descendant(elt, homebrew_libdir)) ? "#{elt} #{error_string %Q{error: should not be descendant of Homebrew Library dir}}" : elt end end def self.render_cached_downloads - files = Cask::CLI::Cleanup.all_cache_files + files = Hbc::CLI::Cleanup.all_cache_files count = files.count - space = Cask::CLI::Cleanup.space_in_megs files + space = Hbc::CLI::Cleanup.space_in_megs files [ HOMEBREW_CACHE, HOMEBREW_CACHE_CASKS, diff --git a/lib/cask/cli/edit.rb b/lib/hbc/cli/edit.rb similarity index 56% rename from lib/cask/cli/edit.rb rename to lib/hbc/cli/edit.rb index b492447220..b0ff82a515 100644 --- a/lib/cask/cli/edit.rb +++ b/lib/hbc/cli/edit.rb @@ -1,13 +1,13 @@ -class Cask::CLI::Edit < Cask::CLI::Base +class Hbc::CLI::Edit < Hbc::CLI::Base def self.run(*args) cask_tokens = cask_tokens_from(args) - raise CaskUnspecifiedError if cask_tokens.empty? + raise Hbc::CaskUnspecifiedError if cask_tokens.empty? # only respects the first argument cask_token = cask_tokens.first.sub(/\.rb$/i, '') - cask_path = Cask.path(cask_token) + cask_path = Hbc.path(cask_token) odebug "Opening editor for Cask #{cask_token}" unless cask_path.exist? - raise CaskUnavailableError, %Q{#{cask_token}, run "brew cask create #{cask_token}" to create a new Cask} + raise Hbc::CaskUnavailableError, %Q{#{cask_token}, run "brew cask create #{cask_token}" to create a new Cask} end exec_editor cask_path end diff --git a/lib/cask/cli/fetch.rb b/lib/hbc/cli/fetch.rb similarity index 63% rename from lib/cask/cli/fetch.rb rename to lib/hbc/cli/fetch.rb index 1207f0ee19..0057e408aa 100644 --- a/lib/cask/cli/fetch.rb +++ b/lib/hbc/cli/fetch.rb @@ -1,13 +1,13 @@ -class Cask::CLI::Fetch < Cask::CLI::Base +class Hbc::CLI::Fetch < Hbc::CLI::Base def self.run(*args) cask_tokens = cask_tokens_from(args) - raise CaskUnspecifiedError if cask_tokens.empty? + raise Hbc::CaskUnspecifiedError if cask_tokens.empty? force = args.include? '--force' cask_tokens.each do |cask_token| ohai "Fetching resources for Cask #{cask_token}" - cask = Cask.load(cask_token) - @downloaded_path = Cask::Download.new(cask).perform force + cask = Hbc.load(cask_token) + @downloaded_path = Hbc::Download.new(cask).perform force ohai "Success! Downloaded to -> #{@downloaded_path}" end end diff --git a/lib/cask/cli/home.rb b/lib/hbc/cli/home.rb similarity index 83% rename from lib/cask/cli/home.rb rename to lib/hbc/cli/home.rb index 749bb81606..76882635fc 100644 --- a/lib/cask/cli/home.rb +++ b/lib/hbc/cli/home.rb @@ -1,4 +1,4 @@ -class Cask::CLI::Home < Cask::CLI::Base +class Hbc::CLI::Home < Hbc::CLI::Base def self.run(*cask_tokens) if cask_tokens.empty? odebug "Opening project homepage" @@ -6,7 +6,7 @@ class Cask::CLI::Home < Cask::CLI::Base else cask_tokens.each do |cask_token| odebug "Opening homepage for Cask #{cask_token}" - cask = Cask.load(cask_token) + cask = Hbc.load(cask_token) system "/usr/bin/open", '--', cask.homepage end end diff --git a/lib/cask/cli/info.rb b/lib/hbc/cli/info.rb similarity index 87% rename from lib/cask/cli/info.rb rename to lib/hbc/cli/info.rb index c9b2c636cc..5973209916 100644 --- a/lib/cask/cli/info.rb +++ b/lib/hbc/cli/info.rb @@ -1,12 +1,12 @@ -class Cask::CLI::Info < Cask::CLI::Base +class Hbc::CLI::Info < Hbc::CLI::Base def self.run(*args) cask_tokens = cask_tokens_from(args) - raise CaskUnspecifiedError if cask_tokens.empty? + raise Hbc::CaskUnspecifiedError if cask_tokens.empty? cask_tokens.each do |cask_token| odebug "Getting info for Cask #{cask_token}" - cask = Cask.load(cask_token) + cask = Hbc.load(cask_token) puts info(cask) - Cask::Installer.print_caveats(cask) + Hbc::Installer.print_caveats(cask) end end @@ -16,7 +16,7 @@ class Cask::CLI::Info < Cask::CLI::Base def self.info(cask) installation = if cask.installed? - "#{cask.staged_path} (#{Cask::Utils.cabv(cask.staged_path)})" + "#{cask.staged_path} (#{Hbc::Utils.cabv(cask.staged_path)})" else "Not installed" end @@ -58,7 +58,7 @@ PURPOSE def self.artifact_info(cask) retval = '' - Cask::DSL::ClassMethods.ordinary_artifact_types.each do |type| + Hbc::DSL::ClassMethods.ordinary_artifact_types.each do |type| if cask.artifacts[type].length > 0 retval = "#{Tty.blue.bold}==>#{Tty.white} Contents#{Tty.reset}\n" unless retval.length > 0 cask.artifacts[type].each do |artifact| diff --git a/lib/cask/cli/install.rb b/lib/hbc/cli/install.rb similarity index 58% rename from lib/cask/cli/install.rb rename to lib/hbc/cli/install.rb index 314d5934dd..0dcc82a5b3 100644 --- a/lib/cask/cli/install.rb +++ b/lib/hbc/cli/install.rb @@ -1,14 +1,14 @@ -class Cask::CLI::Install < Cask::CLI::Base +class Hbc::CLI::Install < Hbc::CLI::Base def self.run(*args) cask_tokens = cask_tokens_from(args) - raise CaskUnspecifiedError if cask_tokens.empty? + raise Hbc::CaskUnspecifiedError if cask_tokens.empty? force = args.include? '--force' retval = install_casks cask_tokens, force # retval is ternary: true/false/nil if retval.nil? - raise CaskError.new("nothing to install") + raise Hbc::CaskError.new("nothing to install") elsif ! retval - raise CaskError.new("install incomplete") + raise Hbc::CaskError.new("install incomplete") end end @@ -16,13 +16,13 @@ class Cask::CLI::Install < Cask::CLI::Base count = 0 cask_tokens.each do |cask_token| begin - cask = Cask.load(cask_token) - Cask::Installer.new(cask).install(force) + cask = Hbc.load(cask_token) + Hbc::Installer.new(cask).install(force) count += 1 - rescue CaskAlreadyInstalledError => e + rescue Hbc::CaskAlreadyInstalledError => e opoo e.message count += 1 - rescue CaskUnavailableError => e + rescue Hbc::CaskUnavailableError => e warn_unavailable_with_suggestion cask_token, e end end @@ -30,12 +30,12 @@ class Cask::CLI::Install < Cask::CLI::Base end def self.warn_unavailable_with_suggestion(cask_token, e) - exact_match, partial_matches, search_term = Cask::CLI::Search.search(cask_token) + exact_match, partial_matches, search_term = Hbc::CLI::Search.search(cask_token) errmsg = e.message if exact_match errmsg.concat(". Did you mean:\n#{exact_match}") elsif !partial_matches.empty? - errmsg.concat(". Did you mean one of:\n#{Cask::Utils.stringify_columns(partial_matches.take(20))}\n") + errmsg.concat(". Did you mean one of:\n#{Hbc::Utils.stringify_columns(partial_matches.take(20))}\n") end onoe errmsg end diff --git a/lib/cask/cli/internal_checkurl.rb b/lib/hbc/cli/internal_checkurl.rb similarity index 53% rename from lib/cask/cli/internal_checkurl.rb rename to lib/hbc/cli/internal_checkurl.rb index c68d72a141..d53f420e28 100644 --- a/lib/cask/cli/internal_checkurl.rb +++ b/lib/hbc/cli/internal_checkurl.rb @@ -1,9 +1,9 @@ -class Cask::CLI::InternalCheckurl < Cask::CLI::InternalUseBase +class Hbc::CLI::InternalCheckurl < Hbc::CLI::InternalUseBase def self.run(*args) - casks_to_check = args.empty? ? Cask.all : args.map { |arg| Cask.load(arg) } + casks_to_check = args.empty? ? Hbc.all : args.map { |arg| Hbc.load(arg) } casks_to_check.each do |cask| odebug "Checking URL for Cask #{cask}" - checker = Cask::UrlChecker.new(cask) + checker = Hbc::UrlChecker.new(cask) checker.run puts checker.summary end diff --git a/lib/cask/cli/internal_dump.rb b/lib/hbc/cli/internal_dump.rb similarity index 62% rename from lib/cask/cli/internal_dump.rb rename to lib/hbc/cli/internal_dump.rb index b3a76bb5e5..cf90cc6929 100644 --- a/lib/cask/cli/internal_dump.rb +++ b/lib/hbc/cli/internal_dump.rb @@ -1,22 +1,22 @@ -class Cask::CLI::InternalDump < Cask::CLI::InternalUseBase +class Hbc::CLI::InternalDump < Hbc::CLI::InternalUseBase def self.run(*arguments) cask_tokens = cask_tokens_from(arguments) - raise CaskUnspecifiedError if cask_tokens.empty? + raise Hbc::CaskUnspecifiedError if cask_tokens.empty? retval = dump_casks(*cask_tokens) # retval is ternary: true/false/nil if retval.nil? - raise CaskError.new("nothing to dump") + raise Hbc::CaskError.new("nothing to dump") elsif ! retval - raise CaskError.new("dump incomplete") + raise Hbc::CaskError.new("dump incomplete") end end def self.dump_casks(*cask_tokens) - Cask.debug = true # Yuck. At the moment this is the only way to make dumps visible + 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 = Cask.load(cask_token) + cask = Hbc.load(cask_token) count += 1 cask.dumpcask rescue StandardError => e diff --git a/lib/cask/cli/internal_help.rb b/lib/hbc/cli/internal_help.rb similarity index 69% rename from lib/cask/cli/internal_help.rb rename to lib/hbc/cli/internal_help.rb index aa9d4eca81..81d7ee6731 100644 --- a/lib/cask/cli/internal_help.rb +++ b/lib/hbc/cli/internal_help.rb @@ -1,8 +1,8 @@ -class Cask::CLI::InternalHelp < Cask::CLI::InternalUseBase +class Hbc::CLI::InternalHelp < Hbc::CLI::InternalUseBase def self.run(*_ignored) - max_command_len = Cask::CLI.commands.map(&:length).max + max_command_len = Hbc::CLI.commands.map(&:length).max puts "Unstable Internal-use Commands:\n\n" - Cask::CLI.command_classes.each do |klass| + Hbc::CLI.command_classes.each do |klass| next if klass.visible puts " #{klass.command_name.ljust(max_command_len)} #{help_for(klass)}" end diff --git a/lib/cask/cli/internal_stanza.rb b/lib/hbc/cli/internal_stanza.rb similarity index 92% rename from lib/cask/cli/internal_stanza.rb rename to lib/hbc/cli/internal_stanza.rb index 9a99b054a8..54037823f2 100644 --- a/lib/cask/cli/internal_stanza.rb +++ b/lib/hbc/cli/internal_stanza.rb @@ -1,4 +1,4 @@ -class Cask::CLI::InternalStanza < Cask::CLI::InternalUseBase +class Hbc::CLI::InternalStanza < Hbc::CLI::InternalUseBase # Syntax # @@ -20,7 +20,7 @@ class Cask::CLI::InternalStanza < Cask::CLI::InternalUseBase # brew cask _stanza artifacts --table --yaml alfred google-chrome adium voicemac logisim vagrant # - # todo: this should be retrievable from Cask::DSL + # todo: this should be retrievable from Hbc::DSL ARTIFACTS = Set.new([ :app, :suite, @@ -54,17 +54,17 @@ class Cask::CLI::InternalStanza < Cask::CLI::InternalUseBase format = :inspect if arguments.include? '--inspect' cask_tokens = arguments.reject { |arg| arg.chars.first == '-' } stanza = cask_tokens.shift.to_sym - cask_tokens = Cask.all_tokens if cask_tokens.empty? + cask_tokens = Hbc.all_tokens if cask_tokens.empty? retval = print_stanzas(stanza, format, table, quiet, *cask_tokens) # retval is ternary: true/false/nil if retval.nil? exit 1 if quiet - raise CaskError.new("nothing to print") + raise Hbc::CaskError.new("nothing to print") elsif ! retval exit 1 if quiet - raise CaskError.new("print incomplete") + raise Hbc::CaskError.new("print incomplete") end end @@ -81,7 +81,7 @@ class Cask::CLI::InternalStanza < Cask::CLI::InternalUseBase print "#{cask_token}\t" if table begin - cask = Cask.load(cask_token) + cask = Hbc.load(cask_token) rescue StandardError opoo "Cask '#{cask_token}' was not found" unless quiet puts '' diff --git a/lib/cask/cli/internal_use_base.rb b/lib/hbc/cli/internal_use_base.rb similarity index 67% rename from lib/cask/cli/internal_use_base.rb rename to lib/hbc/cli/internal_use_base.rb index 4cb8f5105d..7688547b84 100644 --- a/lib/cask/cli/internal_use_base.rb +++ b/lib/hbc/cli/internal_use_base.rb @@ -1,4 +1,4 @@ -class Cask::CLI::InternalUseBase < Cask::CLI::Base +class Hbc::CLI::InternalUseBase < Hbc::CLI::Base def self.command_name super.sub(%r{^internal_}i, '_') end diff --git a/lib/cask/cli/list.rb b/lib/hbc/cli/list.rb similarity index 79% rename from lib/cask/cli/list.rb rename to lib/hbc/cli/list.rb index 757aae2d7b..609fa80ba4 100644 --- a/lib/cask/cli/list.rb +++ b/lib/hbc/cli/list.rb @@ -1,4 +1,4 @@ -class Cask::CLI::List < Cask::CLI::Base +class Hbc::CLI::List < Hbc::CLI::Base def self.run(*arguments) @options = Hash.new @options[:one] = true if arguments.delete('-1') @@ -13,9 +13,9 @@ class Cask::CLI::List < Cask::CLI::Base if retval.nil? and not arguments.any? opoo "nothing to list" # special case: avoid exit code elsif retval.nil? - raise CaskError.new("nothing to list") + raise Hbc::CaskError.new("nothing to list") elsif ! retval - raise CaskError.new("listing incomplete") + raise Hbc::CaskError.new("listing incomplete") end end @@ -23,7 +23,7 @@ class Cask::CLI::List < Cask::CLI::Base count = 0 cask_tokens.each do |cask_token| odebug "Listing files for Cask #{cask_token}" - cask = Cask.load(cask_token) + cask = Hbc.load(cask_token) if cask.installed? count += 1 list_artifacts(cask) @@ -36,7 +36,7 @@ class Cask::CLI::List < Cask::CLI::Base end def self.list_artifacts(cask) - artifacts = Cask::Artifact.for_cask(cask) + artifacts = Hbc::Artifact.for_cask(cask) artifacts.each do |artifact| summary = artifact.new(cask).summary ohai summary[:english_description], summary[:contents] unless summary.empty? @@ -45,16 +45,16 @@ class Cask::CLI::List < Cask::CLI::Base def self.list_files(cask) ohai "Staged content:" - Cask::PrettyListing.new(cask).print + Hbc::PrettyListing.new(cask).print end def self.list_installed - installed_casks = Cask.installed + installed_casks = Hbc.installed columns = installed_casks.map(&:to_s) if @options[:one] puts columns elsif @options[:long] - puts Cask::SystemCommand.run!("/bin/ls", :args => ["-l", Cask.caskroom]).stdout + puts Hbc::SystemCommand.run!("/bin/ls", :args => ["-l", Hbc.caskroom]).stdout else puts_columns columns end diff --git a/lib/cask/cli/search.rb b/lib/hbc/cli/search.rb similarity index 86% rename from lib/cask/cli/search.rb rename to lib/hbc/cli/search.rb index efccb89e22..d7e26016ac 100644 --- a/lib/cask/cli/search.rb +++ b/lib/hbc/cli/search.rb @@ -1,4 +1,4 @@ -class Cask::CLI::Search < Cask::CLI::Base +class Hbc::CLI::Search < Hbc::CLI::Base def self.run(*arguments) render_results *search(*arguments) end @@ -18,10 +18,10 @@ class Cask::CLI::Search < Cask::CLI::Base search_regexp = extract_regexp arguments.first if search_regexp search_term = arguments.first - partial_matches = Cask::CLI.nice_listing(Cask.all_tokens).grep(/#{search_regexp}/i) + partial_matches = Hbc::CLI.nice_listing(Hbc.all_tokens).grep(/#{search_regexp}/i) else # suppressing search of the font Tap is a quick hack until behavior can be made configurable - all_tokens = Cask::CLI.nice_listing Cask.all_tokens.reject{ |t| %r{^caskroom/homebrew-fonts/}.match(t)} + all_tokens = Hbc::CLI.nice_listing Hbc.all_tokens.reject{ |t| %r{^caskroom/homebrew-fonts/}.match(t)} simplified_tokens = all_tokens.map { |t| t.sub(/^.*\//, '').gsub(/[^a-z0-9]+/i, '') } simplified_search_term = search_term.sub(/\.rb$/i, '').gsub(/[^a-z0-9]+/i, '') exact_match = simplified_tokens.grep(/^#{simplified_search_term}$/i) { |t| all_tokens[simplified_tokens.index(t)] }.first diff --git a/lib/hbc/cli/uninstall.rb b/lib/hbc/cli/uninstall.rb new file mode 100644 index 0000000000..bef08b2ad7 --- /dev/null +++ b/lib/hbc/cli/uninstall.rb @@ -0,0 +1,17 @@ +class Hbc::CLI::Uninstall < Hbc::CLI::Base + def self.run(*args) + cask_tokens = cask_tokens_from(args) + raise Hbc::CaskUnspecifiedError if cask_tokens.empty? + force = args.include? '--force' + cask_tokens.each do |cask_token| + odebug "Uninstalling Cask #{cask_token}" + cask = Hbc.load(cask_token) + raise Hbc::CaskNotInstalledError.new(cask) unless cask.installed? or force + Hbc::Installer.new(cask).uninstall(force) + end + end + + def self.help + "uninstalls the given Cask" + end +end diff --git a/lib/cask/cli/update.rb b/lib/hbc/cli/update.rb similarity index 67% rename from lib/cask/cli/update.rb rename to lib/hbc/cli/update.rb index 20e8aaa36e..720700fd7e 100644 --- a/lib/cask/cli/update.rb +++ b/lib/hbc/cli/update.rb @@ -1,9 +1,9 @@ -class Cask::CLI::Update < Cask::CLI::Base +class Hbc::CLI::Update < Hbc::CLI::Base def self.run(*_ignored) - result = Cask::SystemCommand.run(HOMEBREW_BREW_FILE, + result = Hbc::SystemCommand.run(HOMEBREW_BREW_FILE, :args => %w{update}) # todo: separating stderr/stdout is undesirable here. - # Cask::SystemCommand should have an option for plain + # Hbc::SystemCommand should have an option for plain # unbuffered output. print result.stdout $stderr.print result.stderr diff --git a/lib/cask/cli/zap.rb b/lib/hbc/cli/zap.rb similarity index 58% rename from lib/cask/cli/zap.rb rename to lib/hbc/cli/zap.rb index ace2da25c9..0813783309 100644 --- a/lib/cask/cli/zap.rb +++ b/lib/hbc/cli/zap.rb @@ -1,11 +1,11 @@ -class Cask::CLI::Zap < Cask::CLI::Base +class Hbc::CLI::Zap < Hbc::CLI::Base def self.run(*args) cask_tokens = cask_tokens_from(args) - raise CaskUnspecifiedError if cask_tokens.empty? + raise Hbc::CaskUnspecifiedError if cask_tokens.empty? cask_tokens.each do |cask_token| odebug "Zapping Cask #{cask_token}" - cask = Cask.load(cask_token) - Cask::Installer.new(cask).zap + cask = Hbc.load(cask_token) + Hbc::Installer.new(cask).zap end end diff --git a/lib/hbc/container.rb b/lib/hbc/container.rb new file mode 100644 index 0000000000..a3c16408c5 --- /dev/null +++ b/lib/hbc/container.rb @@ -0,0 +1,62 @@ +class Hbc::Container; end + +require 'hbc/container/base' +require 'hbc/container/air' +require 'hbc/container/bzip2' +require 'hbc/container/cab' +require 'hbc/container/criteria' +require 'hbc/container/dmg' +require 'hbc/container/generic_unar' +require 'hbc/container/gzip' +require 'hbc/container/naked' +require 'hbc/container/otf' +require 'hbc/container/pkg' +require 'hbc/container/seven_zip' +require 'hbc/container/sit' +require 'hbc/container/tar' +require 'hbc/container/ttf' +require 'hbc/container/rar' +require 'hbc/container/xar' +require 'hbc/container/zip' + +class Hbc::Container + def self.autodetect_containers + [ + Hbc::Container::Pkg, + Hbc::Container::Ttf, + Hbc::Container::Otf, + Hbc::Container::Air, + Hbc::Container::Cab, + Hbc::Container::Dmg, + Hbc::Container::SevenZip, + Hbc::Container::Sit, + Hbc::Container::Tar, # or compressed tar + Hbc::Container::Rar, + Hbc::Container::Zip, + Hbc::Container::Bzip2, + Hbc::Container::Gzip, # pure gzip, not tar/gzip + Hbc::Container::Xar, + ] + # for explicit use only (never autodetected): + # Hbc::Container::Naked + # Hbc::Container::GenericUnar + end + + def self.for_path(path, command) + odebug "Determining which containers to use based on filetype" + criteria = Hbc::Container::Criteria.new(path, command) + autodetect_containers.find do |c| + odebug "Checking container class #{c}" + c.me?(criteria) + end + end + + def self.from_type(type) + odebug "Determining which containers to use based on 'container :type'" + begin + Hbc::Container.const_get(type.to_s.split('_').map(&:capitalize).join) + rescue NameError + false + end + end +end diff --git a/lib/cask/container/air.rb b/lib/hbc/container/air.rb similarity index 88% rename from lib/cask/container/air.rb rename to lib/hbc/container/air.rb index cfbd0b8cca..0a9f276c50 100644 --- a/lib/cask/container/air.rb +++ b/lib/hbc/container/air.rb @@ -1,4 +1,4 @@ -class Cask::Container::Air < Cask::Container::Base +class Hbc::Container::Air < Hbc::Container::Base def self.me?(criteria) %w[.air].include?(criteria.path.extname) end @@ -7,7 +7,7 @@ class Cask::Container::Air < Cask::Container::Base @installer_cmd ||= if installer_exist? _installer_pathname else - raise CaskError.new <<-ERRMSG.undent + raise Hbc::CaskError.new <<-ERRMSG.undent Adobe AIR runtime not present, try installing it via brew cask install adobe-air diff --git a/lib/cask/container/base.rb b/lib/hbc/container/base.rb similarity index 78% rename from lib/cask/container/base.rb rename to lib/hbc/container/base.rb index 969ea195a9..c04ed952f8 100644 --- a/lib/cask/container/base.rb +++ b/lib/hbc/container/base.rb @@ -1,4 +1,4 @@ -class Cask::Container::Base +class Hbc::Container::Base def initialize(cask, path, command) @cask = cask @path = path diff --git a/lib/cask/container/bzip2.rb b/lib/hbc/container/bzip2.rb similarity index 89% rename from lib/cask/container/bzip2.rb rename to lib/hbc/container/bzip2.rb index 22a4e8909f..993925bea1 100644 --- a/lib/cask/container/bzip2.rb +++ b/lib/hbc/container/bzip2.rb @@ -1,6 +1,6 @@ require 'tmpdir' -class Cask::Container::Bzip2 < Cask::Container::Base +class Hbc::Container::Bzip2 < Hbc::Container::Base def self.me?(criteria) criteria.file.include? 'compressed-encoding=application/x-bzip2;' end diff --git a/lib/cask/container/cab.rb b/lib/hbc/container/cab.rb similarity index 76% rename from lib/cask/container/cab.rb rename to lib/hbc/container/cab.rb index dfaf464f42..9807538d3f 100644 --- a/lib/cask/container/cab.rb +++ b/lib/hbc/container/cab.rb @@ -1,6 +1,6 @@ require 'tmpdir' -class Cask::Container::Cab < Cask::Container::Base +class Hbc::Container::Cab < Hbc::Container::Base def self.me?(criteria) (criteria.file.include? 'application/octet-stream;' or criteria.file.include? 'application/vnd.ms-cab-compressed;') and @@ -11,7 +11,7 @@ class Cask::Container::Cab < Cask::Container::Base def extract cabextract = HOMEBREW_PREFIX.join('bin/cabextract') if ! Pathname.new(cabextract).exist? - raise CaskError.new "Expected to find cabextract executable. Cask '#{@cask}' must add: depends_on :formula => 'cabextract'" + raise Hbc::CaskError.new "Expected to find cabextract executable. Cask '#{@cask}' must add: depends_on :formula => 'cabextract'" end Dir.mktmpdir do |unpack_dir| @command.run!(cabextract, :args => ['-d', unpack_dir, '--', @path]) diff --git a/lib/cask/container/criteria.rb b/lib/hbc/container/criteria.rb similarity index 97% rename from lib/cask/container/criteria.rb rename to lib/hbc/container/criteria.rb index 2eed7b3171..6e9bedd133 100644 --- a/lib/cask/container/criteria.rb +++ b/lib/hbc/container/criteria.rb @@ -1,4 +1,4 @@ -class Cask::Container::Criteria +class Hbc::Container::Criteria attr_reader :path def initialize(path, command) diff --git a/lib/cask/container/dmg.rb b/lib/hbc/container/dmg.rb similarity index 92% rename from lib/cask/container/dmg.rb rename to lib/hbc/container/dmg.rb index 2110c334f7..bdc71861a1 100644 --- a/lib/cask/container/dmg.rb +++ b/lib/hbc/container/dmg.rb @@ -1,4 +1,4 @@ -class Cask::Container::Dmg < Cask::Container::Base +class Hbc::Container::Dmg < Hbc::Container::Base def self.me?(criteria) criteria.imageinfo != '' end @@ -50,7 +50,7 @@ class Cask::Container::Dmg < Cask::Container::Base def assert_mounts_found if @mounts.empty? - raise CaskError.new %Q{No mounts found in '#{@path}'; perhaps it is a bad DMG?} + raise Hbc::CaskError.new %Q{No mounts found in '#{@path}'; perhaps it is a bad DMG?} end end @@ -72,7 +72,7 @@ class Cask::Container::Dmg < Cask::Container::Base :args => ['eject', mountpath], :print_stderr => false) next unless mountpath.exist? - raise CaskError.new "Failed to eject #{mountpath}" + raise Hbc::CaskError.new "Failed to eject #{mountpath}" end end end diff --git a/lib/cask/container/generic_unar.rb b/lib/hbc/container/generic_unar.rb similarity index 71% rename from lib/cask/container/generic_unar.rb rename to lib/hbc/container/generic_unar.rb index b5a5194b9a..eb776f51dc 100644 --- a/lib/cask/container/generic_unar.rb +++ b/lib/hbc/container/generic_unar.rb @@ -1,6 +1,6 @@ require 'tmpdir' -class Cask::Container::GenericUnar < Cask::Container::Base +class Hbc::Container::GenericUnar < Hbc::Container::Base def self.me?(criteria) ! criteria.lsar.nil? and criteria.lsar.include? 'passed, 0 failed' @@ -9,7 +9,7 @@ class Cask::Container::GenericUnar < Cask::Container::Base def extract unar = HOMEBREW_PREFIX.join('bin/unar') if ! Pathname.new(unar).exist? - raise CaskError.new "Expected to find unar executable. Cask #{@cask} must add: depends_on :formula => 'unar'" + raise Hbc::CaskError.new "Expected to find unar executable. Cask #{@cask} must add: depends_on :formula => 'unar'" end Dir.mktmpdir do |unpack_dir| @command.run!(unar, :args => ['-q', '-D', '-o', unpack_dir, '--', @path]) diff --git a/lib/cask/container/gzip.rb b/lib/hbc/container/gzip.rb similarity index 90% rename from lib/cask/container/gzip.rb rename to lib/hbc/container/gzip.rb index 9ad13b9a23..47852a73ca 100644 --- a/lib/cask/container/gzip.rb +++ b/lib/hbc/container/gzip.rb @@ -3,7 +3,7 @@ require 'tmpdir' -class Cask::Container::Gzip < Cask::Container::Base +class Hbc::Container::Gzip < Hbc::Container::Base def self.me?(criteria) criteria.file.include? 'compressed-encoding=application/x-gzip;' end diff --git a/lib/cask/container/naked.rb b/lib/hbc/container/naked.rb similarity index 88% rename from lib/cask/container/naked.rb rename to lib/hbc/container/naked.rb index cc207b0e5f..fc4fde5e27 100644 --- a/lib/cask/container/naked.rb +++ b/lib/hbc/container/naked.rb @@ -1,4 +1,4 @@ -class Cask::Container::Naked < Cask::Container::Base +class Hbc::Container::Naked < Hbc::Container::Base def self.me?(criteria) # Either inherit from this class and override self.me?, # or use this class directly as "container :type => :naked", diff --git a/lib/cask/container/otf.rb b/lib/hbc/container/otf.rb similarity index 78% rename from lib/cask/container/otf.rb rename to lib/hbc/container/otf.rb index 405bbe4e6b..c831d2e8f8 100644 --- a/lib/cask/container/otf.rb +++ b/lib/hbc/container/otf.rb @@ -1,4 +1,4 @@ -class Cask::Container::Otf < Cask::Container::Naked +class Hbc::Container::Otf < Hbc::Container::Naked def self.me?(criteria) criteria.extension 'otf' and (criteria.file.include? 'application/vnd.ms-opentype' or diff --git a/lib/cask/container/pkg.rb b/lib/hbc/container/pkg.rb similarity index 80% rename from lib/cask/container/pkg.rb rename to lib/hbc/container/pkg.rb index c59c03f57b..4184c9f0a3 100644 --- a/lib/cask/container/pkg.rb +++ b/lib/hbc/container/pkg.rb @@ -1,4 +1,4 @@ -class Cask::Container::Pkg < Cask::Container::Naked +class Hbc::Container::Pkg < Hbc::Container::Naked def self.me?(criteria) (criteria.extension 'pkg' or criteria.extension 'mpkg') and (criteria.file.include? 'application/x-directory' or diff --git a/lib/cask/container/rar.rb b/lib/hbc/container/rar.rb similarity index 82% rename from lib/cask/container/rar.rb rename to lib/hbc/container/rar.rb index 111e04f7e1..ac342dcbea 100644 --- a/lib/cask/container/rar.rb +++ b/lib/hbc/container/rar.rb @@ -1,4 +1,4 @@ -class Cask::Container::Rar < Cask::Container::GenericUnar +class Hbc::Container::Rar < Hbc::Container::GenericUnar def self.me?(criteria) (criteria.file.include? 'application/x-rar;' or criteria.file.include? 'application/octet-stream;') and diff --git a/lib/cask/container/seven_zip.rb b/lib/hbc/container/seven_zip.rb similarity index 85% rename from lib/cask/container/seven_zip.rb rename to lib/hbc/container/seven_zip.rb index 0544263426..b72af90a2a 100644 --- a/lib/cask/container/seven_zip.rb +++ b/lib/hbc/container/seven_zip.rb @@ -1,4 +1,4 @@ -class Cask::Container::SevenZip < Cask::Container::GenericUnar +class Hbc::Container::SevenZip < Hbc::Container::GenericUnar def self.me?(criteria) # todo: cover self-extracting archives criteria.extension '7z' and diff --git a/lib/cask/container/sit.rb b/lib/hbc/container/sit.rb similarity index 78% rename from lib/cask/container/sit.rb rename to lib/hbc/container/sit.rb index 4e5dd7a7af..ce256f77fd 100644 --- a/lib/cask/container/sit.rb +++ b/lib/hbc/container/sit.rb @@ -1,4 +1,4 @@ -class Cask::Container::Sit < Cask::Container::GenericUnar +class Hbc::Container::Sit < Hbc::Container::GenericUnar def self.me?(criteria) criteria.file.include? 'application/x-stuffit' and ! criteria.lsar.nil? and diff --git a/lib/cask/container/tar.rb b/lib/hbc/container/tar.rb similarity index 86% rename from lib/cask/container/tar.rb rename to lib/hbc/container/tar.rb index 35cefea584..0ec8677f21 100644 --- a/lib/cask/container/tar.rb +++ b/lib/hbc/container/tar.rb @@ -1,6 +1,6 @@ require 'tmpdir' -class Cask::Container::Tar < Cask::Container::Base +class Hbc::Container::Tar < Hbc::Container::Base def self.me?(criteria) criteria.file.include? 'application/x-tar' end diff --git a/lib/cask/container/ttf.rb b/lib/hbc/container/ttf.rb similarity index 83% rename from lib/cask/container/ttf.rb rename to lib/hbc/container/ttf.rb index 2b2c8eb21a..67924367c5 100644 --- a/lib/cask/container/ttf.rb +++ b/lib/hbc/container/ttf.rb @@ -1,4 +1,4 @@ -class Cask::Container::Ttf < Cask::Container::Naked +class Hbc::Container::Ttf < Hbc::Container::Naked def self.me?(criteria) (criteria.extension 'ttf' and (criteria.file.include? 'application/x-font-ttf' or diff --git a/lib/cask/container/xar.rb b/lib/hbc/container/xar.rb similarity index 86% rename from lib/cask/container/xar.rb rename to lib/hbc/container/xar.rb index 658dfa809e..2e2373273e 100644 --- a/lib/cask/container/xar.rb +++ b/lib/hbc/container/xar.rb @@ -1,6 +1,6 @@ require 'tmpdir' -class Cask::Container::Xar < Cask::Container::Base +class Hbc::Container::Xar < Hbc::Container::Base def self.me?(criteria) criteria.magic_number(4, 'xar!'.unpack('C*')) end diff --git a/lib/cask/container/zip.rb b/lib/hbc/container/zip.rb similarity index 80% rename from lib/cask/container/zip.rb rename to lib/hbc/container/zip.rb index 73f68bed36..5425d7f645 100644 --- a/lib/cask/container/zip.rb +++ b/lib/hbc/container/zip.rb @@ -1,4 +1,4 @@ -class Cask::Container::Zip < Cask::Container::Base +class Hbc::Container::Zip < Hbc::Container::Base def self.me?(criteria) criteria.file.include? 'compressed-encoding=application/zip;' end diff --git a/lib/cask/download.rb b/lib/hbc/download.rb similarity index 71% rename from lib/cask/download.rb rename to lib/hbc/download.rb index 9949c7fd1b..6e0eb0abc9 100644 --- a/lib/cask/download.rb +++ b/lib/hbc/download.rb @@ -1,6 +1,6 @@ require 'digest' -class Cask::Download +class Hbc::Download attr_reader :cask def initialize(cask) @@ -9,17 +9,17 @@ class Cask::Download def perform(force=false) if cask.url.using == :svn - downloader = Cask::SubversionDownloadStrategy.new(cask) + downloader = Hbc::SubversionDownloadStrategy.new(cask) elsif cask.url.using == :post - downloader = Cask::CurlPostDownloadStrategy.new(cask) + downloader = Hbc::CurlPostDownloadStrategy.new(cask) else - downloader = Cask::CurlDownloadStrategy.new(cask) + downloader = Hbc::CurlDownloadStrategy.new(cask) end downloader.clear_cache if force begin downloaded_path = downloader.fetch rescue StandardError => e - raise CaskError.new("Download failed on Cask '#{cask}' with message: #{e}") + raise Hbc::CaskError.new("Download failed on Cask '#{cask}' with message: #{e}") end begin # this symlink helps track which downloads are ours @@ -45,13 +45,13 @@ class Cask::Download return if expected == :no_check computed = _calc_sha256(path) if expected.nil? or expected.empty? - raise CaskSha256MissingError.new("sha256 required: sha256 '#{computed}'") + raise Hbc::CaskSha256MissingError.new("sha256 required: sha256 '#{computed}'") end if expected == computed odebug "SHA256 checksums match" else ohai 'Note: running "brew update" may fix sha256 checksum errors' - raise CaskSha256MismatchError.new(path, expected, computed) + raise Hbc::CaskSha256MismatchError.new(path, expected, computed) end end end diff --git a/lib/cask/download_strategy.rb b/lib/hbc/download_strategy.rb similarity index 92% rename from lib/cask/download_strategy.rb rename to lib/hbc/download_strategy.rb index 7cc7e24e97..8abccb98e3 100644 --- a/lib/cask/download_strategy.rb +++ b/lib/hbc/download_strategy.rb @@ -6,16 +6,16 @@ require 'cgi' # * Our overridden fetch methods are expected to return # a value: the successfully downloaded file. -module Cask::DownloadStrategy +module Hbc::DownloadStrategy attr_reader :cask, :cask_url - def initialize(cask, command=Cask::SystemCommand) + def initialize(cask, command=Hbc::SystemCommand) @cask = cask @command = command @cask_url = cask.url super( cask.token, - ::Resource.new(cask.token) do |r| + Hbc::Resource.new(cask.token) do |r| r.url cask.url.to_s r.version cask.version.to_s end @@ -23,9 +23,9 @@ module Cask::DownloadStrategy end end -class Cask::CurlDownloadStrategy < CurlDownloadStrategy +class Hbc::CurlDownloadStrategy < Hbc::HbCurlDownloadStrategy - include Cask::DownloadStrategy + include Hbc::DownloadStrategy def _fetch odebug "Calling curl with args #{curl_args.utf8_inspect}" @@ -82,7 +82,7 @@ class Cask::CurlDownloadStrategy < CurlDownloadStrategy end end -class Cask::CurlPostDownloadStrategy < Cask::CurlDownloadStrategy +class Hbc::CurlPostDownloadStrategy < Hbc::CurlDownloadStrategy def curl_args super @@ -101,8 +101,8 @@ class Cask::CurlPostDownloadStrategy < Cask::CurlDownloadStrategy end end -class Cask::SubversionDownloadStrategy < SubversionDownloadStrategy - include Cask::DownloadStrategy +class Hbc::SubversionDownloadStrategy < Hbc::HbSubversionDownloadStrategy + include Hbc::DownloadStrategy # super does not provide checks for already-existing downloads def fetch diff --git a/lib/cask/dsl.rb b/lib/hbc/dsl.rb similarity index 68% rename from lib/cask/dsl.rb rename to lib/hbc/dsl.rb index 6a4caa56d5..1fdc450a1c 100644 --- a/lib/cask/dsl.rb +++ b/lib/hbc/dsl.rb @@ -1,22 +1,22 @@ require 'set' -module Cask::DSL; end +module Hbc::DSL; end -require 'cask/dsl/appcast' -require 'cask/dsl/base' -require 'cask/dsl/conflicts_with' -require 'cask/dsl/container' -require 'cask/dsl/depends_on' -require 'cask/dsl/gpg' -require 'cask/dsl/installer' -require 'cask/dsl/license' -require 'cask/dsl/postflight' -require 'cask/dsl/preflight' -require 'cask/dsl/tags' -require 'cask/dsl/uninstall_postflight' -require 'cask/dsl/uninstall_preflight' +require 'hbc/dsl/appcast' +require 'hbc/dsl/base' +require 'hbc/dsl/conflicts_with' +require 'hbc/dsl/container' +require 'hbc/dsl/depends_on' +require 'hbc/dsl/gpg' +require 'hbc/dsl/installer' +require 'hbc/dsl/license' +require 'hbc/dsl/postflight' +require 'hbc/dsl/preflight' +require 'hbc/dsl/tags' +require 'hbc/dsl/uninstall_postflight' +require 'hbc/dsl/uninstall_preflight' -module Cask::DSL +module Hbc::DSL def self.included(base) base.extend(ClassMethods) end @@ -74,7 +74,7 @@ module Cask::DSL def homepage(homepage=nil) if @homepage and !homepage.nil? - raise CaskInvalidError.new(self.token, "'homepage' stanza may only appear once") + raise Hbc::CaskInvalidError.new(self.token, "'homepage' stanza may only appear once") end @homepage ||= homepage end @@ -82,36 +82,36 @@ module Cask::DSL def url(*args) return @url if args.empty? if @url and !args.empty? - raise CaskInvalidError.new(self.token, "'url' stanza may only appear once") + raise Hbc::CaskInvalidError.new(self.token, "'url' stanza may only appear once") end @url ||= begin - Cask::URL.new(*args) + Hbc::URL.new(*args) rescue StandardError => e - raise CaskInvalidError.new(self.token, "'url' stanza failed with: #{e}") + raise Hbc::CaskInvalidError.new(self.token, "'url' stanza failed with: #{e}") end end def appcast(*args) return @appcast if args.empty? if @appcast and !args.empty? - raise CaskInvalidError.new(self.token, "'appcast' stanza may only appear once") + raise Hbc::CaskInvalidError.new(self.token, "'appcast' stanza may only appear once") end @appcast ||= begin - Cask::DSL::Appcast.new(*args) unless args.empty? + Hbc::DSL::Appcast.new(*args) unless args.empty? rescue StandardError => e - raise CaskInvalidError.new(self.token, e) + raise Hbc::CaskInvalidError.new(self.token, e) end end def gpg(*args) return @gpg if args.empty? if @gpg and !args.empty? - raise CaskInvalidError.new(self.token, "'gpg' stanza may only appear once") + raise Hbc::CaskInvalidError.new(self.token, "'gpg' stanza may only appear once") end @gpg ||= begin - Cask::DSL::Gpg.new(*args) unless args.empty? + Hbc::DSL::Gpg.new(*args) unless args.empty? rescue StandardError => e - raise CaskInvalidError.new(self.token, e) + raise Hbc::CaskInvalidError.new(self.token, e) end end @@ -119,12 +119,12 @@ module Cask::DSL return @container if args.empty? if @container and !args.empty? # todo: remove this constraint, and instead merge multiple container stanzas - raise CaskInvalidError.new(self.token, "'container' stanza may only appear once") + raise Hbc::CaskInvalidError.new(self.token, "'container' stanza may only appear once") end @container ||= begin - Cask::DSL::Container.new(*args) unless args.empty? + Hbc::DSL::Container.new(*args) unless args.empty? rescue StandardError => e - raise CaskInvalidError.new(self.token, e) + raise Hbc::CaskInvalidError.new(self.token, e) end # todo: remove this backward-compatibility section after removing nested_container if @container and @container.nested @@ -141,9 +141,9 @@ module Cask::DSL if arg.nil? @version elsif @version - raise CaskInvalidError.new(self.token, "'version' stanza may only appear once") + raise Hbc::CaskInvalidError.new(self.token, "'version' stanza may only appear once") elsif !arg.is_a?(String) and !SYMBOLIC_VERSIONS.include?(arg) - raise CaskInvalidError.new(self.token, "invalid 'version' value: '#{arg.inspect}'") + raise Hbc::CaskInvalidError.new(self.token, "invalid 'version' value: '#{arg.inspect}'") end @version ||= arg end @@ -156,9 +156,9 @@ module Cask::DSL if arg.nil? @sha256 elsif @sha256 - raise CaskInvalidError.new(self.token, "'sha256' stanza may only appear once") + raise Hbc::CaskInvalidError.new(self.token, "'sha256' stanza may only appear once") elsif !arg.is_a?(String) and !SYMBOLIC_SHA256S.include?(arg) - raise CaskInvalidError.new(self.token, "invalid 'sha256' value: '#{arg.inspect}'") + raise Hbc::CaskInvalidError.new(self.token, "invalid 'sha256' value: '#{arg.inspect}'") end @sha256 ||= arg end @@ -167,35 +167,35 @@ module Cask::DSL return @tags if args.empty? if @tags and !args.empty? # consider removing this limitation - raise CaskInvalidError.new(self.token, "'tags' stanza may only appear once") + raise Hbc::CaskInvalidError.new(self.token, "'tags' stanza may only appear once") end @tags ||= begin - Cask::DSL::Tags.new(*args) unless args.empty? + Hbc::DSL::Tags.new(*args) unless args.empty? rescue StandardError => e - raise CaskInvalidError.new(self.token, e) + raise Hbc::CaskInvalidError.new(self.token, e) end end def license(arg=nil) return @license if arg.nil? if @license and !arg.nil? - raise CaskInvalidError.new(self.token, "'license' stanza may only appear once") + raise Hbc::CaskInvalidError.new(self.token, "'license' stanza may only appear once") end @license ||= begin - Cask::DSL::License.new(arg) unless arg.nil? + Hbc::DSL::License.new(arg) unless arg.nil? rescue StandardError => e - raise CaskInvalidError.new(self.token, e) + raise Hbc::CaskInvalidError.new(self.token, e) end end # depends_on uses a load method so that multiple stanzas can be merged def depends_on(*args) return @depends_on if args.empty? - @depends_on ||= Cask::DSL::DependsOn.new() + @depends_on ||= Hbc::DSL::DependsOn.new() begin @depends_on.load(*args) unless args.empty? rescue RuntimeError => e - raise CaskInvalidError.new(self.token, e) + raise Hbc::CaskInvalidError.new(self.token, e) end @depends_on end @@ -203,13 +203,13 @@ module Cask::DSL def conflicts_with(*args) if @conflicts_with and !args.empty? # todo: remove this constraint, and instead merge multiple conflicts_with stanzas - raise CaskInvalidError.new(self.token, "'conflicts_with' stanza may only appear once") + raise Hbc::CaskInvalidError.new(self.token, "'conflicts_with' stanza may only appear once") end return @conflicts_with if args.empty? @conflicts_with ||= begin - Cask::DSL::ConflictsWith.new(*args) unless args.empty? + Hbc::DSL::ConflictsWith.new(*args) unless args.empty? rescue StandardError => e - raise CaskInvalidError.new(self.token, e) + raise Hbc::CaskInvalidError.new(self.token, e) end end @@ -220,7 +220,7 @@ module Cask::DSL def caveats(*string, &block) @caveats ||= [] if block_given? - @caveats << Cask::Caveats.new(block) + @caveats << Hbc::Caveats.new(block) elsif string.any? @caveats << string.map{ |s| s.to_s.sub(/[\r\n \t]*\Z/, "\n\n") } else @@ -231,7 +231,7 @@ module Cask::DSL def accessibility_access(accessibility_access=nil) if @accessibility_access and !accessibility_access.nil? - raise CaskInvalidError.new(self.token, "'accessibility_access' stanza may only appear once") + raise Hbc::CaskInvalidError.new(self.token, "'accessibility_access' stanza may only appear once") end @accessibility_access ||= accessibility_access end @@ -263,13 +263,13 @@ module Cask::DSL ordinary_artifact_types.each do |type| define_method(type) do |*args| if type == :stage_only and args != [true] - raise CaskInvalidError.new(self.token, "'stage_only' takes a single argument: true") + raise Hbc::CaskInvalidError.new(self.token, "'stage_only' takes a single argument: true") end artifacts[type] << args if artifacts.key?(:stage_only) and artifacts.keys.count > 1 and - ! (artifacts.keys & Cask::DSL::ClassMethods.activatable_artifact_types).empty? - raise CaskInvalidError.new(self.token, "'stage_only' must be the only activatable artifact") + ! (artifacts.keys & Hbc::DSL::ClassMethods.activatable_artifact_types).empty? + raise Hbc::CaskInvalidError.new(self.token, "'stage_only' must be the only activatable artifact") end end end @@ -279,10 +279,10 @@ module Cask::DSL return artifacts[:installer] end begin - artifacts[:installer] << Cask::DSL::Installer.new(*args) + artifacts[:installer] << Hbc::DSL::Installer.new(*args) raise "'stage_only' must be the only activatable artifact" if artifacts.key?(:stage_only) rescue StandardError => e - raise CaskInvalidError.new(self.token, e) + raise Hbc::CaskInvalidError.new(self.token, e) end end @@ -311,7 +311,7 @@ module Cask::DSL end def method_missing(method, *args) - Cask::Utils.method_missing_message(method, self.token) + Hbc::Utils.method_missing_message(method, self.token) return nil end end diff --git a/lib/cask/dsl/appcast.rb b/lib/hbc/dsl/appcast.rb similarity index 90% rename from lib/cask/dsl/appcast.rb rename to lib/hbc/dsl/appcast.rb index 265aad780c..37d3d22f10 100644 --- a/lib/cask/dsl/appcast.rb +++ b/lib/hbc/dsl/appcast.rb @@ -1,4 +1,4 @@ -class Cask::DSL::Appcast +class Hbc::DSL::Appcast # todo :latest_version is considered experimental # and may be removed @@ -13,7 +13,7 @@ class Cask::DSL::Appcast def initialize(uri, parameters={}) @parameters = parameters - @uri = Cask::UnderscoreSupportingURI.parse(uri) + @uri = Hbc::UnderscoreSupportingURI.parse(uri) @sha256 = @parameters[:sha256] @latest_version = @parameters[:latest_version] # experimental @format = @parameters[:format] diff --git a/lib/cask/dsl/base.rb b/lib/hbc/dsl/base.rb similarity index 82% rename from lib/cask/dsl/base.rb rename to lib/hbc/dsl/base.rb index c0bd32b8ba..87d3d6ef79 100644 --- a/lib/cask/dsl/base.rb +++ b/lib/hbc/dsl/base.rb @@ -1,5 +1,5 @@ -class Cask::DSL::Base - def initialize(cask, command = Cask::SystemCommand) +class Hbc::DSL::Base + def initialize(cask, command = Hbc::SystemCommand) @cask = cask @command = command end diff --git a/lib/cask/dsl/conflicts_with.rb b/lib/hbc/dsl/conflicts_with.rb similarity index 95% rename from lib/cask/dsl/conflicts_with.rb rename to lib/hbc/dsl/conflicts_with.rb index 1f94eb0f61..05d5936264 100644 --- a/lib/cask/dsl/conflicts_with.rb +++ b/lib/hbc/dsl/conflicts_with.rb @@ -1,4 +1,4 @@ -class Cask::DSL::ConflictsWith +class Hbc::DSL::ConflictsWith VALID_KEYS = Set.new [ :formula, diff --git a/lib/cask/dsl/container.rb b/lib/hbc/dsl/container.rb similarity index 94% rename from lib/cask/dsl/container.rb rename to lib/hbc/dsl/container.rb index 716223885b..c86c60b78a 100644 --- a/lib/cask/dsl/container.rb +++ b/lib/hbc/dsl/container.rb @@ -1,4 +1,4 @@ -class Cask::DSL::Container +class Hbc::DSL::Container VALID_KEYS = Set.new [ :type, diff --git a/lib/cask/dsl/depends_on.rb b/lib/hbc/dsl/depends_on.rb similarity index 99% rename from lib/cask/dsl/depends_on.rb rename to lib/hbc/dsl/depends_on.rb index a4e54039a0..24b4ccfc7b 100644 --- a/lib/cask/dsl/depends_on.rb +++ b/lib/hbc/dsl/depends_on.rb @@ -1,6 +1,6 @@ require 'rubygems' -class Cask::DSL::DependsOn +class Hbc::DSL::DependsOn VALID_KEYS = Set.new [ :formula, diff --git a/lib/cask/dsl/gpg.rb b/lib/hbc/dsl/gpg.rb similarity index 81% rename from lib/cask/dsl/gpg.rb rename to lib/hbc/dsl/gpg.rb index 7ee3ef0e05..f36d664191 100644 --- a/lib/cask/dsl/gpg.rb +++ b/lib/hbc/dsl/gpg.rb @@ -1,4 +1,4 @@ -class Cask::DSL::Gpg +class Hbc::DSL::Gpg KEY_PARAMETERS = Set.new [ :key_id, @@ -13,11 +13,11 @@ class Cask::DSL::Gpg def initialize(signature, parameters={}) @parameters = parameters - @signature = Cask::UnderscoreSupportingURI.parse(signature) + @signature = Hbc::UnderscoreSupportingURI.parse(signature) parameters.each do |hkey, hvalue| raise "invalid 'gpg' parameter: '#{hkey.inspect}'" unless VALID_PARAMETERS.include?(hkey) writer_method = "#{hkey}=".to_sym - hvalue = Cask::UnderscoreSupportingURI.parse(hvalue) if hkey == :key_url + hvalue = Hbc::UnderscoreSupportingURI.parse(hvalue) if hkey == :key_url valid_id?(hvalue) if hkey == :key_id send(writer_method, hvalue) end @@ -35,7 +35,7 @@ class Cask::DSL::Gpg end def to_yaml - # bug, :key_url value is not represented as an instance of Cask::UnderscoreSupportingURI + # bug, :key_url value is not represented as an instance of Hbc::UnderscoreSupportingURI [@signature, @parameters].to_yaml end diff --git a/lib/cask/dsl/installer.rb b/lib/hbc/dsl/installer.rb similarity index 78% rename from lib/cask/dsl/installer.rb rename to lib/hbc/dsl/installer.rb index 07ee0d925a..24ec40e30f 100644 --- a/lib/cask/dsl/installer.rb +++ b/lib/hbc/dsl/installer.rb @@ -1,4 +1,4 @@ -class Cask::DSL::Installer +class Hbc::DSL::Installer VALID_KEYS = Set.new [ :manual, @@ -9,12 +9,12 @@ class Cask::DSL::Installer def initialize(*parameters) unless parameters.length > 0 - raise CaskInvalidError.new(self.token, "'installer' stanza requires an argument") + raise Hbc::CaskInvalidError.new(self.token, "'installer' stanza requires an argument") end parameters = Hash.new().merge(*parameters) if parameters.key?(:script) and ! parameters[:script].respond_to?(:key?) if parameters.key?(:executable) - raise CaskInvalidError.new(self.token, "'installer' stanza gave arguments for both :script and :executable") + raise Hbc::CaskInvalidError.new(self.token, "'installer' stanza gave arguments for both :script and :executable") end parameters[:executable] = parameters[:script] parameters.delete(:script) diff --git a/lib/cask/dsl/license.rb b/lib/hbc/dsl/license.rb similarity index 98% rename from lib/cask/dsl/license.rb rename to lib/hbc/dsl/license.rb index 390943a08b..cf888bb058 100644 --- a/lib/cask/dsl/license.rb +++ b/lib/hbc/dsl/license.rb @@ -1,4 +1,4 @@ -class Cask::DSL::License +class Hbc::DSL::License # a generic category can always be given as a license, so # category names should be given as both key and value diff --git a/lib/cask/dsl/postflight.rb b/lib/hbc/dsl/postflight.rb similarity index 71% rename from lib/cask/dsl/postflight.rb rename to lib/hbc/dsl/postflight.rb index c0eda165e7..d0ef29ea80 100644 --- a/lib/cask/dsl/postflight.rb +++ b/lib/hbc/dsl/postflight.rb @@ -1,7 +1,7 @@ -require 'cask/staged' +require 'hbc/staged' -class Cask::DSL::Postflight < Cask::DSL::Base - include Cask::Staged +class Hbc::DSL::Postflight < Hbc::DSL::Base + include Hbc::Staged def suppress_move_to_applications(options = {}) permitted_keys = [:key] @@ -13,12 +13,12 @@ class Cask::DSL::Postflight < Cask::DSL::Base begin @command.run!('/usr/bin/defaults', :args => ['write', bundle_identifier, key, '-bool', 'true']) rescue StandardError => e - raise CaskError.new("#{@cask.token}: 'suppress_move_to_applications' failed with: #{e}") + raise Hbc::CaskError.new("#{@cask.token}: 'suppress_move_to_applications' failed with: #{e}") end end def method_missing(method, *args) - Cask::Utils.method_missing_message(method, @cask.to_s, 'postflight') + Hbc::Utils.method_missing_message(method, @cask.to_s, 'postflight') return nil end end diff --git a/lib/hbc/dsl/preflight.rb b/lib/hbc/dsl/preflight.rb new file mode 100644 index 0000000000..7fbdd30adb --- /dev/null +++ b/lib/hbc/dsl/preflight.rb @@ -0,0 +1,6 @@ +class Hbc::DSL::Preflight < Hbc::DSL::Base + def method_missing(method, *args) + Hbc::Utils.method_missing_message(method, @cask.to_s, 'preflight') + return nil + end +end diff --git a/lib/cask/dsl/tags.rb b/lib/hbc/dsl/tags.rb similarity index 96% rename from lib/cask/dsl/tags.rb rename to lib/hbc/dsl/tags.rb index 59d9f68eb3..9f222027a7 100644 --- a/lib/cask/dsl/tags.rb +++ b/lib/hbc/dsl/tags.rb @@ -1,4 +1,4 @@ -class Cask::DSL::Tags +class Hbc::DSL::Tags # In the future we may want a different data structure # here to store limitations/validations on tag values. diff --git a/lib/hbc/dsl/uninstall_postflight.rb b/lib/hbc/dsl/uninstall_postflight.rb new file mode 100644 index 0000000000..2af945418b --- /dev/null +++ b/lib/hbc/dsl/uninstall_postflight.rb @@ -0,0 +1,6 @@ +class Hbc::DSL::UninstallPostflight < Hbc::DSL::Base + def method_missing(method, *args) + Hbc::Utils.method_missing_message(method, @cask.to_s, 'uninstall_postflight') + return nil + end +end diff --git a/lib/hbc/dsl/uninstall_preflight.rb b/lib/hbc/dsl/uninstall_preflight.rb new file mode 100644 index 0000000000..0d4e0d33f9 --- /dev/null +++ b/lib/hbc/dsl/uninstall_preflight.rb @@ -0,0 +1,10 @@ +require 'hbc/staged' + +class Hbc::DSL::UninstallPreflight < Hbc::DSL::Base + include Hbc::Staged + + def method_missing(method, *args) + Hbc::Utils.method_missing_message(method, @cask.to_s, 'uninstall_preflight') + return nil + end +end diff --git a/lib/cask/exceptions.rb b/lib/hbc/exceptions.rb similarity index 77% rename from lib/cask/exceptions.rb rename to lib/hbc/exceptions.rb index 0f708d537d..ae7e3c7a46 100644 --- a/lib/cask/exceptions.rb +++ b/lib/hbc/exceptions.rb @@ -1,6 +1,6 @@ -class CaskError < RuntimeError; end +class Hbc::CaskError < RuntimeError; end -class CaskNotInstalledError < CaskError +class Hbc::CaskNotInstalledError < Hbc::CaskError attr_reader :token def initialize(token) @token = token @@ -11,7 +11,7 @@ class CaskNotInstalledError < CaskError end end -class CaskUnavailableError < CaskError +class Hbc::CaskUnavailableError < Hbc::CaskError attr_reader :token def initialize(token) @token = token @@ -22,7 +22,7 @@ class CaskUnavailableError < CaskError end end -class CaskAlreadyCreatedError < CaskError +class Hbc::CaskAlreadyCreatedError < Hbc::CaskError attr_reader :token def initialize(token) @token = token @@ -33,7 +33,7 @@ class CaskAlreadyCreatedError < CaskError end end -class CaskAlreadyInstalledError < CaskError +class Hbc::CaskAlreadyInstalledError < Hbc::CaskError attr_reader :token def initialize(token) @token = token @@ -44,7 +44,7 @@ class CaskAlreadyInstalledError < CaskError end end -class CaskCommandFailedError < CaskError +class Hbc::CaskCommandFailedError < Hbc::CaskError def initialize(cmd, output, status) @cmd = cmd @output = output @@ -67,7 +67,7 @@ Command failed to execute! end end -class CaskX11DependencyError < CaskError +class Hbc::CaskX11DependencyError < Hbc::CaskError attr_reader :token def initialize(token) @token = token @@ -86,7 +86,7 @@ class CaskX11DependencyError < CaskError end end -class CaskCyclicCaskDependencyError < CaskError +class Hbc::CaskCyclicCaskDependencyError < Hbc::CaskError attr_reader :token def initialize(token) @token = token @@ -97,13 +97,13 @@ class CaskCyclicCaskDependencyError < CaskError end end -class CaskUnspecifiedError < CaskError +class Hbc::CaskUnspecifiedError < Hbc::CaskError def to_s "This command requires a Cask token" end end -class CaskInvalidError < CaskError +class Hbc::CaskInvalidError < Hbc::CaskError attr_reader :token, :submsg def initialize(token, *submsg) @token = token @@ -115,10 +115,10 @@ class CaskInvalidError < CaskError end end -class CaskSha256MissingError < ArgumentError +class Hbc::CaskSha256MissingError < ArgumentError end -class CaskSha256MismatchError < RuntimeError +class Hbc::CaskSha256MismatchError < RuntimeError attr_reader :path, :expected, :actual def initialize(path, expected, actual) @path = path diff --git a/lib/hbc/extend.rb b/lib/hbc/extend.rb new file mode 100644 index 0000000000..8792a92937 --- /dev/null +++ b/lib/hbc/extend.rb @@ -0,0 +1,4 @@ +# monkeypatching +require 'hbc/extend/hash' +require 'hbc/extend/string' +require 'hbc/extend/pathname' diff --git a/lib/cask/extend/hash.rb b/lib/hbc/extend/hash.rb similarity index 54% rename from lib/cask/extend/hash.rb rename to lib/hbc/extend/hash.rb index 204ea3c89c..14d4cb601b 100644 --- a/lib/cask/extend/hash.rb +++ b/lib/hbc/extend/hash.rb @@ -2,7 +2,7 @@ class Hash def assert_valid_keys(*valid_keys) unknown_keys = self.keys - valid_keys unless unknown_keys.empty? - raise CaskError.new %Q{Unknown keys: #{unknown_keys.inspect}. Running "#{UPDATE_CMD}" will likely fix it.} + raise Hbc::CaskError.new %Q{Unknown keys: #{unknown_keys.inspect}. Running "#{UPDATE_CMD}" will likely fix it.} end end end diff --git a/lib/cask/extend/pathname.rb b/lib/hbc/extend/pathname.rb similarity index 100% rename from lib/cask/extend/pathname.rb rename to lib/hbc/extend/pathname.rb diff --git a/lib/cask/extend/string.rb b/lib/hbc/extend/string.rb similarity index 100% rename from lib/cask/extend/string.rb rename to lib/hbc/extend/string.rb diff --git a/lib/cask/fetcher.rb b/lib/hbc/fetcher.rb similarity index 92% rename from lib/cask/fetcher.rb rename to lib/hbc/fetcher.rb index 132fd0bf9d..1354e4a578 100644 --- a/lib/cask/fetcher.rb +++ b/lib/hbc/fetcher.rb @@ -1,13 +1,13 @@ require 'open3' -class Cask::Fetcher +class Hbc::Fetcher TIMEOUT = 10 def self.head(url) if url.to_s =~ /googlecode/ googlecode_fake_head(url) else - Cask::SystemCommand.run("curl", + Hbc::SystemCommand.run("curl", :args => ["--max-time", TIMEOUT, "--silent", "--location", "--head", url]).stdout end end diff --git a/lib/cask/gpg_check.rb b/lib/hbc/gpg_check.rb similarity index 94% rename from lib/cask/gpg_check.rb rename to lib/hbc/gpg_check.rb index 0cddcd8884..ba11ec551a 100644 --- a/lib/cask/gpg_check.rb +++ b/lib/hbc/gpg_check.rb @@ -1,7 +1,7 @@ -class Cask::GpgCheck +class Hbc::GpgCheck attr_reader :available - def initialize(cask, command=Cask::SystemCommand) + def initialize(cask, command=Hbc::SystemCommand) @command = command @cask = cask @available = @cask.gpg ? installed? : false diff --git a/lib/hbc/hardware.rb b/lib/hbc/hardware.rb new file mode 100644 index 0000000000..451967ecda --- /dev/null +++ b/lib/hbc/hardware.rb @@ -0,0 +1,3 @@ +module Hbc::Hardware; end + +require 'hbc/hardware/cpu' diff --git a/lib/cask/hardware/cpu.rb b/lib/hbc/hardware/cpu.rb similarity index 95% rename from lib/cask/hardware/cpu.rb rename to lib/hbc/hardware/cpu.rb index 7d6eae6e3e..828317bf8d 100644 --- a/lib/cask/hardware/cpu.rb +++ b/lib/hbc/hardware/cpu.rb @@ -1,6 +1,6 @@ # originally from Homebrew -module Cask::Hardware::CPU +module Hbc::Hardware::CPU extend self def is_32_bit? diff --git a/lib/cask/installer.rb b/lib/hbc/installer.rb similarity index 81% rename from lib/cask/installer.rb rename to lib/hbc/installer.rb index 784730920b..b3c50d0c3f 100644 --- a/lib/cask/installer.rb +++ b/lib/hbc/installer.rb @@ -1,19 +1,20 @@ require 'rubygems' -require 'cask/cask_dependencies' -require 'cask/staged' -class Cask::Installer +require 'hbc/cask_dependencies' +require 'hbc/staged' - # todo: it is unwise for Cask::Staged to be a module, when we are +class Hbc::Installer + + # todo: it is unwise for Hbc::Staged to be a module, when we are # dealing with both staged and unstaged Casks here. This should # either be a class which is only sometimes instantiated, or there # should be explicit checks on whether staged state is valid in # every method. - include Cask::Staged + include Hbc::Staged PERSISTENT_METADATA_SUBDIRS = [ 'gpg' ] - def initialize(cask, command=Cask::SystemCommand) + def initialize(cask, command=Hbc::SystemCommand) @cask = cask @command = command end @@ -48,9 +49,9 @@ class Cask::Installer end def install(force=false, skip_cask_deps=false) - odebug "Cask::Installer.install" + odebug "Hbc::Installer.install" if @cask.installed? && !force - raise CaskAlreadyInstalledError.new(@cask) + raise Hbc::CaskAlreadyInstalledError.new(@cask) end print_caveats @@ -76,12 +77,12 @@ class Cask::Installer else "#{Tty.blue.bold}==>#{Tty.white} Success!#{Tty.reset} " end - s << "#{@cask} staged at '#{@cask.staged_path}' (#{Cask::Utils.cabv(@cask.staged_path)})" + s << "#{@cask} staged at '#{@cask.staged_path}' (#{Hbc::Utils.cabv(@cask.staged_path)})" end def download odebug "Downloading" - download = Cask::Download.new(@cask) + download = Hbc::Download.new(@cask) @downloaded_path = download.perform odebug "Downloaded to -> #{@downloaded_path}" @downloaded_path @@ -91,12 +92,12 @@ class Cask::Installer odebug "Extracting primary container" FileUtils.mkdir_p @cask.staged_path container = if @cask.container and @cask.container.type - Cask::Container.from_type(@cask.container.type) + Hbc::Container.from_type(@cask.container.type) else - Cask::Container.for_path(@downloaded_path, @command) + Hbc::Container.for_path(@downloaded_path, @command) end unless container - raise CaskError.new "Uh oh, could not identify primary container for '#{@downloaded_path}'" + raise Hbc::CaskError.new "Uh oh, could not identify primary container for '#{@downloaded_path}'" end odebug "Using container class #{container} for #{@downloaded_path}" container.new(@cask, @downloaded_path, @command).extract @@ -104,7 +105,7 @@ class Cask::Installer def install_artifacts odebug "Installing artifacts" - artifacts = Cask::Artifact.for_cask(@cask) + artifacts = Hbc::Artifact.for_cask(@cask) odebug "#{artifacts.length} artifact/s defined", artifacts artifacts.each do |artifact| odebug "Installing artifact of class #{artifact}" @@ -132,15 +133,15 @@ class Cask::Installer if @cask.depends_on.macos.first.is_a?(Array) operator, release = @cask.depends_on.macos.first unless MacOS.release.send(operator, release) - raise CaskError.new "Cask #{@cask} depends on OS X release #{operator} #{release}, but you are running release #{MacOS.release}." + raise Hbc::CaskError.new "Cask #{@cask} depends on OS X release #{operator} #{release}, but you are running release #{MacOS.release}." end elsif @cask.depends_on.macos.length > 1 unless @cask.depends_on.macos.include?(Gem::Version.new(MacOS.release.to_s)) - raise CaskError.new "Cask #{@cask} depends on OS X release being one of: #{@cask.depends_on.macos(&:to_s).inspect}, but you are running release #{MacOS.release}." + raise Hbc::CaskError.new "Cask #{@cask} depends on OS X release being one of: #{@cask.depends_on.macos(&:to_s).inspect}, but you are running release #{MacOS.release}." end else unless MacOS.release == @cask.depends_on.macos.first - raise CaskError.new "Cask #{@cask} depends on OS X release #{@cask.depends_on.macos.first}, but you are running release #{MacOS.release}." + raise Hbc::CaskError.new "Cask #{@cask} depends on OS X release #{@cask.depends_on.macos.first}, but you are running release #{MacOS.release}." end end end @@ -154,13 +155,13 @@ class Cask::Installer (Hardware::CPU.intel? ? :x86_64 : :ppc_64) ] return unless Array(@cask.depends_on.arch & @current_arch).empty? - raise CaskError.new "Cask #{@cask} depends on hardware architecture being one of #{@cask.depends_on.arch.inspect}, but you are running #{@current_arch.inspect}" + raise Hbc::CaskError.new "Cask #{@cask} depends on hardware architecture being one of #{@cask.depends_on.arch.inspect}, but you are running #{@current_arch.inspect}" end def x11_dependencies return unless @cask.depends_on.x11 - if Cask.x11_libpng.select(&:exist?).empty? - raise CaskX11DependencyError.new(@cask.token) + if Hbc.x11_libpng.select(&:exist?).empty? + raise Hbc::CaskX11DependencyError.new(@cask.token) end end @@ -185,14 +186,14 @@ class Cask::Installer def cask_dependencies return unless @cask.depends_on.cask and not @cask.depends_on.cask.empty? ohai "Installing Cask dependencies: #{@cask.depends_on.cask.join(', ')}" - deps = Cask::CaskDependencies.new(@cask) + deps = Hbc::CaskDependencies.new(@cask) deps.sorted.each do |dep_token| puts "#{dep_token} ..." - dep = Cask.load(dep_token) + dep = Hbc.load(dep_token) if dep.installed? puts "already installed" else - Cask::Installer.new(dep).install(false, true) + Hbc::Installer.new(dep).install(false, true) puts "done" end end @@ -209,13 +210,13 @@ class Cask::Installer if MacOS.release >= :mavericks @command.run!('/usr/bin/sqlite3', :args => [ - Cask.tcc_db, + Hbc.tcc_db, "INSERT INTO access VALUES('kTCCServiceAccessibility','#{bundle_identifier}',0,1,1,NULL);", ], :sudo => true) else @command.run!('/usr/bin/touch', - :args => [Cask.pre_mavericks_accessibility_dotfile], + :args => [Hbc.pre_mavericks_accessibility_dotfile], :sudo => true) end end @@ -226,7 +227,7 @@ class Cask::Installer ohai 'Disabling accessibility access' @command.run!('/usr/bin/sqlite3', :args => [ - Cask.tcc_db, + Hbc.tcc_db, "DELETE FROM access WHERE client='#{bundle_identifier}';", ], :sudo => true) @@ -248,14 +249,14 @@ class Cask::Installer savedir.rmtree FileUtils.mkdir_p savedir else - raise CaskAlreadyInstalledError.new(@cask) + raise Hbc::CaskAlreadyInstalledError.new(@cask) end end FileUtils.copy(@cask.sourcefile_path, savedir) if @cask.sourcefile_path end def uninstall(force=false) - odebug "Cask::Installer.uninstall" + odebug "Hbc::Installer.uninstall" disable_accessibility_access uninstall_artifacts purge_versioned_files @@ -264,7 +265,7 @@ class Cask::Installer def uninstall_artifacts odebug "Un-installing artifacts" - artifacts = Cask::Artifact.for_cask(@cask) + artifacts = Hbc::Artifact.for_cask(@cask) odebug "#{artifacts.length} artifact/s defined", artifacts artifacts.each do |artifact| odebug "Un-installing artifact of class #{artifact}" @@ -275,9 +276,9 @@ class Cask::Installer def zap ohai %Q{Implied "brew cask uninstall #{@cask}"} uninstall_artifacts - if Cask::Artifact::Zap.me?(@cask) + if Hbc::Artifact::Zap.me?(@cask) ohai "Dispatching zap stanza" - Cask::Artifact::Zap.new(@cask, @command).zap_phase + Hbc::Artifact::Zap.new(@cask, @command).zap_phase else opoo "No zap stanza present for Cask '#{@cask}'" end @@ -336,11 +337,11 @@ class Cask::Installer permissions_rmtree subdir unless PERSISTENT_METADATA_SUBDIRS.include?(subdir.basename) end end - Cask::Utils.rmdir_if_possible(@cask.metadata_versioned_container_path) - Cask::Utils.rmdir_if_possible(@cask.metadata_master_container_path) + Hbc::Utils.rmdir_if_possible(@cask.metadata_versioned_container_path) + Hbc::Utils.rmdir_if_possible(@cask.metadata_master_container_path) # toplevel staged distribution - Cask::Utils.rmdir_if_possible(@cask.caskroom_path) + Hbc::Utils.rmdir_if_possible(@cask.caskroom_path) end def purge_caskroom_path diff --git a/lib/cask/locations.rb b/lib/hbc/locations.rb similarity index 99% rename from lib/cask/locations.rb rename to lib/hbc/locations.rb index 96c7fa18a2..257e5da052 100644 --- a/lib/cask/locations.rb +++ b/lib/hbc/locations.rb @@ -1,4 +1,4 @@ -module Cask::Locations +module Hbc::Locations def self.included(base) base.extend(ClassMethods) end diff --git a/lib/cask/macos.rb b/lib/hbc/macos.rb similarity index 79% rename from lib/cask/macos.rb rename to lib/hbc/macos.rb index 7a46467359..9d5ac0d4ed 100644 --- a/lib/cask/macos.rb +++ b/lib/hbc/macos.rb @@ -1,8 +1,8 @@ # originally from Homebrew -require 'cask/macos/release' +require 'hbc/macos/release' -module Cask::MacOS +module Hbc::MacOS extend self # This Comparable instance can be compared to numerics, strings, or symbols diff --git a/lib/cask/macos/release.rb b/lib/hbc/macos/release.rb similarity index 97% rename from lib/cask/macos/release.rb rename to lib/hbc/macos/release.rb index 4cfd0a4001..ad1ef74b10 100644 --- a/lib/cask/macos/release.rb +++ b/lib/hbc/macos/release.rb @@ -2,7 +2,7 @@ require 'rubygems' -module Cask::MacOS +module Hbc::MacOS class Release include Comparable diff --git a/lib/cask/options.rb b/lib/hbc/options.rb similarity index 96% rename from lib/cask/options.rb rename to lib/hbc/options.rb index b6fb9ebd9c..ec236bf9af 100644 --- a/lib/cask/options.rb +++ b/lib/hbc/options.rb @@ -1,4 +1,4 @@ -module Cask::Options +module Hbc::Options def self.included(base) base.extend(ClassMethods) end diff --git a/lib/cask/pkg.rb b/lib/hbc/pkg.rb similarity index 99% rename from lib/cask/pkg.rb rename to lib/hbc/pkg.rb index 3605e839d0..3e7805bd85 100644 --- a/lib/cask/pkg.rb +++ b/lib/hbc/pkg.rb @@ -1,4 +1,4 @@ -class Cask::Pkg +class Hbc::Pkg SYSTEM_DIRS = [ '/', '/Applications', @@ -234,7 +234,7 @@ class Cask::Pkg attr_reader :package_id - def initialize(package_id, command=Cask::SystemCommand) + def initialize(package_id, command=Hbc::SystemCommand) @package_id = package_id @command = command end diff --git a/lib/cask/pretty_listing.rb b/lib/hbc/pretty_listing.rb similarity index 88% rename from lib/cask/pretty_listing.rb rename to lib/hbc/pretty_listing.rb index 7224034f66..ed4bb5bc86 100644 --- a/lib/cask/pretty_listing.rb +++ b/lib/hbc/pretty_listing.rb @@ -1,4 +1,4 @@ -class Cask::PrettyListing +class Hbc::PrettyListing attr_reader :cask def initialize(cask) @cask = cask diff --git a/lib/cask/qualified_token.rb b/lib/hbc/qualified_token.rb similarity index 98% rename from lib/cask/qualified_token.rb rename to lib/hbc/qualified_token.rb index d662ded1d2..977681395c 100644 --- a/lib/cask/qualified_token.rb +++ b/lib/hbc/qualified_token.rb @@ -1,4 +1,4 @@ -module Cask::QualifiedToken +module Hbc::QualifiedToken def self.repo_prefix 'homebrew-' end diff --git a/lib/cask/scopes.rb b/lib/hbc/scopes.rb similarity index 80% rename from lib/cask/scopes.rb rename to lib/hbc/scopes.rb index 5996cdf405..7735cdeb57 100644 --- a/lib/cask/scopes.rb +++ b/lib/hbc/scopes.rb @@ -1,4 +1,4 @@ -module Cask::Scopes +module Hbc::Scopes def self.included(base) base.extend(ClassMethods) end @@ -42,19 +42,19 @@ module Cask::Scopes def installed installed_cask_dirs = Pathname.glob(caskroom.join("*")) - # Cask.load has some DWIM which is slow. Optimize here - # by spoon-feeding Cask.load fully-qualified paths. - # todo: speed up Cask::Source::Tapped (main perf drag is calling Cask.all_tokens repeatedly) - # todo: ability to specify expected source when calling Cask.load (minor perf benefit) + # Hbc.load has some DWIM which is slow. Optimize here + # by spoon-feeding Hbc.load fully-qualified paths. + # todo: speed up Hbc::Source::Tapped (main perf drag is calling Hbc.all_tokens repeatedly) + # todo: ability to specify expected source when calling Hbc.load (minor perf benefit) installed_cask_dirs.map do |install_dir| cask_token = install_dir.basename.to_s path_to_cask = all_tapped_cask_dirs.find do |tap_dir| tap_dir.join("#{cask_token}.rb").exist? end if path_to_cask - Cask.load(path_to_cask.join("#{cask_token}.rb")) + Hbc.load(path_to_cask.join("#{cask_token}.rb")) else - Cask.load(cask_token) + Hbc.load(cask_token) end end end diff --git a/lib/hbc/source.rb b/lib/hbc/source.rb new file mode 100644 index 0000000000..8a1c65dfb4 --- /dev/null +++ b/lib/hbc/source.rb @@ -0,0 +1,36 @@ +module Hbc::Source; end + +require 'hbc/source/gone' +require 'hbc/source/path_slash_required' +require 'hbc/source/path_slash_optional' +require 'hbc/source/tapped_qualified' +require 'hbc/source/untapped_qualified' +require 'hbc/source/tapped' +require 'hbc/source/uri' + +module Hbc::Source + def self.sources + [ + Hbc::Source::URI, + Hbc::Source::PathSlashRequired, + Hbc::Source::TappedQualified, + Hbc::Source::UntappedQualified, + Hbc::Source::Tapped, + Hbc::Source::PathSlashOptional, + Hbc::Source::Gone, + ] + end + + def self.for_query(query) + odebug "Translating '#{query}' into a valid Cask source" + source = sources.find do |s| + odebug "Testing source class #{s}" + s.me?(query) + end + raise Hbc::CaskUnavailableError.new(query) unless source + odebug "Success! Using source class #{source}" + resolved_cask_source = source.new(query) + odebug "Resolved Cask URI or file source to '#{resolved_cask_source}'" + resolved_cask_source + end +end diff --git a/lib/cask/source/gone.rb b/lib/hbc/source/gone.rb similarity index 58% rename from lib/cask/source/gone.rb rename to lib/hbc/source/gone.rb index bfb13d8a3a..da7396b302 100644 --- a/lib/cask/source/gone.rb +++ b/lib/hbc/source/gone.rb @@ -1,6 +1,6 @@ -class Cask::Source::Gone +class Hbc::Source::Gone def self.me?(query) - Cask::WithoutSource.new(query).installed? + Hbc::WithoutSource.new(query).installed? end attr_reader :query @@ -10,7 +10,7 @@ class Cask::Source::Gone end def load - Cask::WithoutSource.new(query) + Hbc::WithoutSource.new(query) end def to_s diff --git a/lib/cask/source/path_base.rb b/lib/hbc/source/path_base.rb similarity index 69% rename from lib/cask/source/path_base.rb rename to lib/hbc/source/path_base.rb index be8125271c..d96f67e72c 100644 --- a/lib/cask/source/path_base.rb +++ b/lib/hbc/source/path_base.rb @@ -1,6 +1,6 @@ require 'rubygems' -class Cask::Source::PathBase +class Hbc::Source::PathBase # derived classes must define method self.me? @@ -17,9 +17,9 @@ class Cask::Source::PathBase end def load - raise CaskError.new "File '#{path}' does not exist" unless path.exist? - raise CaskError.new "File '#{path}' is not readable" unless path.readable? - raise CaskError.new "File '#{path}' is not a plain file" unless path.file? + raise Hbc::CaskError.new "File '#{path}' does not exist" unless path.exist? + raise Hbc::CaskError.new "File '#{path}' is not readable" unless path.readable? + raise Hbc::CaskError.new "File '#{path}' is not a plain file" unless path.file? begin # transitional hack: convert first lines of the new form @@ -28,7 +28,7 @@ class Cask::Source::PathBase # # to the old form # - # class GoogleChrome < Cask + # class GoogleChrome < Hbc (class GoogleChrome < Cask) # # limitation: does not support Ruby extended quoting such as %Q{} # @@ -51,18 +51,18 @@ class Cask::Source::PathBase is_test = ! $2.nil? header_token = $4 dsl_version = Gem::Version.new(dsl_version_string.gsub('_','.')) - superclass_name = is_test ? 'TestCask' : 'Cask' + superclass_name = is_test ? 'TestHbc' : 'Hbc' cask_contents.sub!(%r{\A[^\n]+\n}, "class #{cask_class_name} < #{superclass_name}\n") # todo the minimum DSL version should be defined globally elsewhere minimum_dsl_version = Gem::Version.new('1.0') unless dsl_version >= minimum_dsl_version - raise CaskInvalidError.new(cask_token, "Bad header line: 'v#{dsl_version_string}' is less than required minimum version '#{minimum_dsl_version}'") + raise Hbc::CaskInvalidError.new(cask_token, "Bad header line: 'v#{dsl_version_string}' is less than required minimum version '#{minimum_dsl_version}'") end if header_token != cask_token - raise CaskInvalidError.new(cask_token, "Bad header line: '#{header_token}' does not match file name") + raise Hbc::CaskInvalidError.new(cask_token, "Bad header line: '#{header_token}' does not match file name") end else - raise CaskInvalidError.new(cask_token, "Bad header line: parse failed") + raise Hbc::CaskInvalidError.new(cask_token, "Bad header line: parse failed") end # simulate "require" @@ -72,15 +72,15 @@ class Cask::Source::PathBase eval(cask_contents, TOPLEVEL_BINDING) end - rescue CaskError, StandardError, ScriptError => e - # bug: e.message.concat doesn't work with CaskError exceptions + rescue Hbc::CaskError, StandardError, ScriptError => e + # bug: e.message.concat doesn't work with Hbc::CaskError exceptions e.message.concat(" while loading '#{path}'") raise e end begin Object.const_get(cask_class_name).new(path) - rescue CaskError, StandardError, ScriptError => e - # bug: e.message.concat doesn't work with CaskError exceptions + rescue Hbc::CaskError, StandardError, ScriptError => e + # bug: e.message.concat doesn't work with Hbc::CaskError exceptions e.message.concat(" while instantiating '#{cask_class_name}' from '#{path}'") raise e end diff --git a/lib/hbc/source/path_slash_optional.rb b/lib/hbc/source/path_slash_optional.rb new file mode 100644 index 0000000000..72431d2ea2 --- /dev/null +++ b/lib/hbc/source/path_slash_optional.rb @@ -0,0 +1,8 @@ +require 'hbc/source/path_base' + +class Hbc::Source::PathSlashOptional < Hbc::Source::PathBase + def self.me?(query) + path = self.path_for_query(query) + path.exist? + end +end diff --git a/lib/cask/source/path_slash_required.rb b/lib/hbc/source/path_slash_required.rb similarity index 54% rename from lib/cask/source/path_slash_required.rb rename to lib/hbc/source/path_slash_required.rb index 2e4ff6eabc..47fe36b2c1 100644 --- a/lib/cask/source/path_slash_required.rb +++ b/lib/hbc/source/path_slash_required.rb @@ -1,6 +1,6 @@ -require 'cask/source/path_base' +require 'hbc/source/path_base' -class Cask::Source::PathSlashRequired < Cask::Source::PathBase +class Hbc::Source::PathSlashRequired < Hbc::Source::PathBase def self.me?(query) path = self.path_for_query(query) path.to_s.include?('/') and path.exist? diff --git a/lib/cask/source/tapped.rb b/lib/hbc/source/tapped.rb similarity index 62% rename from lib/cask/source/tapped.rb rename to lib/hbc/source/tapped.rb index cf4e17f125..d1b2f6a870 100644 --- a/lib/cask/source/tapped.rb +++ b/lib/hbc/source/tapped.rb @@ -1,19 +1,19 @@ -class Cask::Source::Tapped +class Hbc::Source::Tapped def self.me?(query) path_for_query(query).exist? end def self.path_for_query(query) - # Repeating Cask.all_tokens is very slow for operations such as + # Repeating Hbc.all_tokens is very slow for operations such as # brew cask list, but memoizing the value might cause breakage # elsewhere, given that installation and tap status is permitted # to change during the course of an invocation. - token_with_tap = Cask.all_tokens.find { |t| t.split('/').last == query.sub(/\.rb$/i,'') } + token_with_tap = Hbc.all_tokens.find { |t| t.split('/').last == query.sub(/\.rb$/i,'') } if token_with_tap user, repo, token = token_with_tap.split('/') - Cask.tapspath.join(user, repo, 'Casks', "#{token}.rb") + Hbc.tapspath.join(user, repo, 'Casks', "#{token}.rb") else - Cask.tapspath.join(Cask.default_tap, 'Casks', "#{query.sub(/\.rb$/i,'')}.rb") + Hbc.tapspath.join(Hbc.default_tap, 'Casks', "#{query.sub(/\.rb$/i,'')}.rb") end end @@ -25,7 +25,7 @@ class Cask::Source::Tapped def load path = self.class.path_for_query(token) - Cask::Source::PathSlashOptional.new(path).load + Hbc::Source::PathSlashOptional.new(path).load end def to_s diff --git a/lib/hbc/source/tapped_qualified.rb b/lib/hbc/source/tapped_qualified.rb new file mode 100644 index 0000000000..1ffbaae8ab --- /dev/null +++ b/lib/hbc/source/tapped_qualified.rb @@ -0,0 +1,14 @@ +require 'hbc/source/tapped' + +class Hbc::Source::TappedQualified < Hbc::Source::Tapped + def self.me?(query) + !!Hbc::QualifiedToken::parse(query) and path_for_query(query).exist? + end + + def self.path_for_query(query) + user, repo, token = Hbc::QualifiedToken::parse(query) + token.sub!(/\.rb$/i,'') + tap = "#{user}/homebrew-#{repo}" + Hbc.tapspath.join(tap, 'Casks', "#{token}.rb") + end +end diff --git a/lib/hbc/source/untapped_qualified.rb b/lib/hbc/source/untapped_qualified.rb new file mode 100644 index 0000000000..64a086fbb7 --- /dev/null +++ b/lib/hbc/source/untapped_qualified.rb @@ -0,0 +1,17 @@ +require 'hbc/source/tapped_qualified' + +class Hbc::Source::UntappedQualified < Hbc::Source::TappedQualified + def self.path_for_query(query) + user, repo, token = Hbc::QualifiedToken::parse(query) + token.sub!(/\.rb$/i,'') + tap = "#{user}/homebrew-#{repo}" + unless Hbc.tapspath.join(tap).exist? + ohai "Adding new tap '#{tap}'" + result = Hbc::SystemCommand.run!(HOMEBREW_BREW_FILE, + :args => ['tap', "#{user}/#{repo}"]) + puts result.stdout + $stderr.puts result.stderr + end + Hbc.tapspath.join(tap, 'Casks', "#{token}.rb") + end +end diff --git a/lib/cask/source/uri.rb b/lib/hbc/source/uri.rb similarity index 71% rename from lib/cask/source/uri.rb rename to lib/hbc/source/uri.rb index 3f6dffe9b6..4435e61310 100644 --- a/lib/cask/source/uri.rb +++ b/lib/hbc/source/uri.rb @@ -1,4 +1,4 @@ -class Cask::Source::URI +class Hbc::Source::URI def self.me?(query) !!(query.to_s =~ URI.regexp) end @@ -16,10 +16,10 @@ class Cask::Source::URI odebug "Download target -> #{path.to_s}" begin curl(uri, '-o', path.to_s) - rescue ErrorDuringExecution - raise CaskUnavailableError.new uri + rescue Hbc::ErrorDuringExecution + raise Hbc::CaskUnavailableError.new uri end - Cask::Source::PathSlashOptional.new(path).load + Hbc::Source::PathSlashOptional.new(path).load end def to_s diff --git a/lib/cask/staged.rb b/lib/hbc/staged.rb similarity index 76% rename from lib/cask/staged.rb rename to lib/hbc/staged.rb index 54a518e489..24f9cb9b7f 100644 --- a/lib/cask/staged.rb +++ b/lib/hbc/staged.rb @@ -1,4 +1,4 @@ -module Cask::Staged +module Hbc::Staged def info_plist_file(index = 0) index = 0 if index == :first index = 1 if index == :second @@ -14,7 +14,7 @@ module Cask::Staged begin plist_exec("Set #{key} #{value}") rescue StandardError => e - raise CaskError.new("#{@cask.token}: 'plist_set' failed with: #{e}") + raise Hbc::CaskError.new("#{@cask.token}: 'plist_set' failed with: #{e}") end end @@ -22,7 +22,7 @@ module Cask::Staged begin plist_exec('Print CFBundleIdentifier').stdout.chomp rescue StandardError => e - raise CaskError.new("#{@cask.token}: 'bundle_identifier' failed with: #{e}") + raise Hbc::CaskError.new("#{@cask.token}: 'bundle_identifier' failed with: #{e}") end end end diff --git a/lib/cask/system_command.rb b/lib/hbc/system_command.rb similarity index 87% rename from lib/cask/system_command.rb rename to lib/hbc/system_command.rb index 31eb607ee7..edd0346ebc 100644 --- a/lib/cask/system_command.rb +++ b/lib/hbc/system_command.rb @@ -1,6 +1,6 @@ require 'open3' -class Cask::SystemCommand +class Hbc::SystemCommand def self.run(executable, options={}) command = _process_options(executable, options) odebug "Executing: #{command.utf8_inspect}" @@ -32,7 +32,7 @@ class Cask::SystemCommand _assert_success(processed_status, command, processed_stdout) if options[:must_succeed] - Cask::SystemCommand::Result.new(command, processed_stdout, processed_stderr, processed_status.exitstatus) + Hbc::SystemCommand::Result.new(command, processed_stdout, processed_stderr, processed_status.exitstatus) end def self.run!(command, options={}) @@ -53,12 +53,12 @@ class Cask::SystemCommand def self._assert_success(status, command, output) unless status and status.success? - raise CaskCommandFailedError.new(command.utf8_inspect, output, status) + raise Hbc::CaskCommandFailedError.new(command.utf8_inspect, output, status) end end end -class Cask::SystemCommand::Result +class Hbc::SystemCommand::Result attr_accessor :command, :stdout, :stderr, :exit_status @@ -95,14 +95,14 @@ class Cask::SystemCommand::Result def self._parse_plist(command, output) begin - raise CaskError.new("Empty plist input") unless output =~ %r{\S} + raise Hbc::CaskError.new("Empty plist input") unless output =~ %r{\S} output.sub!(%r{\A(.*?)(<\?\s*xml)}m, '\2') - _warn_plist_garbage(command, $1) if Cask.debug + _warn_plist_garbage(command, $1) if Hbc.debug output.sub!(%r{(<\s*/\s*plist\s*>)(.*?)\Z}m, '\1') _warn_plist_garbage(command, $2) xml = Plist::parse_xml(output) unless xml.respond_to?(:keys) and xml.keys.size > 0 - raise CaskError.new(<<-ERRMSG) + raise Hbc::CaskError.new(<<-ERRMSG) Empty result parsing plist output from command. command was: #{command.utf8_inspect} @@ -112,7 +112,7 @@ Empty result parsing plist output from command. end xml rescue Plist::ParseError => e - raise CaskError.new(<<-ERRMSG) + raise Hbc::CaskError.new(<<-ERRMSG) Error parsing plist output from command. command was: #{command.utf8_inspect} diff --git a/lib/cask/topological_hash.rb b/lib/hbc/topological_hash.rb similarity index 84% rename from lib/cask/topological_hash.rb rename to lib/hbc/topological_hash.rb index a1a6279354..522d752f3a 100644 --- a/lib/cask/topological_hash.rb +++ b/lib/hbc/topological_hash.rb @@ -1,7 +1,7 @@ require 'tsort' # a basic topologically sortable hashmap -class TopologicalHash < Hash +class Hbc::TopologicalHash < Hash include TSort alias tsort_each_node each_key diff --git a/lib/cask/underscore_supporting_uri.rb b/lib/hbc/underscore_supporting_uri.rb similarity index 95% rename from lib/cask/underscore_supporting_uri.rb rename to lib/hbc/underscore_supporting_uri.rb index b537af9c9e..ad732066de 100644 --- a/lib/cask/underscore_supporting_uri.rb +++ b/lib/hbc/underscore_supporting_uri.rb @@ -1,6 +1,6 @@ require 'uri' -module Cask::UnderscoreSupportingURI +module Hbc::UnderscoreSupportingURI def self.parse(maybe_uri) return nil if maybe_uri.nil? URI.parse(maybe_uri) diff --git a/lib/cask/url.rb b/lib/hbc/url.rb similarity index 89% rename from lib/cask/url.rb rename to lib/hbc/url.rb index 799b6db8d4..c376248dad 100644 --- a/lib/cask/url.rb +++ b/lib/hbc/url.rb @@ -1,6 +1,6 @@ require 'forwardable' -class Cask::URL +class Hbc::URL FAKE_USER_AGENT = 'Chrome/32.0.1000.00' attr_reader :using, :revision, :trust_cert, :uri, :cookies, :referer, :data @@ -9,7 +9,7 @@ class Cask::URL def_delegators :uri, :path, :scheme, :to_s def initialize(uri, options={}) - @uri = Cask::UnderscoreSupportingURI.parse(uri) + @uri = Hbc::UnderscoreSupportingURI.parse(uri) @user_agent = options[:user_agent] @cookies = options[:cookies] @referer = options[:referer] diff --git a/lib/cask/url_checker.rb b/lib/hbc/url_checker.rb similarity index 93% rename from lib/cask/url_checker.rb rename to lib/hbc/url_checker.rb index b6f5bc80dd..8642fb720a 100644 --- a/lib/cask/url_checker.rb +++ b/lib/hbc/url_checker.rb @@ -1,11 +1,11 @@ -require 'cask/checkable' +require 'hbc/checkable' -class Cask::UrlChecker +class Hbc::UrlChecker attr_accessor :cask, :response_status, :headers - include Cask::Checkable + include Hbc::Checkable - def initialize(cask, fetcher=Cask::Fetcher) + def initialize(cask, fetcher=Hbc::Fetcher) @cask = cask @fetcher = fetcher @headers = {} diff --git a/lib/cask/utils.rb b/lib/hbc/utils.rb similarity index 93% rename from lib/cask/utils.rb rename to lib/hbc/utils.rb index 7b201d87f1..8280ee28b6 100644 --- a/lib/cask/utils.rb +++ b/lib/hbc/utils.rb @@ -1,11 +1,17 @@ -require 'cask/utils/tty' +module Hbc::Utils; end + require 'yaml' require 'open3' require 'stringio' +require 'hbc/utils/tty' + UPDATE_CMD = "brew update && brew upgrade brew-cask && brew cleanup && brew cask cleanup" ISSUES_URL = "https://github.com/caskroom/homebrew-cask/issues" +# todo: temporary +Tty = Hbc::Utils::Tty + # monkeypatch Object - not a great idea class Object def utf8_inspect @@ -38,7 +44,7 @@ end # originally from Homebrew def ohai(title, *sput) - title = Tty.truncate(title) if $stdout.tty? && !Cask.verbose + title = Tty.truncate(title) if $stdout.tty? && !Hbc.verbose puts "#{Tty.blue.bold}==>#{Tty.white} #{title}#{Tty.reset}" puts sput unless sput.empty? end @@ -54,7 +60,7 @@ def onoe(error) end def odebug(title, *sput) - if Cask.respond_to?(:debug) and Cask.debug + if Hbc.respond_to?(:debug) and Hbc.debug width = Tty.width * 4 - 6 if $stdout.tty? and title.to_s.length > width title = title.to_s[0, width - 3] + '...' @@ -66,12 +72,12 @@ end def puts_columns(items, star_items=[]) return if items.empty? - puts Cask::Utils.stringify_columns(items, star_items) + puts Hbc::Utils.stringify_columns(items, star_items) end -module Cask::Utils +module Hbc::Utils def dumpcask - if Cask.respond_to?(:debug) and Cask.debug + if Hbc.respond_to?(:debug) and Hbc.debug odebug "Cask instance dumps in YAML:" odebug "Cask instance toplevel:", self.to_yaml [ @@ -175,10 +181,10 @@ module Cask::Utils # originally from Homebrew abv def self.cabv(dir) output = '' - count = Cask::SystemCommand.run!('/usr/bin/find', + count = Hbc::SystemCommand.run!('/usr/bin/find', :args => [dir, *%w[-type f -not -name .DS_Store -print0]], :print_stderr => false).stdout.count("\000") - size = Cask::SystemCommand.run!('/usr/bin/du', + size = Hbc::SystemCommand.run!('/usr/bin/du', :args => ['-hs', '--', dir], :print_stderr => false).stdout.split("\t").first.strip output << "#{count} files, " if count > 1 diff --git a/lib/cask/utils/tty.rb b/lib/hbc/utils/tty.rb similarity index 99% rename from lib/cask/utils/tty.rb rename to lib/hbc/utils/tty.rb index afc09eb341..6b97cc267e 100644 --- a/lib/cask/utils/tty.rb +++ b/lib/hbc/utils/tty.rb @@ -1,6 +1,6 @@ # originally from Homebrew utils.rb -class Tty +class Hbc::Utils::Tty COLORS = { :black => 0, :red => 1, diff --git a/lib/hbc/version.rb b/lib/hbc/version.rb new file mode 100644 index 0000000000..be5ca67942 --- /dev/null +++ b/lib/hbc/version.rb @@ -0,0 +1 @@ +HBC_VERSION = '0.51.1' diff --git a/lib/cask/without_source.rb b/lib/hbc/without_source.rb similarity index 88% rename from lib/cask/without_source.rb rename to lib/hbc/without_source.rb index 6655a8a2a3..1f018aa80f 100644 --- a/lib/cask/without_source.rb +++ b/lib/hbc/without_source.rb @@ -1,4 +1,4 @@ -class Cask::WithoutSource < Cask +class Hbc::WithoutSource < Hbc def staged_path caskroom_path.children.first end diff --git a/lib/vendor/homebrew-fork/download_strategy.rb b/lib/vendor/homebrew-fork/download_strategy.rb index 8ca34ad0bb..f359d2216b 100644 --- a/lib/vendor/homebrew-fork/download_strategy.rb +++ b/lib/vendor/homebrew-fork/download_strategy.rb @@ -1,6 +1,6 @@ require 'vendor/homebrew-fork/resource' -class AbstractDownloadStrategy +class Hbc::HbAbstractDownloadStrategy attr_reader :name, :resource def initialize name, resource @@ -13,7 +13,7 @@ class AbstractDownloadStrategy args = args.dup args.each_with_index do |arg, ii| if arg.is_a? Hash - unless Cask.verbose + unless Hbc.verbose args[ii] = arg[:quiet_flag] else args.delete_at ii @@ -22,7 +22,7 @@ class AbstractDownloadStrategy end end # 2 as default because commands are eg. svn up, git pull - args.insert(2, '-q') unless Cask.verbose + args.insert(2, '-q') unless Hbc.verbose args end @@ -36,7 +36,7 @@ class AbstractDownloadStrategy def clear_cache; end end -class VCSDownloadStrategy < AbstractDownloadStrategy +class Hbc::HbVCSDownloadStrategy < Hbc::HbAbstractDownloadStrategy REF_TYPES = [:branch, :revision, :revisions, :tag].freeze def initialize name, resource @@ -67,7 +67,7 @@ class VCSDownloadStrategy < AbstractDownloadStrategy end end -class CurlDownloadStrategy < AbstractDownloadStrategy +class Hbc::HbCurlDownloadStrategy < Hbc::HbAbstractDownloadStrategy def mirrors @mirrors ||= resource.mirrors.dup end @@ -103,7 +103,7 @@ class CurlDownloadStrategy < AbstractDownloadStrategy had_incomplete_download = temporary_path.exist? begin _fetch - rescue ErrorDuringExecution + rescue Hbc::ErrorDuringExecution # 33 == range not supported # try wiping the incomplete download and retrying once if $?.exitstatus == 33 && had_incomplete_download @@ -117,14 +117,14 @@ class CurlDownloadStrategy < AbstractDownloadStrategy else msg = "Download failed: #{@url}" end - raise CurlDownloadStrategyError, msg + raise Hbc::CurlDownloadStrategyError, msg end end ignore_interrupts { temporary_path.rename(tarball_path) } else puts "Already downloaded: #{tarball_path}" end - rescue CurlDownloadStrategyError + rescue Hbc::CurlDownloadStrategyError raise if mirrors.empty? puts "Trying a mirror..." @url = mirrors.shift @@ -149,14 +149,14 @@ end # Download via an HTTP POST. # Query parameters on the URL are converted into POST parameters -class CurlPostDownloadStrategy < CurlDownloadStrategy +class Hbc::HbCurlPostDownloadStrategy < Hbc::HbCurlDownloadStrategy def _fetch base_url,data = @url.split('?') curl base_url, '-d', data, '-C', downloaded_size, '-o', temporary_path end end -class SubversionDownloadStrategy < VCSDownloadStrategy +class Hbc::HbSubversionDownloadStrategy < Hbc::HbVCSDownloadStrategy def cache_tag # todo: pass versions as symbols, support :head here resource.version == 'head' ? "svn-HEAD" : "svn" @@ -227,7 +227,7 @@ class SubversionDownloadStrategy < VCSDownloadStrategy end # Require a newer version of Subversion than 1.4.x (Leopard-provided version) -class StrictSubversionDownloadStrategy < SubversionDownloadStrategy +class Hbc::HbStrictSubversionDownloadStrategy < Hbc::HbSubversionDownloadStrategy def find_svn exe = `svn -print-path` `#{exe} --version` =~ /version (\d+\.\d+(\.\d+)*)/ @@ -245,7 +245,7 @@ class StrictSubversionDownloadStrategy < SubversionDownloadStrategy end # Download from SVN servers with invalid or self-signed certs -class UnsafeSubversionDownloadStrategy < SubversionDownloadStrategy +class Hbc::HbUnsafeSubversionDownloadStrategy < Hbc::HbSubversionDownloadStrategy def fetch_repo target, url, revision=nil, ignore_externals=false # Use "svn up" when the repository already exists locally. # This saves on bandwidth and will have a similar effect to verifying the @@ -260,11 +260,11 @@ class UnsafeSubversionDownloadStrategy < SubversionDownloadStrategy end end -class DownloadStrategyDetector +class Hbc::HbDownloadStrategyDetector def self.detect(url, strategy=nil) if strategy.nil? detect_from_url(url) - elsif Class === strategy && strategy < AbstractDownloadStrategy + elsif Class === strategy && strategy < Hbc::AbstractDownloadStrategy strategy elsif Symbol === strategy detect_from_symbol(strategy) @@ -277,19 +277,19 @@ class DownloadStrategyDetector def self.detect_from_url(url) case url when %r[^https?://(.+?\.)?googlecode\.com/svn], %r[^https?://svn\.], %r[^svn://], %r[^https?://(.+?\.)?sourceforge\.net/svnroot/] - SubversionDownloadStrategy + Hbc::HbSubversionDownloadStrategy when %r[^http://svn\.apache\.org/repos/], %r[^svn\+http://] - SubversionDownloadStrategy + Hbc::HbSubversionDownloadStrategy else - CurlDownloadStrategy + Hbc::HbCurlDownloadStrategy end end def self.detect_from_symbol(symbol) case symbol - when :svn then SubversionDownloadStrategy - when :curl then CurlDownloadStrategy - when :post then CurlPostDownloadStrategy + when :svn then Hbc::HbSubversionDownloadStrategy + when :curl then Hbc::HbCurlDownloadStrategy + when :post then Hbc::HbCurlPostDownloadStrategy else raise "Unknown download strategy #{strategy} was requested." end diff --git a/lib/vendor/homebrew-fork/exceptions.rb b/lib/vendor/homebrew-fork/exceptions.rb index 7d7043beb6..7f89582c78 100644 --- a/lib/vendor/homebrew-fork/exceptions.rb +++ b/lib/vendor/homebrew-fork/exceptions.rb @@ -1,10 +1,12 @@ +class Hbc; end + # raised by safe_system in utils.rb -class ErrorDuringExecution < RuntimeError +class Hbc::ErrorDuringExecution < RuntimeError def initialize(cmd, args=[]) args = args.map { |a| a.to_s.gsub " ", "\\ " }.join(" ") super "Failure while executing: #{cmd} #{args}" end end -# raised in CurlDownloadStrategy.fetch -class CurlDownloadStrategyError < RuntimeError; end +# raised in Hbc::HbCurlDownloadStrategy.fetch +class Hbc::CurlDownloadStrategyError < RuntimeError; end diff --git a/lib/vendor/homebrew-fork/resource.rb b/lib/vendor/homebrew-fork/resource.rb index 6d1cf1d655..d10a6cc72e 100644 --- a/lib/vendor/homebrew-fork/resource.rb +++ b/lib/vendor/homebrew-fork/resource.rb @@ -3,7 +3,7 @@ require 'vendor/homebrew-fork/download_strategy' # Resource is the fundamental representation of an external resource. The # primary formula download, along with other declared resources, are instances # of this class. -class Resource +class Hbc::Resource attr_reader :mirrors, :specs, :using attr_writer :url, :version @@ -78,7 +78,7 @@ class Resource # Ensure the cache exists HOMEBREW_CACHE.mkpath downloader.fetch - rescue ErrorDuringExecution, CurlDownloadStrategyError => e + rescue Hbc::ErrorDuringExecution, Hbc::CurlDownloadStrategyError => e raise RuntimeError.new else cached_download @@ -89,7 +89,7 @@ class Resource @url = val @specs.merge!(specs) @using = @specs.delete(:using) - @download_strategy = DownloadStrategyDetector.detect(url, using) + @download_strategy = Hbc::HbDownloadStrategyDetector.detect(url, using) end def version val=nil diff --git a/lib/vendor/homebrew-fork/utils.rb b/lib/vendor/homebrew-fork/utils.rb index 796ca53b18..7c34c7d881 100644 --- a/lib/vendor/homebrew-fork/utils.rb +++ b/lib/vendor/homebrew-fork/utils.rb @@ -2,7 +2,7 @@ require 'pathname' require 'vendor/homebrew-fork/exceptions' def homebrew_fork_system cmd, *args - puts "#{cmd} #{args*' '}" if Cask.verbose + puts "#{cmd} #{args*' '}" if Hbc.verbose pid = fork do yield if block_given? args.collect!{|arg| arg.to_s} @@ -15,7 +15,7 @@ end # Kernel.system but with exceptions def safe_system cmd, *args - homebrew_fork_system(cmd, *args) or raise ErrorDuringExecution.new(cmd, args) + homebrew_fork_system(cmd, *args) or raise Hbc::ErrorDuringExecution.new(cmd, args) end # prints no output @@ -33,7 +33,7 @@ def curl *args raise "#{curl} is not executable" unless curl.exist? and curl.executable? flags = HOMEBREW_CURL_ARGS - flags = flags.delete("#") if Cask.verbose + flags = flags.delete("#") if Hbc.verbose args = [flags, HOMEBREW_USER_AGENT, *args] # See https://github.com/Homebrew/homebrew/issues/6103 diff --git a/spec/cask/audit_spec.rb b/spec/cask/audit_spec.rb index a16efc0686..784be10fd2 100644 --- a/spec/cask/audit_spec.rb +++ b/spec/cask/audit_spec.rb @@ -1,60 +1,60 @@ require 'spec_helper' -class CaskMissingUrl < Cask +class CaskMissingUrl < Hbc version '1.2.3' homepage 'http://example.com' end -class CaskMissingVersion < Cask +class CaskMissingVersion < Hbc url 'http://localhost/something.dmg' homepage 'http://example.com' end -class CaskMissingHomepage < Cask +class CaskMissingHomepage < Hbc url 'http://localhost/something.dmg' version '1.2.3' end -class CaskSourceForgeIncorrectURLFormat < Cask +class CaskSourceForgeIncorrectURLFormat < Hbc version '1.2.3' homepage 'http://sourceforge.net/projects/something/' url 'http://sourceforge.net/projects/something/files/Something-1.2.3.dmg/download' end -class CaskSourceForgeCorrectURLFormat < Cask +class CaskSourceForgeCorrectURLFormat < Hbc version '1.2.3' homepage 'http://sourceforge.net/projects/something/' url 'http://downloads.sourceforge.net/project/something/Something-1.2.3.dmg' end -class CaskSourceForgeOtherCorrectURLFormat < Cask +class CaskSourceForgeOtherCorrectURLFormat < Hbc version :latest homepage 'http://sourceforge.net/projects/something/' url 'http://sourceforge.net/projects/something/files/latest/download' end -class CaskVersionLatestWithChecksum < Cask +class CaskVersionLatestWithChecksum < Hbc version :latest sha256 '9203c30951f9aab41ac294bbeb1dcef7bed401ff0b353dcb34d68af32ea51853' end -describe Cask::Audit do +describe Hbc::Audit do describe "result" do it "is 'failed' if there are have been any errors added" do - audit = Cask::Audit.new(Cask.new) + audit = Hbc::Audit.new(Hbc.new) audit.add_error 'bad' audit.add_warning 'eh' expect(audit.result).to match(/failed/) end it "is 'warning' if there are no errors, but there are warnings" do - audit = Cask::Audit.new(Cask.new) + audit = Hbc::Audit.new(Hbc.new) audit.add_warning 'eh' expect(audit.result).to match(/warning/) end it "is 'passed' if there are no errors or warning" do - audit = Cask::Audit.new(Cask.new) + audit = Hbc::Audit.new(Hbc.new) expect(audit.result).to match(/passed/) end end @@ -62,25 +62,25 @@ describe Cask::Audit do describe "run!" do describe "required fields" do it "adds an error if url is missing" do - audit = Cask::Audit.new(CaskMissingUrl.new) + audit = Hbc::Audit.new(CaskMissingUrl.new) audit.run! expect(audit.errors).to include('a url stanza is required') end it "adds an error if version is missing" do - audit = Cask::Audit.new(CaskMissingVersion.new) + audit = Hbc::Audit.new(CaskMissingVersion.new) audit.run! expect(audit.errors).to include('a version stanza is required') end it "adds an error if homepage is missing" do - audit = Cask::Audit.new(CaskMissingHomepage.new) + audit = Hbc::Audit.new(CaskMissingHomepage.new) audit.run! expect(audit.errors).to include('a homepage stanza is required') end it "adds an error if version is latest and using sha256" do - audit = Cask::Audit.new(CaskVersionLatestWithChecksum.new) + audit = Hbc::Audit.new(CaskVersionLatestWithChecksum.new) audit.run! expect(audit.errors).to include(%q{you should use sha256 :no_check when version is :latest}) end @@ -91,15 +91,15 @@ describe Cask::Audit do warning_msg = 'SourceForge URL format incorrect. See https://github.com/caskroom/homebrew-cask/blob/master/CONTRIBUTING.md#sourceforge-urls' - audit = Cask::Audit.new(CaskSourceForgeIncorrectURLFormat.new) + audit = Hbc::Audit.new(CaskSourceForgeIncorrectURLFormat.new) audit.run! expect(audit.warnings).to include(warning_msg) - audit = Cask::Audit.new(CaskSourceForgeCorrectURLFormat.new) + audit = Hbc::Audit.new(CaskSourceForgeCorrectURLFormat.new) audit.run! expect(audit.warnings).to_not include(warning_msg) - audit = Cask::Audit.new(CaskSourceForgeOtherCorrectURLFormat.new) + audit = Hbc::Audit.new(CaskSourceForgeOtherCorrectURLFormat.new) audit.run! expect(audit.warnings).to_not include(warning_msg) end @@ -111,7 +111,7 @@ describe Cask::Audit do download = double() download.expects(:perform).raises(StandardError.new(error_message)) - audit = Cask::Audit.new(Cask.new) + audit = Hbc::Audit.new(Hbc.new) audit.run!(download) expect(audit.errors).to include(/#{error_message}/) end diff --git a/spec/cask/cli_spec.rb b/spec/cask/cli_spec.rb index 703046fbf0..f91c4ac451 100644 --- a/spec/cask/cli_spec.rb +++ b/spec/cask/cli_spec.rb @@ -1,8 +1,8 @@ require 'spec_helper' -describe Cask::CLI do +describe Hbc::CLI do it "lists the taps for Casks that show up in two taps" do - listing = Cask::CLI.nice_listing(%w[ + listing = Hbc::CLI.nice_listing(%w[ caskroom/cask/adium caskroom/cask/google-chrome passcod/homebrew-cask/adium @@ -18,16 +18,16 @@ describe Cask::CLI do describe ".process" do let(:noop_command) { double('CLI::Noop') } before { - allow(Cask::CLI).to receive(:lookup_command) { noop_command } + allow(Hbc::CLI).to receive(:lookup_command) { noop_command } allow(noop_command).to receive(:run) } it "respects the env variable when choosing what appdir to create" do with_env_var('HOMEBREW_CASK_OPTS', "--appdir=/custom/appdir") do - allow(Cask).to receive(:init) { - expect(Cask.appdir.to_s).to eq('/custom/appdir') + allow(Hbc).to receive(:init) { + expect(Hbc.appdir.to_s).to eq('/custom/appdir') } - Cask::CLI.process('noop') + Hbc::CLI.process('noop') end end @@ -35,18 +35,18 @@ describe Cask::CLI do # # it "respects the ENV variable when choosing a non-default Caskroom location" do # with_env_var 'HOMEBREW_CASK_OPTS', "--caskroom=/custom/caskdir" do - # allow(Cask).to receive(:init) { - # expect(Cask.caskroom.to_s).to eq('/custom/caskdir') + # allow(Hbc).to receive(:init) { + # expect(Hbc.caskroom.to_s).to eq('/custom/caskdir') # } - # Cask::CLI.process('noop') + # Hbc::CLI.process('noop') # end # end it "exits with a status of 1 when something goes wrong" do - Cask::CLI.expects(:exit).with(1) - Cask::CLI.expects(:lookup_command).raises(CaskError) + Hbc::CLI.expects(:exit).with(1) + Hbc::CLI.expects(:lookup_command).raises(Hbc::CaskError) shutup { - Cask::CLI.process('noop') + Hbc::CLI.process('noop') } end end diff --git a/spec/cask/download_strategy_spec.rb b/spec/cask/download_strategy_spec.rb index cd112c9299..05ee81e598 100644 --- a/spec/cask/download_strategy_spec.rb +++ b/spec/cask/download_strategy_spec.rb @@ -4,15 +4,15 @@ describe 'download strategies' do let(:url) { 'http://example.com/cask.dmg' } let(:url_options) { Hash.new } let(:cask) { - class_double(Cask, + class_double(Hbc, :token => 'some-cask', - :url => Cask::URL.new(url, url_options), + :url => Hbc::URL.new(url, url_options), :version => '1.2.3.4' ) } - describe Cask::CurlDownloadStrategy do - let(:downloader) { Cask::CurlDownloadStrategy.new(cask) } + describe Hbc::CurlDownloadStrategy do + let(:downloader) { Hbc::CurlDownloadStrategy.new(cask) } before do allow(downloader.temporary_path).to receive(:rename) @@ -103,8 +103,8 @@ describe 'download strategies' do end end - describe Cask::CurlPostDownloadStrategy do - let(:downloader) { Cask::CurlPostDownloadStrategy.new(cask) } + describe Hbc::CurlPostDownloadStrategy do + let(:downloader) { Hbc::CurlPostDownloadStrategy.new(cask) } before do allow(downloader.temporary_path).to receive(:rename) @@ -145,12 +145,12 @@ describe 'download strategies' do end end - describe Cask::SubversionDownloadStrategy do + describe Hbc::SubversionDownloadStrategy do let(:url_options) {{ :using => :svn }} - let(:fake_system_command) { class_double(Cask::SystemCommand) } - let(:downloader) { Cask::SubversionDownloadStrategy.new(cask, fake_system_command) } + let(:fake_system_command) { class_double(Hbc::SystemCommand) } + let(:downloader) { Hbc::SubversionDownloadStrategy.new(cask, fake_system_command) } before do allow(fake_system_command).to receive(:run!) end @@ -272,8 +272,8 @@ describe 'download strategies' do # does not work yet, because (for unknown reasons), the tar command # returns an error code when running under the test suite # it 'creates a tarball matching the expected checksum' do - # cask = Cask.load('svn-download-check-cask') - # downloader = Cask::SubversionDownloadStrategy.new(cask) + # cask = Hbc.load('svn-download-check-cask') + # downloader = Hbc::SubversionDownloadStrategy.new(cask) # # special mocking required for tar to have something to work with # def downloader.fetch_repo(target, url, revision=nil, ignore_externals=false) # target.mkpath @@ -281,7 +281,7 @@ describe 'download strategies' do # File.utime(1000,1000,target.join('empty_file.txt')) # end # expect(shutup { downloader.fetch }).to equal(downloader.tarball_path) - # d = Cask::Download.new(cask) + # d = Hbc::Download.new(cask) # d.send(:_check_sums, downloader.tarball_path, cask.sums) # end end diff --git a/spec/cask/scopes_spec.rb b/spec/cask/scopes_spec.rb index 94c3719ab3..602a6d79e5 100644 --- a/spec/cask/scopes_spec.rb +++ b/spec/cask/scopes_spec.rb @@ -1,44 +1,44 @@ require 'spec_helper' -describe Cask::Scopes do +describe Hbc::Scopes do describe 'installed' do let(:fake_caskroom) { Pathname(Dir.mktmpdir) } before do - allow(Cask).to receive(:caskroom) { fake_caskroom } + allow(Hbc).to receive(:caskroom) { fake_caskroom } end after { fake_caskroom.rmtree } it 'returns a list installed Casks by loading Casks for all the dirs that exist in the caskroom' do - allow(Cask).to receive(:load) { |token| "loaded-#{token}" } + allow(Hbc).to receive(:load) { |token| "loaded-#{token}" } fake_caskroom.join('cask-bar').mkdir fake_caskroom.join('cask-foo').mkdir - installed_casks = Cask.installed + installed_casks = Hbc.installed - expect(Cask).to have_received(:load).with('cask-bar') - expect(Cask).to have_received(:load).with('cask-foo') + expect(Hbc).to have_received(:load).with('cask-bar') + expect(Hbc).to have_received(:load).with('cask-foo') expect(installed_casks).to eq(%w[ loaded-cask-bar loaded-cask-foo ]) end - it 'optimizes performance by resolving to a fully qualified path before calling Cask.load' do + it 'optimizes performance by resolving to a fully qualified path before calling Hbc.load' do fake_tapped_cask_dir = Pathname(Dir.mktmpdir).join('Casks') absolute_path_to_cask = fake_tapped_cask_dir.join('some-cask.rb') - allow(Cask).to receive(:load) - allow(Cask).to receive(:all_tapped_cask_dirs) { [fake_tapped_cask_dir] } + allow(Hbc).to receive(:load) + allow(Hbc).to receive(:all_tapped_cask_dirs) { [fake_tapped_cask_dir] } fake_caskroom.join('some-cask').mkdir fake_tapped_cask_dir.mkdir FileUtils.touch(absolute_path_to_cask) - Cask.installed + Hbc.installed - expect(Cask).to have_received(:load).with(absolute_path_to_cask) + expect(Hbc).to have_received(:load).with(absolute_path_to_cask) end end end diff --git a/spec/cask/underscore_supporting_uri_spec.rb b/spec/cask/underscore_supporting_uri_spec.rb index e6df2ac256..10c1f8c68b 100644 --- a/spec/cask/underscore_supporting_uri_spec.rb +++ b/spec/cask/underscore_supporting_uri_spec.rb @@ -1,14 +1,14 @@ require 'spec_helper' -describe Cask::UnderscoreSupportingURI do +describe Hbc::UnderscoreSupportingURI do describe 'parse' do it 'works like normal on normal URLs' do - uri = Cask::UnderscoreSupportingURI.parse('http://example.com/TestCask.dmg') + uri = Hbc::UnderscoreSupportingURI.parse('http://example.com/TestCask.dmg') expect(uri).to eq(URI('http://example.com/TestCask.dmg')) end it 'works just fine on URIs with underscores' do - uri = Cask::UnderscoreSupportingURI.parse('http://dl_dir.qq.com/qqfile/qq/QQforMac/QQ_V3.0.0.dmg') + uri = Hbc::UnderscoreSupportingURI.parse('http://dl_dir.qq.com/qqfile/qq/QQforMac/QQ_V3.0.0.dmg') expect(uri.host).to include('_') expect(uri.to_s).to eq('http://dl_dir.qq.com/qqfile/qq/QQforMac/QQ_V3.0.0.dmg') end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index ab7732f124..0d065295df 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -15,14 +15,14 @@ require 'mocha/api' # add homebrew-cask lib to load path $:.push(project_root.join('lib').to_s) -require 'cask' +require 'hbc' # Look for Casks in testcasks by default. It is elsewhere required that # the string "test" appear in the directory name. -Cask.default_tap = 'caskroom/homebrew-testcasks' +Hbc.default_tap = 'caskroom/homebrew-testcasks' # our own testy caskroom -Cask.caskroom = HOMEBREW_PREFIX.join('TestCaskroom') +Hbc.caskroom = HOMEBREW_PREFIX.join('TestCaskroom') RSpec.configure do |config| config.include ShutupHelper diff --git a/test/Casks/compliance_test.rb b/test/Casks/compliance_test.rb index 946ef2469e..bbcf50ca62 100644 --- a/test/Casks/compliance_test.rb +++ b/test/Casks/compliance_test.rb @@ -1,10 +1,10 @@ require 'test_helper' describe "Casks" do - Cask.all.reject {|c| c.is_a?(TestCask) }.each do |cask| + Hbc.all.reject {|c| c.is_a?(TestHbc) }.each do |cask| describe "#{cask}" do it "passes audit" do - audit = Cask::Audit.new(cask) + audit = Hbc::Audit.new(cask) audit.run! audit.errors.must_equal [], "[#{cask}] Cask audit must be error free" audit.warnings.must_equal [], "[#{cask}] Cask audit must be warning free" diff --git a/test/cask/accessibility_test.rb b/test/cask/accessibility_test.rb index f92891af00..07c6d5071f 100644 --- a/test/cask/accessibility_test.rb +++ b/test/cask/accessibility_test.rb @@ -4,8 +4,8 @@ require 'test_helper' # that class is abstracted from installer.rb. describe "Accessibility Access" do before do - cask = Cask.load('with-accessibility-access') - @installer = Cask::Installer.new(cask, Cask::FakeSystemCommand) + cask = Hbc.load('with-accessibility-access') + @installer = Hbc::Installer.new(cask, Hbc::FakeSystemCommand) end describe "install" do @@ -14,8 +14,8 @@ describe "Accessibility Access" do @installer.stubs(:bundle_identifier => 'com.example.BasicCask') - Cask::FakeSystemCommand.expects_command( - ['/usr/bin/sudo', '-E', '--', '/usr/bin/sqlite3', Cask.tcc_db, %q{INSERT INTO access VALUES('kTCCServiceAccessibility','com.example.BasicCask',0,1,1,NULL);}] + Hbc::FakeSystemCommand.expects_command( + ['/usr/bin/sudo', '-E', '--', '/usr/bin/sqlite3', Hbc.tcc_db, %q{INSERT INTO access VALUES('kTCCServiceAccessibility','com.example.BasicCask',0,1,1,NULL);}] ) shutup do @installer.enable_accessibility_access @@ -25,8 +25,8 @@ describe "Accessibility Access" do it "can enable accessibility access in OS X releases prior to Mavericks" do MacOS.stubs(:release => MacOS::Release.new('10.8')) - Cask::FakeSystemCommand.expects_command( - ['/usr/bin/sudo', '-E', '--', '/usr/bin/touch', Cask.pre_mavericks_accessibility_dotfile] + Hbc::FakeSystemCommand.expects_command( + ['/usr/bin/sudo', '-E', '--', '/usr/bin/touch', Hbc.pre_mavericks_accessibility_dotfile] ) shutup do @installer.enable_accessibility_access @@ -40,8 +40,8 @@ describe "Accessibility Access" do @installer.stubs(:bundle_identifier => 'com.example.BasicCask') - Cask::FakeSystemCommand.expects_command( - ['/usr/bin/sudo', '-E', '--', '/usr/bin/sqlite3', Cask.tcc_db, %q{DELETE FROM access WHERE client='com.example.BasicCask';}] + Hbc::FakeSystemCommand.expects_command( + ['/usr/bin/sudo', '-E', '--', '/usr/bin/sqlite3', Hbc.tcc_db, %q{DELETE FROM access WHERE client='com.example.BasicCask';}] ) shutup do @installer.disable_accessibility_access diff --git a/test/cask/artifact/alt_target_test.rb b/test/cask/artifact/alt_target_test.rb index ca2c25519e..247b101eae 100644 --- a/test/cask/artifact/alt_target_test.rb +++ b/test/cask/artifact/alt_target_test.rb @@ -1,8 +1,8 @@ require 'test_helper' -describe Cask::Artifact::App do +describe Hbc::Artifact::App do let(:local_alt_caffeine) { - Cask.load('with-alt-target').tap do |cask| + Hbc.load('with-alt-target').tap do |cask| TestHelper.install_without_artifacts(cask) end } @@ -12,28 +12,28 @@ describe Cask::Artifact::App do cask = local_alt_caffeine shutup do - Cask::Artifact::App.new(cask).install_phase + Hbc::Artifact::App.new(cask).install_phase end - TestHelper.valid_alias?(Cask.appdir.join('AnotherName.app')).must_equal true + TestHelper.valid_alias?(Hbc.appdir.join('AnotherName.app')).must_equal true end it "creates metadata containing the alternate target name" do cask = local_alt_caffeine shutup do - Cask::Artifact::App.new(cask).install_phase + Hbc::Artifact::App.new(cask).install_phase end - Cask::SystemCommand.run('/usr/bin/xattr', + Hbc::SystemCommand.run('/usr/bin/xattr', :args => ['-p', 'com.apple.metadata:kMDItemAlternateNames', - Cask.appdir.join('AnotherName.app')], + Hbc.appdir.join('AnotherName.app')], :print_stderr => false).stdout.must_match(/AnotherName/) end it "works with an application in a subdir" do - AltSubDirCask = Class.new(Cask) + AltSubDirCask = Class.new(Hbc) AltSubDirCask.class_eval do url TestHelper.local_binary_url('caffeine.zip') homepage 'http://example.com/local-caffeine' @@ -51,14 +51,14 @@ describe Cask::Artifact::App do FileUtils.mv(subdir_cask.staged_path.join('Caffeine.app'), appsubdir) shutup do - Cask::Artifact::App.new(subdir_cask).install_phase + Hbc::Artifact::App.new(subdir_cask).install_phase end - TestHelper.valid_alias?(Cask.appdir.join('AnotherName.app')).must_equal true + TestHelper.valid_alias?(Hbc.appdir.join('AnotherName.app')).must_equal true ensure if defined?(subdir_cask) shutup do - Cask::Installer.new(subdir_cask).uninstall + Hbc::Installer.new(subdir_cask).uninstall end end end @@ -71,35 +71,35 @@ describe Cask::Artifact::App do FileUtils.cp_r app_path, app_path.sub('Caffeine.app', 'CaffeineAgain.app') shutup do - Cask::Artifact::App.new(cask).install_phase + Hbc::Artifact::App.new(cask).install_phase end - TestHelper.valid_alias?(Cask.appdir.join('AnotherName.app')).must_equal true - TestHelper.valid_alias?(Cask.appdir.join('AnotherNameAgain.app')).must_equal false + TestHelper.valid_alias?(Hbc.appdir.join('AnotherName.app')).must_equal true + TestHelper.valid_alias?(Hbc.appdir.join('AnotherNameAgain.app')).must_equal false end it "avoids clobbering an existing app by linking over it" do cask = local_alt_caffeine - Cask.appdir.join('AnotherName.app').mkpath + Hbc.appdir.join('AnotherName.app').mkpath TestHelper.must_output(self, lambda { - Cask::Artifact::App.new(cask).install_phase - }, "==> It seems there is already an App at '#{Cask.appdir.join('AnotherName.app')}'; not linking.") + Hbc::Artifact::App.new(cask).install_phase + }, "==> It seems there is already an App at '#{Hbc.appdir.join('AnotherName.app')}'; not linking.") - Cask.appdir.join('AnotherName.app').wont_be :symlink? + Hbc.appdir.join('AnotherName.app').wont_be :symlink? end it "happily clobbers an existing symlink" do cask = local_alt_caffeine - Cask.appdir.join('AnotherName.app').make_symlink('/tmp') + Hbc.appdir.join('AnotherName.app').make_symlink('/tmp') TestHelper.must_output(self, lambda { - Cask::Artifact::App.new(cask).install_phase - }, "==> Symlinking App 'Caffeine.app' to '#{Cask.appdir.join('AnotherName.app')}'") + Hbc::Artifact::App.new(cask).install_phase + }, "==> Symlinking App 'Caffeine.app' to '#{Hbc.appdir.join('AnotherName.app')}'") - File.readlink(Cask.appdir.join('AnotherName.app')).wont_equal '/tmp' + File.readlink(Hbc.appdir.join('AnotherName.app')).wont_equal '/tmp' end end end diff --git a/test/cask/artifact/app_test.rb b/test/cask/artifact/app_test.rb index 6c0a555a9a..1f22bbc144 100644 --- a/test/cask/artifact/app_test.rb +++ b/test/cask/artifact/app_test.rb @@ -1,8 +1,8 @@ require 'test_helper' -describe Cask::Artifact::App do +describe Hbc::Artifact::App do let(:local_caffeine) { - Cask.load('local-caffeine').tap do |cask| + Hbc.load('local-caffeine').tap do |cask| TestHelper.install_without_artifacts(cask) end } @@ -12,14 +12,14 @@ describe Cask::Artifact::App do cask = local_caffeine shutup do - Cask::Artifact::App.new(cask).install_phase + Hbc::Artifact::App.new(cask).install_phase end - TestHelper.valid_alias?(Cask.appdir.join('Caffeine.app')).must_equal true + TestHelper.valid_alias?(Hbc.appdir.join('Caffeine.app')).must_equal true end it "works with an application in a subdir" do - SubDirCask = Class.new(Cask) + SubDirCask = Class.new(Hbc) SubDirCask.class_eval do url TestHelper.local_binary_url('caffeine.zip') homepage 'http://example.com/local-caffeine' @@ -37,14 +37,14 @@ describe Cask::Artifact::App do FileUtils.mv(subdir_cask.staged_path.join('Caffeine.app'), appsubdir) shutup do - Cask::Artifact::App.new(subdir_cask).install_phase + Hbc::Artifact::App.new(subdir_cask).install_phase end - TestHelper.valid_alias?(Cask.appdir.join('Caffeine.app')).must_equal true + TestHelper.valid_alias?(Hbc.appdir.join('Caffeine.app')).must_equal true ensure if defined?(subdir_cask) shutup do - Cask::Installer.new(subdir_cask).uninstall + Hbc::Installer.new(subdir_cask).uninstall end end end @@ -57,35 +57,35 @@ describe Cask::Artifact::App do FileUtils.cp_r app_path, app_path.sub('Caffeine.app', 'CaffeineAgain.app') shutup do - Cask::Artifact::App.new(cask).install_phase + Hbc::Artifact::App.new(cask).install_phase end - TestHelper.valid_alias?(Cask.appdir.join('Caffeine.app')).must_equal true - TestHelper.valid_alias?(Cask.appdir.join('CaffeineAgain.app')).must_equal false + TestHelper.valid_alias?(Hbc.appdir.join('Caffeine.app')).must_equal true + TestHelper.valid_alias?(Hbc.appdir.join('CaffeineAgain.app')).must_equal false end it "avoids clobbering an existing app by linking over it" do cask = local_caffeine - Cask.appdir.join('Caffeine.app').mkpath + Hbc.appdir.join('Caffeine.app').mkpath TestHelper.must_output(self, lambda { - Cask::Artifact::App.new(cask).install_phase - }, "==> It seems there is already an App at '#{Cask.appdir.join('Caffeine.app')}'; not linking.") + Hbc::Artifact::App.new(cask).install_phase + }, "==> It seems there is already an App at '#{Hbc.appdir.join('Caffeine.app')}'; not linking.") - Cask.appdir.join('Caffeine.app').wont_be :symlink? + Hbc.appdir.join('Caffeine.app').wont_be :symlink? end it "happily clobbers an existing symlink" do cask = local_caffeine - Cask.appdir.join('Caffeine.app').make_symlink('/tmp') + Hbc.appdir.join('Caffeine.app').make_symlink('/tmp') TestHelper.must_output(self, lambda { - Cask::Artifact::App.new(cask).install_phase - }, "==> Symlinking App 'Caffeine.app' to '#{Cask.appdir.join('Caffeine.app')}'") + Hbc::Artifact::App.new(cask).install_phase + }, "==> Symlinking App 'Caffeine.app' to '#{Hbc.appdir.join('Caffeine.app')}'") - File.readlink(Cask.appdir.join('Caffeine.app')).wont_equal '/tmp' + File.readlink(Hbc.appdir.join('Caffeine.app')).wont_equal '/tmp' end end end diff --git a/test/cask/artifact/binary_test.rb b/test/cask/artifact/binary_test.rb index 9d5039b2fe..e59a490547 100644 --- a/test/cask/artifact/binary_test.rb +++ b/test/cask/artifact/binary_test.rb @@ -1,18 +1,18 @@ require 'test_helper' -describe Cask::Artifact::App do +describe Hbc::Artifact::App do let(:cask) { - Cask.load('with-binary').tap do |cask| + Hbc.load('with-binary').tap do |cask| TestHelper.install_without_artifacts(cask) end } let(:expected_path) { - Cask.binarydir.join('binary') + Hbc.binarydir.join('binary') } it "links the binary to the proper directory" do shutup do - Cask::Artifact::Binary.new(cask).install_phase + Hbc::Artifact::Binary.new(cask).install_phase end TestHelper.valid_alias?(expected_path).must_equal true @@ -22,7 +22,7 @@ describe Cask::Artifact::App do FileUtils.touch expected_path shutup do - Cask::Artifact::Binary.new(cask).install_phase + Hbc::Artifact::Binary.new(cask).install_phase end expected_path.wont_be :symlink? @@ -32,21 +32,21 @@ describe Cask::Artifact::App do expected_path.make_symlink('/tmp') shutup do - Cask::Artifact::Binary.new(cask).install_phase + Hbc::Artifact::Binary.new(cask).install_phase end File.readlink(expected_path).wont_equal '/tmp' end it "respects --no-binaries flag" do - Cask.no_binaries = true + Hbc.no_binaries = true shutup do - Cask::Artifact::Binary.new(cask).install_phase + Hbc::Artifact::Binary.new(cask).install_phase end expected_path.exist?.must_equal false - Cask.no_binaries = false + Hbc.no_binaries = false end end diff --git a/test/cask/artifact/generic_artifact_test.rb b/test/cask/artifact/generic_artifact_test.rb index eea8f9004c..13d292f247 100644 --- a/test/cask/artifact/generic_artifact_test.rb +++ b/test/cask/artifact/generic_artifact_test.rb @@ -1,21 +1,21 @@ require 'test_helper' -describe Cask::Artifact::Artifact do +describe Hbc::Artifact::Artifact do let(:cask) { - Cask.load('with-generic-artifact').tap do |cask| + Hbc.load('with-generic-artifact').tap do |cask| TestHelper.install_without_artifacts(cask) end } let(:expected_path) { # todo 'artifact' should be changed to require a :target, in - # which case it will no longer default to Cask.appdir + # which case it will no longer default to Hbc.appdir # as below - Cask.appdir.join('Caffeine.app') + Hbc.appdir.join('Caffeine.app') } it "links the artifact to the proper directory" do shutup do - Cask::Artifact::Artifact.new(cask).install_phase + Hbc::Artifact::Artifact.new(cask).install_phase end TestHelper.valid_alias?(expected_path).must_equal true @@ -25,7 +25,7 @@ describe Cask::Artifact::Artifact do FileUtils.touch expected_path shutup do - Cask::Artifact::Artifact.new(cask).install_phase + Hbc::Artifact::Artifact.new(cask).install_phase end expected_path.wont_be :symlink? @@ -35,7 +35,7 @@ describe Cask::Artifact::Artifact do expected_path.make_symlink('/tmp') shutup do - Cask::Artifact::Artifact.new(cask).install_phase + Hbc::Artifact::Artifact.new(cask).install_phase end File.readlink(expected_path).wont_equal '/tmp' diff --git a/test/cask/artifact/nested_container_test.rb b/test/cask/artifact/nested_container_test.rb index e84b08f973..c872c6130d 100644 --- a/test/cask/artifact/nested_container_test.rb +++ b/test/cask/artifact/nested_container_test.rb @@ -1,14 +1,14 @@ require 'test_helper' -describe Cask::Artifact::NestedContainer do +describe Hbc::Artifact::NestedContainer do describe 'install' do it 'extracts the specified paths as containers' do - cask = Cask.load('nested-app').tap do |c| + cask = Hbc.load('nested-app').tap do |c| TestHelper.install_without_artifacts(c) end shutup do - Cask::Artifact::NestedContainer.new(cask).install_phase + Hbc::Artifact::NestedContainer.new(cask).install_phase end cask.staged_path.join('MyNestedApp.app').must_be :directory? diff --git a/test/cask/artifact/pkg_test.rb b/test/cask/artifact/pkg_test.rb index 02af8662dc..8e384a62a1 100644 --- a/test/cask/artifact/pkg_test.rb +++ b/test/cask/artifact/pkg_test.rb @@ -1,8 +1,8 @@ require 'test_helper' -describe Cask::Artifact::Pkg do +describe Hbc::Artifact::Pkg do before { - @cask = Cask.load('with-installable') + @cask = Hbc.load('with-installable') shutup do TestHelper.install_without_artifacts(@cask) end @@ -10,9 +10,9 @@ describe Cask::Artifact::Pkg do describe 'install_phase' do it 'runs the system installer on the specified pkgs' do - pkg = Cask::Artifact::Pkg.new(@cask, Cask::FakeSystemCommand) + pkg = Hbc::Artifact::Pkg.new(@cask, Hbc::FakeSystemCommand) - Cask::FakeSystemCommand.expects_command(['/usr/bin/sudo', '-E', '--', '/usr/sbin/installer', '-pkg', @cask.staged_path.join('MyFancyPkg','Fancy.pkg'), '-target', '/']) + Hbc::FakeSystemCommand.expects_command(['/usr/bin/sudo', '-E', '--', '/usr/sbin/installer', '-pkg', @cask.staged_path.join('MyFancyPkg','Fancy.pkg'), '-target', '/']) shutup do pkg.install_phase @@ -22,7 +22,7 @@ describe Cask::Artifact::Pkg do describe 'uninstall_phase' do it 'does nothing, because the uninstall_phase method is a no-op' do - pkg = Cask::Artifact::Pkg.new(@cask, Cask::FakeSystemCommand) + pkg = Hbc::Artifact::Pkg.new(@cask, Hbc::FakeSystemCommand) shutup do pkg.uninstall_phase end diff --git a/test/cask/artifact/postflight_block_test.rb b/test/cask/artifact/postflight_block_test.rb index aa1d849360..44b092f5e1 100644 --- a/test/cask/artifact/postflight_block_test.rb +++ b/test/cask/artifact/postflight_block_test.rb @@ -1,12 +1,12 @@ require 'test_helper' -describe Cask::Artifact::PostflightBlock do +describe Hbc::Artifact::PostflightBlock do describe 'install_phase' do it 'calls the specified block after installing, passing a Cask mini-dsl' do called = false yielded_arg = nil - CaskWithPostflight = Class.new(Cask) + CaskWithPostflight = Class.new(Hbc) CaskWithPostflight.class_eval do postflight do |c| called = true @@ -15,10 +15,10 @@ describe Cask::Artifact::PostflightBlock do end cask = CaskWithPostflight.new - Cask::Artifact::PostflightBlock.new(cask).install_phase + Hbc::Artifact::PostflightBlock.new(cask).install_phase called.must_equal true - yielded_arg.must_be_kind_of Cask::DSL::Postflight + yielded_arg.must_be_kind_of Hbc::DSL::Postflight end end @@ -27,7 +27,7 @@ describe Cask::Artifact::PostflightBlock do called = false yielded_arg = nil - CaskWithUninstallPostflight = Class.new(Cask) + CaskWithUninstallPostflight = Class.new(Hbc) CaskWithUninstallPostflight.class_eval do uninstall_postflight do |c| called = true @@ -36,10 +36,10 @@ describe Cask::Artifact::PostflightBlock do end cask = CaskWithUninstallPostflight.new - Cask::Artifact::PostflightBlock.new(cask).uninstall_phase + Hbc::Artifact::PostflightBlock.new(cask).uninstall_phase called.must_equal true - yielded_arg.must_be_kind_of Cask::DSL::UninstallPostflight + yielded_arg.must_be_kind_of Hbc::DSL::UninstallPostflight end end end diff --git a/test/cask/artifact/preflight_block_test.rb b/test/cask/artifact/preflight_block_test.rb index 64db82a5cf..45ee97a242 100644 --- a/test/cask/artifact/preflight_block_test.rb +++ b/test/cask/artifact/preflight_block_test.rb @@ -1,12 +1,12 @@ require 'test_helper' -describe Cask::Artifact::PreflightBlock do +describe Hbc::Artifact::PreflightBlock do describe 'install_phase' do it 'calls the specified block before installing, passing a Cask mini-dsl' do called = false yielded_arg = nil - CaskWithPreflight = Class.new(Cask) + CaskWithPreflight = Class.new(Hbc) CaskWithPreflight.class_eval do preflight do |c| called = true @@ -15,10 +15,10 @@ describe Cask::Artifact::PreflightBlock do end cask = CaskWithPreflight.new - Cask::Artifact::PreflightBlock.new(cask).install_phase + Hbc::Artifact::PreflightBlock.new(cask).install_phase called.must_equal true - yielded_arg.must_be_kind_of Cask::DSL::Preflight + yielded_arg.must_be_kind_of Hbc::DSL::Preflight end end @@ -27,7 +27,7 @@ describe Cask::Artifact::PreflightBlock do called = false yielded_arg = nil - CaskWithUninstallPreflight = Class.new(Cask) + CaskWithUninstallPreflight = Class.new(Hbc) CaskWithUninstallPreflight.class_eval do uninstall_preflight do |c| called = true @@ -36,10 +36,10 @@ describe Cask::Artifact::PreflightBlock do end cask = CaskWithUninstallPreflight.new - Cask::Artifact::PreflightBlock.new(cask).uninstall_phase + Hbc::Artifact::PreflightBlock.new(cask).uninstall_phase called.must_equal true - yielded_arg.must_be_kind_of Cask::DSL::UninstallPreflight + yielded_arg.must_be_kind_of Hbc::DSL::UninstallPreflight end end end diff --git a/test/cask/artifact/suite_test.rb b/test/cask/artifact/suite_test.rb index 84116b602a..7310b175f1 100644 --- a/test/cask/artifact/suite_test.rb +++ b/test/cask/artifact/suite_test.rb @@ -1,18 +1,18 @@ require 'test_helper' -describe Cask::Artifact::Suite do +describe Hbc::Artifact::Suite do let(:cask) { - Cask.load('with-suite').tap do |cask| + Hbc.load('with-suite').tap do |cask| TestHelper.install_without_artifacts(cask) end } let(:expected_path) { - Cask.appdir.join('caffeine_suite') + Hbc.appdir.join('caffeine_suite') } it "links the suite to the proper directory" do shutup do - Cask::Artifact::Suite.new(cask).install_phase + Hbc::Artifact::Suite.new(cask).install_phase end TestHelper.valid_alias?(expected_path).must_equal true @@ -20,7 +20,7 @@ describe Cask::Artifact::Suite do it "creates a suite containing the expected app" do shutup do - Cask::Artifact::Suite.new(cask).install_phase + Hbc::Artifact::Suite.new(cask).install_phase end expected_path.join('Caffeine.app').must_be :exist? @@ -30,7 +30,7 @@ describe Cask::Artifact::Suite do FileUtils.touch expected_path shutup do - Cask::Artifact::Suite.new(cask).install_phase + Hbc::Artifact::Suite.new(cask).install_phase end expected_path.wont_be :symlink? @@ -40,7 +40,7 @@ describe Cask::Artifact::Suite do expected_path.make_symlink('/tmp') shutup do - Cask::Artifact::Suite.new(cask).install_phase + Hbc::Artifact::Suite.new(cask).install_phase end File.readlink(expected_path).wont_equal '/tmp' diff --git a/test/cask/artifact/two_apps_correct_test.rb b/test/cask/artifact/two_apps_correct_test.rb index 8a6c20801b..275a1ac55e 100644 --- a/test/cask/artifact/two_apps_correct_test.rb +++ b/test/cask/artifact/two_apps_correct_test.rb @@ -1,8 +1,8 @@ require 'test_helper' -describe Cask::Artifact::App do +describe Hbc::Artifact::App do let(:local_two_apps_caffeine) { - Cask.load('with-two-apps-correct').tap do |cask| + Hbc.load('with-two-apps-correct').tap do |cask| TestHelper.install_without_artifacts(cask) end } @@ -12,15 +12,15 @@ describe Cask::Artifact::App do cask = local_two_apps_caffeine shutup do - Cask::Artifact::App.new(cask).install_phase + Hbc::Artifact::App.new(cask).install_phase end - TestHelper.valid_alias?(Cask.appdir.join('Caffeine.app')).must_equal true - TestHelper.valid_alias?(Cask.appdir.join('AnotherName.app')).must_equal true + TestHelper.valid_alias?(Hbc.appdir.join('Caffeine.app')).must_equal true + TestHelper.valid_alias?(Hbc.appdir.join('AnotherName.app')).must_equal true end it "works with an application in a subdir" do - AltSubDirTwoAppsCask = Class.new(Cask) + AltSubDirTwoAppsCask = Class.new(Hbc) AltSubDirTwoAppsCask.class_eval do url TestHelper.local_binary_url('caffeine.zip') homepage 'http://example.com/local-caffeine' @@ -39,15 +39,15 @@ describe Cask::Artifact::App do FileUtils.mv(subdir_cask.staged_path.join('Caffeine.app'), appsubdir) shutup do - Cask::Artifact::App.new(subdir_cask).install_phase + Hbc::Artifact::App.new(subdir_cask).install_phase end - TestHelper.valid_alias?(Cask.appdir.join('Caffeine.app')).must_equal true - TestHelper.valid_alias?(Cask.appdir.join('AnotherName.app')).must_equal true + TestHelper.valid_alias?(Hbc.appdir.join('Caffeine.app')).must_equal true + TestHelper.valid_alias?(Hbc.appdir.join('AnotherName.app')).must_equal true ensure if defined?(subdir_cask) shutup do - Cask::Installer.new(subdir_cask).uninstall + Hbc::Installer.new(subdir_cask).uninstall end end end @@ -61,71 +61,71 @@ describe Cask::Artifact::App do # FileUtils.cp_r app_path, app_path.sub('Caffeine.app', 'CaffeineAgain.app') # # shutup do - # Cask::Artifact::App.new(cask).install_phase + # Hbc::Artifact::App.new(cask).install_phase # end # - # TestHelper.valid_alias?(Cask.appdir.join('AnotherName.app')).must_equal true - # TestHelper.valid_alias?(Cask.appdir.join('AnotherNameAgain.app').must_equal false + # TestHelper.valid_alias?(Hbc.appdir.join('AnotherName.app')).must_equal true + # TestHelper.valid_alias?(Hbc.appdir.join('AnotherNameAgain.app').must_equal false # end it "avoids clobbering an existing app by linking over it (link 1)" do cask = local_two_apps_caffeine - Cask.appdir.join('Caffeine.app').mkpath + Hbc.appdir.join('Caffeine.app').mkpath TestHelper.must_output(self, lambda { - Cask::Artifact::App.new(cask).install_phase + Hbc::Artifact::App.new(cask).install_phase }, <<-MESSAGE.undent.chomp) - ==> It seems there is already an App at '#{Cask.appdir.join('Caffeine.app')}'; not linking. - ==> Symlinking App 'Caffeine.app' to '#{Cask.appdir.join('AnotherName.app')}' + ==> It seems there is already an App at '#{Hbc.appdir.join('Caffeine.app')}'; not linking. + ==> Symlinking App 'Caffeine.app' to '#{Hbc.appdir.join('AnotherName.app')}' MESSAGE - Cask.appdir.join('Caffeine.app').wont_be :symlink? + Hbc.appdir.join('Caffeine.app').wont_be :symlink? end it "avoids clobbering an existing app by linking over it (link 2)" do cask = local_two_apps_caffeine - Cask.appdir.join('AnotherName.app').mkpath + Hbc.appdir.join('AnotherName.app').mkpath TestHelper.must_output(self, lambda { - Cask::Artifact::App.new(cask).install_phase + Hbc::Artifact::App.new(cask).install_phase }, <<-MESSAGE.undent.chomp) - ==> Symlinking App 'Caffeine.app' to '#{Cask.appdir.join('Caffeine.app')}' - ==> It seems there is already an App at '#{Cask.appdir.join('AnotherName.app')}'; not linking. + ==> Symlinking App 'Caffeine.app' to '#{Hbc.appdir.join('Caffeine.app')}' + ==> It seems there is already an App at '#{Hbc.appdir.join('AnotherName.app')}'; not linking. MESSAGE - Cask.appdir.join('AnotherName.app').wont_be :symlink? + Hbc.appdir.join('AnotherName.app').wont_be :symlink? end it "happily clobbers an existing symlink (link 1)" do cask = local_two_apps_caffeine - Cask.appdir.join('Caffeine.app').make_symlink('/tmp') + Hbc.appdir.join('Caffeine.app').make_symlink('/tmp') TestHelper.must_output(self, lambda { - Cask::Artifact::App.new(cask).install_phase + Hbc::Artifact::App.new(cask).install_phase }, <<-MESSAGE.undent.chomp) - ==> Symlinking App 'Caffeine.app' to '#{Cask.appdir.join('Caffeine.app')}' - ==> Symlinking App 'Caffeine.app' to '#{Cask.appdir.join('AnotherName.app')}' + ==> Symlinking App 'Caffeine.app' to '#{Hbc.appdir.join('Caffeine.app')}' + ==> Symlinking App 'Caffeine.app' to '#{Hbc.appdir.join('AnotherName.app')}' MESSAGE - File.readlink(Cask.appdir.join('Caffeine.app')).wont_equal '/tmp' + File.readlink(Hbc.appdir.join('Caffeine.app')).wont_equal '/tmp' end it "happily clobbers an existing symlink (link 2)" do cask = local_two_apps_caffeine - Cask.appdir.join('AnotherName.app').make_symlink('/tmp') + Hbc.appdir.join('AnotherName.app').make_symlink('/tmp') TestHelper.must_output(self, lambda { - Cask::Artifact::App.new(cask).install_phase + Hbc::Artifact::App.new(cask).install_phase }, <<-MESSAGE.undent.chomp) - ==> Symlinking App 'Caffeine.app' to '#{Cask.appdir.join('Caffeine.app')}' - ==> Symlinking App 'Caffeine.app' to '#{Cask.appdir.join('AnotherName.app')}' + ==> Symlinking App 'Caffeine.app' to '#{Hbc.appdir.join('Caffeine.app')}' + ==> Symlinking App 'Caffeine.app' to '#{Hbc.appdir.join('AnotherName.app')}' MESSAGE - File.readlink(Cask.appdir.join('AnotherName.app')).wont_equal '/tmp' + File.readlink(Hbc.appdir.join('AnotherName.app')).wont_equal '/tmp' end end end diff --git a/test/cask/artifact/two_apps_incorrect_test.rb b/test/cask/artifact/two_apps_incorrect_test.rb index c7cb1f544e..d5a91e419e 100644 --- a/test/cask/artifact/two_apps_incorrect_test.rb +++ b/test/cask/artifact/two_apps_incorrect_test.rb @@ -1,9 +1,9 @@ require 'test_helper' -describe Cask::Artifact::App do +describe Hbc::Artifact::App do it 'must raise' do begin - Cask.load('two-apps-incorrect') + Hbc.load('two-apps-incorrect') rescue => e end # todo: later give the user a nice exception for this case and check for it here diff --git a/test/cask/artifact/uninstall_test.rb b/test/cask/artifact/uninstall_test.rb index 4d2f0324f7..c5787fdcc8 100644 --- a/test/cask/artifact/uninstall_test.rb +++ b/test/cask/artifact/uninstall_test.rb @@ -1,8 +1,8 @@ require 'test_helper' -describe Cask::Artifact::Uninstall do +describe Hbc::Artifact::Uninstall do before { - @cask = Cask.load('with-installable') + @cask = Hbc.load('with-installable') shutup do TestHelper.install_without_artifacts(@cask) end @@ -10,7 +10,7 @@ describe Cask::Artifact::Uninstall do describe 'install_phase' do it 'does nothing, because the install_phase method is a no-op' do - uninstall_artifact = Cask::Artifact::Uninstall.new(@cask, Cask::FakeSystemCommand) + uninstall_artifact = Hbc::Artifact::Uninstall.new(@cask, Hbc::FakeSystemCommand) shutup do uninstall_artifact.install_phase end @@ -19,7 +19,7 @@ describe Cask::Artifact::Uninstall do describe 'zap_phase' do it 'does nothing, because the zap_phase method is a no-op' do - uninstall_artifact = Cask::Artifact::Uninstall.new(@cask, Cask::FakeSystemCommand) + uninstall_artifact = Hbc::Artifact::Uninstall.new(@cask, Hbc::FakeSystemCommand) shutup do uninstall_artifact.zap_phase end @@ -29,15 +29,15 @@ describe Cask::Artifact::Uninstall do describe 'uninstall_phase' do # todo: uninstall tests for :signal (implementation does not use SystemCommand) it 'runs the specified uninstaller for the Cask' do - uninstall_artifact = Cask::Artifact::Uninstall.new(@cask, Cask::FakeSystemCommand) + uninstall_artifact = Hbc::Artifact::Uninstall.new(@cask, Hbc::FakeSystemCommand) - Cask::FakeSystemCommand.stubs_command(['/usr/bin/sudo', '-E', '--', '/usr/bin/osascript', '-e', 'tell application "System Events" to count processes whose bundle identifier is "my.fancy.package.app"'], '1') - Cask::FakeSystemCommand.stubs_command(['/usr/bin/sudo', '-E', '--', '/usr/bin/osascript', '-e', 'tell application id "my.fancy.package.app" to quit']) + Hbc::FakeSystemCommand.stubs_command(['/usr/bin/sudo', '-E', '--', '/usr/bin/osascript', '-e', 'tell application "System Events" to count processes whose bundle identifier is "my.fancy.package.app"'], '1') + Hbc::FakeSystemCommand.stubs_command(['/usr/bin/sudo', '-E', '--', '/usr/bin/osascript', '-e', 'tell application id "my.fancy.package.app" to quit']) - Cask::FakeSystemCommand.expects_command(['/usr/bin/sudo', '-E', '--', @cask.staged_path.join('MyFancyPkg','FancyUninstaller.tool'), '--please']) - Cask::FakeSystemCommand.expects_command(['/usr/bin/sudo', '-E', '--', '/bin/rm', '-rf', '--', '/permissible/absolute/path']) - Cask::FakeSystemCommand.expects_command(['/usr/bin/sudo', '-E', '--', '/bin/rm', '-f', '--', Pathname.new(TestHelper.local_binary_path('empty_directory')).join('.DS_Store')]) - Cask::FakeSystemCommand.expects_command(['/usr/bin/sudo', '-E', '--', '/bin/rmdir', '--', Pathname.new(TestHelper.local_binary_path('empty_directory'))]) + Hbc::FakeSystemCommand.expects_command(['/usr/bin/sudo', '-E', '--', @cask.staged_path.join('MyFancyPkg','FancyUninstaller.tool'), '--please']) + Hbc::FakeSystemCommand.expects_command(['/usr/bin/sudo', '-E', '--', '/bin/rm', '-rf', '--', '/permissible/absolute/path']) + Hbc::FakeSystemCommand.expects_command(['/usr/bin/sudo', '-E', '--', '/bin/rm', '-f', '--', Pathname.new(TestHelper.local_binary_path('empty_directory')).join('.DS_Store')]) + Hbc::FakeSystemCommand.expects_command(['/usr/bin/sudo', '-E', '--', '/bin/rmdir', '--', Pathname.new(TestHelper.local_binary_path('empty_directory'))]) shutup do uninstall_artifact.uninstall_phase @@ -45,10 +45,10 @@ describe Cask::Artifact::Uninstall do end it 'can uninstall using pkgutil, launchctl, and file lists' do - cask = Cask.load('with-pkgutil-uninstall') - uninstall_artifact = Cask::Artifact::Uninstall.new(cask, Cask::FakeSystemCommand) + cask = Hbc.load('with-pkgutil-uninstall') + uninstall_artifact = Hbc::Artifact::Uninstall.new(cask, Hbc::FakeSystemCommand) - Cask::FakeSystemCommand.stubs_command( + Hbc::FakeSystemCommand.stubs_command( ['/usr/sbin/pkgutil', '--pkgs=my.fancy.package.*'], [ 'my.fancy.package.main', @@ -56,14 +56,14 @@ describe Cask::Artifact::Uninstall do ].join("\n") ) - Cask::FakeSystemCommand.stubs_command( + Hbc::FakeSystemCommand.stubs_command( ['/usr/sbin/pkgutil', '--only-files', '--files', 'my.fancy.package.main'], [ 'fancy/bin/fancy.exe', 'fancy/var/fancy.data', ].join("\n") ) - Cask::FakeSystemCommand.stubs_command( + Hbc::FakeSystemCommand.stubs_command( ['/usr/sbin/pkgutil', '--only-dirs', '--files', 'my.fancy.package.main'], [ 'fancy', @@ -71,7 +71,7 @@ describe Cask::Artifact::Uninstall do 'fancy/var', ].join("\n") ) - Cask::FakeSystemCommand.stubs_command( + Hbc::FakeSystemCommand.stubs_command( ['/usr/sbin/pkgutil', '--files', 'my.fancy.package.main'], [ 'fancy', @@ -81,7 +81,7 @@ describe Cask::Artifact::Uninstall do 'fancy/var/fancy.data', ].join("\n") ) - Cask::FakeSystemCommand.stubs_command( + Hbc::FakeSystemCommand.stubs_command( ['/usr/sbin/pkgutil', '--pkg-info-plist', 'my.fancy.package.main'], <<-PLIST @@ -97,11 +97,11 @@ describe Cask::Artifact::Uninstall do PLIST ) - Cask::FakeSystemCommand.stubs_command( + Hbc::FakeSystemCommand.stubs_command( ['/bin/launchctl', 'list', 'my.fancy.package.service'], "launchctl list returned unknown response\n" ) - Cask::FakeSystemCommand.stubs_command( + Hbc::FakeSystemCommand.stubs_command( ['/usr/bin/sudo', '-E', '--', '/bin/launchctl', 'list', 'my.fancy.package.service'], <<-"PLIST" { @@ -117,14 +117,14 @@ describe Cask::Artifact::Uninstall do PLIST ) - Cask::FakeSystemCommand.expects_command(['/usr/bin/sudo', '-E', '--', '/bin/launchctl', 'remove', 'my.fancy.package.service']) - Cask::FakeSystemCommand.expects_command(['/usr/bin/sudo', '-E', '--', '/bin/launchctl', 'unload', '-w', '--', 'my.fancy.package.service']) + Hbc::FakeSystemCommand.expects_command(['/usr/bin/sudo', '-E', '--', '/bin/launchctl', 'remove', 'my.fancy.package.service']) + Hbc::FakeSystemCommand.expects_command(['/usr/bin/sudo', '-E', '--', '/bin/launchctl', 'unload', '-w', '--', 'my.fancy.package.service']) - Cask::FakeSystemCommand.stubs_command(['/usr/bin/sudo', '-E', '--', '/usr/sbin/kextstat', '-l', '-b', 'my.fancy.package.kernelextension'], 'loaded') - Cask::FakeSystemCommand.expects_command(['/usr/bin/sudo', '-E', '--', '/sbin/kextunload', '-b', 'my.fancy.package.kernelextension']) - Cask::FakeSystemCommand.stubs_command(['/usr/bin/sudo', '-E', '--', '/usr/sbin/pkgutil', '--forget', 'my.fancy.package.main']) + Hbc::FakeSystemCommand.stubs_command(['/usr/bin/sudo', '-E', '--', '/usr/sbin/kextstat', '-l', '-b', 'my.fancy.package.kernelextension'], 'loaded') + Hbc::FakeSystemCommand.expects_command(['/usr/bin/sudo', '-E', '--', '/sbin/kextunload', '-b', 'my.fancy.package.kernelextension']) + Hbc::FakeSystemCommand.stubs_command(['/usr/bin/sudo', '-E', '--', '/usr/sbin/pkgutil', '--forget', 'my.fancy.package.main']) - Cask::FakeSystemCommand.stubs_command( + Hbc::FakeSystemCommand.stubs_command( ['/usr/sbin/pkgutil', '--only-files', '--files', 'my.fancy.package.agent'], [ 'fancy/agent/fancy-agent.exe', @@ -132,14 +132,14 @@ describe Cask::Artifact::Uninstall do 'fancy/agent/fancy-agent.log', ].join("\n") ) - Cask::FakeSystemCommand.stubs_command( + Hbc::FakeSystemCommand.stubs_command( ['/usr/sbin/pkgutil', '--only-dirs', '--files', 'my.fancy.package.agent'], [ 'fancy', 'fancy/agent', ].join("\n") ) - Cask::FakeSystemCommand.stubs_command( + Hbc::FakeSystemCommand.stubs_command( ['/usr/sbin/pkgutil', '--files', 'my.fancy.package.agent'], [ 'fancy', @@ -149,7 +149,7 @@ describe Cask::Artifact::Uninstall do 'fancy/agent/fancy-agent.log', ].join("\n") ) - Cask::FakeSystemCommand.stubs_command( + Hbc::FakeSystemCommand.stubs_command( ['/usr/sbin/pkgutil', '--pkg-info-plist', 'my.fancy.package.agent'], <<-PLIST @@ -171,15 +171,15 @@ describe Cask::Artifact::Uninstall do /tmp/fancy/bin /tmp/fancy/var ].each do |dir| - Cask::FakeSystemCommand.stubs_command(['/usr/bin/sudo', '-E', '--', '/bin/chmod', '--', '777', '#{dir}']) + Hbc::FakeSystemCommand.stubs_command(['/usr/bin/sudo', '-E', '--', '/bin/chmod', '--', '777', '#{dir}']) end - Cask::FakeSystemCommand.stubs_command(['/usr/bin/sudo', '-E', '--', '/usr/sbin/pkgutil', '--forget', 'my.fancy.package.agent']) + Hbc::FakeSystemCommand.stubs_command(['/usr/bin/sudo', '-E', '--', '/usr/sbin/pkgutil', '--forget', 'my.fancy.package.agent']) - Cask::FakeSystemCommand.stubs_command(['/usr/bin/sudo', '-E', '--', '/bin/rm', '-f', '--', + Hbc::FakeSystemCommand.stubs_command(['/usr/bin/sudo', '-E', '--', '/bin/rm', '-f', '--', Pathname.new('/tmp/fancy/bin/fancy.exe'), Pathname.new('/tmp/fancy/var/fancy.data')]) - Cask::FakeSystemCommand.stubs_command(['/usr/bin/sudo', '-E', '--', '/bin/rm', '-f', '--', + Hbc::FakeSystemCommand.stubs_command(['/usr/bin/sudo', '-E', '--', '/bin/rm', '-f', '--', Pathname.new('/tmp/fancy/agent/fancy-agent.exe'), Pathname.new('/tmp/fancy/agent/fancy-agent.pid'), Pathname.new('/tmp/fancy/agent/fancy-agent.log')]) diff --git a/test/cask/artifact/zap_test.rb b/test/cask/artifact/zap_test.rb index ff8340967d..bbe5ebc812 100644 --- a/test/cask/artifact/zap_test.rb +++ b/test/cask/artifact/zap_test.rb @@ -3,9 +3,9 @@ require 'test_helper' # todo # - test that zap removes an alternate version of the same Cask -describe Cask::Artifact::Zap do +describe Hbc::Artifact::Zap do before { - @cask = Cask.load('with-zap') + @cask = Hbc.load('with-zap') shutup do TestHelper.install_without_artifacts(@cask) end @@ -13,7 +13,7 @@ describe Cask::Artifact::Zap do describe 'install_phase' do it 'does nothing, because the install_phase method is a no-op' do - zap_artifact = Cask::Artifact::Zap.new(@cask, Cask::FakeSystemCommand) + zap_artifact = Hbc::Artifact::Zap.new(@cask, Hbc::FakeSystemCommand) shutup do zap_artifact.install_phase end @@ -22,7 +22,7 @@ describe Cask::Artifact::Zap do describe 'uninstall_phase' do it 'does nothing, because the uninstall_phase method is a no-op' do - zap_artifact = Cask::Artifact::Zap.new(@cask, Cask::FakeSystemCommand) + zap_artifact = Hbc::Artifact::Zap.new(@cask, Hbc::FakeSystemCommand) shutup do zap_artifact.uninstall_phase end @@ -32,13 +32,13 @@ describe Cask::Artifact::Zap do describe 'zap_phase' do # todo: zap tests for :signal (implementation does not use SystemCommand) it 'runs the specified zap procedures for the Cask' do - zap_artifact = Cask::Artifact::Zap.new(@cask, Cask::FakeSystemCommand) + zap_artifact = Hbc::Artifact::Zap.new(@cask, Hbc::FakeSystemCommand) - Cask::FakeSystemCommand.stubs_command(['/usr/bin/sudo', '-E', '--', '/usr/bin/osascript', '-e', 'tell application "System Events" to count processes whose bundle identifier is "my.fancy.package.app"'], '1') - Cask::FakeSystemCommand.stubs_command(['/usr/bin/sudo', '-E', '--', '/usr/bin/osascript', '-e', 'tell application id "my.fancy.package.app" to quit']) + Hbc::FakeSystemCommand.stubs_command(['/usr/bin/sudo', '-E', '--', '/usr/bin/osascript', '-e', 'tell application "System Events" to count processes whose bundle identifier is "my.fancy.package.app"'], '1') + Hbc::FakeSystemCommand.stubs_command(['/usr/bin/sudo', '-E', '--', '/usr/bin/osascript', '-e', 'tell application id "my.fancy.package.app" to quit']) - Cask::FakeSystemCommand.expects_command(['/usr/bin/sudo', '-E', '--', @cask.staged_path.join('MyFancyPkg','FancyUninstaller.tool'), '--please']) - Cask::FakeSystemCommand.expects_command(['/usr/bin/sudo', '-E', '--', '/bin/rm', '-rf', '--', + Hbc::FakeSystemCommand.expects_command(['/usr/bin/sudo', '-E', '--', @cask.staged_path.join('MyFancyPkg','FancyUninstaller.tool'), '--please']) + Hbc::FakeSystemCommand.expects_command(['/usr/bin/sudo', '-E', '--', '/bin/rm', '-rf', '--', Pathname.new('~/Library/Preferences/my.fancy.app.plist').expand_path]) shutup do @@ -47,10 +47,10 @@ describe Cask::Artifact::Zap do end it 'can zap using pkgutil, launchctl, and file lists' do - cask = Cask.load('with-pkgutil-zap') - zap_artifact = Cask::Artifact::Zap.new(cask, Cask::FakeSystemCommand) + cask = Hbc.load('with-pkgutil-zap') + zap_artifact = Hbc::Artifact::Zap.new(cask, Hbc::FakeSystemCommand) - Cask::FakeSystemCommand.stubs_command( + Hbc::FakeSystemCommand.stubs_command( ['/usr/sbin/pkgutil', '--pkgs=my.fancy.package.*'], [ 'my.fancy.package.main', @@ -58,14 +58,14 @@ describe Cask::Artifact::Zap do ].join("\n") ) - Cask::FakeSystemCommand.stubs_command( + Hbc::FakeSystemCommand.stubs_command( ['/usr/sbin/pkgutil', '--only-files', '--files', 'my.fancy.package.main'], [ 'fancy/bin/fancy.exe', 'fancy/var/fancy.data', ].join("\n") ) - Cask::FakeSystemCommand.stubs_command( + Hbc::FakeSystemCommand.stubs_command( ['/usr/sbin/pkgutil', '--only-dirs', '--files', 'my.fancy.package.main'], [ 'fancy', @@ -73,7 +73,7 @@ describe Cask::Artifact::Zap do 'fancy/var', ].join("\n") ) - Cask::FakeSystemCommand.stubs_command( + Hbc::FakeSystemCommand.stubs_command( ['/usr/sbin/pkgutil', '--files', 'my.fancy.package.main'], [ 'fancy', @@ -83,7 +83,7 @@ describe Cask::Artifact::Zap do 'fancy/var/fancy.data', ].join("\n") ) - Cask::FakeSystemCommand.stubs_command( + Hbc::FakeSystemCommand.stubs_command( ['/usr/sbin/pkgutil', '--pkg-info-plist', 'my.fancy.package.main'], <<-PLIST @@ -99,11 +99,11 @@ describe Cask::Artifact::Zap do PLIST ) - Cask::FakeSystemCommand.stubs_command( + Hbc::FakeSystemCommand.stubs_command( ['/bin/launchctl', 'list', 'my.fancy.package.service'], "launchctl list returned unknown response\n" ) - Cask::FakeSystemCommand.stubs_command( + Hbc::FakeSystemCommand.stubs_command( ['/usr/bin/sudo', '-E', '--', '/bin/launchctl', 'list', 'my.fancy.package.service'], <<-"PLIST" { @@ -119,14 +119,14 @@ describe Cask::Artifact::Zap do PLIST ) - Cask::FakeSystemCommand.expects_command(['/usr/bin/sudo', '-E', '--', '/bin/launchctl', 'remove', 'my.fancy.package.service']) - Cask::FakeSystemCommand.expects_command(['/usr/bin/sudo', '-E', '--', '/bin/launchctl', 'unload', '-w', '--', 'my.fancy.package.service']) + Hbc::FakeSystemCommand.expects_command(['/usr/bin/sudo', '-E', '--', '/bin/launchctl', 'remove', 'my.fancy.package.service']) + Hbc::FakeSystemCommand.expects_command(['/usr/bin/sudo', '-E', '--', '/bin/launchctl', 'unload', '-w', '--', 'my.fancy.package.service']) - Cask::FakeSystemCommand.stubs_command(['/usr/bin/sudo', '-E', '--', '/usr/sbin/kextstat', '-l', '-b', 'my.fancy.package.kernelextension'], 'loaded') - Cask::FakeSystemCommand.expects_command(['/usr/bin/sudo', '-E', '--', '/sbin/kextunload', '-b', 'my.fancy.package.kernelextension']) - Cask::FakeSystemCommand.stubs_command(['/usr/bin/sudo', '-E', '--', '/usr/sbin/pkgutil', '--forget', 'my.fancy.package.main']) + Hbc::FakeSystemCommand.stubs_command(['/usr/bin/sudo', '-E', '--', '/usr/sbin/kextstat', '-l', '-b', 'my.fancy.package.kernelextension'], 'loaded') + Hbc::FakeSystemCommand.expects_command(['/usr/bin/sudo', '-E', '--', '/sbin/kextunload', '-b', 'my.fancy.package.kernelextension']) + Hbc::FakeSystemCommand.stubs_command(['/usr/bin/sudo', '-E', '--', '/usr/sbin/pkgutil', '--forget', 'my.fancy.package.main']) - Cask::FakeSystemCommand.stubs_command( + Hbc::FakeSystemCommand.stubs_command( ['/usr/sbin/pkgutil', '--only-files', '--files', 'my.fancy.package.agent'], [ 'fancy/agent/fancy-agent.exe', @@ -134,14 +134,14 @@ describe Cask::Artifact::Zap do 'fancy/agent/fancy-agent.log', ].join("\n") ) - Cask::FakeSystemCommand.stubs_command( + Hbc::FakeSystemCommand.stubs_command( ['/usr/sbin/pkgutil', '--only-dirs', '--files', 'my.fancy.package.agent'], [ 'fancy', 'fancy/agent', ].join("\n") ) - Cask::FakeSystemCommand.stubs_command( + Hbc::FakeSystemCommand.stubs_command( ['/usr/sbin/pkgutil', '--files', 'my.fancy.package.agent'], [ 'fancy', @@ -151,7 +151,7 @@ describe Cask::Artifact::Zap do 'fancy/agent/fancy-agent.log', ].join("\n") ) - Cask::FakeSystemCommand.stubs_command( + Hbc::FakeSystemCommand.stubs_command( ['/usr/sbin/pkgutil', '--pkg-info-plist', 'my.fancy.package.agent'], <<-PLIST @@ -173,15 +173,15 @@ describe Cask::Artifact::Zap do /tmp/fancy/bin /tmp/fancy/var ].each do |dir| - Cask::FakeSystemCommand.stubs_command(['/usr/bin/sudo', '-E', '--', '/bin/chmod', '--', '777', '#{dir}']) + Hbc::FakeSystemCommand.stubs_command(['/usr/bin/sudo', '-E', '--', '/bin/chmod', '--', '777', '#{dir}']) end - Cask::FakeSystemCommand.stubs_command(['/usr/bin/sudo', '-E', '--', '/usr/sbin/pkgutil', '--forget', 'my.fancy.package.agent']) + Hbc::FakeSystemCommand.stubs_command(['/usr/bin/sudo', '-E', '--', '/usr/sbin/pkgutil', '--forget', 'my.fancy.package.agent']) - Cask::FakeSystemCommand.stubs_command(['/usr/bin/sudo', '-E', '--', '/bin/rm', '-f', '--', + Hbc::FakeSystemCommand.stubs_command(['/usr/bin/sudo', '-E', '--', '/bin/rm', '-f', '--', Pathname.new('/tmp/fancy/bin/fancy.exe'), Pathname.new('/tmp/fancy/var/fancy.data')]) - Cask::FakeSystemCommand.stubs_command(['/usr/bin/sudo', '-E', '--', '/bin/rm', '-f', '--', + Hbc::FakeSystemCommand.stubs_command(['/usr/bin/sudo', '-E', '--', '/bin/rm', '-f', '--', Pathname.new('/tmp/fancy/agent/fancy-agent.exe'), Pathname.new('/tmp/fancy/agent/fancy-agent.pid'), Pathname.new('/tmp/fancy/agent/fancy-agent.log')]) diff --git a/test/cask/cli/alfred_test.rb b/test/cask/cli/alfred_test.rb index 91ba89b14e..ba8665f0ca 100644 --- a/test/cask/cli/alfred_test.rb +++ b/test/cask/cli/alfred_test.rb @@ -1,37 +1,37 @@ require 'test_helper' # slightly different format for read/write -scope = (Cask::CLI::Alfred::DEFAULT_SCOPES).map { |s| %Q{"#{s}"} } +scope = (Hbc::CLI::Alfred::DEFAULT_SCOPES).map { |s| %Q{"#{s}"} } DEFAULT_READ_SCOPE = %Q{(\n#{scope.join(",\n ")}\n)} -scope = (Cask::CLI::Alfred::DEFAULT_SCOPES + [Cask.caskroom.to_s]).map { |s| %Q{"#{s}"} } +scope = (Hbc::CLI::Alfred::DEFAULT_SCOPES + [Hbc.caskroom.to_s]).map { |s| %Q{"#{s}"} } ALTERED_READ_SCOPE = %Q{(\n#{scope.join(",\n ")}\n)} -scope = (Cask::CLI::Alfred::DEFAULT_SCOPES).map { |s| %Q{'#{s}'} } +scope = (Hbc::CLI::Alfred::DEFAULT_SCOPES).map { |s| %Q{'#{s}'} } DEFAULT_WRITE_SCOPE = %Q{(#{scope.join(',')})} -scope = (Cask::CLI::Alfred::DEFAULT_SCOPES + [Cask.caskroom.to_s]).map { |s| %Q{'#{s}'} } +scope = (Hbc::CLI::Alfred::DEFAULT_SCOPES + [Hbc.caskroom.to_s]).map { |s| %Q{'#{s}'} } ALTERED_WRITE_SCOPE = %Q{(#{scope.join(',')})} DEFAULT_SYNCDIR = '~/Library/Application Support/Alfred 2' def fake_alfred_read_primary_preference(key, response) - Cask::FakeSystemCommand.stubs_command(['/usr/bin/defaults', 'read', 'com.runningwithcrayons.Alfred-Preferences', key], response) + Hbc::FakeSystemCommand.stubs_command(['/usr/bin/defaults', 'read', 'com.runningwithcrayons.Alfred-Preferences', key], response) end def fake_alfred_write_primary_preference(key, value) - Cask::FakeSystemCommand.stubs_command(['/usr/bin/defaults', 'write', 'com.runningwithcrayons.Alfred-Preferences', key, value]) + Hbc::FakeSystemCommand.stubs_command(['/usr/bin/defaults', 'write', 'com.runningwithcrayons.Alfred-Preferences', key, value]) end def fake_alfred_read_local_preference(key, response) - local_files = Pathname.glob(Pathname.new(DEFAULT_SYNCDIR + Cask::CLI::Alfred::LOCALPREFS_SUBPATH).expand_path) + local_files = Pathname.glob(Pathname.new(DEFAULT_SYNCDIR + Hbc::CLI::Alfred::LOCALPREFS_SUBPATH).expand_path) local_files.each do |file| - Cask::FakeSystemCommand.stubs_command(['/usr/bin/defaults', 'read', file, key], response) + Hbc::FakeSystemCommand.stubs_command(['/usr/bin/defaults', 'read', file, key], response) end end def fake_alfred_write_local_preference(key, value) - local_files = Pathname.glob(Pathname.new(DEFAULT_SYNCDIR + Cask::CLI::Alfred::LOCALPREFS_SUBPATH).expand_path) + local_files = Pathname.glob(Pathname.new(DEFAULT_SYNCDIR + Hbc::CLI::Alfred::LOCALPREFS_SUBPATH).expand_path) local_files.each do |file| - Cask::FakeSystemCommand.stubs_command(['/usr/bin/defaults', 'write', file, key, value]) + Hbc::FakeSystemCommand.stubs_command(['/usr/bin/defaults', 'write', file, key, value]) end end @@ -46,14 +46,14 @@ def fake_alfred_installed(installed=true) end end -describe Cask::CLI::Alfred do +describe Hbc::CLI::Alfred do describe "status" do it "properly reports when alfred is not installed" do fake_alfred_installed(false) fake_alfred_read_local_preference('scope', DEFAULT_READ_SCOPE) TestHelper.must_output(self, lambda { - Cask::CLI::Alfred.run('status', Cask::FakeSystemCommand) + Hbc::CLI::Alfred.run('status', Hbc::FakeSystemCommand) }, "Warning: Could not find Alfred 2 preferences. Alfred 2 is probably not installed.") end @@ -63,7 +63,7 @@ describe Cask::CLI::Alfred do fake_alfred_read_primary_preference 'features.defaultresults.scope', DEFAULT_READ_SCOPE TestHelper.must_output(self, lambda { - Cask::CLI::Alfred.run('status', Cask::FakeSystemCommand) + Hbc::CLI::Alfred.run('status', Hbc::FakeSystemCommand) }, "==> Alfred is not linked to homebrew-cask.") end end @@ -73,7 +73,7 @@ describe Cask::CLI::Alfred do fake_alfred_installed(false) TestHelper.must_output(self, lambda { - Cask::CLI::Alfred.run('link', Cask::FakeSystemCommand) + Hbc::CLI::Alfred.run('link', Hbc::FakeSystemCommand) }, "Warning: Could not find Alfred 2 preferences. Alfred 2 is probably not installed.") end @@ -86,7 +86,7 @@ describe Cask::CLI::Alfred do # todo: the message text is out of expected order because of mixing STDERR/STDOUT TestHelper.must_output(self, lambda { - Cask::CLI::Alfred.run('link', Cask::FakeSystemCommand) + Hbc::CLI::Alfred.run('link', Hbc::FakeSystemCommand) }, "==> Successfully linked Alfred to homebrew-cask.\nWarning: Alfred appears to be already linked. Updating defaults anyway.") end @@ -98,7 +98,7 @@ describe Cask::CLI::Alfred do fake_alfred_write_local_preference 'scope', ALTERED_WRITE_SCOPE TestHelper.must_output(self, lambda { - Cask::CLI::Alfred.run('link', Cask::FakeSystemCommand) + Hbc::CLI::Alfred.run('link', Hbc::FakeSystemCommand) }, "==> Successfully linked Alfred to homebrew-cask.") end @@ -117,7 +117,7 @@ describe Cask::CLI::Alfred do fake_alfred_write_local_preference 'scope', ALTERED_WRITE_SCOPE TestHelper.must_output(self, lambda { - Cask::CLI::Alfred.run('link', Cask::FakeSystemCommand) + Hbc::CLI::Alfred.run('link', Hbc::FakeSystemCommand) }, "==> Successfully linked Alfred to homebrew-cask.") end end @@ -127,7 +127,7 @@ describe Cask::CLI::Alfred do fake_alfred_installed(false) TestHelper.must_output(self, lambda { - Cask::CLI::Alfred.run('unlink', Cask::FakeSystemCommand) + Hbc::CLI::Alfred.run('unlink', Hbc::FakeSystemCommand) }, "Warning: Could not find Alfred 2 preferences. Alfred 2 is probably not installed.") end @@ -140,7 +140,7 @@ describe Cask::CLI::Alfred do # todo: the message text is out of expected order because of mixing STDERR/STDOUT TestHelper.must_output(self, lambda { - Cask::CLI::Alfred.run('unlink', Cask::FakeSystemCommand) + Hbc::CLI::Alfred.run('unlink', Hbc::FakeSystemCommand) }, "==> Successfully unlinked Alfred from homebrew-cask.\nWarning: Alfred appears to be already unlinked. Updating defaults anyway.") end @@ -152,7 +152,7 @@ describe Cask::CLI::Alfred do fake_alfred_write_local_preference 'scope', DEFAULT_WRITE_SCOPE TestHelper.must_output(self, lambda { - Cask::CLI::Alfred.run('unlink', Cask::FakeSystemCommand) + Hbc::CLI::Alfred.run('unlink', Hbc::FakeSystemCommand) }, "==> Successfully unlinked Alfred from homebrew-cask.") end end diff --git a/test/cask/cli/audit_test.rb b/test/cask/cli/audit_test.rb index b9fe253c49..15b9432238 100644 --- a/test/cask/cli/audit_test.rb +++ b/test/cask/cli/audit_test.rb @@ -1,12 +1,12 @@ require 'test_helper' -describe Cask::CLI::Audit do +describe Hbc::CLI::Audit do let(:auditor) { mock() } let(:cask) { mock() } describe 'selection of Casks to audit' do it 'audits all Casks if no tokens are given' do - Cask.stubs(:all => [cask, cask]) + Hbc.stubs(:all => [cask, cask]) auditor.expects(:audit).times(2) run_audit([], auditor) @@ -14,7 +14,7 @@ describe Cask::CLI::Audit do it 'audits specified Casks if tokens are given' do cask_token = 'nice-app' - Cask.expects(:load).with(cask_token).returns(cask) + Hbc.expects(:load).with(cask_token).returns(cask) auditor.expects(:audit).with(cask, :audit_download => false) run_audit([cask_token], auditor) @@ -23,7 +23,7 @@ describe Cask::CLI::Audit do describe 'rules for downloading a Cask' do it 'does not download the Cask per default' do - Cask.stubs(:load => cask) + Hbc.stubs(:load => cask) auditor.expects(:audit).with(cask, :audit_download => false) @@ -31,7 +31,7 @@ describe Cask::CLI::Audit do end it 'download a Cask if --download flag is set' do - Cask.stubs(:load => cask) + Hbc.stubs(:load => cask) auditor.expects(:audit).with(cask, :audit_download => true) @@ -40,6 +40,6 @@ describe Cask::CLI::Audit do end def run_audit(args, auditor) - Cask::CLI::Audit.new(args, auditor).run + Hbc::CLI::Audit.new(args, auditor).run end end diff --git a/test/cask/cli/cat_test.rb b/test/cask/cli/cat_test.rb index 55471a30aa..69584eadd0 100644 --- a/test/cask/cli/cat_test.rb +++ b/test/cask/cli/cat_test.rb @@ -1,6 +1,6 @@ require 'test_helper' -describe Cask::CLI::Cat do +describe Hbc::CLI::Cat do describe 'given a basic Cask' do before do @expected_output = <<-CLIOUTPUT.undent @@ -18,42 +18,42 @@ describe Cask::CLI::Cat do it 'displays the Cask file content about the specified Cask' do lambda { - Cask::CLI::Cat.run('basic-cask') + Hbc::CLI::Cat.run('basic-cask') }.must_output(@expected_output) end it 'throws away additional Cask arguments and uses the first' do lambda{ - Cask::CLI::Cat.run('basic-cask', 'local-caffeine') + Hbc::CLI::Cat.run('basic-cask', 'local-caffeine') }.must_output(@expected_output) end it 'throws away stray options' do lambda{ - Cask::CLI::Cat.run('--notavalidoption', 'basic-cask') + Hbc::CLI::Cat.run('--notavalidoption', 'basic-cask') }.must_output(@expected_output) end end it %q{raises an exception when the Cask doesn't exist} do lambda { - Cask::CLI::Cat.run('notacask') - }.must_raise CaskUnavailableError + Hbc::CLI::Cat.run('notacask') + }.must_raise Hbc::CaskUnavailableError end describe "when no Cask is specified" do it "raises an exception" do lambda { - Cask::CLI::Cat.run() - }.must_raise CaskUnspecifiedError + Hbc::CLI::Cat.run() + }.must_raise Hbc::CaskUnspecifiedError end end describe "when no Cask is specified, but an invalid option" do it "raises an exception" do lambda { - Cask::CLI::Cat.run('--notavalidoption') - }.must_raise CaskUnspecifiedError + Hbc::CLI::Cat.run('--notavalidoption') + }.must_raise Hbc::CaskUnspecifiedError end end end diff --git a/test/cask/cli/cleanup_test.rb b/test/cask/cli/cleanup_test.rb index 7f893cd3ed..ee5d892e22 100644 --- a/test/cask/cli/cleanup_test.rb +++ b/test/cask/cli/cleanup_test.rb @@ -1,10 +1,10 @@ require 'test_helper' -describe Cask::CLI::Cleanup do +describe Hbc::CLI::Cleanup do it 'does nothing with --outdated in the clean test environment' do - Cask.outdated = true + Hbc.outdated = true out, err = capture_io do - Cask::CLI::Cleanup.run + Hbc::CLI::Cleanup.run end out.must_equal <<-OUTPUT.undent ==> Removing dead symlinks @@ -17,9 +17,9 @@ describe Cask::CLI::Cleanup do # note: this test will fail in isolation. It depends on other # portions of the test suite leaving some files to do cleanup. it 'cleans up new files in the test environment' do - Cask.outdated = false + Hbc.outdated = false out, err = capture_io do - Cask::CLI::Cleanup.run + Hbc::CLI::Cleanup.run end out.must_match(/^==> Removing dead symlinks\nNothing to do\n==> Removing cached downloads\n/) end diff --git a/test/cask/cli/create_test.rb b/test/cask/cli/create_test.rb index 8482633200..b963d769e6 100644 --- a/test/cask/cli/create_test.rb +++ b/test/cask/cli/create_test.rb @@ -1,7 +1,7 @@ require 'test_helper' # monkeypatch for testing -class Cask::CLI::Create +class Hbc::CLI::Create def self.exec_editor(*command) editor_commands << command end @@ -15,26 +15,26 @@ class Cask::CLI::Create end end -describe Cask::CLI::Create do - before { Cask::CLI::Create.reset! } +describe Hbc::CLI::Create do + before { Hbc::CLI::Create.reset! } after { %w[ new-cask additional-cask another-cask yet-another-cask feine ].each do |cask| - path = Cask.path(cask) + path = Hbc.path(cask) path.delete if path.exist? end } it 'opens the editor for the specified Cask' do - Cask::CLI::Create.run('new-cask') - Cask::CLI::Create.editor_commands.must_equal [ - [Cask.path('new-cask')] + Hbc::CLI::Create.run('new-cask') + Hbc::CLI::Create.editor_commands.must_equal [ + [Hbc.path('new-cask')] ] end it 'drops a template down for the specified Cask' do - Cask::CLI::Create.run('new-cask') - template = File.read(Cask.path('new-cask')) + Hbc::CLI::Create.run('new-cask') + template = File.read(Hbc.path('new-cask')) template.must_equal <<-TEMPLATE.undent cask :v1 => 'new-cask' do version '' @@ -51,45 +51,45 @@ describe Cask::CLI::Create do end it 'throws away additional Cask arguments and uses the first' do - Cask::CLI::Create.run('additional-cask', 'another-cask') - Cask::CLI::Create.editor_commands.must_equal [ - [Cask.path('additional-cask')] + Hbc::CLI::Create.run('additional-cask', 'another-cask') + Hbc::CLI::Create.editor_commands.must_equal [ + [Hbc.path('additional-cask')] ] end it 'throws away stray options' do - Cask::CLI::Create.run('--notavalidoption', 'yet-another-cask') - Cask::CLI::Create.editor_commands.must_equal [ - [Cask.path('yet-another-cask')] + Hbc::CLI::Create.run('--notavalidoption', 'yet-another-cask') + Hbc::CLI::Create.editor_commands.must_equal [ + [Hbc.path('yet-another-cask')] ] end it 'raises an exception when the Cask already exists' do lambda { - Cask::CLI::Create.run('caffeine') - }.must_raise CaskAlreadyCreatedError + Hbc::CLI::Create.run('caffeine') + }.must_raise Hbc::CaskAlreadyCreatedError end it 'allows creating Casks that are substrings of existing Casks' do - Cask::CLI::Create.run('feine') - Cask::CLI::Create.editor_commands.must_equal [ - [Cask.path('feine')] + Hbc::CLI::Create.run('feine') + Hbc::CLI::Create.editor_commands.must_equal [ + [Hbc.path('feine')] ] end describe "when no Cask is specified" do it "raises an exception" do lambda { - Cask::CLI::Create.run() - }.must_raise CaskUnspecifiedError + Hbc::CLI::Create.run() + }.must_raise Hbc::CaskUnspecifiedError end end describe "when no Cask is specified, but an invalid option" do it "raises an exception" do lambda { - Cask::CLI::Create.run('--notavalidoption') - }.must_raise CaskUnspecifiedError + Hbc::CLI::Create.run('--notavalidoption') + }.must_raise Hbc::CaskUnspecifiedError end end end diff --git a/test/cask/cli/doctor_test.rb b/test/cask/cli/doctor_test.rb index 1de287ab5d..4c5af95177 100644 --- a/test/cask/cli/doctor_test.rb +++ b/test/cask/cli/doctor_test.rb @@ -1,10 +1,10 @@ require 'test_helper' -require 'cask/version' +require 'hbc/version' -describe Cask::CLI::Doctor do +describe Hbc::CLI::Doctor do it 'displays some nice info about the environment' do out, err = capture_io do - Cask::CLI::Doctor.run + Hbc::CLI::Doctor.run end # no point in trying to match more of this environment-specific info out.must_match /\A==> OS X Release:/ @@ -12,7 +12,7 @@ describe Cask::CLI::Doctor do it "raises an exception when arguments are given" do lambda { - Cask::CLI::Doctor.run('argument') + Hbc::CLI::Doctor.run('argument') }.must_raise ArgumentError end end diff --git a/test/cask/cli/edit_test.rb b/test/cask/cli/edit_test.rb index 84c535d522..308bb1460f 100644 --- a/test/cask/cli/edit_test.rb +++ b/test/cask/cli/edit_test.rb @@ -1,7 +1,7 @@ require 'test_helper' # monkeypatch for testing -class Cask::CLI::Edit +class Hbc::CLI::Edit def self.exec_editor(*command) editor_commands << command end @@ -15,44 +15,44 @@ class Cask::CLI::Edit end end -describe Cask::CLI::Edit do +describe Hbc::CLI::Edit do before do - Cask::CLI::Edit.reset! + Hbc::CLI::Edit.reset! end it 'opens the editor for the specified Cask' do - Cask::CLI::Edit.run('alfred') - Cask::CLI::Edit.editor_commands.must_equal [ - [Cask.path('alfred')] + Hbc::CLI::Edit.run('alfred') + Hbc::CLI::Edit.editor_commands.must_equal [ + [Hbc.path('alfred')] ] end it 'throws away additional arguments and uses the first' do - Cask::CLI::Edit.run('adium', 'alfred') - Cask::CLI::Edit.editor_commands.must_equal [ - [Cask.path('adium')] + Hbc::CLI::Edit.run('adium', 'alfred') + Hbc::CLI::Edit.editor_commands.must_equal [ + [Hbc.path('adium')] ] end it 'raises an exception when the Cask doesnt exist' do lambda { - Cask::CLI::Edit.run('notacask') - }.must_raise CaskUnavailableError + Hbc::CLI::Edit.run('notacask') + }.must_raise Hbc::CaskUnavailableError end describe "when no Cask is specified" do it "raises an exception" do lambda { - Cask::CLI::Edit.run() - }.must_raise CaskUnspecifiedError + Hbc::CLI::Edit.run() + }.must_raise Hbc::CaskUnspecifiedError end end describe "when no Cask is specified, but an invalid option" do it "raises an exception" do lambda { - Cask::CLI::Edit.run('--notavalidoption') - }.must_raise CaskUnspecifiedError + Hbc::CLI::Edit.run('--notavalidoption') + }.must_raise Hbc::CaskUnspecifiedError end end end diff --git a/test/cask/cli/fetch_test.rb b/test/cask/cli/fetch_test.rb index a6a1eddabd..e813401c27 100644 --- a/test/cask/cli/fetch_test.rb +++ b/test/cask/cli/fetch_test.rb @@ -1,32 +1,32 @@ require 'test_helper' -describe Cask::CLI::Fetch do +describe Hbc::CLI::Fetch do let(:local_transmission) do - Cask.load('local-transmission') + Hbc.load('local-transmission') end let(:local_caffeine) do - Cask.load('local-caffeine') + Hbc.load('local-caffeine') end it "allows download the installer of a Cask" do shutup do - Cask::CLI::Fetch.run('local-transmission', 'local-caffeine') + Hbc::CLI::Fetch.run('local-transmission', 'local-caffeine') end - Cask::CurlDownloadStrategy.new(local_transmission).cached_location.must_be :exist? - Cask::CurlDownloadStrategy.new(local_caffeine).cached_location.must_be :exist? + Hbc::CurlDownloadStrategy.new(local_transmission).cached_location.must_be :exist? + Hbc::CurlDownloadStrategy.new(local_caffeine).cached_location.must_be :exist? end it "prevents double fetch (without nuking existing installation)" do - download_stategy = Cask::CurlDownloadStrategy.new(local_transmission) + download_stategy = Hbc::CurlDownloadStrategy.new(local_transmission) shutup do - Cask::Download.new(local_transmission).perform + Hbc::Download.new(local_transmission).perform end old_ctime = File.stat(download_stategy.cached_location).ctime shutup do - Cask::CLI::Fetch.run('local-transmission') + Hbc::CLI::Fetch.run('local-transmission') end new_ctime = File.stat(download_stategy.cached_location).ctime @@ -36,17 +36,17 @@ describe Cask::CLI::Fetch do it "allows double fetch with --force" do shutup do - Cask::Download.new(local_transmission).perform + Hbc::Download.new(local_transmission).perform end - download_stategy = Cask::CurlDownloadStrategy.new(local_transmission) + download_stategy = Hbc::CurlDownloadStrategy.new(local_transmission) old_ctime = File.stat(download_stategy.cached_location).ctime sleep(1) shutup do - Cask::CLI::Fetch.run('local-transmission','--force') + Hbc::CLI::Fetch.run('local-transmission','--force') end - download_stategy = Cask::CurlDownloadStrategy.new(local_transmission) + download_stategy = Hbc::CurlDownloadStrategy.new(local_transmission) new_ctime = File.stat(download_stategy.cached_location).ctime # new_ctime.to_i.must_be :>, old_ctime.to_i @@ -56,24 +56,24 @@ describe Cask::CLI::Fetch do it "properly handles Casks that are not present" do lambda { shutup do - Cask::CLI::Fetch.run('notacask') + Hbc::CLI::Fetch.run('notacask') end - }.must_raise CaskUnavailableError + }.must_raise Hbc::CaskUnavailableError end describe "when no Cask is specified" do it "raises an exception" do lambda { - Cask::CLI::Fetch.run() - }.must_raise CaskUnspecifiedError + Hbc::CLI::Fetch.run() + }.must_raise Hbc::CaskUnspecifiedError end end describe "when no Cask is specified, but an invalid option" do it "raises an exception" do lambda { - Cask::CLI::Fetch.run('--notavalidoption') - }.must_raise CaskUnspecifiedError + Hbc::CLI::Fetch.run('--notavalidoption') + }.must_raise Hbc::CaskUnspecifiedError end end end diff --git a/test/cask/cli/home_test.rb b/test/cask/cli/home_test.rb index 5829768e4b..b88140db0c 100644 --- a/test/cask/cli/home_test.rb +++ b/test/cask/cli/home_test.rb @@ -1,7 +1,7 @@ require 'test_helper' # monkeypatch for testing -class Cask::CLI::Home +class Hbc::CLI::Home def self.system(*command) system_commands << command end @@ -15,29 +15,29 @@ class Cask::CLI::Home end end -describe Cask::CLI::Home do +describe Hbc::CLI::Home do before do - Cask::CLI::Home.reset! + Hbc::CLI::Home.reset! end it 'opens the homepage for the specified Cask' do - Cask::CLI::Home.run('alfred') - Cask::CLI::Home.system_commands.must_equal [ + Hbc::CLI::Home.run('alfred') + Hbc::CLI::Home.system_commands.must_equal [ ['/usr/bin/open', '--', 'http://www.alfredapp.com/'] ] end it 'works for multiple Casks' do - Cask::CLI::Home.run('alfred', 'adium') - Cask::CLI::Home.system_commands.must_equal [ + Hbc::CLI::Home.run('alfred', 'adium') + Hbc::CLI::Home.system_commands.must_equal [ ['/usr/bin/open', '--', 'http://www.alfredapp.com/'], ['/usr/bin/open', '--', 'https://www.adium.im/'] ] end it "opens the project page when no Cask is specified" do - Cask::CLI::Home.run - Cask::CLI::Home.system_commands.must_equal [ + Hbc::CLI::Home.run + Hbc::CLI::Home.system_commands.must_equal [ ['/usr/bin/open', '--', 'http://caskroom.io/'], ] end diff --git a/test/cask/cli/info_test.rb b/test/cask/cli/info_test.rb index b889b6b97d..e567f1db07 100644 --- a/test/cask/cli/info_test.rb +++ b/test/cask/cli/info_test.rb @@ -1,9 +1,9 @@ require 'test_helper' -describe Cask::CLI::Info do +describe Hbc::CLI::Info do it 'displays some nice info about the specified Cask' do lambda { - Cask::CLI::Info.run('local-caffeine') + Hbc::CLI::Info.run('local-caffeine') }.must_output <<-CLIOUTPUT.undent local-caffeine: 1.2.3 local-caffeine @@ -37,20 +37,20 @@ describe Cask::CLI::Info do it 'displays the info' do lambda { - Cask::CLI::Info.run('local-caffeine', 'local-transmission') + Hbc::CLI::Info.run('local-caffeine', 'local-transmission') }.must_output(@expected_output) end it 'throws away stray options' do lambda { - Cask::CLI::Info.run('--notavalidoption', 'local-caffeine', 'local-transmission') + Hbc::CLI::Info.run('--notavalidoption', 'local-caffeine', 'local-transmission') }.must_output(@expected_output) end end it 'should print caveats if the Cask provided one' do lambda { - Cask::CLI::Info.run('with-caveats') + Hbc::CLI::Info.run('with-caveats') }.must_output <<-CLIOUTPUT.undent with-caveats: 1.2.3 with-caveats @@ -75,7 +75,7 @@ describe Cask::CLI::Info do it 'should not print "Caveats" section divider if the caveats block has no output' do lambda { - Cask::CLI::Info.run('with-conditional-caveats') + Hbc::CLI::Info.run('with-conditional-caveats') }.must_output <<-CLIOUTPUT.undent with-conditional-caveats: 1.2.3 with-conditional-caveats @@ -90,16 +90,16 @@ describe Cask::CLI::Info do describe "when no Cask is specified" do it "raises an exception" do lambda { - Cask::CLI::Info.run() - }.must_raise CaskUnspecifiedError + Hbc::CLI::Info.run() + }.must_raise Hbc::CaskUnspecifiedError end end describe "when no Cask is specified, but an invalid option" do it "raises an exception" do lambda { - Cask::CLI::Info.run('--notavalidoption') - }.must_raise CaskUnspecifiedError + Hbc::CLI::Info.run('--notavalidoption') + }.must_raise Hbc::CaskUnspecifiedError end end end diff --git a/test/cask/cli/install_test.rb b/test/cask/cli/install_test.rb index d6f6c4a5ea..199cf965bb 100644 --- a/test/cask/cli/install_test.rb +++ b/test/cask/cli/install_test.rb @@ -1,60 +1,60 @@ require 'test_helper' -describe Cask::CLI::Install do +describe Hbc::CLI::Install do it "allows staging and activation of multiple Casks at once" do shutup do - Cask::CLI::Install.run('local-transmission', 'local-caffeine') + Hbc::CLI::Install.run('local-transmission', 'local-caffeine') end - Cask.load('local-transmission').must_be :installed? - Cask.appdir.join('Transmission.app').must_be :symlink? - Cask.load('local-caffeine').must_be :installed? - Cask.appdir.join('Caffeine.app').must_be :symlink? + Hbc.load('local-transmission').must_be :installed? + Hbc.appdir.join('Transmission.app').must_be :symlink? + Hbc.load('local-caffeine').must_be :installed? + Hbc.appdir.join('Caffeine.app').must_be :symlink? end it "skips double install (without nuking existing installation)" do shutup do - Cask::CLI::Install.run('local-transmission') + Hbc::CLI::Install.run('local-transmission') end shutup do - Cask::CLI::Install.run('local-transmission') + Hbc::CLI::Install.run('local-transmission') end - Cask.load('local-transmission').must_be :installed? + Hbc.load('local-transmission').must_be :installed? end it "prints a warning message on double install" do shutup do - Cask::CLI::Install.run('local-transmission') + Hbc::CLI::Install.run('local-transmission') end TestHelper.must_output(self, lambda { - Cask::CLI::Install.run('local-transmission', '') + Hbc::CLI::Install.run('local-transmission', '') }, %r{Warning: A Cask for local-transmission is already installed. Add the "--force" option to force re-install.}) end it "allows double install with --force" do shutup do - Cask::CLI::Install.run('local-transmission') + Hbc::CLI::Install.run('local-transmission') end TestHelper.must_output(self, lambda { - Cask::CLI::Install.run('local-transmission', '--force') - }, %r{==> Success! local-transmission staged at '#{Cask.caskroom}/local-transmission/2.61' \(487 files, 11M\)}) + Hbc::CLI::Install.run('local-transmission', '--force') + }, %r{==> Success! local-transmission staged at '#{Hbc.caskroom}/local-transmission/2.61' \(487 files, 11M\)}) end it "properly handles Casks that are not present" do lambda { shutup do - Cask::CLI::Install.run('notacask') + Hbc::CLI::Install.run('notacask') end - }.must_raise CaskError + }.must_raise Hbc::CaskError end it "returns a suggestion for a misspelled Cask" do out, err = capture_io do begin - Cask::CLI::Install.run('googlechrome') - rescue CaskError; end + Hbc::CLI::Install.run('googlechrome') + rescue Hbc::CaskError; end end err.must_match %r{No available Cask for googlechrome\. Did you mean:\ngoogle-chrome} end @@ -62,8 +62,8 @@ describe Cask::CLI::Install do it "returns multiple suggestions for a Cask fragment" do out, err = capture_io do begin - Cask::CLI::Install.run('google') - rescue CaskError; end + Hbc::CLI::Install.run('google') + rescue Hbc::CaskError; end end err.must_match %r{No available Cask for google\. Did you mean one of:\ngoogle} end @@ -72,8 +72,8 @@ describe Cask::CLI::Install do with_options = lambda do |options| it "raises an exception" do lambda { - Cask::CLI::Install.run(*options) - }.must_raise CaskUnspecifiedError + Hbc::CLI::Install.run(*options) + }.must_raise Hbc::CaskUnspecifiedError end end diff --git a/test/cask/cli/list_test.rb b/test/cask/cli/list_test.rb index 9513d0cacd..5515fdba31 100644 --- a/test/cask/cli/list_test.rb +++ b/test/cask/cli/list_test.rb @@ -1,13 +1,13 @@ require 'test_helper' -describe Cask::CLI::List do +describe Hbc::CLI::List do it 'lists the installed Casks in a pretty fashion' do - casks = %w[local-caffeine local-transmission].map { |c| Cask.load(c) } + casks = %w[local-caffeine local-transmission].map { |c| Hbc.load(c) } casks.each { |c| TestHelper.install_without_artifacts(c) } lambda { - Cask::CLI::List.run + Hbc::CLI::List.run }.must_output <<-OUTPUT.gsub(/^ */, '') local-caffeine local-transmission @@ -16,7 +16,7 @@ describe Cask::CLI::List do describe 'when Casks have been renamed' do before do - @renamed_path = Cask.caskroom.join('ive-been-renamed','latest','Renamed.app').tap(&:mkpath) + @renamed_path = Hbc.caskroom.join('ive-been-renamed','latest','Renamed.app').tap(&:mkpath) @renamed_path.join('Info.plist').open('w') { |f| f.puts "Oh plist" } end @@ -26,7 +26,7 @@ describe Cask::CLI::List do it 'lists installed Casks without backing ruby files (due to renames or otherwise)' do lambda { - Cask::CLI::List.run + Hbc::CLI::List.run }.must_output <<-OUTPUT.gsub(/^ */, '') ive-been-renamed (!) OUTPUT @@ -35,7 +35,7 @@ describe Cask::CLI::List do it 'given a set of installed Casks, lists the installed files for those Casks' do - casks = %w[local-caffeine local-transmission].map { |c| Cask.load(c) } + casks = %w[local-caffeine local-transmission].map { |c| Hbc.load(c) } casks.each { |c| TestHelper.install_without_artifacts(c) } @@ -45,7 +45,7 @@ describe Cask::CLI::List do # aren't created under the test harness. Todo: managed links should # be fully mocked and confirmed here. lambda { - Cask::CLI::List.run('local-transmission', 'local-caffeine') + Hbc::CLI::List.run('local-transmission', 'local-caffeine') }.must_output <<-OUTPUT.gsub(/^ */, '') ==> App Symlinks managed by brew-cask: ==> Staged content: diff --git a/test/cask/cli/options_test.rb b/test/cask/cli/options_test.rb index 54a056e822..c3b39afa0d 100644 --- a/test/cask/cli/options_test.rb +++ b/test/cask/cli/options_test.rb @@ -1,132 +1,132 @@ require 'test_helper' -describe Cask::CLI do +describe Hbc::CLI do it "supports setting the appdir" do - Cask::CLI.process_options %w{help --appdir=/some/path/foo} + Hbc::CLI.process_options %w{help --appdir=/some/path/foo} - Cask.appdir.must_equal Pathname('/some/path/foo') + Hbc.appdir.must_equal Pathname('/some/path/foo') end it "supports setting the appdir from ENV" do ENV['HOMEBREW_CASK_OPTS'] = "--appdir=/some/path/bar" - Cask::CLI.process_options %w{help} + Hbc::CLI.process_options %w{help} - Cask.appdir.must_equal Pathname('/some/path/bar') + Hbc.appdir.must_equal Pathname('/some/path/bar') end it "supports setting the prefpanedir" do - Cask::CLI.process_options %w{help --prefpanedir=/some/path/foo} + Hbc::CLI.process_options %w{help --prefpanedir=/some/path/foo} - Cask.prefpanedir.must_equal Pathname('/some/path/foo') + Hbc.prefpanedir.must_equal Pathname('/some/path/foo') end it "supports setting the prefpanedir from ENV" do ENV['HOMEBREW_CASK_OPTS'] = "--prefpanedir=/some/path/bar" - Cask::CLI.process_options %w{help} + Hbc::CLI.process_options %w{help} - Cask.prefpanedir.must_equal Pathname('/some/path/bar') + Hbc.prefpanedir.must_equal Pathname('/some/path/bar') end it "supports setting the qlplugindir" do - Cask::CLI.process_options %w{help --qlplugindir=/some/path/foo} + Hbc::CLI.process_options %w{help --qlplugindir=/some/path/foo} - Cask.qlplugindir.must_equal Pathname('/some/path/foo') + Hbc.qlplugindir.must_equal Pathname('/some/path/foo') end it "supports setting the qlplugindir from ENV" do ENV['HOMEBREW_CASK_OPTS'] = "--qlplugindir=/some/path/bar" - Cask::CLI.process_options %w{help} + Hbc::CLI.process_options %w{help} - Cask.qlplugindir.must_equal Pathname('/some/path/bar') + Hbc.qlplugindir.must_equal Pathname('/some/path/bar') end it "supports setting the colorpickerdir" do - Cask::CLI.process_options %w{help --colorpickerdir=/some/path/foo} + Hbc::CLI.process_options %w{help --colorpickerdir=/some/path/foo} - Cask.colorpickerdir.must_equal Pathname('/some/path/foo') + Hbc.colorpickerdir.must_equal Pathname('/some/path/foo') end it "supports setting the colorpickerdir from ENV" do ENV['HOMEBREW_CASK_OPTS'] = "--colorpickerdir=/some/path/bar" - Cask::CLI.process_options %w{help} + Hbc::CLI.process_options %w{help} - Cask.colorpickerdir.must_equal Pathname('/some/path/bar') + Hbc.colorpickerdir.must_equal Pathname('/some/path/bar') end it "supports setting the fontdir" do - Cask::CLI.process_options %w{help --fontdir=/some/path/foo} + Hbc::CLI.process_options %w{help --fontdir=/some/path/foo} - Cask.fontdir.must_equal Pathname('/some/path/foo') + Hbc.fontdir.must_equal Pathname('/some/path/foo') end it "supports setting the fontdir from ENV" do ENV['HOMEBREW_CASK_OPTS'] = "--fontdir=/some/path/bar" - Cask::CLI.process_options %w{help} + Hbc::CLI.process_options %w{help} - Cask.fontdir.must_equal Pathname('/some/path/bar') + Hbc.fontdir.must_equal Pathname('/some/path/bar') end it "supports setting the widgetdir" do - Cask::CLI.process_options %w{help --widgetdir=/some/path/foo} + Hbc::CLI.process_options %w{help --widgetdir=/some/path/foo} - Cask.widgetdir.must_equal Pathname('/some/path/foo') + Hbc.widgetdir.must_equal Pathname('/some/path/foo') end it "supports setting the widgetdir from ENV" do ENV['HOMEBREW_CASK_OPTS'] = "--widgetdir=/some/path/bar" - Cask::CLI.process_options %w{help} + Hbc::CLI.process_options %w{help} - Cask.widgetdir.must_equal Pathname('/some/path/bar') + Hbc.widgetdir.must_equal Pathname('/some/path/bar') end it "supports setting the servicedir" do - Cask::CLI.process_options %w{help --servicedir=/some/path/foo} + Hbc::CLI.process_options %w{help --servicedir=/some/path/foo} - Cask.servicedir.must_equal Pathname('/some/path/foo') + Hbc.servicedir.must_equal Pathname('/some/path/foo') end it "supports setting the servicedir from ENV" do ENV['HOMEBREW_CASK_OPTS'] = "--servicedir=/some/path/bar" - Cask::CLI.process_options %w{help} + Hbc::CLI.process_options %w{help} - Cask.servicedir.must_equal Pathname('/some/path/bar') + Hbc.servicedir.must_equal Pathname('/some/path/bar') end it "allows additional options to be passed through" do - rest = Cask::CLI.process_options %w{edit foo --create --appdir=/some/path/qux} + rest = Hbc::CLI.process_options %w{edit foo --create --appdir=/some/path/qux} - Cask.appdir.must_equal Pathname('/some/path/qux') + Hbc.appdir.must_equal Pathname('/some/path/qux') rest.must_equal %w{edit foo --create} end describe "when a mandatory argument is missing" do it "shows a user-friendly error message" do lambda { - Cask::CLI.process_options %w{install -f} - }.must_raise CaskError + Hbc::CLI.process_options %w{install -f} + }.must_raise Hbc::CaskError end end describe "given an ambiguous option" do it "shows a user-friendly error message" do lambda { - Cask::CLI.process_options %w{edit -c} - }.must_raise CaskError + Hbc::CLI.process_options %w{edit -c} + }.must_raise Hbc::CaskError end end describe "--debug" do it "sets the Cask debug method to true" do - Cask::CLI.process_options %w{help --debug} - Cask.debug.must_equal true - Cask.debug = false + Hbc::CLI.process_options %w{help --debug} + Hbc.debug.must_equal true + Hbc.debug = false end end diff --git a/test/cask/cli/search_test.rb b/test/cask/cli/search_test.rb index 7d3c6eece2..f02f051d9b 100644 --- a/test/cask/cli/search_test.rb +++ b/test/cask/cli/search_test.rb @@ -1,9 +1,9 @@ require 'test_helper' -describe Cask::CLI::Search do +describe Hbc::CLI::Search do it "lists the available Casks that match the search term" do lambda { - Cask::CLI::Search.run('intellij') + Hbc::CLI::Search.run('intellij') }.must_output <<-OUTPUT.gsub(/^ */, '') ==> Partial matches intellij-idea @@ -13,13 +13,13 @@ describe Cask::CLI::Search do it "shows that there are no Casks matching a search term that did not result in anything" do lambda { - Cask::CLI::Search.run('foo-bar-baz') + Hbc::CLI::Search.run('foo-bar-baz') }.must_output("No Cask found for \"foo-bar-baz\".\n") end it "lists all available Casks with no search term" do out, err = capture_io do - Cask::CLI::Search.run + Hbc::CLI::Search.run end out.must_match(/google-chrome/) out.length.must_be :>, 1000 @@ -27,7 +27,7 @@ describe Cask::CLI::Search do it "ignores hyphens in search terms" do out, err = capture_io do - Cask::CLI::Search.run('goo-gle-chrome') + Hbc::CLI::Search.run('goo-gle-chrome') end out.must_match(/google-chrome/) out.length.must_be :<, 100 @@ -35,7 +35,7 @@ describe Cask::CLI::Search do it "ignores hyphens in Cask tokens" do out, err = capture_io do - Cask::CLI::Search.run('googlechrome') + Hbc::CLI::Search.run('googlechrome') end out.must_match(/google-chrome/) out.length.must_be :<, 100 @@ -43,7 +43,7 @@ describe Cask::CLI::Search do it "accepts multiple arguments" do out, err = capture_io do - Cask::CLI::Search.run('google chrome') + Hbc::CLI::Search.run('google chrome') end out.must_match(/google-chrome/) out.length.must_be :<, 100 @@ -51,20 +51,20 @@ describe Cask::CLI::Search do it "accepts a regexp argument" do lambda { - Cask::CLI::Search.run('/^google-c[a-z]rome$/') + Hbc::CLI::Search.run('/^google-c[a-z]rome$/') }.must_output "==> Regexp matches\ngoogle-chrome\n" end it "Returns both exact and partial matches" do out, err = capture_io do - Cask::CLI::Search.run('mnemosyne') + Hbc::CLI::Search.run('mnemosyne') end out.must_match(/^==> Exact match\nmnemosyne\n==> Partial matches\nsubclassed-mnemosyne/) end it "does not search the Tap name" do out, err = capture_io do - Cask::CLI::Search.run('caskroom') + Hbc::CLI::Search.run('caskroom') end out.must_match(/^No Cask found for "caskroom"\.\n/) end diff --git a/test/cask/cli/uninstall_test.rb b/test/cask/cli/uninstall_test.rb index 8701850729..e007ed7566 100644 --- a/test/cask/cli/uninstall_test.rb +++ b/test/cask/cli/uninstall_test.rb @@ -1,49 +1,49 @@ require 'test_helper' -describe Cask::CLI::Uninstall do +describe Hbc::CLI::Uninstall do it "shows an error when a bad Cask is provided" do lambda { - Cask::CLI::Uninstall.run('notacask') - }.must_raise CaskUnavailableError + Hbc::CLI::Uninstall.run('notacask') + }.must_raise Hbc::CaskUnavailableError end it "shows an error when a Cask is provided that's not installed" do lambda { - Cask::CLI::Uninstall.run('anvil') - }.must_raise CaskNotInstalledError + Hbc::CLI::Uninstall.run('anvil') + }.must_raise Hbc::CaskNotInstalledError end it "tries anyway on a non-present Cask when --force is given" do lambda { - Cask::CLI::Uninstall.run('anvil', '--force') + Hbc::CLI::Uninstall.run('anvil', '--force') } # wont_raise end it "can uninstall and unlink multiple Casks at once" do - caffeine = Cask.load('local-caffeine') - transmission = Cask.load('local-transmission') + caffeine = Hbc.load('local-caffeine') + transmission = Hbc.load('local-transmission') shutup do - Cask::Installer.new(caffeine).install - Cask::Installer.new(transmission).install + Hbc::Installer.new(caffeine).install + Hbc::Installer.new(transmission).install end caffeine.must_be :installed? transmission.must_be :installed? shutup do - Cask::CLI::Uninstall.run('local-caffeine', 'local-transmission') + Hbc::CLI::Uninstall.run('local-caffeine', 'local-transmission') end caffeine.wont_be :installed? - Cask.appdir.join('Transmission.app').wont_be :symlink? + Hbc.appdir.join('Transmission.app').wont_be :symlink? transmission.wont_be :installed? - Cask.appdir.join('Caffeine.app').wont_be :symlink? + Hbc.appdir.join('Caffeine.app').wont_be :symlink? end describe "when Casks have been renamed" do before do - @renamed_path = Cask.caskroom.join('ive-been-renamed','latest','Renamed.app').tap(&:mkpath) + @renamed_path = Hbc.caskroom.join('ive-been-renamed','latest','Renamed.app').tap(&:mkpath) @renamed_path.join('Info.plist').open('w') { |f| f.puts "Oh plist" } end @@ -53,7 +53,7 @@ describe Cask::CLI::Uninstall do it "can uninstall non-ruby-backed Casks" do shutup do - Cask::CLI::Uninstall.run('ive-been-renamed') + Hbc::CLI::Uninstall.run('ive-been-renamed') end @renamed_path.wont_be :exist? @@ -63,16 +63,16 @@ describe Cask::CLI::Uninstall do describe "when no Cask is specified" do it "raises an exception" do lambda { - Cask::CLI::Uninstall.run() - }.must_raise CaskUnspecifiedError + Hbc::CLI::Uninstall.run() + }.must_raise Hbc::CaskUnspecifiedError end end describe "when no Cask is specified, but an invalid option" do it "raises an exception" do lambda { - Cask::CLI::Uninstall.run('--notavalidoption') - }.must_raise CaskUnspecifiedError + Hbc::CLI::Uninstall.run('--notavalidoption') + }.must_raise Hbc::CaskUnspecifiedError end end end diff --git a/test/cask/cli/version_test.rb b/test/cask/cli/version_test.rb index f0ea3e0121..ace1260d13 100644 --- a/test/cask/cli/version_test.rb +++ b/test/cask/cli/version_test.rb @@ -3,7 +3,7 @@ require 'test_helper' describe 'brew cask --version' do it 'respects the --version argument' do lambda { - Cask::CLI::NullCommand.new('--version').run - }.must_output "#{HOMEBREW_CASK_VERSION}\n" + Hbc::CLI::NullCommand.new('--version').run + }.must_output "#{HBC_VERSION}\n" end end diff --git a/test/cask/cli/zap_test.rb b/test/cask/cli/zap_test.rb index d14588263a..7c17bcc2af 100644 --- a/test/cask/cli/zap_test.rb +++ b/test/cask/cli/zap_test.rb @@ -1,33 +1,33 @@ require 'test_helper' -describe Cask::CLI::Zap do +describe Hbc::CLI::Zap do it "shows an error when a bad Cask is provided" do lambda { - Cask::CLI::Zap.run('notacask') - }.must_raise CaskUnavailableError + Hbc::CLI::Zap.run('notacask') + }.must_raise Hbc::CaskUnavailableError end it "can zap and unlink multiple Casks at once" do - caffeine = Cask.load('local-caffeine') - transmission = Cask.load('local-transmission') + caffeine = Hbc.load('local-caffeine') + transmission = Hbc.load('local-transmission') shutup do - Cask::Installer.new(caffeine).install - Cask::Installer.new(transmission).install + Hbc::Installer.new(caffeine).install + Hbc::Installer.new(transmission).install end caffeine.must_be :installed? transmission.must_be :installed? shutup do - Cask::CLI::Zap.run('--notavalidoption', + Hbc::CLI::Zap.run('--notavalidoption', 'local-caffeine', 'local-transmission') end caffeine.wont_be :installed? - Cask.appdir.join('Transmission.app').wont_be :symlink? + Hbc.appdir.join('Transmission.app').wont_be :symlink? transmission.wont_be :installed? - Cask.appdir.join('Caffeine.app').wont_be :symlink? + Hbc.appdir.join('Caffeine.app').wont_be :symlink? end # todo @@ -35,25 +35,25 @@ describe Cask::CLI::Zap do # The above tests that implicitly. # # it "dispatches both uninstall and zap stanzas" do - # with_zap = Cask.load('with-zap') + # with_zap = Hbc.load('with-zap') # # shutup do - # Cask::Installer.new(with_zap).install + # Hbc::Installer.new(with_zap).install # end # # with_zap.must_be :installed? # - # Cask::FakeSystemCommand.stubs_command(['/usr/bin/sudo', '-E', '--', '/usr/bin/osascript', '-e', 'tell application "System Events" to count processes whose bundle identifier is "my.fancy.package.app"'], '1') - # Cask::FakeSystemCommand.stubs_command(['/usr/bin/sudo', '-E', '--', '/usr/bin/osascript', '-e', 'tell application id "my.fancy.package.app" to quit']) - # Cask::FakeSystemCommand.stubs_command(['/usr/bin/sudo', '-E', '--', '/usr/bin/osascript', '-e', 'tell application "System Events" to count processes whose bundle identifier is "my.fancy.package.app.from.uninstall"'], '1') - # Cask::FakeSystemCommand.stubs_command(['/usr/bin/sudo', '-E', '--', '/usr/bin/osascript', '-e', 'tell application id "my.fancy.package.app.from.uninstall" to quit']) + # Hbc::FakeSystemCommand.stubs_command(['/usr/bin/sudo', '-E', '--', '/usr/bin/osascript', '-e', 'tell application "System Events" to count processes whose bundle identifier is "my.fancy.package.app"'], '1') + # Hbc::FakeSystemCommand.stubs_command(['/usr/bin/sudo', '-E', '--', '/usr/bin/osascript', '-e', 'tell application id "my.fancy.package.app" to quit']) + # Hbc::FakeSystemCommand.stubs_command(['/usr/bin/sudo', '-E', '--', '/usr/bin/osascript', '-e', 'tell application "System Events" to count processes whose bundle identifier is "my.fancy.package.app.from.uninstall"'], '1') + # Hbc::FakeSystemCommand.stubs_command(['/usr/bin/sudo', '-E', '--', '/usr/bin/osascript', '-e', 'tell application id "my.fancy.package.app.from.uninstall" to quit']) # - # Cask::FakeSystemCommand.expects_command(['/usr/bin/sudo', '-E', '--', with_zap.staged_path.join('MyFancyPkg','FancyUninstaller.tool'), '--please']) - # Cask::FakeSystemCommand.expects_command(['/usr/bin/sudo', '-E', '--', '/bin/rm', '-rf', '--', + # Hbc::FakeSystemCommand.expects_command(['/usr/bin/sudo', '-E', '--', with_zap.staged_path.join('MyFancyPkg','FancyUninstaller.tool'), '--please']) + # Hbc::FakeSystemCommand.expects_command(['/usr/bin/sudo', '-E', '--', '/bin/rm', '-rf', '--', # Pathname.new('~/Library/Preferences/my.fancy.app.plist').expand_path]) # # shutup do - # Cask::CLI::Zap.run('with-zap') + # Hbc::CLI::Zap.run('with-zap') # end # with_zap.wont_be :installed? # end @@ -61,16 +61,16 @@ describe Cask::CLI::Zap do describe "when no Cask is specified" do it "raises an exception" do lambda { - Cask::CLI::Zap.run() - }.must_raise CaskUnspecifiedError + Hbc::CLI::Zap.run() + }.must_raise Hbc::CaskUnspecifiedError end end describe "when no Cask is specified, but an invalid option" do it "raises an exception" do lambda { - Cask::CLI::Zap.run('--notavalidoption') - }.must_raise CaskUnspecifiedError + Hbc::CLI::Zap.run('--notavalidoption') + }.must_raise Hbc::CaskUnspecifiedError end end end diff --git a/test/cask/container/dmg_test.rb b/test/cask/container/dmg_test.rb index c876b2f82f..c3bb32f32c 100644 --- a/test/cask/container/dmg_test.rb +++ b/test/cask/container/dmg_test.rb @@ -1,14 +1,14 @@ require 'test_helper' -describe Cask::Container::Dmg do +describe Hbc::Container::Dmg do describe "mount!" do it "does not store nil mounts for dmgs with extra data" do - transmission = Cask.load('local-transmission') + transmission = Hbc.load('local-transmission') - dmg = Cask::Container::Dmg.new( + dmg = Hbc::Container::Dmg.new( transmission, Pathname(transmission.url.path), - Cask::SystemCommand + Hbc::SystemCommand ) begin diff --git a/test/cask/container/naked_test.rb b/test/cask/container/naked_test.rb index 8fbce7d991..85ef2776f1 100644 --- a/test/cask/container/naked_test.rb +++ b/test/cask/container/naked_test.rb @@ -1,8 +1,8 @@ require 'test_helper' -describe Cask::Container::Naked do +describe Hbc::Container::Naked do it "saves files with spaces in them from uris with encoded spaces" do - SpaceyCask = Class.new(Cask) + SpaceyCask = Class.new(Hbc) SpaceyCask.class_eval do url 'http://example.com/kevin%20spacey.pkg' version '1.2' @@ -12,11 +12,11 @@ describe Cask::Container::Naked do path = '/tmp/downloads/kevin-spacey-1.2.pkg' expected_destination = cask.staged_path.join('kevin spacey.pkg') expected_command = ['/usr/bin/ditto', '--', path, expected_destination] - Cask::FakeSystemCommand.stubs_command(expected_command) + Hbc::FakeSystemCommand.stubs_command(expected_command) - container = Cask::Container::Naked.new(cask, path, Cask::FakeSystemCommand) + container = Hbc::Container::Naked.new(cask, path, Hbc::FakeSystemCommand) container.extract - Cask::FakeSystemCommand.system_calls[expected_command].must_equal 1 + Hbc::FakeSystemCommand.system_calls[expected_command].must_equal 1 end end diff --git a/test/cask/depends_on_test.rb b/test/cask/depends_on_test.rb index 3be9cee068..afceaa6994 100644 --- a/test/cask/depends_on_test.rb +++ b/test/cask/depends_on_test.rb @@ -14,19 +14,19 @@ describe "Satisfy Dependencies and Requirements" do describe "depends_on :cask" do it "raises an exception when depends_on :cask is cyclic" do - dep_cask = Cask.load('with-depends-on-cask-cyclic') + dep_cask = Hbc.load('with-depends-on-cask-cyclic') lambda { shutup do - Cask::Installer.new(dep_cask).install + Hbc::Installer.new(dep_cask).install end - }.must_raise(CaskCyclicCaskDependencyError) + }.must_raise(Hbc::CaskCyclicCaskDependencyError) end it "installs the dependency of a Cask and the Cask itself" do - csk = Cask.load('with-depends-on-cask') - dependency = Cask.load(csk.depends_on.cask.first) + csk = Hbc.load('with-depends-on-cask') + dependency = Hbc.load(csk.depends_on.cask.first) shutup do - Cask::Installer.new(csk).install + Hbc::Installer.new(csk).install end csk.must_be :installed? @@ -36,85 +36,85 @@ describe "Satisfy Dependencies and Requirements" do describe "depends_on :macos" do it "understands depends_on :macos => " do - macos_cask = Cask.load('with-depends-on-macos-array') + macos_cask = Hbc.load('with-depends-on-macos-array') shutup do - Cask::Installer.new(macos_cask).install + Hbc::Installer.new(macos_cask).install end end it "understands depends_on :macos => " do - macos_cask = Cask.load('with-depends-on-macos-comparison') + macos_cask = Hbc.load('with-depends-on-macos-comparison') shutup do - Cask::Installer.new(macos_cask).install + Hbc::Installer.new(macos_cask).install end end it "understands depends_on :macos => " do - macos_cask = Cask.load('with-depends-on-macos-string') + macos_cask = Hbc.load('with-depends-on-macos-string') shutup do - Cask::Installer.new(macos_cask).install + Hbc::Installer.new(macos_cask).install end end it "understands depends_on :macos => " do - macos_cask = Cask.load('with-depends-on-macos-symbol') + macos_cask = Hbc.load('with-depends-on-macos-symbol') shutup do - Cask::Installer.new(macos_cask).install + Hbc::Installer.new(macos_cask).install end end it "raises an exception when depends_on :macos is not satisfied" do - macos_cask = Cask.load('with-depends-on-macos-failure') + macos_cask = Hbc.load('with-depends-on-macos-failure') lambda { shutup do - Cask::Installer.new(macos_cask).install + Hbc::Installer.new(macos_cask).install end - }.must_raise(CaskError) + }.must_raise(Hbc::CaskError) end end describe "depends_on :arch" do it "succeeds when depends_on :arch is satisfied" do - arch_cask = Cask.load('with-depends-on-arch') + arch_cask = Hbc.load('with-depends-on-arch') shutup do - Cask::Installer.new(arch_cask).install + Hbc::Installer.new(arch_cask).install end end it "raises an exception when depends_on :arch is not satisfied" do - arch_cask = Cask.load('with-depends-on-arch-failure') + arch_cask = Hbc.load('with-depends-on-arch-failure') lambda { shutup do - Cask::Installer.new(arch_cask).install + Hbc::Installer.new(arch_cask).install end - }.must_raise(CaskError) + }.must_raise(Hbc::CaskError) end end describe "depends_on :x11" do it "succeeds when depends_on :x11 is satisfied" do - x11_cask = Cask.load('with-depends-on-x11') + x11_cask = Hbc.load('with-depends-on-x11') shutup do - Cask::Installer.new(x11_cask).install + Hbc::Installer.new(x11_cask).install end end it "raises an exception when depends_on :x11 is not satisfied" do - x11_cask = Cask.load('with-depends-on-x11') - Cask.stubs(:x11_libpng).returns([Pathname.new('/usr/path/does/not/exist')]) + x11_cask = Hbc.load('with-depends-on-x11') + Hbc.stubs(:x11_libpng).returns([Pathname.new('/usr/path/does/not/exist')]) lambda { shutup do - Cask::Installer.new(x11_cask).install + Hbc::Installer.new(x11_cask).install end - }.must_raise(CaskX11DependencyError) + }.must_raise(Hbc::CaskX11DependencyError) end it "never raises when depends_on :x11 => false" do - x11_cask = Cask.load('with-depends-on-x11-false') - Cask.stubs(:x11_executable).returns(Pathname.new('/usr/path/does/not/exist')) + x11_cask = Hbc.load('with-depends-on-x11-false') + Hbc.stubs(:x11_executable).returns(Pathname.new('/usr/path/does/not/exist')) lambda { shutup do - Cask::Installer.new(x11_cask).install + Hbc::Installer.new(x11_cask).install end } # won't raise end diff --git a/test/cask/dsl/postflight_test.rb b/test/cask/dsl/postflight_test.rb index 85d169a9e3..6e759d715b 100644 --- a/test/cask/dsl/postflight_test.rb +++ b/test/cask/dsl/postflight_test.rb @@ -1,13 +1,13 @@ require "test_helper" -describe Cask::DSL::Postflight do +describe Hbc::DSL::Postflight do before do - cask = Cask.load('basic-cask') - @dsl = Cask::DSL::Postflight.new(cask, Cask::FakeSystemCommand) + cask = Hbc.load('basic-cask') + @dsl = Hbc::DSL::Postflight.new(cask, Hbc::FakeSystemCommand) end it "can run system commands with list-form arguments" do - Cask::FakeSystemCommand.expects_command( + Hbc::FakeSystemCommand.expects_command( ['echo', 'homebrew-cask', 'rocks!'] ) @dsl.system_command("echo", :args => ["homebrew-cask", "rocks!"]) @@ -20,7 +20,7 @@ describe Cask::DSL::Postflight do it "can execute commands on the Info.plist file" do @dsl.stubs(:bundle_identifier => 'com.example.BasicCask') - Cask::FakeSystemCommand.expects_command( + Hbc::FakeSystemCommand.expects_command( ['/usr/libexec/PlistBuddy', '-c', 'Print CFBundleIdentifier', @dsl.info_plist_file] ) @dsl.plist_exec('Print CFBundleIdentifier') @@ -29,7 +29,7 @@ describe Cask::DSL::Postflight do it "can set a key in the Info.plist file" do @dsl.stubs(:bundle_identifier => 'com.example.BasicCask') - Cask::FakeSystemCommand.expects_command( + Hbc::FakeSystemCommand.expects_command( ['/usr/libexec/PlistBuddy', '-c', 'Set :JVMOptions:JVMVersion 1.6+', @dsl.info_plist_file] ) @dsl.plist_set(':JVMOptions:JVMVersion', '1.6+') @@ -38,7 +38,7 @@ describe Cask::DSL::Postflight do it "can suppress move to applications folder alert " do @dsl.stubs(:bundle_identifier => 'com.example.BasicCask') - Cask::FakeSystemCommand.expects_command( + Hbc::FakeSystemCommand.expects_command( ['/usr/bin/defaults', 'write', 'com.example.BasicCask', 'moveToApplicationsFolderAlertSuppress', '-bool', 'true'] ) @dsl.suppress_move_to_applications @@ -47,7 +47,7 @@ describe Cask::DSL::Postflight do it "can suppress move to applications folder alert with a different key" do @dsl.stubs(:bundle_identifier => 'com.example.BasicCask') - Cask::FakeSystemCommand.expects_command( + Hbc::FakeSystemCommand.expects_command( ['/usr/bin/defaults', 'write', 'com.example.BasicCask', 'suppressMoveToApplications', '-bool', 'true'] ) @dsl.suppress_move_to_applications :key => 'suppressMoveToApplications' diff --git a/test/cask/dsl/uninstall_preflight_test.rb b/test/cask/dsl/uninstall_preflight_test.rb index aaafb87d9d..56c8782b05 100644 --- a/test/cask/dsl/uninstall_preflight_test.rb +++ b/test/cask/dsl/uninstall_preflight_test.rb @@ -1,8 +1,8 @@ require "test_helper" -describe Cask::DSL::UninstallPreflight do +describe Hbc::DSL::UninstallPreflight do before do - cask = Cask.load('basic-cask') - @dsl = Cask::DSL::UninstallPreflight.new(cask, Cask::FakeSystemCommand) + cask = Hbc.load('basic-cask') + @dsl = Hbc::DSL::UninstallPreflight.new(cask, Hbc::FakeSystemCommand) end end diff --git a/test/cask/dsl_test.rb b/test/cask/dsl_test.rb index a71bb168f5..eb91fda80e 100644 --- a/test/cask/dsl_test.rb +++ b/test/cask/dsl_test.rb @@ -1,15 +1,15 @@ require 'test_helper' -describe Cask::DSL do +describe Hbc::DSL do it "lets you set url, homepage, and version" do - test_cask = Cask.load('basic-cask') + test_cask = Hbc.load('basic-cask') test_cask.url.to_s.must_equal 'http://example.com/TestCask.dmg' test_cask.homepage.must_equal 'http://example.com/' test_cask.version.must_equal '1.2.3' end describe "when a Cask includes an unknown method" do - UnexpectedMethodCask = Class.new(Cask) + UnexpectedMethodCask = Class.new(Hbc) attempt_unknown_method = nil before do @@ -47,23 +47,23 @@ describe Cask::DSL do describe "header line" do it "requires a valid header format" do err = lambda { - invalid_cask = Cask.load('invalid/invalid-header-format') - }.must_raise(CaskInvalidError) + invalid_cask = Hbc.load('invalid/invalid-header-format') + }.must_raise(Hbc::CaskInvalidError) err.message.must_include 'Bad header line: parse failed' end it "requires the header token to match the file name" do err = lambda { - invalid_cask = Cask.load('invalid/invalid-header-token-mismatch') - }.must_raise(CaskInvalidError) + invalid_cask = Hbc.load('invalid/invalid-header-token-mismatch') + }.must_raise(Hbc::CaskInvalidError) err.message.must_include 'Bad header line:' err.message.must_include 'does not match file name' end it "requires a valid minimum DSL version in the header" do err = lambda { - invalid_cask = Cask.load('invalid/invalid-header-version') - }.must_raise(CaskInvalidError) + invalid_cask = Hbc.load('invalid/invalid-header-version') + }.must_raise(Hbc::CaskInvalidError) err.message.must_include 'Bad header line:' err.message.must_include 'is less than required minimum version' end @@ -71,7 +71,7 @@ describe Cask::DSL do describe "name stanza" do it "lets you set the full name via a name stanza" do - NameCask = Class.new(Cask) + NameCask = Class.new(Hbc) NameCask.class_eval do name 'Proper Name' end @@ -82,7 +82,7 @@ describe Cask::DSL do end it "Accepts an array value to the name stanza" do - ArrayNameCask = Class.new(Cask) + ArrayNameCask = Class.new(Hbc) ArrayNameCask.class_eval do name ['Proper Name', 'Alternate Name'] end @@ -94,7 +94,7 @@ describe Cask::DSL do end it "Accepts multiple name stanzas" do - MultiNameCask = Class.new(Cask) + MultiNameCask = Class.new(Hbc) MultiNameCask.class_eval do name 'Proper Name' name 'Alternate Name' @@ -109,7 +109,7 @@ describe Cask::DSL do describe "sha256 stanza" do it "lets you set checksum via sha256" do - ChecksumCask = Class.new(Cask) + ChecksumCask = Class.new(Hbc) ChecksumCask.class_eval do sha256 'imasha2' end @@ -120,7 +120,7 @@ describe Cask::DSL do describe "app stanza" do it "allows you to specify app stanzas" do - CaskWithApps = Class.new(Cask) + CaskWithApps = Class.new(Hbc) CaskWithApps.class_eval do app 'Foo.app' app 'Bar.app' @@ -131,7 +131,7 @@ describe Cask::DSL do end it "allow app stanzas to be empty" do - CaskWithNoApps = Class.new(Cask) + CaskWithNoApps = Class.new(Hbc) instance = CaskWithNoApps.new Array(instance.artifacts[:app]).must_equal %w[] @@ -140,13 +140,13 @@ describe Cask::DSL do describe "caveats stanza" do it "allows caveats to be specified via a method define" do - PlainCask = Class.new(Cask) + PlainCask = Class.new(Hbc) instance = PlainCask.new instance.caveats.must_be :empty? - CaskWithCaveats = Class.new(Cask) + CaskWithCaveats = Class.new(Hbc) CaskWithCaveats.class_eval do def caveats; <<-EOS.undent When you install this Cask, you probably want to know this. @@ -162,7 +162,7 @@ describe Cask::DSL do describe "pkg stanza" do it "allows installable pkgs to be specified" do - CaskWithPkgs = Class.new(Cask) + CaskWithPkgs = Class.new(Hbc) CaskWithPkgs.class_eval do pkg 'Foo.pkg' pkg 'Bar.pkg' @@ -176,8 +176,8 @@ describe Cask::DSL do describe "url stanza" do it "prevents defining multiple urls" do err = lambda { - invalid_cask = Cask.load('invalid/invalid-two-url') - }.must_raise(CaskInvalidError) + invalid_cask = Hbc.load('invalid/invalid-two-url') + }.must_raise(Hbc::CaskInvalidError) err.message.must_include "'url' stanza may only appear once" end end @@ -185,8 +185,8 @@ describe Cask::DSL do describe "homepage stanza" do it "prevents defining multiple homepages" do err = lambda { - invalid_cask = Cask.load('invalid/invalid-two-homepage') - }.must_raise(CaskInvalidError) + invalid_cask = Hbc.load('invalid/invalid-two-homepage') + }.must_raise(Hbc::CaskInvalidError) err.message.must_include "'homepage' stanza may only appear once" end end @@ -194,250 +194,250 @@ describe Cask::DSL do describe "version stanza" do it "prevents defining multiple versions" do err = lambda { - invalid_cask = Cask.load('invalid/invalid-two-version') - }.must_raise(CaskInvalidError) + invalid_cask = Hbc.load('invalid/invalid-two-version') + }.must_raise(Hbc::CaskInvalidError) err.message.must_include "'version' stanza may only appear once" end end describe "appcast stanza" do it "allows appcasts to be specified" do - cask = Cask.load('with-appcast') + cask = Hbc.load('with-appcast') cask.appcast.to_s.must_match %r{^http} end it "prevents defining multiple appcasts" do err = lambda { - invalid_cask = Cask.load('invalid/invalid-appcast-multiple') - }.must_raise(CaskInvalidError) + invalid_cask = Hbc.load('invalid/invalid-appcast-multiple') + }.must_raise(Hbc::CaskInvalidError) err.message.must_include "'appcast' stanza may only appear once" end it "refuses to load invalid appcast URLs" do err = lambda { - invalid_cask = Cask.load('invalid/invalid-appcast-url') - }.must_raise(CaskInvalidError) + invalid_cask = Hbc.load('invalid/invalid-appcast-url') + }.must_raise(Hbc::CaskInvalidError) end it "refuses to load if appcast :format is invalid" do err = lambda { - invalid_cask = Cask.load('invalid/invalid-appcast-format') - }.must_raise(CaskInvalidError) + invalid_cask = Hbc.load('invalid/invalid-appcast-format') + }.must_raise(Hbc::CaskInvalidError) end end describe "gpg stanza" do it "allows gpg stanza to be specified" do - cask = Cask.load('with-gpg') + cask = Hbc.load('with-gpg') cask.gpg.to_s.must_match %r{\S} end it "allows gpg stanza to be specified with :key_url" do - cask = Cask.load('with-gpg-key-url') + cask = Hbc.load('with-gpg-key-url') cask.gpg.to_s.must_match %r{\S} end it "prevents specifying gpg stanza multiple times" do err = lambda { - invalid_cask = Cask.load('invalid/invalid-gpg-multiple-stanzas') - }.must_raise(CaskInvalidError) + invalid_cask = Hbc.load('invalid/invalid-gpg-multiple-stanzas') + }.must_raise(Hbc::CaskInvalidError) err.message.must_include "'gpg' stanza may only appear once" end it "prevents missing gpg key parameters" do err = lambda { - invalid_cask = Cask.load('invalid/invalid-gpg-missing-key') - }.must_raise(CaskInvalidError) + invalid_cask = Hbc.load('invalid/invalid-gpg-missing-key') + }.must_raise(Hbc::CaskInvalidError) err.message.must_include "'gpg' stanza must include exactly one" end it "prevents conflicting gpg key parameters" do err = lambda { - invalid_cask = Cask.load('invalid/invalid-gpg-conflicting-keys') - }.must_raise(CaskInvalidError) + invalid_cask = Hbc.load('invalid/invalid-gpg-conflicting-keys') + }.must_raise(Hbc::CaskInvalidError) err.message.must_include "'gpg' stanza must include exactly one" end it "refuses to load invalid gpg signature URLs" do err = lambda { - invalid_cask = Cask.load('invalid/invalid-gpg-signature-url') - }.must_raise(CaskInvalidError) + invalid_cask = Hbc.load('invalid/invalid-gpg-signature-url') + }.must_raise(Hbc::CaskInvalidError) end it "refuses to load invalid gpg key URLs" do err = lambda { - invalid_cask = Cask.load('invalid/invalid-gpg-key-url') - }.must_raise(CaskInvalidError) + invalid_cask = Hbc.load('invalid/invalid-gpg-key-url') + }.must_raise(Hbc::CaskInvalidError) end it "refuses to load invalid gpg key IDs" do err = lambda { - invalid_cask = Cask.load('invalid/invalid-gpg-key-id') - }.must_raise(CaskInvalidError) + invalid_cask = Hbc.load('invalid/invalid-gpg-key-id') + }.must_raise(Hbc::CaskInvalidError) end it "refuses to load if gpg parameter is unknown" do err = lambda { - invalid_cask = Cask.load('invalid/invalid-gpg-parameter') - }.must_raise(CaskInvalidError) + invalid_cask = Hbc.load('invalid/invalid-gpg-parameter') + }.must_raise(Hbc::CaskInvalidError) end end describe "depends_on stanza" do it "refuses to load with an invalid depends_on key" do err = lambda { - invalid_cask = Cask.load('invalid/invalid-depends-on-key') - }.must_raise(CaskInvalidError) + invalid_cask = Hbc.load('invalid/invalid-depends-on-key') + }.must_raise(Hbc::CaskInvalidError) end end describe "depends_on :formula" do it "allows depends_on :formula to be specified" do - cask = Cask.load('with-depends-on-formula') + cask = Hbc.load('with-depends-on-formula') cask.depends_on.formula.wont_be_nil end it "allows multiple depends_on :formula to be specified" do - cask = Cask.load('with-depends-on-formula-multiple') + cask = Hbc.load('with-depends-on-formula-multiple') cask.depends_on.formula.wont_be_nil end end describe "depends_on :cask" do it "allows depends_on :cask to be specified" do - cask = Cask.load('with-depends-on-cask') + cask = Hbc.load('with-depends-on-cask') cask.depends_on.cask.wont_be_nil end it "allows multiple depends_on :cask to be specified" do - cask = Cask.load('with-depends-on-cask-multiple') + cask = Hbc.load('with-depends-on-cask-multiple') cask.depends_on.cask.wont_be_nil end end describe "depends_on :macos" do it "allows depends_on :macos to be specified" do - cask = Cask.load('with-depends-on-macos-string') + cask = Hbc.load('with-depends-on-macos-string') cask.depends_on.macos.wont_be_nil end it "refuses to load with an invalid depends_on :macos value" do err = lambda { - invalid_cask = Cask.load('invalid/invalid-depends-on-macos-bad-release') - }.must_raise(CaskInvalidError) + invalid_cask = Hbc.load('invalid/invalid-depends-on-macos-bad-release') + }.must_raise(Hbc::CaskInvalidError) end it "refuses to load with conflicting depends_on :macos forms" do err = lambda { - invalid_cask = Cask.load('invalid/invalid-depends-on-macos-conflicting-forms') - }.must_raise(CaskInvalidError) + invalid_cask = Hbc.load('invalid/invalid-depends-on-macos-conflicting-forms') + }.must_raise(Hbc::CaskInvalidError) end end describe "depends_on :arch" do it "allows depends_on :arch to be specified" do - cask = Cask.load('with-depends-on-arch') + cask = Hbc.load('with-depends-on-arch') cask.depends_on.arch.wont_be_nil end it "refuses to load with an invalid depends_on :arch value" do err = lambda { - invalid_cask = Cask.load('invalid/invalid-depends-on-arch-value') - }.must_raise(CaskInvalidError) + invalid_cask = Hbc.load('invalid/invalid-depends-on-arch-value') + }.must_raise(Hbc::CaskInvalidError) end end describe "depends_on :x11" do it "allows depends_on :x11 to be specified" do - cask = Cask.load('with-depends-on-x11') + cask = Hbc.load('with-depends-on-x11') cask.depends_on.x11.wont_be_nil end it "refuses to load with an invalid depends_on :x11 value" do err = lambda { - invalid_cask = Cask.load('invalid/invalid-depends-on-x11-value') - }.must_raise(CaskInvalidError) + invalid_cask = Hbc.load('invalid/invalid-depends-on-x11-value') + }.must_raise(Hbc::CaskInvalidError) end end describe "conflicts_with stanza" do it "allows conflicts_with stanza to be specified" do - cask = Cask.load('with-conflicts-with') + cask = Hbc.load('with-conflicts-with') cask.conflicts_with.formula.wont_be_nil end it "refuses to load invalid conflicts_with key" do err = lambda { - invalid_cask = Cask.load('invalid/invalid-conflicts-with-key') - }.must_raise(CaskInvalidError) + invalid_cask = Hbc.load('invalid/invalid-conflicts-with-key') + }.must_raise(Hbc::CaskInvalidError) end end describe "license stanza" do it "allows the license to be specified" do - cask = Cask.load('with-license') + cask = Hbc.load('with-license') cask.license.value.must_equal :gpl end it "the license has a category" do - cask = Cask.load('with-license') + cask = Hbc.load('with-license') cask.license.category.must_equal :oss end it "prevents defining multiple license stanzas" do err = lambda { - invalid_cask = Cask.load('invalid/invalid-license-multiple') - }.must_raise(CaskInvalidError) + invalid_cask = Hbc.load('invalid/invalid-license-multiple') + }.must_raise(Hbc::CaskInvalidError) err.message.must_include "'license' stanza may only appear once" end it "refuses to load on invalid license value" do err = lambda { - invalid_cask = Cask.load('invalid/invalid-license-value') - }.must_raise(CaskInvalidError) + invalid_cask = Hbc.load('invalid/invalid-license-value') + }.must_raise(Hbc::CaskInvalidError) end end describe "installer stanza" do it "allows installer :script to be specified" do - cask = Cask.load('with-installer-script') + cask = Hbc.load('with-installer-script') cask.artifacts[:installer].first.script[:executable].must_equal '/usr/bin/true' cask.artifacts[:installer].first.script[:args].must_equal ['--flag'] cask.artifacts[:installer].to_a[1].script[:executable].must_equal '/usr/bin/false' cask.artifacts[:installer].to_a[1].script[:args].must_equal ['--flag'] end it "allows installer :manual to be specified" do - cask = Cask.load('with-installer-manual') + cask = Hbc.load('with-installer-manual') cask.artifacts[:installer].first.manual.must_equal 'Caffeine.app' end end describe "tags stanza" do it "allows tags stanza to be specified" do - cask = Cask.load('with-tags') + cask = Hbc.load('with-tags') cask.tags.to_s.must_match %r{\S} end it "prevents specifying tags multiple times" do err = lambda { - invalid_cask = Cask.load('invalid/invalid-tags-multiple') - }.must_raise(CaskInvalidError) + invalid_cask = Hbc.load('invalid/invalid-tags-multiple') + }.must_raise(Hbc::CaskInvalidError) err.message.must_include "'tags' stanza may only appear once" end it "refuses to load if tags key is invalid" do err = lambda { - invalid_cask = Cask.load('invalid/invalid-tags-key') - }.must_raise(CaskInvalidError) + invalid_cask = Hbc.load('invalid/invalid-tags-key') + }.must_raise(Hbc::CaskInvalidError) end end describe "stage_only stanza" do it "allows stage_only stanza to be specified" do - cask = Cask.load('stage-only') + cask = Hbc.load('stage-only') cask.artifacts[:stage_only].first.must_equal [true] end it "prevents specifying stage_only with other activatables" do err = lambda { - invalid_cask = Cask.load('invalid/invalid-stage-only-conflict') - }.must_raise(CaskInvalidError) + invalid_cask = Hbc.load('invalid/invalid-stage-only-conflict') + }.must_raise(Hbc::CaskInvalidError) err.message.must_include "'stage_only' must be the only activatable artifact" end end diff --git a/test/cask/installer_test.rb b/test/cask/installer_test.rb index a6a0ea5575..c3ea96013c 100644 --- a/test/cask/installer_test.rb +++ b/test/cask/installer_test.rb @@ -1,41 +1,41 @@ require 'test_helper' -describe Cask::Installer do +describe Hbc::Installer do describe "install" do it "downloads and installs a nice fresh Cask" do - caffeine = Cask.load('local-caffeine') + caffeine = Hbc.load('local-caffeine') shutup do - Cask::Installer.new(caffeine).install + Hbc::Installer.new(caffeine).install end - dest_path = Cask.caskroom.join('local-caffeine',caffeine.version) + dest_path = Hbc.caskroom.join('local-caffeine',caffeine.version) dest_path.must_be :directory? application = dest_path.join('Caffeine.app') application.must_be :directory? end it "works with dmg-based Casks" do - transmission = Cask.load('local-transmission') + transmission = Hbc.load('local-transmission') shutup do - Cask::Installer.new(transmission).install + Hbc::Installer.new(transmission).install end - dest_path = Cask.caskroom.join('local-transmission',transmission.version) + dest_path = Hbc.caskroom.join('local-transmission',transmission.version) dest_path.must_be :directory? application = dest_path.join('Transmission.app') application.must_be :directory? end it "works with tar-based Casks" do - tarball = Cask.load('tarball') + tarball = Hbc.load('tarball') shutup do - Cask::Installer.new(tarball).install + Hbc::Installer.new(tarball).install end - dest_path = Cask.caskroom.join('tarball',tarball.version) + dest_path = Hbc.caskroom.join('tarball',tarball.version) dest_path.must_be :directory? application = dest_path.join('Tarball.app') application.must_be :directory? @@ -43,15 +43,15 @@ describe Cask::Installer do it "works with cab-based Casks" do skip unless HOMEBREW_PREFIX.join('bin/cabextract').exist? - cab_container = Cask.load('cab-container') + cab_container = Hbc.load('cab-container') empty = stub(:formula => [], :cask => [], :macos => nil, :arch => nil, :x11 => nil) cab_container.stubs(:depends_on).returns(empty) shutup do - Cask::Installer.new(cab_container).install + Hbc::Installer.new(cab_container).install end - dest_path = Cask.caskroom.join('cab-container',cab_container.version) + dest_path = Hbc.caskroom.join('cab-container',cab_container.version) dest_path.must_be :directory? application = dest_path.join('cabcontainer','Application.app') application.must_be :directory? @@ -59,11 +59,11 @@ describe Cask::Installer do it "works with Adobe AIR-based Casks" do skip unless Pathname('/Applications/Utilities/Adobe AIR Application Installer.app/Contents/MacOS/Adobe AIR Application Installer').exist? - air_container = Cask.load('adobe-air-container') + air_container = Hbc.load('adobe-air-container') shutup do - Cask::Installer.new(air_container).install + Hbc::Installer.new(air_container).install end - dest_path = Cask.caskroom.join('adobe-air-container',air_container.version) + dest_path = Hbc.caskroom.join('adobe-air-container',air_container.version) dest_path.must_be :directory? application = dest_path.join('GMDesk.app') application.must_be :directory? @@ -71,28 +71,28 @@ describe Cask::Installer do it "works with 7z-based Casks" do skip unless HOMEBREW_PREFIX.join('bin','unar').exist? - sevenzip_container = Cask.load('sevenzip-container') + sevenzip_container = Hbc.load('sevenzip-container') empty = stub(:formula => [], :cask => [], :macos => nil, :arch => nil, :x11 => nil) sevenzip_container.stubs(:depends_on).returns(empty) shutup do - Cask::Installer.new(sevenzip_container).install + Hbc::Installer.new(sevenzip_container).install end - dest_path = Cask.caskroom.join('sevenzip-container',sevenzip_container.version) + dest_path = Hbc.caskroom.join('sevenzip-container',sevenzip_container.version) dest_path.must_be :directory? application = dest_path.join('sevenzipcontainer','Application.app') application.must_be :directory? end it "works with xar-based Casks" do - xar_container = Cask.load('xar-container') + xar_container = Hbc.load('xar-container') shutup do - Cask::Installer.new(xar_container).install + Hbc::Installer.new(xar_container).install end - dest_path = Cask.caskroom.join('xar-container',xar_container.version) + dest_path = Hbc.caskroom.join('xar-container',xar_container.version) dest_path.must_be :directory? application = dest_path.join('xarcontainer','Application.app') application.must_be :directory? @@ -100,15 +100,15 @@ describe Cask::Installer do it "works with Stuffit-based Casks" do skip unless HOMEBREW_PREFIX.join('bin','unar').exist? - stuffit_container = Cask.load('stuffit-container') + stuffit_container = Hbc.load('stuffit-container') empty = stub(:formula => [], :cask => [], :macos => nil, :arch => nil, :x11 => nil) stuffit_container.stubs(:depends_on).returns(empty) shutup do - Cask::Installer.new(stuffit_container).install + Hbc::Installer.new(stuffit_container).install end - dest_path = Cask.caskroom.join('stuffit-container',stuffit_container.version) + dest_path = Hbc.caskroom.join('stuffit-container',stuffit_container.version) dest_path.must_be :directory? application = dest_path.join('sheldonmac','v1.0') application.must_be :directory? @@ -116,112 +116,112 @@ describe Cask::Installer do it "works with RAR-based Casks" do skip unless HOMEBREW_PREFIX.join('bin','unar').exist? - rar_container = Cask.load('rar-container') + rar_container = Hbc.load('rar-container') empty = stub(:formula => [], :cask => [], :macos => nil, :arch => nil, :x11 => nil) rar_container.stubs(:depends_on).returns(empty) shutup do - Cask::Installer.new(rar_container).install + Hbc::Installer.new(rar_container).install end - dest_path = Cask.caskroom.join('rar-container',rar_container.version) + dest_path = Hbc.caskroom.join('rar-container',rar_container.version) dest_path.must_be :directory? application = dest_path.join('rarcontainer','Application.app') application.must_be :directory? end it "works with bz2-based Casks" do - asset = Cask.load('bzipped-asset') + asset = Hbc.load('bzipped-asset') shutup do - Cask::Installer.new(asset).install + Hbc::Installer.new(asset).install end - dest_path = Cask.caskroom.join('bzipped-asset',asset.version) + dest_path = Hbc.caskroom.join('bzipped-asset',asset.version) dest_path.must_be :directory? file = dest_path.join("bzipped-asset-#{asset.version}") file.must_be :file? end it "works with pure gz-based Casks" do - asset = Cask.load('gzipped-asset') + asset = Hbc.load('gzipped-asset') shutup do - Cask::Installer.new(asset).install + Hbc::Installer.new(asset).install end - dest_path = Cask.caskroom.join('gzipped-asset',asset.version) + dest_path = Hbc.caskroom.join('gzipped-asset',asset.version) dest_path.must_be :directory? file = dest_path.join("gzipped-asset-#{asset.version}") file.must_be :file? end it "blows up on a bad checksum" do - bad_checksum = Cask.load('bad-checksum') + bad_checksum = Hbc.load('bad-checksum') lambda { shutup do - Cask::Installer.new(bad_checksum).install + Hbc::Installer.new(bad_checksum).install end - }.must_raise(CaskSha256MismatchError) + }.must_raise(Hbc::CaskSha256MismatchError) end it "blows up on a missing checksum" do - missing_checksum = Cask.load('missing-checksum') + missing_checksum = Hbc.load('missing-checksum') lambda { shutup do - Cask::Installer.new(missing_checksum).install + Hbc::Installer.new(missing_checksum).install end - }.must_raise(CaskSha256MissingError) + }.must_raise(Hbc::CaskSha256MissingError) end it "installs fine if sha256 :no_check is used" do - no_checksum = Cask.load('no-checksum') + no_checksum = Hbc.load('no-checksum') shutup do - Cask::Installer.new(no_checksum).install + Hbc::Installer.new(no_checksum).install end no_checksum.must_be :installed? end it "prints caveats if they're present" do - with_caveats = Cask.load('with-caveats') + with_caveats = Hbc.load('with-caveats') TestHelper.must_output(self, lambda { - Cask::Installer.new(with_caveats).install + Hbc::Installer.new(with_caveats).install }, /Here are some things you might want to know/) with_caveats.must_be :installed? end it "prints installer :manual instructions when present" do - with_installer_manual = Cask.load('with-installer-manual') + with_installer_manual = Hbc.load('with-installer-manual') TestHelper.must_output(self, lambda { - Cask::Installer.new(with_installer_manual).install + Hbc::Installer.new(with_installer_manual).install }, /To complete the installation of Cask with-installer-manual, you must also\nrun the installer at\n\n '#{with_installer_manual.staged_path.join(%Q{Caffeine.app})}'/) with_installer_manual.must_be :installed? end it "does not extract __MACOSX directories from zips" do - with_macosx_dir = Cask.load('with-macosx-dir') + with_macosx_dir = Hbc.load('with-macosx-dir') shutup do - Cask::Installer.new(with_macosx_dir).install + Hbc::Installer.new(with_macosx_dir).install end with_macosx_dir.staged_path.join('__MACOSX').wont_be :directory? end # unlike the CLI, the internal interface throws exception on double-install it "installer method raises an exception when already-installed Casks are attempted" do - transmission = Cask.load('local-transmission') + transmission = Hbc.load('local-transmission') transmission.installed?.must_equal false - installer = Cask::Installer.new(transmission) + installer = Hbc::Installer.new(transmission) shutup { installer.install } lambda { installer.install - }.must_raise(CaskAlreadyInstalledError) + }.must_raise(Hbc::CaskAlreadyInstalledError) end it "allows already-installed Casks to be installed if force is provided" do - transmission = Cask.load('local-transmission') + transmission = Hbc.load('local-transmission') transmission.installed?.must_equal false - installer = Cask::Installer.new(transmission) + installer = Hbc::Installer.new(transmission) shutup { installer.install } shutup { @@ -230,45 +230,45 @@ describe Cask::Installer do end it "works properly with a direct URL to a pkg" do - naked_pkg = Cask.load('naked-pkg') + naked_pkg = Hbc.load('naked-pkg') shutup do - Cask::Installer.new(naked_pkg).install + Hbc::Installer.new(naked_pkg).install end - dest_path = Cask.caskroom.join('naked-pkg',naked_pkg.version) + dest_path = Hbc.caskroom.join('naked-pkg',naked_pkg.version) pkg = dest_path.join('Naked.pkg') pkg.must_be :file? end it "works properly with an overridden container :type" do - naked_executable = Cask.load('naked-executable') + naked_executable = Hbc.load('naked-executable') shutup do - Cask::Installer.new(naked_executable).install + Hbc::Installer.new(naked_executable).install end - dest_path = Cask.caskroom.join('naked-executable',naked_executable.version) + dest_path = Hbc.caskroom.join('naked-executable',naked_executable.version) executable = dest_path.join('naked_executable') executable.must_be :file? end it "works fine with a nested container" do - nested_app = Cask.load('nested-app') + nested_app = Hbc.load('nested-app') shutup do - Cask::Installer.new(nested_app).install + Hbc::Installer.new(nested_app).install end - dest_path = Cask.appdir.join('MyNestedApp.app') + dest_path = Hbc.appdir.join('MyNestedApp.app') TestHelper.valid_alias?(dest_path).must_equal true end it "generates and finds a timestamped metadata directory for an installed Cask" do - caffeine = Cask.load('local-caffeine') + caffeine = Hbc.load('local-caffeine') shutup do - Cask::Installer.new(caffeine).install + Hbc::Installer.new(caffeine).install end m_path = caffeine.metadata_path(:now, true) @@ -277,10 +277,10 @@ describe Cask::Installer do end it "generates and finds a metadata subdirectory for an installed Cask" do - caffeine = Cask.load('local-caffeine') + caffeine = Hbc.load('local-caffeine') shutup do - Cask::Installer.new(caffeine).install + Hbc::Installer.new(caffeine).install end subdir_name = 'Casks' @@ -292,41 +292,41 @@ describe Cask::Installer do describe "uninstall" do it "fully uninstalls a Cask" do - caffeine = Cask.load('local-caffeine') - installer = Cask::Installer.new(caffeine) + caffeine = Hbc.load('local-caffeine') + installer = Hbc::Installer.new(caffeine) shutup do installer.install installer.uninstall end - Cask.caskroom.join('local-caffeine',caffeine.version,'Caffeine.app').wont_be :directory? - Cask.caskroom.join('local-caffeine',caffeine.version).wont_be :directory? - Cask.caskroom.join('local-caffeine').wont_be :directory? + Hbc.caskroom.join('local-caffeine',caffeine.version,'Caffeine.app').wont_be :directory? + Hbc.caskroom.join('local-caffeine',caffeine.version).wont_be :directory? + Hbc.caskroom.join('local-caffeine').wont_be :directory? end it "uninstalls all versions if force is set" do - caffeine = Cask.load('local-caffeine') - installer = Cask::Installer.new(caffeine) + caffeine = Hbc.load('local-caffeine') + installer = Hbc::Installer.new(caffeine) mutated_version = caffeine.version + '.1' shutup do installer.install end - Cask.caskroom.join('local-caffeine',caffeine.version).must_be :directory? - Cask.caskroom.join('local-caffeine',mutated_version).wont_be :directory? - FileUtils.mv(Cask.caskroom.join('local-caffeine',caffeine.version), Cask.caskroom.join('local-caffeine',mutated_version)) - Cask.caskroom.join('local-caffeine',caffeine.version).wont_be :directory? - Cask.caskroom.join('local-caffeine',mutated_version).must_be :directory? + Hbc.caskroom.join('local-caffeine',caffeine.version).must_be :directory? + Hbc.caskroom.join('local-caffeine',mutated_version).wont_be :directory? + FileUtils.mv(Hbc.caskroom.join('local-caffeine',caffeine.version), Hbc.caskroom.join('local-caffeine',mutated_version)) + Hbc.caskroom.join('local-caffeine',caffeine.version).wont_be :directory? + Hbc.caskroom.join('local-caffeine',mutated_version).must_be :directory? shutup do installer.uninstall(true) end - Cask.caskroom.join('local-caffeine',caffeine.version).wont_be :directory? - Cask.caskroom.join('local-caffeine',mutated_version).wont_be :directory? - Cask.caskroom.join('local-caffeine').wont_be :directory? + Hbc.caskroom.join('local-caffeine',caffeine.version).wont_be :directory? + Hbc.caskroom.join('local-caffeine',mutated_version).wont_be :directory? + Hbc.caskroom.join('local-caffeine').wont_be :directory? end end end diff --git a/test/cask/pkg_test.rb b/test/cask/pkg_test.rb index 96f45bfd5b..66dfd492ab 100644 --- a/test/cask/pkg_test.rb +++ b/test/cask/pkg_test.rb @@ -1,9 +1,9 @@ require 'test_helper' -describe Cask::Pkg do +describe Hbc::Pkg do describe 'uninstall' do it 'removes files and dirs referenced by the pkg' do - pkg = Cask::Pkg.new('my.fake.pkg', Cask::NeverSudoSystemCommand) + pkg = Hbc::Pkg.new('my.fake.pkg', Hbc::NeverSudoSystemCommand) some_files = Array.new(3) { Pathname(Tempfile.new('testfile').path) } pkg.stubs(:pkgutil_bom_files).returns some_files @@ -23,19 +23,19 @@ describe Cask::Pkg do end it 'forgets the pkg' do - pkg = Cask::Pkg.new('my.fake.pkg', Cask::FakeSystemCommand) + pkg = Hbc::Pkg.new('my.fake.pkg', Hbc::FakeSystemCommand) - Cask::FakeSystemCommand.stubs_command( + Hbc::FakeSystemCommand.stubs_command( ['/usr/sbin/pkgutil', '--only-files', '--files', 'my.fake.pkg'] ) - Cask::FakeSystemCommand.stubs_command( + Hbc::FakeSystemCommand.stubs_command( ['/usr/sbin/pkgutil', '--only-dirs', '--files', 'my.fake.pkg'] ) - Cask::FakeSystemCommand.stubs_command( + Hbc::FakeSystemCommand.stubs_command( ['/usr/sbin/pkgutil', '--files', 'my.fake.pkg'] ) - Cask::FakeSystemCommand.expects_command( + Hbc::FakeSystemCommand.expects_command( ['/usr/bin/sudo', '-E', '--', '/usr/sbin/pkgutil', '--forget', 'my.fake.pkg'] ) @@ -43,7 +43,7 @@ describe Cask::Pkg do end it 'cleans broken symlinks, but leaves AOK symlinks' do - pkg = Cask::Pkg.new('my.fake.pkg', Cask::NeverSudoSystemCommand) + pkg = Hbc::Pkg.new('my.fake.pkg', Hbc::NeverSudoSystemCommand) fake_dir = Pathname(Dir.mktmpdir) fake_file = fake_dir.join('ima_file').tap { |path| FileUtils.touch(path) } @@ -64,7 +64,7 @@ describe Cask::Pkg do end it 'snags permissions on ornery dirs, but returns them afterwords' do - pkg = Cask::Pkg.new('my.fake.pkg', Cask::NeverSudoSystemCommand) + pkg = Hbc::Pkg.new('my.fake.pkg', Hbc::NeverSudoSystemCommand) fake_dir = Pathname(Dir.mktmpdir) diff --git a/test/cask/staged_test.rb b/test/cask/staged_test.rb index 5d17ec28cd..336a4e933e 100644 --- a/test/cask/staged_test.rb +++ b/test/cask/staged_test.rb @@ -6,8 +6,8 @@ require 'test_helper' describe "Operations on staged Casks" do describe "bundle ID" do it "fetches the bundle ID from a staged cask" do - transmission_cask = Cask.load('local-transmission') - tr_installer = Cask::Installer.new(transmission_cask) + transmission_cask = Hbc.load('local-transmission') + tr_installer = Hbc::Installer.new(transmission_cask) shutup do tr_installer.install diff --git a/test/cask/system_command_test.rb b/test/cask/system_command_test.rb index cf2ced6b8d..8e60cfabe4 100644 --- a/test/cask/system_command_test.rb +++ b/test/cask/system_command_test.rb @@ -1,6 +1,6 @@ require 'test_helper' -describe Cask::SystemCommand do +describe Hbc::SystemCommand do describe "when the exit code is 0" do result = nil @@ -9,7 +9,7 @@ describe Cask::SystemCommand do options = { :must_succeed => false } - result = Cask::SystemCommand.run(command, options) + result = Hbc::SystemCommand.run(command, options) end it "says the command was successful" do @@ -29,8 +29,8 @@ describe Cask::SystemCommand do options = { :must_succeed => true } - result = Cask::SystemCommand.run(command, options) - }.must_raise(CaskCommandFailedError) + result = Hbc::SystemCommand.run(command, options) + }.must_raise(Hbc::CaskCommandFailedError) end end @@ -42,7 +42,7 @@ describe Cask::SystemCommand do options = { :must_succeed => false } - result = Cask::SystemCommand.run(command, options) + result = Hbc::SystemCommand.run(command, options) end it "says the command failed" do diff --git a/test/cask/url_checker_test.rb b/test/cask/url_checker_test.rb index 032b6941fe..0409c9c0af 100644 --- a/test/cask/url_checker_test.rb +++ b/test/cask/url_checker_test.rb @@ -1,11 +1,11 @@ require 'test_helper' -describe Cask::UrlChecker do +describe Hbc::UrlChecker do describe "request processing" do it "adds an error if response is empty" do cask = TestHelper.test_cask TestHelper.fake_response_for(cask.url, "") - checker = Cask::UrlChecker.new(cask, TestHelper.fake_fetcher) + checker = Hbc::UrlChecker.new(cask, TestHelper.fake_fetcher) checker.run checker.errors.must_include "timeout while requesting #{cask.url}" end @@ -19,7 +19,7 @@ describe Cask::UrlChecker do Last-Modified: Sun, 12 Aug 2012 21:17:21 GMT RESPONSE - checker = Cask::UrlChecker.new(TestHelper.test_cask, TestHelper.fake_fetcher) + checker = Hbc::UrlChecker.new(TestHelper.test_cask, TestHelper.fake_fetcher) checker.run checker.response_status.must_equal 'HTTP/1.1 200 OK' checker.headers.must_equal({ diff --git a/test/cask_test.rb b/test/cask_test.rb index 3e992ea17f..def6a366fd 100644 --- a/test/cask_test.rb +++ b/test/cask_test.rb @@ -3,8 +3,8 @@ require 'test_helper' describe "Cask" do describe "load" do it "returns an instance of the Cask for the given token" do - c = Cask.load("adium") - c.must_be_kind_of(Cask) + c = Hbc.load("adium") + c.must_be_kind_of(Hbc) c.must_be_instance_of(KlassPrefixAdium) end @@ -16,8 +16,8 @@ describe "Cask" do rescue end location = File.expand_path('./Casks/dia.rb') - c = Cask.load(location) - c.must_be_kind_of(Cask) + c = Hbc.load(location) + c.must_be_kind_of(Hbc) c.must_be_instance_of(KlassPrefixDia) Object.class_eval{remove_const :KlassPrefixDia} end @@ -29,9 +29,9 @@ describe "Cask" do end url = "file://" + File.expand_path('./Casks/dia.rb') c = shutup do - Cask.load(url) + Hbc.load(url) end - c.must_be_kind_of(Cask) + c.must_be_kind_of(Hbc) c.must_be_instance_of(KlassPrefixDia) Object.class_eval{remove_const :KlassPrefixDia} end @@ -40,9 +40,9 @@ describe "Cask" do lambda { url = "file://" + File.expand_path('./Casks/notacask.rb') shutup do - Cask.load(url) + Hbc.load(url) end - }.must_raise(CaskUnavailableError) + }.must_raise(Hbc::CaskUnavailableError) end it "returns an instance of the Cask from a relative file location" do @@ -50,27 +50,27 @@ describe "Cask" do Object.class_eval{remove_const :KlassPrefixBbedit} rescue end - c = Cask.load("./Casks/bbedit.rb") - c.must_be_kind_of(Cask) + c = Hbc.load("./Casks/bbedit.rb") + c.must_be_kind_of(Hbc) c.must_be_instance_of(KlassPrefixBbedit) Object.class_eval{remove_const :KlassPrefixBbedit} end it "uses exact match when loading by token" do - Cask.load('test-opera').must_be_instance_of(KlassPrefixTestOpera) - Cask.load('test-opera-mail').must_be_instance_of(KlassPrefixTestOperaMail) + Hbc.load('test-opera').must_be_instance_of(KlassPrefixTestOpera) + Hbc.load('test-opera-mail').must_be_instance_of(KlassPrefixTestOperaMail) end it "raises an error when attempting to load a Cask that doesn't exist" do lambda { - Cask.load("notacask") - }.must_raise(CaskUnavailableError) + Hbc.load("notacask") + }.must_raise(Hbc::CaskUnavailableError) end end describe "all_tokens" do it "returns a token for every Cask" do - all_cask_tokens = Cask.all_tokens + all_cask_tokens = Hbc.all_tokens all_cask_tokens.count.must_be :>, 20 all_cask_tokens.each { |cask| cask.must_be_kind_of String } end @@ -78,12 +78,12 @@ describe "Cask" do describe "token" do it "converts a class constant to a token-style dashed string" do - KlassPrefixPascalCasedConstant = Class.new(Cask) + KlassPrefixPascalCasedConstant = Class.new(Hbc) KlassPrefixPascalCasedConstant.token.must_equal 'pascal-cased-constant' end it "properly dasherizes constants with single letters in the middle" do - KlassPrefixGamesXChange = Class.new(Cask) + KlassPrefixGamesXChange = Class.new(Hbc) KlassPrefixGamesXChange.token.must_equal 'games-x-change' end end @@ -91,8 +91,8 @@ describe "Cask" do describe "metadata" do it "proposes a versioned metadata directory name for each instance" do cask_token = "adium" - c = Cask.load(cask_token) - metadata_path = Cask.caskroom.join(cask_token, '.metadata', c.version) + c = Hbc.load(cask_token) + metadata_path = Hbc.caskroom.join(cask_token, '.metadata', c.version) c.metadata_versioned_container_path.to_s.must_equal(metadata_path.to_s) end end diff --git a/test/support/cleanup.rb b/test/support/cleanup.rb index 54d13f9f13..810f4f4a52 100644 --- a/test/support/cleanup.rb +++ b/test/support/cleanup.rb @@ -1,8 +1,8 @@ -module Cask::CleanupHooks +module Hbc::CleanupHooks def after_teardown super - Cask.installed.each do |cask| - Cask::Installer.new(cask).tap do |installer| + Hbc.installed.each do |cask| + Hbc::Installer.new(cask).tap do |installer| installer.purge_versioned_files end end @@ -10,5 +10,5 @@ module Cask::CleanupHooks end class MiniTest::Spec - include Cask::CleanupHooks + include Hbc::CleanupHooks end diff --git a/test/support/fake_dirs.rb b/test/support/fake_dirs.rb index f0fc618902..f68028e418 100644 --- a/test/support/fake_dirs.rb +++ b/test/support/fake_dirs.rb @@ -10,7 +10,7 @@ module FakeDirHooks DIRS.each do |dir_name| dir = HOMEBREW_REPOSITORY.join("#{dir_name}-#{Time.now.to_i}-#{rand(1024)}") dir.mkpath - Cask.send("#{dir_name}=", dir) + Hbc.send("#{dir_name}=", dir) @canned_dirs[:dir_name] = dir end end diff --git a/test/support/fake_fetcher.rb b/test/support/fake_fetcher.rb index 62ce5020dc..04a4527aba 100644 --- a/test/support/fake_fetcher.rb +++ b/test/support/fake_fetcher.rb @@ -1,4 +1,4 @@ -class Cask::FakeFetcher +class Hbc::FakeFetcher def self.fake_response_for(url, response) @responses[url] = response end @@ -23,12 +23,12 @@ end module FakeFetcherHooks def before_setup super - Cask::FakeFetcher.init + Hbc::FakeFetcher.init end def after_teardown super - Cask::FakeFetcher.clear + Hbc::FakeFetcher.clear end end diff --git a/test/support/fake_system_command.rb b/test/support/fake_system_command.rb index 6275e70763..a98686dcae 100644 --- a/test/support/fake_system_command.rb +++ b/test/support/fake_system_command.rb @@ -1,4 +1,4 @@ -class Cask::FakeSystemCommand +class Hbc::FakeSystemCommand def self.responses @responses ||= {} end @@ -35,12 +35,12 @@ class Cask::FakeSystemCommand end def self.run(command, options={}) - command = Cask::SystemCommand._process_options(command, options) + command = Hbc::SystemCommand._process_options(command, options) unless responses.key?(command) fail("no response faked for #{command.inspect}, faked responses are: #{responses.inspect}") end system_calls[command] += 1 - Cask::SystemCommand::Result.new(command, responses[command], '', 0) + Hbc::SystemCommand::Result.new(command, responses[command], '', 0) end def self.run!(command, options={}) @@ -51,9 +51,9 @@ end module FakeSystemCommandHooks def after_teardown super - Cask::FakeSystemCommand.verify_expectations! + Hbc::FakeSystemCommand.verify_expectations! ensure - Cask::FakeSystemCommand.clear + Hbc::FakeSystemCommand.clear end end diff --git a/test/support/never_sudo_system_command.rb b/test/support/never_sudo_system_command.rb index 4553128083..dbf0bf857c 100644 --- a/test/support/never_sudo_system_command.rb +++ b/test/support/never_sudo_system_command.rb @@ -1,4 +1,4 @@ -class Cask::NeverSudoSystemCommand < Cask::SystemCommand +class Hbc::NeverSudoSystemCommand < Hbc::SystemCommand def self.run(command, options={}) super(command, options.merge(:sudo => false)) end diff --git a/test/test_helper.rb b/test/test_helper.rb index e06638e13b..89babfcb32 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -55,14 +55,14 @@ require 'mocha/integration/mini_test' Mocha::Integration::MiniTest.activate # our baby -require 'cask' +require 'hbc' # Look for Casks in testcasks by default. It is elsewhere required that # the string "test" appear in the directory name. -Cask.default_tap = 'caskroom/homebrew-testcasks' +Hbc.default_tap = 'caskroom/homebrew-testcasks' # our own testy caskroom -Cask.caskroom = HOMEBREW_PREFIX.join('TestCaskroom') +Hbc.caskroom = HOMEBREW_PREFIX.join('TestCaskroom') class TestHelper # helpers for test Casks to reference local files easily @@ -75,15 +75,15 @@ class TestHelper end def self.test_cask - Cask.load('basic-cask') + Hbc.load('basic-cask') end def self.fake_fetcher - Cask::FakeFetcher + Hbc::FakeFetcher end def self.fake_response_for(*args) - Cask::FakeFetcher.fake_response_for(*args) + Hbc::FakeFetcher.fake_response_for(*args) end def self.must_output(test, lambda, expected) @@ -104,7 +104,7 @@ class TestHelper end def self.install_without_artifacts(cask) - Cask::Installer.new(cask).tap do |i| + Hbc::Installer.new(cask).tap do |i| shutup do i.download i.extract_primary_container @@ -132,7 +132,7 @@ HOMEBREW_PREFIX.join('bin').mkdir FileUtils.ln_s project_root, taps_dest.join('homebrew-cask') # Common superclass for test Casks for when we need to filter them out -class TestCask < Cask; end +class TestHbc < Hbc; end # jack in some optional utilities FileUtils.ln_s '/usr/local/bin/cabextract', HOMEBREW_PREFIX.join('bin/cabextract')