Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DSL: remove support for after_install and friends #7354

Merged
merged 1 commit into from
Nov 14, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions lib/cask/artifact/after_block.rb
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
class Cask::Artifact::AfterBlock < Cask::Artifact::Base
def self.me?(cask)
cask.artifacts[:after_install].any? ||
cask.artifacts[:after_uninstall].any?
cask.artifacts[:postflight].any? ||
cask.artifacts[:uninstall_postflight].any?
end

def install_phase
@cask.artifacts[:after_install].each do |block|
@cask.artifacts[:postflight].each do |block|
Cask::DSL::AfterInstall.new(@cask).instance_eval &block
end
end

def uninstall_phase
@cask.artifacts[:after_uninstall].each do |block|
@cask.artifacts[:uninstall_postflight].each do |block|
Cask::DSL::AfterUninstall.new(@cask).instance_eval &block
end
end
Expand Down
8 changes: 4 additions & 4 deletions lib/cask/artifact/before_block.rb
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
class Cask::Artifact::BeforeBlock < Cask::Artifact::Base
def self.me?(cask)
cask.artifacts[:before_install].any? ||
cask.artifacts[:before_uninstall].any?
cask.artifacts[:preflight].any? ||
cask.artifacts[:uninstall_preflight].any?
end

def install_phase
@cask.artifacts[:before_install].each do |block|
@cask.artifacts[:preflight].each do |block|
Cask::DSL::BeforeInstall.new(@cask).instance_eval &block
end
end

def uninstall_phase
@cask.artifacts[:before_uninstall].each do |block|
@cask.artifacts[:uninstall_preflight].each do |block|
Cask::DSL::BeforeUninstall.new(@cask).instance_eval &block
end
end
Expand Down
8 changes: 4 additions & 4 deletions lib/cask/cli/internal_stanza.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,10 @@ class Cask::CLI::InternalStanza < Cask::CLI::InternalUseBase
:caskroom_only,
:nested_container,
:uninstall,
:after_install,
:after_uninstall,
:before_install,
:before_uninstall,
:postflight,
:uninstall_postflight,
:preflight,
:uninstall_postflight,
])

def self.run(*arguments)
Expand Down
20 changes: 2 additions & 18 deletions lib/cask/dsl.rb
Original file line number Diff line number Diff line change
Expand Up @@ -209,16 +209,6 @@ def caveats(*string, &block)
end
end

# Todo: this hash is transitional. Each of these stanzas will
# ultimately either be removed or upgraded with its own unique
# semantics.
STANZA_ALIASES = {
:preflight => :before_install, # todo remove
:postflight => :after_install, # todo remove
:uninstall_preflight => :before_uninstall, # todo remove
:uninstall_postflight => :after_uninstall, # todo remove
}

def self.ordinary_artifact_types
@@ordinary_artifact_types ||= [
:app,
Expand All @@ -242,9 +232,8 @@ def self.ordinary_artifact_types
installable_artifact_types.push :caskroom_only

installable_artifact_types.each do |type|
resolved_type = STANZA_ALIASES.key?(type) ? STANZA_ALIASES[type] : type
define_method(type) do |*args|
artifacts[resolved_type] << args
artifacts[type] << args
end
end

Expand All @@ -261,20 +250,15 @@ def self.ordinary_artifact_types
end

ARTIFACT_BLOCK_TYPES = [
:after_install, # todo remove
:after_uninstall, # todo remove
:before_install, # todo remove
:before_uninstall, # todo remove
:preflight,
:postflight,
:uninstall_preflight,
:uninstall_postflight,
]

ARTIFACT_BLOCK_TYPES.each do |type|
resolved_type = STANZA_ALIASES.key?(type) ? STANZA_ALIASES[type] : type
define_method(type) do |&block|
artifacts[resolved_type] << block
artifacts[type] << block
end
end

Expand Down