Skip to content

Commit

Permalink
Use Thor for command parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
mike-burns committed Sep 24, 2012
1 parent c59153f commit ac3b318
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 22 deletions.
6 changes: 4 additions & 2 deletions Gemfile.lock
@@ -1,8 +1,9 @@
PATH
remote: .
specs:
bourbon (1.4.0)
bourbon (2.1.1)
sass (>= 3.1)
thor

GEM
remote: http://rubygems.org/
Expand Down Expand Up @@ -35,8 +36,9 @@ GEM
rspec-expectations (2.8.0)
diff-lcs (~> 1.1.2)
rspec-mocks (2.8.0)
sass (3.1.15)
sass (3.2.1)
term-ansicolor (1.0.7)
thor (0.15.4)

PLATFORMS
ruby
Expand Down
2 changes: 1 addition & 1 deletion bin/bourbon
Expand Up @@ -2,4 +2,4 @@

require "bourbon"

Bourbon::Generator.new(ARGV).run
Bourbon::Generator.start
1 change: 1 addition & 0 deletions bourbon.gemspec
Expand Up @@ -27,6 +27,7 @@ that support only CSS3 prefixed properties.
s.require_paths = ["lib"]

s.add_dependency('sass', '>= 3.1')
s.add_dependency('thor')

s.add_development_dependency('aruba', '~> 0.4')
s.add_development_dependency('rake')
Expand Down
29 changes: 10 additions & 19 deletions lib/bourbon/generator.rb
@@ -1,19 +1,19 @@
require "fileutils"
require 'thor'

module Bourbon
class Generator
def initialize(arguments)
@subcommand = arguments.first
end

def run
if @subcommand == "install"
install
elsif @subcommand == "update"
update
class Generator < Thor
desc 'install', 'Install Bourbon into your project'
def install
if bourbon_files_already_exist?
puts "Bourbon files already installed, doing nothing."
else
install_files
puts "Bourbon files installed to bourbon/"
end
end

desc 'update', 'Update Bourbon'
def update
if bourbon_files_already_exist?
remove_bourbon_directory
Expand All @@ -24,15 +24,6 @@ def update
end
end

def install
if bourbon_files_already_exist?
puts "Bourbon files already installed, doing nothing."
else
install_files
puts "Bourbon files installed to bourbon/"
end
end

private

def bourbon_files_already_exist?
Expand Down

0 comments on commit ac3b318

Please sign in to comment.