Browse files

We shouldn't output anything during tests.

  • Loading branch information...
1 parent 0cbbe98 commit 22773e1602e74763752264b806f44a9b5df864cd @lazyatom committed Dec 22, 2009
Showing with 14 additions and 8 deletions.
  1. +1 −1 bin/gem-this
  2. +11 −5 lib/gem_this.rb
  3. +1 −1 lib/rubygems_plugin.rb
  4. +1 −1 test/test_helper.rb
View
2 bin/gem-this
@@ -15,6 +15,6 @@ end
debug = args.delete("-d")
-GemThis.new(args.first || File.basename(Dir.pwd), debug).create_rakefile
+GemThis.new(args.first || File.basename(Dir.pwd), :debug => debug).create_rakefile
exit
View
16 lib/gem_this.rb
@@ -7,9 +7,11 @@ class GemThis
attr_reader :name, :debug
- def initialize(name, debug)
+ def initialize(name, options={})
@name = name
- @debug = debug
+ options = {:default => false, :silent => false}.update(options)
+ @debug = options[:debug]
+ @silent = options[:silent]
end
def create_rakefile
@@ -20,22 +22,26 @@ def create_rakefile
puts rakefile
else
if File.exist?('Rakefile')
- puts "Appended to existing Rakefile"
+ log "Appended to existing Rakefile"
File.open('Rakefile', 'a') { |f| 2.times { f.puts }; f.write rakefile }
else
- puts "Writing new Rakefile"
+ log "Writing new Rakefile"
File.open('Rakefile', 'w') { |f| f.write rakefile }
end
add_to_gitignore if using_git?
end
unless has_lib_directory?
- puts "You don't see to have a lib directory - please edit the Rakefile to set where your code is."
+ log "You don't see to have a lib directory - please edit the Rakefile to set where your code is."
false
end
end
private
+ def log(message)
+ puts(message) unless @silent
+ end
+
def author_name
Etc.getpwnam(ENV['USER']).gecos rescue ENV['USER'] # for Windows
end
View
2 lib/rubygems_plugin.rb
@@ -15,7 +15,7 @@ def summary
end
def execute
- GemThis.new(options[:args].first || File.basename(Dir.pwd), options[:debug]).create_rakefile
+ GemThis.new(options[:args].first || File.basename(Dir.pwd), options).create_rakefile
end
end
View
2 test/test_helper.rb
@@ -42,7 +42,7 @@ def path_to_gem
def build
result = nil
FileUtils.cd(@gem_path) do
- result = GemThis.new(@name, false).create_rakefile
+ result = GemThis.new(@name, :debug => false, :silent => true).create_rakefile
`rake package 2>&1`
end
result

0 comments on commit 22773e1

Please sign in to comment.