Skip to content

Commit

Permalink
Added --thor option.
Browse files Browse the repository at this point in the history
  • Loading branch information
technicalpickles committed Oct 19, 2009
1 parent 24ad76e commit 9dcbb46
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 3 deletions.
10 changes: 7 additions & 3 deletions lib/jeweler/generator.rb
Expand Up @@ -194,14 +194,18 @@ def create_files

end

def output_template_in_target(source, destination = source)
final_destination = File.join(target_dir, destination)

def render_template(source)
template_contents = File.read(File.join(template_dir, source))
template = ERB.new(template_contents, nil, '<>')

# squish extraneous whitespace from some of the conditionals
template_result = template.result(binding).gsub(/\n\n\n+/, "\n\n")
end

def output_template_in_target(source, destination = source)
final_destination = File.join(target_dir, destination)

template_result = render_template(source)

File.open(final_destination, 'w') {|file| file.write(template_result)}

Expand Down
11 changes: 11 additions & 0 deletions lib/jeweler/generator/options.rb
Expand Up @@ -8,6 +8,7 @@ def initialize(args)
super()

@orig_args = args.clone
self[:scripting_framework] = :rake
self[:testing_framework] = :shoulda
self[:documentation_framework] = :rdoc

Expand Down Expand Up @@ -61,6 +62,16 @@ def initialize(args)

o.separator ""

o.on('--rake', 'generate Rakefile') do
self[:scripting_framework] = :rake
end

o.on('--thor', 'generate Thorfile') do
self[:scripting_framework] = :thor
end

o.separator ""

o.on('--cucumber', 'generate cucumber stories in addition to the other tests') do
self[:use_cucumber] = true
end
Expand Down
16 changes: 16 additions & 0 deletions test/jeweler/generator/test_options.rb
Expand Up @@ -7,6 +7,12 @@ def setup
stub_git_config valid_git_config
end

def self.should_have_scripting_framework(scripting_framework)
should "use #{scripting_framework} for scripting" do
assert_equal scripting_framework.to_sym, @options[:scripting_framework]
end
end

def self.should_have_testing_framework(testing_framework)
should "use #{testing_framework} for testing" do
assert_equal testing_framework.to_sym, @options[:testing_framework]
Expand Down Expand Up @@ -34,6 +40,8 @@ def self.for_options(*options)
setup { setup_options }
should_have_testing_framework :shoulda
should_have_docmentation_framework :rdoc
should_have_scripting_framework :rake

should 'not create repository' do
assert ! @options[:create_repo]
end
Expand Down Expand Up @@ -116,6 +124,14 @@ def self.for_options(*options)
end
end

for_options '--rake' do
should_have_scripting_framework :rake
end

for_options '--thor' do
should_have_scripting_framework :thor
end

for_options '--rdoc' do
should_have_docmentation_framework :rdoc
end
Expand Down

0 comments on commit 9dcbb46

Please sign in to comment.