make install also install a gemfile if you don't have one

This commit is contained in:
John Bintz 2012-08-21 10:43:01 -04:00
parent b7626a1107
commit 5cdbdd4ffc
3 changed files with 41 additions and 13 deletions

View File

@ -23,6 +23,16 @@ class PenchantCLI < Thor
else else
puts "No git repository detected here. Skipping git hook installation..." puts "No git repository detected here. Skipping git hook installation..."
end end
if !File.file?('Gemfile') && !File.file?('Gemfile.penchant')
FileUtils.touch('Gemfile.penchant')
prepend_to_file 'Gemfile.penchant', <<-RB
source :rubygems
RB
install_gemfile_penchant
end
end end
desc "update", "Update the installed scripts" desc "update", "Update the installed scripts"
@ -36,18 +46,7 @@ class PenchantCLI < Thor
def convert def convert
install install
FileUtils.mv 'Gemfile', 'Gemfile.penchant' FileUtils.mv 'Gemfile', 'Gemfile.penchant'
prepend_to_file 'Gemfile.penchant', <<-RB install_gemfile_penchant
# ensure git hooks are always installed
ensure_git_hooks!
# everything in the :local env is assumed to be a sibling directory of this one
defaults_for env(:local), :path => '../%s'
# reference a github repository with gem 'my-gem', :github => 'username'
property :github, :git => 'git://github.com/$1/%s.git'
RB
gemfile(:remote)
end end
method_options :deployment => false method_options :deployment => false
@ -118,6 +117,20 @@ property :github, :git => 'git://github.com/$1/%s.git'
puts puts
end end
end end
def install_gemfile_penchant
prepend_to_file 'Gemfile.penchant', <<-RB
# ensure git hooks are always installed
ensure_git_hooks!
# everything in the :local env is assumed to be a sibling directory of this one
defaults_for env(:local), :path => '../%s'
# reference a github repository with gem 'my-gem', :github => 'username'
property :github, :git => 'git://github.com/$1/%s.git'
RB
gemfile(:remote)
end
end end
default_task :gemfile default_task :gemfile

View File

@ -61,3 +61,18 @@ Feature: CLI
Given I have the symlink "tmp/.git/hooks/pre-commit" which points to "tmp/script/hooks/pre-commit" Given I have the symlink "tmp/.git/hooks/pre-commit" which points to "tmp/script/hooks/pre-commit"
When I run "bin/penchant gemfile remote" in the "tmp" directory When I run "bin/penchant gemfile remote" in the "tmp" directory
Then the output should not include "git hooks not installed" Then the output should not include "git hooks not installed"
@wip
Scenario: Install Penchant into a directory with no Gemfile
Given I have the directory "tmp"
When I run "bin/penchant install" in the "tmp" directory
Then the file "tmp/Gemfile.penchant" should include the following content:
"""
source :rubygems
"""
Then the file "tmp/Gemfile" should include the following content:
"""
source :rubygems
"""
And the output should include "No git"

View File

@ -1,3 +1,3 @@
module Penchant module Penchant
VERSION = "0.2.18" VERSION = "0.2.19"
end end