Replace Hbc.path
with CaskLoader.path
.
This commit is contained in:
parent
d1995dad4b
commit
d7af864be0
@ -6,7 +6,7 @@ module Hbc
|
|||||||
raise CaskUnspecifiedError if cask_tokens.empty?
|
raise CaskUnspecifiedError if cask_tokens.empty?
|
||||||
# only respects the first argument
|
# only respects the first argument
|
||||||
cask_token = cask_tokens.first.sub(/\.rb$/i, "")
|
cask_token = cask_tokens.first.sub(/\.rb$/i, "")
|
||||||
cask_path = Hbc.path(cask_token)
|
cask_path = CaskLoader.path(cask_token)
|
||||||
raise CaskUnavailableError, cask_token.to_s unless cask_path.exist?
|
raise CaskUnavailableError, cask_token.to_s unless cask_path.exist?
|
||||||
puts File.open(cask_path, &:read)
|
puts File.open(cask_path, &:read)
|
||||||
end
|
end
|
||||||
|
@ -5,7 +5,7 @@ module Hbc
|
|||||||
cask_tokens = cask_tokens_from(args)
|
cask_tokens = cask_tokens_from(args)
|
||||||
raise CaskUnspecifiedError if cask_tokens.empty?
|
raise CaskUnspecifiedError if cask_tokens.empty?
|
||||||
cask_token = cask_tokens.first.sub(/\.rb$/i, "")
|
cask_token = cask_tokens.first.sub(/\.rb$/i, "")
|
||||||
cask_path = Hbc.path(cask_token)
|
cask_path = CaskLoader.path(cask_token)
|
||||||
odebug "Creating Cask #{cask_token}"
|
odebug "Creating Cask #{cask_token}"
|
||||||
|
|
||||||
raise CaskAlreadyCreatedError, cask_token if cask_path.exist?
|
raise CaskAlreadyCreatedError, cask_token if cask_path.exist?
|
||||||
|
@ -6,7 +6,7 @@ module Hbc
|
|||||||
raise CaskUnspecifiedError if cask_tokens.empty?
|
raise CaskUnspecifiedError if cask_tokens.empty?
|
||||||
# only respects the first argument
|
# only respects the first argument
|
||||||
cask_token = cask_tokens.first.sub(/\.rb$/i, "")
|
cask_token = cask_tokens.first.sub(/\.rb$/i, "")
|
||||||
cask_path = Hbc.path(cask_token)
|
cask_path = CaskLoader.path(cask_token)
|
||||||
odebug "Opening editor for Cask #{cask_token}"
|
odebug "Opening editor for Cask #{cask_token}"
|
||||||
unless cask_path.exist?
|
unless cask_path.exist?
|
||||||
raise CaskUnavailableError, %Q(#{cask_token}, run "brew cask create #{cask_token}" to create a new Cask)
|
raise CaskUnavailableError, %Q(#{cask_token}, run "brew cask create #{cask_token}" to create a new Cask)
|
||||||
|
@ -39,7 +39,7 @@ module Hbc
|
|||||||
elsif cask_tokens.any? { |file| File.exist?(file) }
|
elsif cask_tokens.any? { |file| File.exist?(file) }
|
||||||
cask_tokens
|
cask_tokens
|
||||||
else
|
else
|
||||||
cask_tokens.map { |token| Hbc.path(token) }
|
cask_tokens.map { |token| CaskLoader.path(token) }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -109,33 +109,6 @@ module Hbc
|
|||||||
@default_tap ||= Tap.fetch("caskroom", "homebrew-cask")
|
@default_tap ||= Tap.fetch("caskroom", "homebrew-cask")
|
||||||
end
|
end
|
||||||
|
|
||||||
def path(query)
|
|
||||||
query_path = Pathname.new(query)
|
|
||||||
|
|
||||||
return query_path if query_path.absolute?
|
|
||||||
return query_path if query_path.exist? && query_path.extname == ".rb"
|
|
||||||
|
|
||||||
query_without_extension = query.sub(/\.rb$/i, "")
|
|
||||||
|
|
||||||
token_with_tap = if query =~ %r{\A[^/]+/[^/]+/[^/]+\Z}
|
|
||||||
query_without_extension
|
|
||||||
else
|
|
||||||
all_tokens.detect do |tap_and_token|
|
|
||||||
tap_and_token.split("/")[2] == query_without_extension
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
if token_with_tap
|
|
||||||
user, repo, token = token_with_tap.split("/", 3)
|
|
||||||
tap = Tap.fetch(user, repo)
|
|
||||||
else
|
|
||||||
token = query_without_extension
|
|
||||||
tap = Hbc.default_tap
|
|
||||||
end
|
|
||||||
|
|
||||||
CaskLoader.default_path(token)
|
|
||||||
end
|
|
||||||
|
|
||||||
def tcc_db
|
def tcc_db
|
||||||
@tcc_db ||= Pathname.new("/Library/Application Support/com.apple.TCC/TCC.db")
|
@tcc_db ||= Pathname.new("/Library/Application Support/com.apple.TCC/TCC.db")
|
||||||
end
|
end
|
||||||
|
@ -24,7 +24,7 @@ describe Hbc::CLI::Create, :cask do
|
|||||||
|
|
||||||
after(:each) do
|
after(:each) do
|
||||||
%w[new-cask additional-cask another-cask yet-another-cask local-caff].each do |cask|
|
%w[new-cask additional-cask another-cask yet-another-cask local-caff].each do |cask|
|
||||||
path = Hbc.path(cask)
|
path = Hbc::CaskLoader.path(cask)
|
||||||
path.delete if path.exist?
|
path.delete if path.exist?
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -32,13 +32,13 @@ describe Hbc::CLI::Create, :cask do
|
|||||||
it "opens the editor for the specified Cask" do
|
it "opens the editor for the specified Cask" do
|
||||||
Hbc::CLI::Create.run("new-cask")
|
Hbc::CLI::Create.run("new-cask")
|
||||||
expect(Hbc::CLI::Create.editor_commands).to eq [
|
expect(Hbc::CLI::Create.editor_commands).to eq [
|
||||||
[Hbc.path("new-cask")],
|
[Hbc::CaskLoader.path("new-cask")],
|
||||||
]
|
]
|
||||||
end
|
end
|
||||||
|
|
||||||
it "drops a template down for the specified Cask" do
|
it "drops a template down for the specified Cask" do
|
||||||
Hbc::CLI::Create.run("new-cask")
|
Hbc::CLI::Create.run("new-cask")
|
||||||
template = File.read(Hbc.path("new-cask"))
|
template = File.read(Hbc::CaskLoader.path("new-cask"))
|
||||||
expect(template).to eq <<-EOS.undent
|
expect(template).to eq <<-EOS.undent
|
||||||
cask 'new-cask' do
|
cask 'new-cask' do
|
||||||
version ''
|
version ''
|
||||||
@ -56,14 +56,14 @@ describe Hbc::CLI::Create, :cask do
|
|||||||
it "throws away additional Cask arguments and uses the first" do
|
it "throws away additional Cask arguments and uses the first" do
|
||||||
Hbc::CLI::Create.run("additional-cask", "another-cask")
|
Hbc::CLI::Create.run("additional-cask", "another-cask")
|
||||||
expect(Hbc::CLI::Create.editor_commands).to eq [
|
expect(Hbc::CLI::Create.editor_commands).to eq [
|
||||||
[Hbc.path("additional-cask")],
|
[Hbc::CaskLoader.path("additional-cask")],
|
||||||
]
|
]
|
||||||
end
|
end
|
||||||
|
|
||||||
it "throws away stray options" do
|
it "throws away stray options" do
|
||||||
Hbc::CLI::Create.run("--notavalidoption", "yet-another-cask")
|
Hbc::CLI::Create.run("--notavalidoption", "yet-another-cask")
|
||||||
expect(Hbc::CLI::Create.editor_commands).to eq [
|
expect(Hbc::CLI::Create.editor_commands).to eq [
|
||||||
[Hbc.path("yet-another-cask")],
|
[Hbc::CaskLoader.path("yet-another-cask")],
|
||||||
]
|
]
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -76,7 +76,7 @@ describe Hbc::CLI::Create, :cask do
|
|||||||
it "allows creating Casks that are substrings of existing Casks" do
|
it "allows creating Casks that are substrings of existing Casks" do
|
||||||
Hbc::CLI::Create.run("local-caff")
|
Hbc::CLI::Create.run("local-caff")
|
||||||
expect(Hbc::CLI::Create.editor_commands).to eq [
|
expect(Hbc::CLI::Create.editor_commands).to eq [
|
||||||
[Hbc.path("local-caff")],
|
[Hbc::CaskLoader.path("local-caff")],
|
||||||
]
|
]
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -25,14 +25,14 @@ describe Hbc::CLI::Edit, :cask do
|
|||||||
it "opens the editor for the specified Cask" do
|
it "opens the editor for the specified Cask" do
|
||||||
Hbc::CLI::Edit.run("local-caffeine")
|
Hbc::CLI::Edit.run("local-caffeine")
|
||||||
expect(Hbc::CLI::Edit.editor_commands).to eq [
|
expect(Hbc::CLI::Edit.editor_commands).to eq [
|
||||||
[Hbc.path("local-caffeine")],
|
[Hbc::CaskLoader.path("local-caffeine")],
|
||||||
]
|
]
|
||||||
end
|
end
|
||||||
|
|
||||||
it "throws away additional arguments and uses the first" do
|
it "throws away additional arguments and uses the first" do
|
||||||
Hbc::CLI::Edit.run("local-caffeine", "local-transmission")
|
Hbc::CLI::Edit.run("local-caffeine", "local-transmission")
|
||||||
expect(Hbc::CLI::Edit.editor_commands).to eq [
|
expect(Hbc::CLI::Edit.editor_commands).to eq [
|
||||||
[Hbc.path("local-caffeine")],
|
[Hbc::CaskLoader.path("local-caffeine")],
|
||||||
]
|
]
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -130,7 +130,7 @@ describe Hbc::CLI::Style, :cask do
|
|||||||
end
|
end
|
||||||
|
|
||||||
it "tries to find paths for all tokens" do
|
it "tries to find paths for all tokens" do
|
||||||
expect(Hbc).to receive(:path).twice
|
expect(Hbc::CaskLoader).to receive(:path).twice
|
||||||
subject
|
subject
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user