[DRE-commits] r3030 - in packages: . libshoulda-ruby libshoulda-ruby/branches libshoulda-ruby/branches/upstream libshoulda-ruby/branches/upstream/current libshoulda-ruby/branches/upstream/current/bin

terceiro-guest at alioth.debian.org terceiro-guest at alioth.debian.org
Sat Sep 27 11:56:05 UTC 2008


Author: terceiro-guest
Date: 2008-09-27 11:56:04 +0000 (Sat, 27 Sep 2008)
New Revision: 3030

Added:
   packages/libshoulda-ruby/
   packages/libshoulda-ruby/branches/
   packages/libshoulda-ruby/branches/upstream/
   packages/libshoulda-ruby/branches/upstream/current/
   packages/libshoulda-ruby/branches/upstream/current/bin/
   packages/libshoulda-ruby/branches/upstream/current/bin/convert_file_to_shoulda
Log:
[svn-inject] Installing original source of libshoulda-ruby

Added: packages/libshoulda-ruby/branches/upstream/current/bin/convert_file_to_shoulda
===================================================================
--- packages/libshoulda-ruby/branches/upstream/current/bin/convert_file_to_shoulda	                        (rev 0)
+++ packages/libshoulda-ruby/branches/upstream/current/bin/convert_file_to_shoulda	2008-09-27 11:56:04 UTC (rev 3030)
@@ -0,0 +1,40 @@
+#!/usr/bin/env ruby
+require 'fileutils'
+
+def usage(msg = nil)
+  puts "Error: #{msg}" if msg
+  puts if msg
+  puts "Usage: #{File.basename(__FILE__)} normal_test_file.rb"
+  puts
+  puts "Will convert an existing test file with names like "
+  puts
+  puts "  def test_should_do_stuff"
+  puts "    ..."
+  puts "  end"
+  puts
+  puts "to one using the new syntax: "
+  puts
+  puts "  should \"be super cool\" do"
+  puts "    ..."
+  puts "  end"
+  puts
+  puts "A copy of the old file will be left under /tmp/ in case this script just seriously screws up"
+  puts
+  exit (msg ? 2 : 0)
+end
+
+usage("Wrong number of arguments.") unless ARGV.size == 1
+usage("This system doesn't have a /tmp directory.  wtf?") unless File.directory?('/tmp')
+
+file = ARGV.shift
+tmpfile = "/tmp/#{File.basename(file)}"
+usage("File '#{file}' doesn't exist") unless File.exists?(file)
+
+FileUtils.cp(file, tmpfile)
+contents = File.read(tmpfile)
+contents.gsub!(/def test_should_(.*)\s*$/, 'should "\1" do')
+contents.gsub!(/def test_(.*)\s*$/, 'should "RENAME ME: test \1" do')
+contents.gsub!(/should ".*" do$/) {|line| line.tr!('_', ' ')}
+File.open(file, 'w') { |f| f.write(contents) }
+
+puts "File '#{file}' has been converted to 'should' syntax.  Old version has been stored in '#{tmpfile}'"




More information about the Pkg-ruby-extras-commits mailing list