Permalink
Browse files

Add support for `--path` option to install

  • Loading branch information...
1 parent 3615bf9 commit fe9443bb43fc41a2806a3c67ba6d67e7dce2eb41 @sikachu sikachu committed with Phil LaPier Sep 28, 2012
View
@@ -2,16 +2,26 @@
Feature: Install bourbon files
Scenario: Bourbon generates a new bourbon installation
- When I install bourbon files
+ When I run `bundle exec bourbon install`
Then the sass directories should have been generated
And the following directories should exist:
- | bourbon |
- | bourbon/lib |
+ | bourbon |
+ | bourbon/lib |
And the master bourbon partial should have been generated
And the lib files should have been generated
And the output should contain "Bourbon files installed to bourbon/"
Scenario: Generating does not overwrite an existing bourbon directory
Given bourbon is already installed
- When I install bourbon files
+ When I run `bundle exec bourbon install`
Then the output should contain "Bourbon files already installed, doing nothing."
+
+ Scenario: Install Bourbon into a custom path
+ When I run `bundle exec bourbon install --path=custom_path`
+ Then the sass directories with "custom_path" prefix should have been generated
+ And the following directories should exist:
+ | custom_path/bourbon |
+ | custom_path/bourbon/lib |
+ And the master bourbon partial should have been generated within "custom_path" directory
+ And the lib files should have been generated within "custom_path" directory
+ And the output should contain "Bourbon files installed to custom_path/bourbon/"
@@ -1,33 +1,32 @@
Given /^bourbon is already installed$/ do
- set_up_bourbon_directory
install_bourbon
end
When /^I install bourbon files$/ do
- set_up_bourbon_directory
install_bourbon
end
When /^I update bourbon files$/ do
update_bourbon
end
-Then /^the sass directories should have been generated$/ do
- sass_directories = ["bourbon/addons", "bourbon/css3", "bourbon/functions"]
+Then /^the sass directories(?: with "([^"]+)" prefix)? should have been generated$/ do |prefix|
+ sass_directories = ["addons", "css3", "functions"]
+ sass_directories.map!{ |directory| bourbon_path(prefix, directory) }
check_directory_presence(sass_directories, true)
end
-Then /^the master bourbon partial should have been generated$/ do
- check_file_presence(["bourbon/_bourbon.scss"], true)
+Then /^the master bourbon partial should have been generated(?: within "([^"]+)" directory)?$/ do |prefix|
+ check_file_presence([bourbon_path(prefix, '_bourbon.scss')], true)
end
-Then /^the lib files should have been generated$/ do
- check_file_presence(["bourbon/lib/bourbon.rb"], true)
- check_directory_presence(["bourbon/lib/bourbon"], true)
- check_file_presence(["bourbon/lib/bourbon/sass_extensions.rb"], true)
- check_directory_presence(["bourbon/lib/bourbon/sass_extensions"], true)
+Then /^the lib files should have been generated(?: within "([^"]+)" directory)?$/ do |prefix|
+ check_file_presence([bourbon_path(prefix, 'lib/bourbon.rb')], true)
+ check_directory_presence([bourbon_path(prefix, 'lib/bourbon')], true)
+ check_file_presence([bourbon_path(prefix, 'lib/bourbon/sass_extensions.rb')], true)
+ check_directory_presence([bourbon_path(prefix, 'lib/bourbon/sass_extensions')], true)
end
Then /^bourbon should not have been generated$/ do
- check_directory_presence(["bourbon"], false)
+ check_directory_presence(['bourbon'], false)
end
@@ -1,16 +1,19 @@
module BourbonSupport
- def set_up_bourbon_directory
- write_file("Gemfile", "gem 'bourbon', :path => '../../..'")
- run_simple("bundle install")
- end
-
def install_bourbon
run_simple("bundle exec bourbon install")
end
def update_bourbon
run_simple("bundle exec bourbon update")
end
+
+ def bourbon_path(prefix, path)
+ if prefix
+ File.join(prefix, 'bourbon', path)
+ else
+ File.join('bourbon', path)
+ end
+ end
end
World(BourbonSupport)
View
@@ -4,12 +4,13 @@
module Bourbon
class Generator < Thor
desc 'install', 'Install Bourbon into your project'
+ method_options :path => :string
def install
if bourbon_files_already_exist?
puts "Bourbon files already installed, doing nothing."
else
install_files
- puts "Bourbon files installed to bourbon/"
+ puts "Bourbon files installed to #{install_path}/"
end
end
@@ -27,7 +28,15 @@ def update
private
def bourbon_files_already_exist?
- File.directory?("bourbon")
+ install_path.exist?
+ end
+
+ def install_path
+ @install_path ||= if options[:path]
+ Pathname.new(File.join(options[:path], 'bourbon'))
+ else
+ Pathname.new('bourbon')
+ end
end
def install_files
@@ -41,17 +50,17 @@ def remove_bourbon_directory
end
def make_lib_directory
- FileUtils.mkdir_p("bourbon/lib/bourbon")
+ FileUtils.mkdir_p(install_path.join('lib', 'bourbon'))
end
def copy_in_sass_extensions
- FileUtils.cp(File.join(lib_directory, "bourbon.rb"), "bourbon/lib/")
- FileUtils.cp(File.join(lib_bourbon_directory, "sass_extensions.rb"), "bourbon/lib/bourbon/")
- FileUtils.cp_r(File.join(lib_bourbon_directory, "sass_extensions"), "bourbon/lib/bourbon/")
+ FileUtils.cp(File.join(lib_directory, "bourbon.rb"), install_path.join('lib'))
+ FileUtils.cp(File.join(lib_bourbon_directory, "sass_extensions.rb"), install_path.join('lib', 'bourbon'))
+ FileUtils.cp_r(File.join(lib_bourbon_directory, "sass_extensions"), install_path.join('lib', 'bourbon'))
end
def copy_in_scss_files
- FileUtils.cp_r(all_stylesheets, "bourbon/")
+ FileUtils.cp_r(all_stylesheets, install_path)
end
def all_stylesheets

0 comments on commit fe9443b

Please sign in to comment.