Skip to content

Commit

Permalink
Merge pull request #3667 from rolandwalker/artifacts_in_info
Browse files Browse the repository at this point in the history
display artifact summary in `brew cask info`
  • Loading branch information
rolandwalker committed Mar 28, 2014
2 parents 0652a39 + 421eafa commit 5bc2b62
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 22 deletions.
26 changes: 20 additions & 6 deletions lib/cask/cli/info.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,13 @@ def self.info(cask)
"Not installed"
end

<<-PURPOSE.undent
#{cask}: #{cask.version}
#{cask.homepage}
#{installation}
#{github_info(cask)}
PURPOSE
<<-PURPOSE
#{cask}: #{cask.version}
#{cask.homepage}
#{installation}
#{github_info(cask)}
#{artifact_info(cask)}
PURPOSE
end

def self.github_info(cask)
Expand All @@ -35,4 +36,17 @@ def self.github_info(cask)
user, repo = tap.split "-"
"https://github.com/#{user}/homebrew-#{repo}/commits/master/Casks/#{name}.rb"
end

def self.artifact_info(cask)
retval = ''
Cask::DSL::ClassMethods.ordinary_artifact_types.each do |type|
if cask.artifacts[type].length > 0
retval = "#{Tty.blue}==>#{Tty.white} Contents#{Tty.reset}\n" unless retval.length > 0
cask.artifacts[type].each do |artifact|
retval.concat " #{artifact.first} (#{type.to_s})\n"
end
end
end
retval.sub!(/\n\Z/, '')
end
end
36 changes: 20 additions & 16 deletions lib/cask/dsl.rb
Original file line number Diff line number Diff line change
Expand Up @@ -84,22 +84,26 @@ def caveats(*string, &block)
end
end

ARTIFACT_TYPES = [
:link,
:prefpane,
:qlplugin,
:font,
:widget,
:service,
:colorpicker,
:binary,
:caskroom_only,
:input_method,
:screen_saver,
:install,
]

ARTIFACT_TYPES.each do |type|
def self.ordinary_artifact_types
@@ordinary_artifact_types ||= [
:link,
:prefpane,
:qlplugin,
:font,
:widget,
:service,
:colorpicker,
:binary,
:input_method,
:screen_saver,
:install,
]
end

installable_artifact_types = ordinary_artifact_types
installable_artifact_types.push :caskroom_only

installable_artifact_types.each do |type|
define_method(type) do |*args|
artifacts[type] << args
end
Expand Down
8 changes: 8 additions & 0 deletions test/cask/cli/info_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
http://example.com/local-caffeine
Not installed
https://github.com/phinze/homebrew-testcasks/commits/master/Casks/local-caffeine.rb
==> Contents
Caffeine.app (link)
CLIOUTPUT
end

Expand All @@ -20,10 +22,14 @@
http://example.com/local-caffeine
Not installed
https://github.com/phinze/homebrew-testcasks/commits/master/Casks/local-caffeine.rb
==> Contents
Caffeine.app (link)
local-transmission: 2.61
http://example.com/local-transmission
Not installed
https://github.com/phinze/homebrew-testcasks/commits/master/Casks/local-transmission.rb
==> Contents
Transmission.app (link)
CLIOUTPUT
end

Expand All @@ -35,6 +41,8 @@
http://example.com/local-caffeine
Not installed
https://github.com/phinze/homebrew-testcasks/commits/master/Casks/with-caveats.rb
==> Contents
Caffeine.app (link)
==> Caveats
Here are some things you might want to know.
Expand Down

0 comments on commit 5bc2b62

Please sign in to comment.