forked from thoughtbot/bourbon
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Actually add the generator. gitignore is weird.
- Loading branch information
Gabe Berke-Williams
committed
Jan 20, 2012
1 parent
13e70d3
commit c2077d8
Showing
2 changed files
with
82 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
*swp | ||
*gem | ||
.sass-cache/ | ||
bourbon/ | ||
/bourbon/ | ||
demo/ | ||
tmp/ | ||
tags |
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,81 @@ | ||
require "fileutils" | ||
|
||
module Bourbon | ||
class Generator | ||
def initialize(arguments) | ||
@subcommand = arguments.first | ||
end | ||
|
||
def run | ||
if @subcommand == "generate" | ||
generate | ||
elsif @subcommand == "update" | ||
update | ||
end | ||
end | ||
|
||
def update | ||
if bourbon_files_already_exist? | ||
remove_bourbon_directory | ||
generate_files | ||
puts "Bourbon files updated." | ||
else | ||
puts "No existing bourbon installation. Doing nothing." | ||
end | ||
end | ||
|
||
def generate | ||
if bourbon_files_already_exist? | ||
puts "Bourbon files already generated, doing nothing." | ||
else | ||
generate_files | ||
puts "Bourbon files generated to bourbon/" | ||
end | ||
end | ||
|
||
private | ||
|
||
def bourbon_files_already_exist? | ||
Dir.exist?("bourbon") | ||
end | ||
|
||
def generate_files | ||
make_lib_directory | ||
copy_in_sass_extensions | ||
copy_in_scss_files | ||
end | ||
|
||
def remove_bourbon_directory | ||
FileUtils.rm_rf("bourbon") | ||
end | ||
|
||
def make_lib_directory | ||
FileUtils.mkdir_p("bourbon/lib") | ||
end | ||
|
||
def copy_in_sass_extensions | ||
FileUtils.cp(File.join(lib_directory, "sass_extensions.rb"), "bourbon/lib/") | ||
FileUtils.cp_r(File.join(lib_directory, "sass_extensions"), "bourbon/lib/") | ||
end | ||
|
||
def copy_in_scss_files | ||
FileUtils.cp_r(all_stylesheets, "bourbon/") | ||
end | ||
|
||
def all_stylesheets | ||
Dir["#{stylesheets_directory}/*"] | ||
end | ||
|
||
def stylesheets_directory | ||
File.join(top_level_directory, "app", "assets", "stylesheets") | ||
end | ||
|
||
def lib_directory | ||
File.join(top_level_directory, "lib", "bourbon") | ||
end | ||
|
||
def top_level_directory | ||
File.dirname(File.dirname(File.dirname(__FILE__))) | ||
end | ||
end | ||
end |