From ee30f839d2f9daa037cb059baca254b6c8fbf00c Mon Sep 17 00:00:00 2001 From: Lucas Garron Date: Thu, 14 Nov 2013 10:09:29 -0800 Subject: [PATCH 1/8] QuickLook plugin support. --- CONTRIBUTING.md | 1 + lib/cask/artifact.rb | 2 ++ lib/cask/artifact/qlplugin.rb | 41 +++++++++++++++++++++++++++++++++++ lib/cask/cli.rb | 3 +++ lib/cask/dsl.rb | 1 + lib/cask/locations.rb | 8 +++++++ test/cask/cli/options_test.rb | 14 ++++++++++++ 7 files changed, 70 insertions(+) create mode 100644 lib/cask/artifact/qlplugin.rb diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 7a2a2699ff5..51ff636f2d1 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -81,6 +81,7 @@ Fill in the following fields for your Cask: | `nested_container` | relative path to an inner container that must be extracted before moving on with the installation; this allows us to support dmg inside tar, zip inside dmg, etc. | `link` | relative path to a file that should be linked into the `Applications` folder on installation | `prefpane` | relative path to a preference pane that should be linked into the `~/Library/PreferencePanes` folder on installation +| `qlplugin` | relative path to a Quicklook plugin that should be linked into the `~/Library/QuickLook` folder on installation | `install` | relative path to `pkg` that should be run to install the application | `uninstall` | indicates what commands/scripts must be run to uninstall a pkg-based application (see "Uninstall Support" for more information) diff --git a/lib/cask/artifact.rb b/lib/cask/artifact.rb index ec708393f82..df3c2b02326 100644 --- a/lib/cask/artifact.rb +++ b/lib/cask/artifact.rb @@ -6,6 +6,7 @@ require 'cask/artifact/app' require 'cask/artifact/nested_container' require 'cask/artifact/pkg' require 'cask/artifact/prefpane' +require 'cask/artifact/qlplugin' module Cask::Artifact # @@ -18,6 +19,7 @@ module Cask::Artifact Cask::Artifact::App, Cask::Artifact::Pkg, Cask::Artifact::Prefpane, + Cask::Artifact::Qlplugin, ] end diff --git a/lib/cask/artifact/qlplugin.rb b/lib/cask/artifact/qlplugin.rb new file mode 100644 index 00000000000..c7c5993bc0c --- /dev/null +++ b/lib/cask/artifact/qlplugin.rb @@ -0,0 +1,41 @@ +class Cask::Artifact::Qlplugin < Cask::Artifact::Base + def self.me?(cask) + cask.artifacts[:qlplugin].any? + end + + def install + @cask.artifacts[:qlplugin].each { |qlplugin| link(qlplugin) } + end + + def uninstall + @cask.artifacts[:qlplugin].each { |qlplugin| unlink(qlplugin) } + end + + def link(qlplugin_relative_path) + source = @cask.destination_path.join(qlplugin_relative_path) + target = Cask.qlplugindir.join(source.basename) + + return unless preflight_checks(source, target) + ohai "Linking QuickLook plugin #{source.basename} to #{target}" + @command.run!('/bin/ln', :args => ['-hfs', source, target]) + end + + def preflight_checks(source, target) + if target.directory? && !target.symlink? + ohai "It seems there is already a QuickLook plugin at #{target}; not linking." + false + end + unless source.exist? + raise "it seems the symlink source is not there: #{source}" + end + true + end + + def unlink(qlplugin_relative_path) + linked_path = Cask.qlplugindir.join(Pathname(qlplugin_relative_path).basename) + if linked_path.exist? && linked_path.symlink? + ohai "Removing QuickLook plugin link: #{linked_path}" + linked_path.delete + end + end +end diff --git a/lib/cask/cli.rb b/lib/cask/cli.rb index cdffeb38322..8a3df20f90c 100644 --- a/lib/cask/cli.rb +++ b/lib/cask/cli.rb @@ -65,6 +65,9 @@ class Cask::CLI opts.on("--prefpanedir=MANDATORY") do |v| Cask.prefpanedir = Pathname(v).expand_path end + opts.on("--qlplugindir=MANDATORY") do |v| + Cask.qlplugindir = Pathname(v).expand_path + end opts.on("--debug") do |v| @debug = true end diff --git a/lib/cask/dsl.rb b/lib/cask/dsl.rb index fbd1e7fb080..d86d259f50b 100644 --- a/lib/cask/dsl.rb +++ b/lib/cask/dsl.rb @@ -40,6 +40,7 @@ module Cask::DSL :link, :nested_container, :prefpane, + :qlplugin, :uninstall, ] diff --git a/lib/cask/locations.rb b/lib/cask/locations.rb index 0324adc7180..7f23e3a8cbb 100644 --- a/lib/cask/locations.rb +++ b/lib/cask/locations.rb @@ -32,6 +32,14 @@ module Cask::Locations @prefpanedir = _prefpanedir end + def qlplugindir + @qlplugindir ||= Pathname.new('~/Library/QuickLook').expand_path + end + + def qlplugindir=(_qlplugindir) + @qlplugindir = _qlplugindir + end + def default_tap @default_tap ||= 'phinze-cask' end diff --git a/test/cask/cli/options_test.rb b/test/cask/cli/options_test.rb index dce5af38fb6..1cd654efe61 100644 --- a/test/cask/cli/options_test.rb +++ b/test/cask/cli/options_test.rb @@ -29,6 +29,20 @@ describe Cask::CLI do Cask.prefpanedir.must_equal Pathname('/some/path/bar') end + it "supports setting the qlplugindir" do + Cask::CLI.process_options %w{help --qlplugindir=/some/path/foo} + + Cask.qlplugindir.must_equal Pathname('/some/path/foo') + end + + it "supports setting the qlplugindir from ENV" do + ENV['HOMEBREW_CASK_OPTS'] = "--qlplugindir=/some/path/bar" + + Cask::CLI.process_options %w{help} + + Cask.qlplugindir.must_equal Pathname('/some/path/bar') + end + it "allows additional options to be passed through" do rest = Cask::CLI.process_options %w{edit foo --create --appdir=/some/path/qux} From 47ffd4c634a74bf7502a7a718982244aa2216c3a Mon Sep 17 00:00:00 2001 From: Lucas Garron Date: Thu, 14 Nov 2013 20:06:30 -0800 Subject: [PATCH 2/8] Added qlplugin cask for BetterZipQL. --- Casks/betterzipql.rb | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 Casks/betterzipql.rb diff --git a/Casks/betterzipql.rb b/Casks/betterzipql.rb new file mode 100644 index 00000000000..613d27a3b89 --- /dev/null +++ b/Casks/betterzipql.rb @@ -0,0 +1,7 @@ +class Betterzipql < Cask + url 'http://macitbetter.com/BetterZipQL.zip' + homepage 'http://macitbetter.com/BetterZip-Quick-Look-Generator/' + version 'latest' + no_checksum + qlplugin 'BetterZipQL.qlgenerator' +end From 909e60801dddd2ad9b48d697a417bfbc230be7d5 Mon Sep 17 00:00:00 2001 From: Lucas Garron Date: Thu, 14 Nov 2013 20:06:47 -0800 Subject: [PATCH 3/8] Added qlplugin cask for jsonlook. --- Casks/jsonlook.rb | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 Casks/jsonlook.rb diff --git a/Casks/jsonlook.rb b/Casks/jsonlook.rb new file mode 100644 index 00000000000..1b85af9f373 --- /dev/null +++ b/Casks/jsonlook.rb @@ -0,0 +1,7 @@ +class Jsonlook < Cask + url 'http://dl.dropbox.com/u/3878216/github/jsonlook.qlgenerator.zip' + homepage 'https://github.com/rjregenold/jsonlook' + version 'latest' + no_checksum + qlplugin 'jsonlook.qlgenerator' +end From 8fd907bb7a49c17ab7ff9a358f6617ea2b26e9b8 Mon Sep 17 00:00:00 2001 From: Lucas Garron Date: Thu, 14 Nov 2013 20:06:58 -0800 Subject: [PATCH 4/8] Added qlplugin cask for QLColorCode. --- Casks/qlcolorcode.rb | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 Casks/qlcolorcode.rb diff --git a/Casks/qlcolorcode.rb b/Casks/qlcolorcode.rb new file mode 100644 index 00000000000..50a501bc384 --- /dev/null +++ b/Casks/qlcolorcode.rb @@ -0,0 +1,7 @@ +class Qlcolorcode < Cask + url 'https://qlcolorcode.googlecode.com/files/QLColorCode-2.0.2.tgz' + homepage 'https://code.google.com/p/qlcolorcode/' + version '2.0.2' + sha256 '317eda251ea5af8412401562395d2fbedb2dd915a7d927479cf09ac7251c4074' + qlplugin 'QLColorCode-2.0.2/QLColorCode.qlgenerator' +end From 7465b48f4b23fe1c9dc4ef188af2d905ae620b3e Mon Sep 17 00:00:00 2001 From: Lucas Garron Date: Thu, 14 Nov 2013 20:07:13 -0800 Subject: [PATCH 5/8] Added qlplugin cask for QLMarkdown. --- Casks/qlmarkdown.rb | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 Casks/qlmarkdown.rb diff --git a/Casks/qlmarkdown.rb b/Casks/qlmarkdown.rb new file mode 100644 index 00000000000..411a7a2a556 --- /dev/null +++ b/Casks/qlmarkdown.rb @@ -0,0 +1,7 @@ +class Qlmarkdown < Cask + url 'https://github.com/downloads/toland/qlmarkdown/QLMarkdown-1.3.zip' + homepage 'https://github.com/toland/qlmarkdown' + version '1.3' + sha256 '8fd344ec0db6ff084cc198ccef51e82da95bfee37cbbd1a7ae1fea937273de03' + qlplugin 'QLMarkdown/QLMarkdown.qlgenerator' +end From f642f171e8dd16a6ff9a7c43f9a2b9ff08c23e48 Mon Sep 17 00:00:00 2001 From: Lucas Garron Date: Thu, 14 Nov 2013 20:07:22 -0800 Subject: [PATCH 6/8] Added qlplugin cask for QLStephen. --- Casks/qlstephen.rb | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 Casks/qlstephen.rb diff --git a/Casks/qlstephen.rb b/Casks/qlstephen.rb new file mode 100644 index 00000000000..c92ea86bb7e --- /dev/null +++ b/Casks/qlstephen.rb @@ -0,0 +1,7 @@ +class Qlstephen < Cask + url 'https://github.com/downloads/whomwah/qlstephen/QLStephen.qlgenerator.zip' + homepage 'http://whomwah.github.io/qlstephen/' + version 'latest' + no_checksum + qlplugin 'QLStephen.qlgenerator' +end From f75b06b83ea14c3f6f9b58f774f06d8fbc945ee4 Mon Sep 17 00:00:00 2001 From: Lucas Garron Date: Thu, 14 Nov 2013 20:07:33 -0800 Subject: [PATCH 7/8] Added qlplugin cask for ScriptQL. --- Casks/scriptql.rb | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 Casks/scriptql.rb diff --git a/Casks/scriptql.rb b/Casks/scriptql.rb new file mode 100644 index 00000000000..02e3239b7e9 --- /dev/null +++ b/Casks/scriptql.rb @@ -0,0 +1,7 @@ +class Scriptql < Cask + url 'http://www.kainjow.com/downloads/ScriptQL_qlgenerator.zip' + homepage 'http://www.kainjow.com/' + version 'latest' + no_checksum + qlplugin 'ScriptQL.qlgenerator' +end From 36e0246b68ec5a0069fb5ebbef10da3d8a745105 Mon Sep 17 00:00:00 2001 From: Lucas Garron Date: Thu, 14 Nov 2013 20:07:44 -0800 Subject: [PATCH 8/8] Added qlplugin cask for Suspicious Package. --- Casks/suspicious-package.rb | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 Casks/suspicious-package.rb diff --git a/Casks/suspicious-package.rb b/Casks/suspicious-package.rb new file mode 100644 index 00000000000..0af82dce1c0 --- /dev/null +++ b/Casks/suspicious-package.rb @@ -0,0 +1,7 @@ +class SuspiciousPackage < Cask + url 'http://www.mothersruin.com/software/downloads/SuspiciousPackage.dmg' + homepage 'http://www.mothersruin.com/software/SuspiciousPackage/' + version 'latest' + no_checksum + qlplugin 'Suspicious Package.qlgenerator' +end