rogerdpack-sane 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/sane.rb +38 -32
- metadata +1 -1
data/lib/sane.rb
CHANGED
@@ -20,37 +20,43 @@ class File
|
|
20
20
|
end
|
21
21
|
|
22
22
|
|
23
|
-
# a method like puts but all on one line--very much like java's println, quite useful
|
24
|
-
def println *args
|
25
|
-
print *args
|
26
|
-
puts
|
27
|
-
end
|
28
23
|
|
29
24
|
class Object
|
30
25
|
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
26
|
+
# a helper for collection.include?
|
27
|
+
def in? collection
|
28
|
+
collection.include?(self)
|
29
|
+
end unless respond_to? :in
|
30
|
+
|
31
|
+
# ex: assert(some statement)
|
32
|
+
# or
|
33
|
+
# assert(some statement, "some helper string")
|
34
|
+
def assert(should_be_true, string = nil)
|
35
|
+
if(!should_be_true)
|
36
|
+
raise "assertion failed #{string}"
|
37
|
+
end
|
38
|
+
end unless respond_to? :assert
|
39
|
+
|
40
|
+
# helper to bring up a debugger
|
41
|
+
# for this to work in 1.9, please follow directions: http://wiki.github.com/mark-moseley/ruby-debug
|
42
|
+
# for 1.8, run gem install ruby-debug
|
43
|
+
def _dbg
|
44
|
+
require 'rubygems'
|
45
|
+
require 'ruby-debug'
|
46
|
+
debugger
|
47
|
+
end
|
44
48
|
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
require 'ruby-debug'
|
51
|
-
debugger
|
52
|
-
end
|
49
|
+
# a method like puts but all on one line--very much like java's println, quite useful
|
50
|
+
def println *args
|
51
|
+
print *args
|
52
|
+
puts
|
53
|
+
end
|
53
54
|
|
55
|
+
def aliaz hash
|
56
|
+
hash.each_pair {|new, old|
|
57
|
+
alias_method new, old
|
58
|
+
}
|
59
|
+
end
|
54
60
|
end
|
55
61
|
|
56
62
|
if RUBY_VERSION < '1.9'
|
@@ -60,10 +66,10 @@ end
|
|
60
66
|
# taken from http://oldrcrs.rubypal.com/rcr/show/309
|
61
67
|
|
62
68
|
module Kernel
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
+
BASE_DIR = Dir.getwd
|
70
|
+
def __DIR__
|
71
|
+
dir = (/^(.+)?:\d+/ =~ caller[0]) ? File.expand_path(File.dirname($1), BASE_DIR) : nil
|
72
|
+
dir += '/' if dir
|
73
|
+
dir
|
74
|
+
end unless defined?(__DIR__)
|
69
75
|
end
|