Created
November 15, 2012 16:21
-
-
Save mikz/4079488 to your computer and use it in GitHub Desktop.
Tiny script to run ruby files or run all files in directory (usefull for tests)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
alias rt="ruby -Itest -I. -e \"alias rt="ruby -Itest -I. -e \"require'pathname';P=Pathname;ARGV.map{|a|p=P.new(a);next unless p.exist?;p.directory?? P.glob(p.join('**/*.rb')):p}.flatten.compact.uniq.each{|p|require p.expand_path}\""\"" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
rt test/unit/cms/ # runs all tests in that folder | |
rt test/unit/contract_test.rb test/unit/user_test.rb # runs both files | |
rt test/unit/contract/*_user* # runs all tests matching the glob |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby -Itest -I. | |
require'pathname';P=Pathname;ARGV.map{|a|p=P.new(a);next unless p.exist?;p.directory?? P.glob(p.join('**/*.rb')):p}.flatten.compact.uniq.each{|p|require p.expand_path} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby -Itest -I. | |
require 'pathname' | |
paths = ARGV.map do |arg| | |
path = Pathname.new(arg) | |
next unless arg.exist? | |
if path.directory? | |
Pathname.glob path.join('**/*.rb') | |
else | |
path | |
end | |
end | |
paths.flatten.compact.uniq.each { |path| require path.expand_path } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment