-
Notifications
You must be signed in to change notification settings - Fork 106
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for bundler dependency manager
Bundler was already around in the codebase with a Gemfile, but now it can explicitly included or excluded (default excluded). It copies the Gemfile and runs `bundle install`. It is enabled with the command line flag `--dependency-managers bundler` or in .liftoffrc: `dependency_managers: bundler` Bundler comes first in the setup script because cocoapods can be installed via bundler. Support bundler through the rest of the codebase Shorten options line length Format liftoffrc manpage Reorder bundler in script Bundler is used to install cocoapods so it should come first
- Loading branch information
1 parent
5ab7846
commit 8439456
Showing
8 changed files
with
124 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
module Liftoff | ||
class Bundler < DependencyManager | ||
def setup | ||
if bundler_installed? | ||
move_gemfile | ||
else | ||
puts "Please install Bundler or disable bundler from liftoff" | ||
end | ||
end | ||
|
||
def install | ||
if bundler_installed? | ||
run_bundle_install | ||
end | ||
end | ||
|
||
private | ||
|
||
def bundler_installed? | ||
system("which bundle > /dev/null") | ||
end | ||
|
||
def move_gemfile | ||
FileManager.new.generate("Gemfile.rb", "Gemfile", config) | ||
end | ||
|
||
def run_bundle_install | ||
puts "Running bundle install" | ||
system("bundle install") | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
require "spec_helper" | ||
|
||
RSpec.describe Liftoff::Bundler do | ||
describe "#setup" do | ||
it "checks to see if bundler is installed" do | ||
system_call = "which bundle > /dev/null" | ||
bundler = Liftoff::Bundler.new(:config) | ||
allow(bundler).to receive(:system).with(system_call) | ||
|
||
bundler.setup | ||
|
||
expect(bundler).to have_received(:system).with(system_call) | ||
end | ||
|
||
context "when bundler is installed" do | ||
it "asks FileManager to move the Gemfile" do | ||
bundler = Liftoff::Bundler.new(:config) | ||
allow(bundler).to receive(:bundler_installed?).and_return(true) | ||
arguments = ["Gemfile.rb", "Gemfile", :config] | ||
file_manager = double("FileManager") | ||
allow(Liftoff::FileManager).to receive(:new).and_return(file_manager) | ||
allow(file_manager).to receive(:generate).with(*arguments) | ||
|
||
bundler.setup | ||
|
||
expect(file_manager).to have_received(:generate).with(*arguments) | ||
end | ||
end | ||
|
||
context "when bundler is not installed" do | ||
it "puts a message out to the system" do | ||
bundler = Liftoff::Bundler.new(:config) | ||
output_string = "Please install Bundler or disable bundler from liftoff" | ||
allow(bundler).to receive(:bundler_installed?).and_return(false) | ||
allow(bundler).to receive(:puts).with(output_string) | ||
|
||
bundler.setup | ||
|
||
expect(bundler).to have_received(:puts).with(output_string) | ||
end | ||
end | ||
end | ||
|
||
describe "#install" do | ||
context "if bundler is installed" do | ||
it "runs bundle install" do | ||
bundler = Liftoff::Bundler.new(:config) | ||
allow(bundler).to receive(:bundler_installed?).and_return(true) | ||
system_call = "bundle install" | ||
allow(bundler).to receive(:system).with(system_call) | ||
|
||
bundler.install | ||
|
||
expect(bundler).to have_received(:system).with(system_call) | ||
end | ||
end | ||
|
||
context "if bundler is not installed" do | ||
it "does not run bundle install" do | ||
bundler = Liftoff::Bundler.new(:config) | ||
allow(bundler).to receive(:bundler_installed?).and_return(false) | ||
allow(bundler).to receive(:system) | ||
|
||
bundler.install | ||
|
||
expect(bundler).not_to have_received(:system) | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters