Skip to content

Commit

Permalink
Merge pull request #6463 from rolandwalker/doc_new_container_type
Browse files Browse the repository at this point in the history
doc and tests for `container :type`
  • Loading branch information
ndr committed Oct 3, 2014
2 parents 96750ba + e3f10f8 commit 88c2f75
Show file tree
Hide file tree
Showing 8 changed files with 18 additions and 37 deletions.
13 changes: 7 additions & 6 deletions doc/CASK_LANGUAGE_REFERENCE.md
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ Each Cask must declare one or more *artifacts* (i.e. something to install)
| `postflight` | yes | a Ruby block containing postflight install operations
| `uninstall_preflight` | yes | a Ruby block containing preflight uninstall operations (needed only in very rare cases)
| `uninstall_postflight` | yes | a Ruby block containing postflight uninstall operations
| `container_type` | no | a symbol to override container-type autodetect. may be one of: `:air`, `:bz2`, `:cab`, `:dmg`, `:generic_unar`, `:gzip`, `:otf`, `:pkg`, `:rar`, `:seven_zip`, `:sit`, `:tar`, `:ttf`, `:xar`, `:zip`, `:naked`
| `container :type =>` | no | a symbol to override container-type autodetect. may be one of: `:air`, `:bz2`, `:cab`, `:dmg`, `:generic_unar`, `:gzip`, `:otf`, `:pkg`, `:rar`, `:seven_zip`, `:sit`, `:tar`, `:ttf`, `:xar`, `:zip`, `:naked`. (example [parse.rb](../Casks/parse.rb))


## Legacy Stanzas
Expand All @@ -117,14 +117,15 @@ The following stanzas are no longer in use.

| name | multiple occurrences allowed? | meaning |
| -------------------- |------------------------------ | ----------- |
| `no_checksum` | no | an obsolete alternative to `sha256 :no_check`
| `before_install` | yes | an obsolete alternative to `preflight`
| `after_install` | yes | an obsolete alternative to `postflight`
| `before_uninstall` | yes | an obsolete alternative to `uninstall_preflight`
| `after_uninstall` | yes | an obsolete alternative to `uninstall_postflight`
| `before_install` | yes | an obsolete alternative to `preflight`
| `before_uninstall` | yes | an obsolete alternative to `uninstall_preflight`
| `container_type` | yes | an obsolete alternative to `container :type =>`
| `depends_on_formula` | yes | an obsolete alternative to `depends_on :formula =>`
| `install` | yes | an obsolete alternative to `pkg`
| `depends_on_formula` | yes | an obsolete alternative to `depends_on :formula`
| `link` | yes | an obsolete alternative to `artifact`
| `no_checksum` | no | an obsolete alternative to `sha256 :no_check`


## Legacy Forms
Expand All @@ -133,8 +134,8 @@ The following forms are no longer in use.

| name | meaning |
| -------------------- | ----------- |
| `version 'latest'` | an obsolete alternative to `version :latest`
| `uninstall :files` | an obsolete alternative to `uninstall :delete`
| `version 'latest'` | an obsolete alternative to `version :latest`


## Conditional Statements
Expand Down
11 changes: 6 additions & 5 deletions doc/cask_language_deltas.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,23 +42,24 @@ This notice will be removed for the final form.**
* stub - not yet functional
* `depends_on :java`
* stub - not yet functional
* `license`
* `suite`
* `uninstall :rmdir`
* `zap`
* `license`


## Renames (1.0)

| old form | new form
| --------------------- |----------------
| `install` | `pkg`
| `link` | `app` (or sometimes `suite` or `artifact`)
| `before_install` | `preflight`
| `after_install` | `postflight`
| `before_uninstall` | `uninstall_preflight`
| `after_uninstall` | `uninstall_postflight`
| `before_install` | `preflight`
| `before_uninstall` | `uninstall_preflight`
| `container_type` | `container :type`
| `depends_on_formula` | `depends_on :formula`
| `install` | `pkg`
| `link` | `app` (or sometimes `suite` or `artifact`)
| `uninstall :files` | `uninstall :delete`
| `version 'latest'` | `version :latest`

Expand Down
2 changes: 1 addition & 1 deletion lib/cask/container.rb
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def self.for_path(path, command)
end

def self.from_type(type)
odebug "Determining which containers to use based on 'container_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
Expand Down
2 changes: 1 addition & 1 deletion lib/cask/container/naked.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
class Cask::Container::Naked < Cask::Container::Base
def self.me?(criteria)
# Either inherit from this class and override self.me?,
# or use this class directly as "container_type :naked",
# or use this class directly as "container :type => :naked",
# in which case self.me? is not called.
false
end
Expand Down
1 change: 1 addition & 0 deletions lib/cask/dsl.rb
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ def gpg(*args)
end
end

# todo: remove this backwards compatibility element after 0.50.0
def container_type(type=nil)
if @container_type and !type.nil?
raise CaskInvalidError.new(self.title, "'container_type' stanza may only appear once")
Expand Down
14 changes: 1 addition & 13 deletions test/cask/installer_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@
pkg.must_be :file?
end

it "works properly with an overridden container_type" do
it "works properly with an overridden container :type" do
naked_executable = Cask.load('naked-executable')

shutup do
Expand All @@ -241,18 +241,6 @@
executable.must_be :file?
end

it "works properly with the new form container :type => <type>" do
naked_executable_dsl_one = Cask.load('naked-executable-dsl-one')

shutup do
Cask::Installer.new(naked_executable_dsl_one).install
end

dest_path = Cask.caskroom/'naked-executable-dsl-one'/naked_executable_dsl_one.version
executable = dest_path/'naked_executable'
executable.must_be :file?
end

it "works fine with a nested container" do
nested_app = Cask.load('nested-app')

Expand Down
10 changes: 0 additions & 10 deletions test/support/Casks/naked-executable-dsl-one.rb

This file was deleted.

2 changes: 1 addition & 1 deletion test/support/Casks/naked-executable.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ class NakedExecutable < TestCask
homepage 'http://example.com/naked-executable'
version '1.2.3'
sha256 '306c6ca7407560340797866e077e053627ad409277d1b9da58106fce4cf717cb'
container_type :naked
container :type => :naked
end

0 comments on commit 88c2f75

Please sign in to comment.