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

display artifact summary in brew cask info #3667

Merged
merged 1 commit into from
Mar 28, 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
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