Skip to content

Commit

Permalink
Merge pull request #7354 from rolandwalker/remove_after_install
Browse files Browse the repository at this point in the history
DSL: remove support for `after_install` and friends
  • Loading branch information
rolandwalker committed Nov 14, 2014
2 parents 64899f7 + fbc9e35 commit a0caa94
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 30 deletions.
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

0 comments on commit a0caa94

Please sign in to comment.