Skip to content

Commit

Permalink
Merge pull request #7401 from rolandwalker/remove_depends_on
Browse files Browse the repository at this point in the history
DSL: remove support for `depends_on_formula`
  • Loading branch information
rolandwalker committed Nov 18, 2014
2 parents b802b72 + d2132ac commit f6079da
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 17 deletions.
10 changes: 0 additions & 10 deletions lib/cask/dsl.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,6 @@ def version; self.class.version; end

def license; self.class.license; end

def depends_on_formula; self.class.depends_on_formula; end

def depends_on; self.class.depends_on; end

def conflicts_with; self.class.conflicts_with; end
Expand Down Expand Up @@ -160,10 +158,6 @@ def license(arg=nil)
end
end

def depends_on_formula(*args)
@depends_on_formula ||= args
end

def depends_on(*args)
if @depends_on and !args.empty?
# todo: remove this constraint, and instead merge multiple depends_on stanzas
Expand All @@ -174,10 +168,6 @@ def depends_on(*args)
rescue StandardError => e
raise CaskInvalidError.new(self.title, e)
end
# todo: remove this backwards compatibility section after removing depends_on_formula
if @depends_on.formula
@depends_on_formula ||= [ @depends_on.formula ]
end
@depends_on
end

Expand Down
1 change: 1 addition & 0 deletions lib/cask/dsl/depends_on.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ def initialize(pairs={})
pairs.each do |key, value|
raise "invalid depends_on key: '#{key.inspect}'" unless VALID_KEYS.include?(key)
writer_method = "#{key}=".to_sym
value = Array(value) if [:formula, :cask].include?(key)
send(writer_method, value)
end
end
Expand Down
7 changes: 5 additions & 2 deletions lib/cask/installer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -100,9 +100,12 @@ def install_artifacts
end

def formula_dependencies
unless @cask.depends_on_formula.empty?
# todo The Cask::DependsOn object needs to be more friendly.
# Currently @cask.depends_on.formula raises an exception
# if :formula was not set.
if @cask.depends_on and not @cask.depends_on.formula.empty?
ohai 'Installing Formula dependencies from Homebrew'
@cask.depends_on_formula.each do |dep_name|
@cask.depends_on.formula.each do |dep_name|
print "#{dep_name} ... "
installed = @command.run(HOMEBREW_BREW_FILE,
:args => ['list', '--versions', dep_name],
Expand Down
2 changes: 1 addition & 1 deletion lib/cask/utils.rb
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ def dumpcask
:sums,
:artifacts,
:caveats,
:depends_on_formula,
:depends_on,
:conflicts_with,
:container_type,
:gpg,
Expand Down
12 changes: 8 additions & 4 deletions test/cask/installer_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@
it "works with cab-based Casks" do
skip unless HOMEBREW_PREFIX.join('bin/cabextract').exist?
cab_container = Cask.load('cab-container')
cab_container.stubs(:depends_on_formula).returns([])
empty = stub(:formula => [])
cab_container.stubs(:depends_on).returns(empty)

shutup do
Cask::Installer.new(cab_container).install
Expand All @@ -71,7 +72,8 @@
it "works with 7z-based Casks" do
skip unless HOMEBREW_PREFIX.join('bin/unar').exist?
sevenzip_container = Cask.load('sevenzip-container')
sevenzip_container.stubs(:depends_on_formula).returns([])
empty = stub(:formula => [])
sevenzip_container.stubs(:depends_on).returns(empty)

shutup do
Cask::Installer.new(sevenzip_container).install
Expand Down Expand Up @@ -99,7 +101,8 @@
it "works with Stuffit-based Casks" do
skip unless HOMEBREW_PREFIX.join('bin/unar').exist?
stuffit_container = Cask.load('stuffit-container')
stuffit_container.stubs(:depends_on_formula).returns([])
empty = stub(:formula => [])
stuffit_container.stubs(:depends_on).returns(empty)

shutup do
Cask::Installer.new(stuffit_container).install
Expand All @@ -114,7 +117,8 @@
it "works with RAR-based Casks" do
skip unless HOMEBREW_PREFIX.join('bin/unar').exist?
rar_container = Cask.load('rar-container')
rar_container.stubs(:depends_on_formula).returns([])
empty = stub(:formula => [])
rar_container.stubs(:depends_on).returns(empty)

shutup do
Cask::Installer.new(rar_container).install
Expand Down

0 comments on commit f6079da

Please sign in to comment.