Revision: 108
Updated Code
at July 3, 2006 09:15 by Catfish
Updated Code
####### #Command : RUBYLIB="$TM_BUNDLE_SUPPORT/lib:$RUBYLIB" "${TM_RUBY:=ruby}" -- "${TM_BUNDLE_SUPPORT}/bin/spec_helper.rb" ####### #Your.bundle/Support/bin/spec_helper.rb :   require 'cgi' #try and remove unnecessary '..'s from paths. #Eg collapse 'config/../app/controllers/../../public' to 'public'. Hopefully. def rationalize_path(path)      components = path.split("/")  real_components = []  components.each do |c|   if (c == "..") && (real_components.size > 0) && (real_components.last != "..")    real_components.pop   else    real_components.push c   end  end    File.join(real_components) end   Dir.chdir(ENV['TM_PROJECT_DIRECTORY']) output = `rake spec 2>&1` output = CGI.escapeHTML(output) #rationalize paths (strip out unnecessary '..'s etc) output.gsub! /(\.\/|\/)[^:\n&]+\.[^:\n]+/ do |m|  rationalize_path(m) end #Find local file names and make them into proper links #It ignores any paths that don't start with './'. # (This is a feature, IMO - too many links otherwise) output.gsub! /\.(\/[^:&]+):([\d]+)/ do |m|  path = Dir.pwd + $1  "<a href=\"txmt://open?url=file://#{path}&line=#{$2}\">#{m}</a>" end #Remove unnecessary repitition of the project path. #Need to keep it in if it's preceeded by '/' - this would indicate it's part of a link url. output.gsub! /([^\/])#{Dir.pwd}\// do |m|  $1+'./' end #Find the result lines (x specification(s), y failure(s)) and color them output.gsub! /^[\d]+ specifications?, [\d]+ failures?/ do |m|  "<span class='result'>#{m}</span>" end output.gsub!("\n", "<br/>") puts <<END <html> <head>  <title>rspec results</title>  <style type='text/css'> body {font-size:0.8em} .result {font-weight:bold;}  </style> </head> <body> <h1>rspec</h1> #{output} </body> </html> END
Revision: 107
Updated Code
at July 3, 2006 08:34 by Catfish
Updated Code
####### #Command : RUBYLIB="$TM_BUNDLE_SUPPORT/lib:$RUBYLIB" "${TM_RUBY:=ruby}" -- "${TM_BUNDLE_SUPPORT}/bin/spec_helper.rb" ####### #Your.bundle/Support/bin/spec_helper.rb : require 'cgi' #try and remove unnecessary '..'s from paths. #Eg collapse 'config/../app/controllers/../../public' to 'public'. Hopefully. def rationalize_path(path)      components = path.split("/")  real_components = []  components.each do |c|   if (c == "..") && (real_components.size > 0) && (real_components.last != "..")    real_components.pop   else    real_components.push c   end  end    File.join(real_components) end   Dir.chdir(ENV['TM_PROJECT_DIRECTORY']) output = `rake spec 2>&1` output = CGI.escapeHTML(output) #rationalize paths (strip out unnecessary '..'s etc) output.gsub! /(\.\/|\/)[^:\n&]+\.[^:\n]+/ do |m|  rationalize_path(m) end #Remove unnecessary repitition of the project path: output.gsub! /#{Dir.pwd}\//, './' #Find local file names and make them into proper links #It ignores any paths that don't start with './'. # (This is a feature, IMO - too many links otherwise) output.gsub! /\.(\/[^:&]+):([\d]+)/ do |m|  path = Dir.pwd + $1  "<a href=\"txmt://open?url=file://#{path}&line=#{$2}\">#{m}</a>" end #Find the result lines (x specification(s), y failure(s)) and color them output.gsub! /^[\d]+ specifications?, [\d]+ failures?/ do |m|  "<span class='result'>#{m}</span>" end output.gsub!("\n", "<br/>") puts <<END <html> <head>  <title>rspec results</title>  <style type='text/css'> body {font-size:0.8em} .result {font-weight:bold;}  </style> </head> <body> <h1>rspec</h1> #{output} </body> </html> END
Revision: 106
Updated Code
at July 3, 2006 04:25 by Catfish
Updated Code
require 'cgi' #try and remove unnecessary '..'s from paths. #Eg collapse 'config/../app/controllers/../../public' to 'public'. Hopefully. def rationalize_path(path)      components = path.split("/")  real_components = []  components.each do |c|   if (c == "..") && (real_components.size > 0) && (real_components.last != "..")    real_components.pop   else    real_components.push c   end  end    File.join(real_components) end   Dir.chdir(ENV['TM_PROJECT_DIRECTORY']) output = `rake spec 2>&1` output = CGI.escapeHTML(output) #rationalize paths (strip out unnecessary '..'s etc) output.gsub! /(\.\/|\/)[^:\n&]+\.[^:\n]+/ do |m|  rationalize_path(m) end #Remove unnecessary repitition of the project path: output.gsub! /#{Dir.pwd}\//, './' #Find local file names and make them into proper links #It ignores any paths that don't start with './'. # (This is a feature, IMO - too many links otherwise) output.gsub! /\.(\/[^:&]+):([\d]+)/ do |m|  path = Dir.pwd + $1  "<a href=\"txmt://open?url=file://#{path}&line=#{$2}\">#{m}</a>" end #Find the result lines (x specification(s), y failure(s)) and color them output.gsub! /^[\d]+ specifications?, [\d]+ failures?/ do |m|  "<span class='result'>#{m}</span>" end output.gsub!("\n", "<br/>") puts <<END <html> <head>  <title>rspec results</title>  <style type='text/css'> body {font-size:0.8em} .result {font-weight:bold;}  </style> </head> <body> <h1>rspec</h1> #{output} </body> </html> END
Revision: 105
Updated Code
at July 3, 2006 03:39 by Catfish
Updated Code
require 'cgi' #try and remove unnecessary '..'s from paths. #Eg collapse 'config/../app/controllers/../../public' to 'public'. Hopefully. def rationalize_path(path)      components = path.split("/")  real_components = []  components.each do |c|   if (c == "..") && (real_components.size > 0) && (real_components.last != "..")    real_components.pop   else    real_components.push c   end  end    File.join(real_components) end   Dir.chdir(ENV['TM_PROJECT_DIRECTORY']) output = `rake spec 2>&1` output = CGI.escapeHTML(output) #rationalize paths (strip out unnecessary '..'s etc) output.gsub! /(\.\/|\/)[^:\n]+\.[^:\n]+/ do |m|  rationalize_path(m) end #Remove unnecessary repitition of the project path: output.gsub! /#{Dir.pwd}\//, './' #Find local file names and make them into proper links #It ignores any paths that don't start with './'. # (This is a feature, IMO - too many links otherwise) output.gsub! /\.(\/[^:]+):([\d]+)/ do |m|  path = Dir.pwd + $1  "<a href=\"txmt://open?url=file://#{path}&line=#{$2}\">#{m}</a>" end #Find the result lines (x specification(s), y failure(s)) and color them output.gsub! /^[\d]+ specifications?, [\d]+ failures?/ do |m|  "<span class='result'>#{m}</span>" end output.gsub!("\n", "<br/>") puts <<END <html> <head>  <title>rspec results</title>  <style type='text/css'> body {font-size:0.8em} .result {font-weight:bold;}  </style> </head> <body> <h1>rspec</h1> #{output} </body> </html> END
Revision: 104
Updated Code
at July 2, 2006 13:58 by Catfish
Updated Code
#!/usr/bin/env ruby require 'cgi' #try and remove unnecessary '..'s from paths. #Eg collapse 'config/../app/controllers/../../public' to 'public'. Hopefully. def rationalize_path(path)      components = path.split("/")  real_components = []  components.each do |c|   if (c == "..") && (real_components.size > 0) && (real_components.last != "..")    real_components.pop   else    real_components.push c   end  end    File.join(real_components) end   Dir.chdir(ENV['TM_PROJECT_DIRECTORY']) output = `rake spec 2>&1` output = CGI.escapeHTML(output) #rationalize paths (strip out unnecessary '..'s etc) output.gsub! /(\.\/|\/)[^:\n]+\.[^:\n]+/ do |m|  rationalize_path(m) end #Find local file names and make them into proper links #It ignores any paths that don't start with './'. # (This is a feature, IMO - too many links otherwise) output.gsub! /\.(\/[^:]+):([\d]+)/ do |m|  path = Dir.pwd + $1  "<a href=\"txmt://open?url=file://#{path}&line=#{$2}\">#{m}</a>" end #Find the result lines (x specification(s), y failure(s)) and color them output.gsub! /^[\d]+ specifications?, [\d]+ failures?/ do |m|  "<span class='result'>#{m}</span>" end #Remove unnecessary repitition of the project path: output.gsub! /#{Dir.pwd}\//, './' output.gsub!("\n", "<br/>") puts <<END <html> <head>  <title>rspec results</title>  <style type='text/css'> body {font-size:0.8em} .result {font-weight:bold;}  </style> </head> <body> <h1>rspec</h1> #{output} </body> </html> END
Revision: 103
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at June 30, 2006 07:00 by Catfish
Initial Code
#!/usr/bin/env ruby require 'cgi' Dir.chdir(ENV['TM_PROJECT_DIRECTORY']) output = `rake spec 2>&1` output = CGI.escapeHTML(output) output.gsub!("\n", "<br/>") #try to find file names and make them into proper links output.gsub! /\.(\/[^:]*):([\d]*)/ do |m| path = Dir.pwd + $1 "<a href=\"txmt://open?url=file://#{path}&line=#{$2}\">#{m}</a>" end puts "<html><style type='text/css'>.error {color:red}</style><body style='font-size:0.8em'>#{"<h1>rspec</h1>"+output}</body></html>"
Initial URL
Initial Description
Initial Title
Running RSpec for Rails from TextMate
Initial Tags
textmate, rails
Initial Language
Ruby