Skip to content

Commit

Permalink
rubocop: fix brew style warnings.
Browse files Browse the repository at this point in the history
  • Loading branch information
MikeMcQuaid committed Jan 17, 2018
1 parent 8cd0d85 commit 1f48e17
Show file tree
Hide file tree
Showing 5 changed files with 75 additions and 77 deletions.
134 changes: 65 additions & 69 deletions Library/Homebrew/dev-cmd/create.rb
Original file line number Diff line number Diff line change
Expand Up @@ -165,77 +165,73 @@ def generate!
path.write ERB.new(template, nil, ">").result(binding)
end

def template; <<~EOS
# Documentation: https://docs.brew.sh/Formula-Cookbook.html
# http://www.rubydoc.info/github/Homebrew/brew/master/Formula
# PLEASE REMOVE ALL GENERATED COMMENTS BEFORE SUBMITTING YOUR PULL REQUEST!
class #{Formulary.class_s(name)} < Formula
desc "#{desc}"
homepage "#{homepage}"
<% if head? %>
head "#{url}"
<% else %>
url "#{url}"
<% unless version.nil? or version.detected_from_url? %>
version "#{version}"
<% end %>
sha256 "#{sha256}"
<% end %>
<% if mode == :cmake %>
depends_on "cmake" => :build
<% elsif mode == :meson %>
depends_on "meson" => :build
depends_on "ninja" => :build
<% elsif mode.nil? %>
# depends_on "cmake" => :build
<% end %>
def install
# ENV.deparallelize # if your formula fails when building in parallel
<% if mode == :cmake %>
system "cmake", ".", *std_cmake_args
<% elsif mode == :autotools %>
# Remove unrecognized options if warned by configure
system "./configure", "--disable-debug",
"--disable-dependency-tracking",
"--disable-silent-rules",
"--prefix=\#{prefix}"
<% elsif mode == :meson %>
mkdir "build" do
system "meson", "--prefix=\#{prefix}", ".."
system "ninja"
system "ninja", "test"
system "ninja", "install"
def template
<<~EOS
# Documentation: https://docs.brew.sh/Formula-Cookbook.html
# http://www.rubydoc.info/github/Homebrew/brew/master/Formula
# PLEASE REMOVE ALL GENERATED COMMENTS BEFORE SUBMITTING YOUR PULL REQUEST!
class #{Formulary.class_s(name)} < Formula
desc "#{desc}"
homepage "#{homepage}"
<% if head? %>
head "#{url}"
<% else %>
url "#{url}"
<% unless version.nil? or version.detected_from_url? %>
version "#{version}"
<% end %>
sha256 "#{sha256}"
<% end %>
<% if mode == :cmake %>
depends_on "cmake" => :build
<% elsif mode == :meson %>
depends_on "meson" => :build
depends_on "ninja" => :build
<% elsif mode.nil? %>
# depends_on "cmake" => :build
<% end %>
def install
# ENV.deparallelize # if your formula fails when building in parallel
<% if mode == :cmake %>
system "cmake", ".", *std_cmake_args
<% elsif mode == :autotools %>
# Remove unrecognized options if warned by configure
system "./configure", "--disable-debug",
"--disable-dependency-tracking",
"--disable-silent-rules",
"--prefix=\#{prefix}"
<% elsif mode == :meson %>
mkdir "build" do
system "meson", "--prefix=\#{prefix}", ".."
system "ninja"
system "ninja", "test"
system "ninja", "install"
end
<% else %>
# Remove unrecognized options if warned by configure
system "./configure", "--disable-debug",
"--disable-dependency-tracking",
"--disable-silent-rules",
"--prefix=\#{prefix}"
# system "cmake", ".", *std_cmake_args
<% end %>
<% if mode != :meson %>
system "make", "install" # if this fails, try separate make/make install steps
<% end %>
end
test do
# `test do` will create, run in and delete a temporary directory.
#
# This test will fail and we won't accept that! For Homebrew/homebrew-core
# this will need to be a test that verifies the functionality of the
# software. Run the test with `brew test #{name}`. Options passed
# to `brew install` such as `--HEAD` also need to be provided to `brew test`.
#
# The installed folder is not in the path, so use the entire path to any
# executables being tested: `system "\#{bin}/program", "do", "something"`.
system "false"
end
<% else %>
# Remove unrecognized options if warned by configure
system "./configure", "--disable-debug",
"--disable-dependency-tracking",
"--disable-silent-rules",
"--prefix=\#{prefix}"
# system "cmake", ".", *std_cmake_args
<% end %>
<% if mode != :meson %>
system "make", "install" # if this fails, try separate make/make install steps
<% end %>
end
test do
# `test do` will create, run in and delete a temporary directory.
#
# This test will fail and we won't accept that! For Homebrew/homebrew-core
# this will need to be a test that verifies the functionality of the
# software. Run the test with `brew test #{name}`. Options passed
# to `brew install` such as `--HEAD` also need to be provided to `brew test`.
#
# The installed folder is not in the path, so use the entire path to any
# executables being tested: `system "\#{bin}/program", "do", "something"`.
system "false"
end
end
EOS
end
end
7 changes: 4 additions & 3 deletions Library/Homebrew/keg.rb
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,10 @@ def to_s
end

class DirectoryNotWritableError < LinkError
def to_s; <<~EOS
Could not symlink #{src}
#{dst.dirname} is not writable.
def to_s
<<~EOS
Could not symlink #{src}
#{dst.dirname} is not writable.
EOS
end
end
Expand Down
5 changes: 3 additions & 2 deletions Library/Homebrew/test/cask/dsl_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -232,8 +232,9 @@
expect(cask.caveats).to be_empty

cask = Hbc::Cask.new("cask-with-caveats") do
def caveats; <<~EOS
When you install this Cask, you probably want to know this.
def caveats
<<~EOS
When you install this Cask, you probably want to know this.
EOS
end
end
Expand Down
4 changes: 2 additions & 2 deletions Library/Homebrew/test/support/helper/output_as_tty.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def matches?(block)
return super(block) unless @tty

colored_tty_block = lambda do
instance_eval("$#{@output}").extend(Module.new do
instance_eval("$#{@output}", __FILE__, __LINE__).extend(Module.new do
def tty?
true
end
Expand All @@ -32,7 +32,7 @@ def tty?
return super(colored_tty_block) if @colors

uncolored_tty_block = lambda do
instance_eval <<-EOS
instance_eval <<-EOS, __FILE__, __LINE__ + 1
begin
captured_stream = StringIO.new
Expand Down
2 changes: 1 addition & 1 deletion Library/Homebrew/utils/github.rb
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ def open(url, data: nil, scopes: [].freeze)
# This is a no-op if the user is opting out of using the GitHub API.
return block_given? ? yield({}) : {} if ENV["HOMEBREW_NO_GITHUB_API"]

args = %W[--header application/vnd.github.v3+json --write-out \n%{http_code}]
args = %W[--header application/vnd.github.v3+json --write-out \n%{http_code}] # rubocop:disable Lint/NestedPercentLiteral
args += curl_args

token, username = api_credentials
Expand Down

0 comments on commit 1f48e17

Please sign in to comment.