Skip to content

Commit

Permalink
Added usable default executable for the Sprout gem - this will at lea…
Browse files Browse the repository at this point in the history
…st emit the currently-installed sprout version.
  • Loading branch information
lukebayes committed Jan 4, 2011
1 parent a15f5a1 commit e8859c0
Show file tree
Hide file tree
Showing 8 changed files with 60 additions and 6 deletions.
2 changes: 1 addition & 1 deletion VERSION
Original file line number Original file line Diff line number Diff line change
@@ -1 +1 @@
1.1.6.pre 1.1.7.pre
9 changes: 7 additions & 2 deletions bin/sprout
Original file line number Original file line Diff line number Diff line change
@@ -1,4 +1,9 @@
#!/usr/bin/bash #!/usr/bin/env ruby


echo 'Type sprout- and then hit the tab key to see the new sprout binaries.' require 'rubygems'
require 'sprout'

generator = Sprout::CommandLine.new
generator.parse! ARGV
generator.execute


1 change: 1 addition & 0 deletions lib/sprout.rb
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
require 'sprout/specification' require 'sprout/specification'
require 'sprout/executable' require 'sprout/executable'
require 'sprout/daemon' require 'sprout/daemon'
require 'sprout/command_line'


# Generators # Generators
require 'sprout/generator' require 'sprout/generator'
Expand Down
26 changes: 26 additions & 0 deletions lib/sprout/command_line.rb
Original file line number Original file line Diff line number Diff line change
@@ -0,0 +1,26 @@
module Sprout

class CommandLine < Sprout::Executable::Base

##
# Get the version of the Sprout gem
add_param :version, Boolean, :default => false, :hidden_value => true

add_param_alias :v, :version

##
# @return [IO] default $stdout, Replace value in test context.
attr_accessor :logger

def initialize
super
@logger = $stdout
end

def execute
if version
logger.puts "sprout #{Sprout::VERSION::STRING}"
end
end
end
end
2 changes: 1 addition & 1 deletion lib/sprout/generators/generator/generator_generator.rb
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ def manifest
massage_input massage_input


directory bin do directory bin do
template "#{input.snake_case}", "generator_executable" template "#{input.dash_case}", "generator_executable"
end end


directory lib do directory lib do
Expand Down
2 changes: 1 addition & 1 deletion lib/sprout/generators/ruby/ruby_generator.rb
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ def manifest
directory fixtures directory fixtures
directory unit do directory unit do
template "#{input.snake_case}_test.rb", 'ruby_test_case.rb' template "#{input.snake_case}_test.rb", 'ruby_test_case.rb'
template 'test_helper.rb', 'ruby_test_helper.rb'
end end
template 'test_helper.rb', 'ruby_test_helper.rb'
end end


directory bin do directory bin do
Expand Down
2 changes: 1 addition & 1 deletion lib/sprout/generators/ruby/templates/ruby_test_case.rb
Original file line number Original file line Diff line number Diff line change
@@ -1,7 +1,7 @@
require 'test_helper' require 'test_helper'


class <%= input.camel_case %>Test < Test::Unit::TestCase class <%= input.camel_case %>Test < Test::Unit::TestCase
include SproutTestCase include Sprout::TestHelper
context "A <%= input.camel_case %>" do context "A <%= input.camel_case %>" do
Expand Down
22 changes: 22 additions & 0 deletions test/unit/command_line_test.rb
Original file line number Original file line Diff line number Diff line change
@@ -0,0 +1,22 @@
require 'test_helper'

class CommandLineTest < Test::Unit::TestCase
include Sprout::TestHelper

context "a new command line ui" do

setup do
@instance = Sprout::CommandLine.new
@instance.logger = Sprout::OutputBuffer.new
end

should "display the version number" do
@instance.version = true
@instance.execute

assert_matches /sprout #{Sprout::VERSION::STRING}/, @instance.logger.read
end
end
end


0 comments on commit e8859c0

Please sign in to comment.