Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

create: add --ruby option #7200

Merged
merged 2 commits into from
Mar 24, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 4 additions & 0 deletions Library/Homebrew/dev-cmd/create.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ def create_args
description: "Create a basic template for a Perl build."
switch "--python",
description: "Create a basic template for a Python build."
switch "--ruby",
description: "Create a basic template for a Ruby build."
switch "--rust",
description: "Create a basic template for a Rust build."
switch "--no-fetch",
Expand Down Expand Up @@ -86,6 +88,8 @@ def create
:perl
elsif args.python?
:python
elsif args.ruby?
:ruby
elsif args.rust?
:rust
end
Expand Down
8 changes: 8 additions & 0 deletions Library/Homebrew/formula_creator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,8 @@ class #{Formulary.class_s(name)} < Formula
uses_from_macos "perl"
<% elsif mode == :python %>
depends_on "python"
<% elsif mode == :ruby %>
uses_from_macos "ruby"
<% elsif mode == :rust %>
depends_on "rust" => :build
<% elsif mode.nil? %>
Expand Down Expand Up @@ -166,6 +168,12 @@ def install
bin.env_script_all_files(libexec/"bin", :PERL5LIB => ENV["PERL5LIB"])
<% elsif mode == :python %>
virtualenv_install_with_resources
<% elsif mode == :ruby %>
ENV["GEM_HOME"] = libexec
system "gem", "build", "\#{name}.gemspec"
system "gem", "install", "\#{name}-\#{version}.gem"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm wondering if we should/could try to use bundle install --standalone here instead. That would avoid needing to resource all the dependent gems, I think?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All dependencies are being installed by gem install AFAIK. Couldn't find any example of a formula in core that uses bundle install.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeh, fair enough, that seems fine 👍

bin.install libexec/"bin/\#{name}"
bin.env_script_all_files(libexec/"bin", :GEM_HOME => ENV["GEM_HOME"])
<% elsif mode == :rust %>
system "cargo", "install", "--locked", "--root", prefix, "--path", "."
<% else %>
Expand Down
25 changes: 0 additions & 25 deletions Library/Homebrew/test/cask/cmd/upgrade_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -71,31 +71,6 @@
expect(local_transmission_path).to be_a_directory
expect(local_transmission.versions).to include("2.60")
end

it 'updates "auto_updates" and "latest" Casks when their tokens are provided in the command line' do
local_caffeine = Cask::CaskLoader.load("local-caffeine")
local_caffeine_path = Cask::Config.global.appdir.join("Caffeine.app")
auto_updates = Cask::CaskLoader.load("auto-updates")
auto_updates_path = Cask::Config.global.appdir.join("MyFancyApp.app")

expect(local_caffeine).to be_installed
expect(local_caffeine_path).to be_a_directory
expect(local_caffeine.versions).to include("1.2.2")

expect(auto_updates).to be_installed
expect(auto_updates_path).to be_a_directory
expect(auto_updates.versions).to include("2.57")

described_class.run("local-caffeine", "auto-updates")

expect(local_caffeine).to be_installed
expect(local_caffeine_path).to be_a_directory
expect(local_caffeine.versions).to include("1.2.3")

expect(auto_updates).to be_installed
expect(auto_updates_path).to be_a_directory
expect(auto_updates.versions).to include("2.61")
end
end

describe "with --greedy it checks additional Casks" do
Expand Down
2 changes: 2 additions & 0 deletions docs/Manpage.md
Original file line number Diff line number Diff line change
Expand Up @@ -813,6 +813,8 @@ a simple example. For the complete API, see:
Create a basic template for a Perl build.
* `--python`:
Create a basic template for a Python build.
* `--ruby`:
Create a basic template for a Ruby build.
* `--rust`:
Create a basic template for a Rust build.
* `--no-fetch`:
Expand Down
4 changes: 4 additions & 0 deletions manpages/brew.1
Original file line number Diff line number Diff line change
Expand Up @@ -1044,6 +1044,10 @@ Create a basic template for a Perl build\.
Create a basic template for a Python build\.
.
.TP
\fB\-\-ruby\fR
Create a basic template for a Ruby build\.
.
.TP
\fB\-\-rust\fR
Create a basic template for a Rust build\.
.
Expand Down