forked from Homebrew/homebrew-cask
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixed Homebrew#1248, Better nested container syntax
I add a new `container` dsl. With this new dsl, we can drop `nested_container`.
- Loading branch information
Võ Anh Duy
committed
Apr 19, 2014
1 parent
9d8fa23
commit 70034f2
Showing
7 changed files
with
65 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
class Cask::Artifact::Container < Cask::Artifact::Base | ||
def install | ||
@cask.artifacts[self.class.artifact_dsl_key].each { |container| extract(container) } | ||
end | ||
|
||
def uninstall | ||
# no need to take action; we will get removed by rmtree of parent | ||
end | ||
|
||
def extract(container_relative_path) | ||
source = @cask.destination_path.join(container_relative_path) | ||
container = Cask::Container.for_path(source, @command) | ||
unless container | ||
raise CaskError.new "Aw dang, could not identify nested_container at '#{source}'" | ||
end | ||
ohai "Extracting nested container #{source.basename}" | ||
container.new(@cask, source, @command).extract | ||
end | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,2 @@ | ||
class Cask::Artifact::NestedContainer < Cask::Artifact::Base | ||
def install | ||
@cask.artifacts[:nested_container].each { |container| extract(container) } | ||
end | ||
|
||
def uninstall | ||
# no need to take action; we will get removed by rmtree of parent | ||
end | ||
|
||
def extract(container_relative_path) | ||
source = @cask.destination_path.join(container_relative_path) | ||
container = Cask::Container.for_path(source, @command) | ||
unless container | ||
raise CaskError.new "Aw dang, could not identify nested_container at '#{source}'" | ||
end | ||
ohai "Extracting nested container #{source.basename}" | ||
container.new(@cask, source, @command).extract | ||
end | ||
class Cask::Artifact::NestedContainer < Cask::Artifact::Container | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
require 'test_helper' | ||
|
||
describe Cask::Artifact::Container do | ||
describe 'install' do | ||
before { | ||
@cask = Cask.load('nested-app-with-container') | ||
|
||
shutup do | ||
Cask::Installer.new(@cask).install | ||
end | ||
} | ||
|
||
it 'extracts the specified paths as containers' do | ||
@cask.destination_path.join('MyNestedApp.app').must_be :directory? | ||
end | ||
it "links the noted applications to the proper directory" do | ||
TestHelper.valid_alias?(Cask.appdir/'MyNestedApp.app').must_equal true | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
class NestedAppWithContainer < TestCask | ||
url TestHelper.local_binary('NestedApp.dmg.zip') | ||
homepage 'http://example.com/nested-app' | ||
version '1.2.3' | ||
sha256 '1866dfa833b123bb8fe7fa7185ebf24d28d300d0643d75798bc23730af734216' | ||
container 'NestedApp.dmg' do | ||
link 'MyNestedApp.app' | ||
end | ||
end |