Merge pull request #3220 from yzguy/yzguy/cask_available_languages_to_info
add available languages to cask info command
This commit is contained in:
commit
ec0d8fa7ba
@ -23,6 +23,7 @@ module Hbc
|
|||||||
installation_info(cask)
|
installation_info(cask)
|
||||||
repo_info(cask)
|
repo_info(cask)
|
||||||
name_info(cask)
|
name_info(cask)
|
||||||
|
language_info(cask)
|
||||||
artifact_info(cask)
|
artifact_info(cask)
|
||||||
Installer.print_caveats(cask)
|
Installer.print_caveats(cask)
|
||||||
end
|
end
|
||||||
@ -51,6 +52,13 @@ module Hbc
|
|||||||
puts cask.name.empty? ? Formatter.error("None") : cask.name
|
puts cask.name.empty? ? Formatter.error("None") : cask.name
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def self.language_info(cask)
|
||||||
|
return if cask.languages.empty?
|
||||||
|
|
||||||
|
ohai "Languages"
|
||||||
|
puts cask.languages.join(", ")
|
||||||
|
end
|
||||||
|
|
||||||
def self.repo_info(cask)
|
def self.repo_info(cask)
|
||||||
user, repo, token = QualifiedToken.parse(Hbc.all_tokens.detect { |t| t.split("/").last == cask.token })
|
user, repo, token = QualifiedToken.parse(Hbc.all_tokens.detect { |t| t.split("/").last == cask.token })
|
||||||
|
|
||||||
|
@ -63,6 +63,7 @@ module Hbc
|
|||||||
:gpg,
|
:gpg,
|
||||||
:homepage,
|
:homepage,
|
||||||
:language,
|
:language,
|
||||||
|
:languages,
|
||||||
:name,
|
:name,
|
||||||
:sha256,
|
:sha256,
|
||||||
:staged_path,
|
:staged_path,
|
||||||
@ -145,6 +146,12 @@ module Hbc
|
|||||||
@language = @language_blocks.default.call
|
@language = @language_blocks.default.call
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def languages
|
||||||
|
return [] if @language_blocks.nil?
|
||||||
|
|
||||||
|
@language_blocks.keys.flatten
|
||||||
|
end
|
||||||
|
|
||||||
def url(*args, &block)
|
def url(*args, &block)
|
||||||
set_unique_stanza(:url, args.empty? && !block_given?) do
|
set_unique_stanza(:url, args.empty? && !block_given?) do
|
||||||
begin
|
begin
|
||||||
|
@ -90,6 +90,38 @@ describe Hbc::CLI::Info, :cask do
|
|||||||
EOS
|
EOS
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it "prints languages specified in the Cask" do
|
||||||
|
expect {
|
||||||
|
Hbc::CLI::Info.run("with-languages")
|
||||||
|
}.to output(<<-EOS.undent).to_stdout
|
||||||
|
with-languages: 1.2.3
|
||||||
|
http://example.com/local-caffeine
|
||||||
|
Not installed
|
||||||
|
From: https://github.com/caskroom/homebrew-spec/blob/master/Casks/with-languages.rb
|
||||||
|
==> Name
|
||||||
|
None
|
||||||
|
==> Languages
|
||||||
|
zh, en-US
|
||||||
|
==> Artifacts
|
||||||
|
Caffeine.app (App)
|
||||||
|
EOS
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'does not print "Languages" section divider if the languages block has no output' do
|
||||||
|
expect {
|
||||||
|
Hbc::CLI::Info.run("without-languages")
|
||||||
|
}.to output(<<-EOS.undent).to_stdout
|
||||||
|
without-languages: 1.2.3
|
||||||
|
http://example.com/local-caffeine
|
||||||
|
Not installed
|
||||||
|
From: https://github.com/caskroom/homebrew-spec/blob/master/Casks/without-languages.rb
|
||||||
|
==> Name
|
||||||
|
None
|
||||||
|
==> Artifacts
|
||||||
|
Caffeine.app (App)
|
||||||
|
EOS
|
||||||
|
end
|
||||||
|
|
||||||
describe "when no Cask is specified" do
|
describe "when no Cask is specified" do
|
||||||
it "raises an exception" do
|
it "raises an exception" do
|
||||||
expect {
|
expect {
|
||||||
|
@ -177,6 +177,36 @@ describe Hbc::DSL, :cask do
|
|||||||
expect(cask.call.sha256).to eq("xyz789")
|
expect(cask.call.sha256).to eq("xyz789")
|
||||||
expect(cask.call.url.to_s).to eq("https://example.org/en-US.zip")
|
expect(cask.call.url.to_s).to eq("https://example.org/en-US.zip")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it "returns an empty array if no languages are specified" do
|
||||||
|
cask = lambda do
|
||||||
|
Hbc::Cask.new("cask-with-apps") do
|
||||||
|
url "https://example.org/file.zip"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
expect(cask.call.languages).to be_empty
|
||||||
|
end
|
||||||
|
|
||||||
|
it "returns an array of available languages" do
|
||||||
|
cask = lambda do
|
||||||
|
Hbc::Cask.new("cask-with-apps") do
|
||||||
|
language "zh" do
|
||||||
|
sha256 "abc123"
|
||||||
|
"zh-CN"
|
||||||
|
end
|
||||||
|
|
||||||
|
language "en-US", default: true do
|
||||||
|
sha256 "xyz789"
|
||||||
|
"en-US"
|
||||||
|
end
|
||||||
|
|
||||||
|
url "https://example.org/file.zip"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
expect(cask.call.languages).to eq(["zh", "en-US"])
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe "app stanza" do
|
describe "app stanza" do
|
||||||
|
@ -0,0 +1,18 @@
|
|||||||
|
cask 'with-languages' do
|
||||||
|
version '1.2.3'
|
||||||
|
|
||||||
|
language "zh" do
|
||||||
|
sha256 "abc123"
|
||||||
|
"zh-CN"
|
||||||
|
end
|
||||||
|
|
||||||
|
language "en-US", default: true do
|
||||||
|
sha256 "xyz789"
|
||||||
|
"en-US"
|
||||||
|
end
|
||||||
|
|
||||||
|
url "file://#{TEST_FIXTURE_DIR}/cask/caffeine.zip"
|
||||||
|
homepage 'http://example.com/local-caffeine'
|
||||||
|
|
||||||
|
app 'Caffeine.app'
|
||||||
|
end
|
@ -0,0 +1,9 @@
|
|||||||
|
cask 'without-languages' do
|
||||||
|
version '1.2.3'
|
||||||
|
sha256 '67cdb8a02803ef37fdbf7e0be205863172e41a561ca446cd84f0d7ab35a99d94'
|
||||||
|
|
||||||
|
url "file://#{TEST_FIXTURE_DIR}/cask/caffeine.zip"
|
||||||
|
homepage 'http://example.com/local-caffeine'
|
||||||
|
|
||||||
|
app 'Caffeine.app'
|
||||||
|
end
|
Loading…
x
Reference in New Issue
Block a user