forked from danlucraft/rak
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Pathname from Ruby stdlib is an instant solution to the huge mess of File.blahs/Dir.blehs * Using supposedly correct way of finding Ruby binary (supports ruby1.9, jruby, ruby.exe etc.). * All specs standarized on behaviour that a group like: file: 1| line 2| line is always followed by empty line. I don't think the last one should - newline should be separator not terminator, but this is another issue. * Reason danlucraft#1 why Ruby is awesome for Unix scripting is that it makes it so easy to totally avoid manipulating global state. Changing directory in any way other than Dir.chdir(dir){ ... } or exactly once on start/exit is just so shell... Current directory is global state of the worst kind - affecting every almost every i/o operation. Never do that. * ENV isn't as bad as chdir, but it's far better to encapsulate it. Here oddly Perl pwns Ruby with its local $ENV{A}='B' that restores either old value or its absence on exit. Ruby code for that would be something horrible like: def with_changed_env(key, *args) existed, old = ENV.has_key?(key), ENV[key] begin if args.empty? ENV.delete(key) else ENV[key] = args[0] end yield ensure if existed ENV[key] = old else ENV.delete(old) end end end But know RAK_TEST doesn't exist when started, so it's simplified. Anyway there is no global mutable state now left, and all specs pass.
- Loading branch information
Showing
3 changed files
with
31 additions
and
72 deletions.
There are no files selected for viewing
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
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
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