8 changed files with 108 additions and 41 deletions
@ -0,0 +1,28 @@ |
|||
module Cask::Scopes |
|||
def self.included(base) |
|||
base.extend(ClassMethods) |
|||
end |
|||
|
|||
module ClassMethods |
|||
def all |
|||
cask_titles = Dir[tapspath.join("*", "Casks", "*.rb")] |
|||
cask_titles.map { |c| |
|||
# => "/usr/local/Library/Taps/example-tap/Casks/example.rb" |
|||
c.sub! /\.rb$/, '' |
|||
# => ".../example" |
|||
c = c.split("/").last 3 |
|||
# => ["example-tap", "Casks", "example"] |
|||
c.delete_at 1 |
|||
# => ["example-tap", "example"] |
|||
c = c.join "/" |
|||
# => "example-tap/example" |
|||
self.load c |
|||
c |
|||
} |
|||
end |
|||
|
|||
def installed |
|||
all.select { |c| load(c).installed? } |
|||
end |
|||
end |
|||
end |
@ -0,0 +1,31 @@ |
|||
require 'test_helper' |
|||
|
|||
describe Cask::CLI::List do |
|||
it "lists the installed casks in a pretty fashion" do |
|||
Cask.stubs(:installed).returns(%w[ |
|||
phinze-cask/adium |
|||
phinze-cask/google-chrome |
|||
]) |
|||
lambda { |
|||
Cask::CLI::List.run |
|||
}.must_output <<-OUTPUT.gsub(/^ */, '') |
|||
adium |
|||
google-chrome |
|||
OUTPUT |
|||
end |
|||
|
|||
it "lists the taps for casks that show up in two" do |
|||
Cask.stubs(:installed).returns(%w[ |
|||
phinze-cask/adium |
|||
phinze-cask/google-chrome |
|||
passcod-cask/adium |
|||
]) |
|||
lambda { |
|||
Cask::CLI::List.run |
|||
}.must_output <<-OUTPUT.gsub(/^ */, '') |
|||
google-chrome |
|||
passcod-cask/adium |
|||
phinze-cask/adium |
|||
OUTPUT |
|||
end |
|||
end |
@ -0,0 +1,17 @@ |
|||
require 'test_helper' |
|||
|
|||
describe Cask::CLI::Search do |
|||
it "lists the available casks that match the search term" do |
|||
Cask.stubs(:all).returns(%w[ |
|||
phinze-cask/foo |
|||
phinze-cask/bar |
|||
phinze-cask/baz |
|||
]) |
|||
lambda { |
|||
Cask::CLI::Search.run('ba') |
|||
}.must_output <<-OUTPUT.gsub(/^ */, '') |
|||
bar |
|||
baz |
|||
OUTPUT |
|||
end |
|||
end |
Loading…
Reference in new issue