tasks/setup.rb in classy-inheritance-0.6.4 vs tasks/setup.rb in classy-inheritance-0.7.0

- old
+ new

@@ -4,11 +4,11 @@ require 'rake/clean' require 'fileutils' require 'ostruct' require 'find' -class OpenStruct; undef :gem; end +class OpenStruct; undef :gem if defined? :gem; end # TODO: make my own openstruct type object that includes descriptions # TODO: use the descriptions to output help on the available bones options PROJ = OpenStruct.new( @@ -122,14 +122,12 @@ # Setup the project libraries %w(lib ext).each {|dir| PROJ.libs << dir if test ?d, dir} # Setup some constants -WIN32 = %r/djgpp|(cyg|ms|bcc)win|mingw/ =~ RUBY_PLATFORM unless defined? WIN32 +DEV_NULL = File.exist?('/dev/null') ? '/dev/null' : 'NUL:' -DEV_NULL = WIN32 ? 'NUL:' : '/dev/null' - def quiet( &block ) io = [STDOUT.dup, STDERR.dup] STDOUT.reopen DEV_NULL STDERR.reopen DEV_NULL block.call @@ -137,24 +135,18 @@ STDOUT.reopen io.first STDERR.reopen io.last $stdout, $stderr = STDOUT, STDERR end -DIFF = if WIN32 then 'diff.exe' - else - if quiet {system "gdiff", __FILE__, __FILE__} then 'gdiff' - else 'diff' end - end unless defined? DIFF +DIFF = if system("gdiff '#{__FILE__}' '#{__FILE__}' > #{DEV_NULL} 2>&1") then 'gdiff' + else 'diff' end unless defined? DIFF -SUDO = if WIN32 then '' - else - if quiet {system 'which sudo'} then 'sudo' - else '' end - end +SUDO = if system("which sudo > #{DEV_NULL} 2>&1") then 'sudo' + else '' end unless defined? SUDO -RCOV = WIN32 ? 'rcov.bat' : 'rcov' -RDOC = WIN32 ? 'rdoc.bat' : 'rdoc' -GEM = WIN32 ? 'gem.bat' : 'gem' +RCOV = "#{RUBY} -S rcov" +RDOC = "#{RUBY} -S rdoc" +GEM = "#{RUBY} -S gem" %w(rcov spec/rake/spectask rubyforge bones facets/ansicode).each do |lib| begin require lib Object.instance_eval {const_set "HAVE_#{lib.tr('/','_').upcase}", true}