sane 0.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/ChangeLog +18 -0
- data/README +24 -0
- data/Rakefile +31 -0
- data/VERSION +1 -0
- data/lib/_dbg.rb +3 -0
- data/lib/sane.rb +8 -0
- data/lib/sane_ruby/add_regexes.rb +13 -0
- data/lib/sane_ruby/bugs.rb +35 -0
- data/lib/sane_ruby/enumerable-extra.rb +161 -0
- data/lib/sane_ruby/enumerable_brackets.rb +10 -0
- data/lib/sane_ruby/hash_hashes.rb +16 -0
- data/lib/sane_ruby/hash_set_operators_bug_fix.rb +11 -0
- data/lib/sane_ruby/irb_startup_options.rb +15 -0
- data/lib/sane_ruby/sane_random.rb +91 -0
- data/sane.gemspec +62 -0
- data/spec/test_sane.spec +72 -0
- data/todo +1 -0
- metadata +102 -0
data/ChangeLog
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
* renamed println to sprint
|
2
|
+
|
3
|
+
|
4
|
+
0.1.0
|
5
|
+
* add File.write [stolen from facets]
|
6
|
+
|
7
|
+
0.0.8
|
8
|
+
* add __DIR__ [stolen from oldrcrs]
|
9
|
+
|
10
|
+
0.0.6
|
11
|
+
* bug fix [require andand]
|
12
|
+
|
13
|
+
0.0.5
|
14
|
+
* add dependency on andand, rogerdpack-rbeautify # essentials
|
15
|
+
* add dbg call [essential]
|
16
|
+
|
17
|
+
0.0.3
|
18
|
+
* add assert method
|
data/README
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
Collection of utilities to make ruby ...more friendly from the get-go [really things that *should* have been added to core, because of immense convenience]
|
2
|
+
|
3
|
+
Currently this includes:
|
4
|
+
|
5
|
+
require_rel glob
|
6
|
+
* require a file relative to the current file, i.e.
|
7
|
+
>> require_rel 'lib/filename'
|
8
|
+
|
9
|
+
Object#in?
|
10
|
+
# ex:
|
11
|
+
>> 3.in? [1,2,3]
|
12
|
+
=> true
|
13
|
+
|
14
|
+
println
|
15
|
+
like print, but with a carriage return at the end:
|
16
|
+
>> println 1,2,3
|
17
|
+
(prints 123\n)
|
18
|
+
|
19
|
+
enumerable-extra
|
20
|
+
#new enumerable #map
|
21
|
+
>> [1,2,3].map(:to_s) # applies it automatically! far less ugly than [1,2,3].map &:to_s
|
22
|
+
=> ["1", "2", "3"]
|
23
|
+
|
24
|
+
Don't leave home without these!
|
data/Rakefile
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'jeweler'
|
3
|
+
Jeweler::Tasks.new do |s|
|
4
|
+
|
5
|
+
s.name = %q{sane}
|
6
|
+
# 3: add hash_set_operators
|
7
|
+
# 0.2.2: add Regex+Regex, bug fixes
|
8
|
+
# 0.2.0:
|
9
|
+
# add irb simple prompt, auto indent by default [sane defaults!]
|
10
|
+
# 1: add $: << '.', don't do Hash#hash on 1.9
|
11
|
+
# 0.1.
|
12
|
+
# 9 add irb autocompletion on by default [if you're in an IRB session, that is]
|
13
|
+
# 8 add Hash#hash
|
14
|
+
# 7 add File.binwrite
|
15
|
+
# rename aliaz alias_h [ for alias hash ]
|
16
|
+
# 6 add File.binread [1.9 has it, 1.8 not]
|
17
|
+
# 5 remove #sum method [not rails compat]
|
18
|
+
# 4 add _dbg as a file
|
19
|
+
# 0.1.3 require 'pp' with _dbg
|
20
|
+
# 0.1.2 add singleton_class
|
21
|
+
# 0.1.1 add aliaz
|
22
|
+
|
23
|
+
s.homepage = 'http://github.com/rogerdpack/sane_ruby'
|
24
|
+
s.authors = ["Roger Pack"]
|
25
|
+
s.description = s.summary = %q{Helper methods for ruby to make it easier to work with out of the box--things that are missing from core but should be there}
|
26
|
+
s.email = ["rogerdpack@gmail.com"]
|
27
|
+
|
28
|
+
s.add_runtime_dependency("require_all")
|
29
|
+
s.add_runtime_dependency("backports")
|
30
|
+
s.add_runtime_dependency("hash_set_operators")
|
31
|
+
end
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.8.0
|
data/lib/_dbg.rb
ADDED
data/lib/sane.rb
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
class Regexp
|
2
|
+
def +(other)
|
3
|
+
if other.is_a?(Regexp)
|
4
|
+
if self.options == other.options
|
5
|
+
Regexp.new(source + other.source, options)
|
6
|
+
else
|
7
|
+
Regexp.new(source + other.to_s, options)
|
8
|
+
end
|
9
|
+
else
|
10
|
+
Regexp.new(source + Regexp.escape(other.to_s), options)
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
|
2
|
+
if RUBY_PLATFORM =~ /mingw|mswin/
|
3
|
+
class File
|
4
|
+
# buggy File.executable? on windows
|
5
|
+
class << self
|
6
|
+
undef :executable?
|
7
|
+
def executable? *args
|
8
|
+
File.stat(*args).executable?
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
if RUBY_VERSION == '1.9.1'
|
15
|
+
# 1.9.1 bug
|
16
|
+
if File.basename(__FILE__).frozen?
|
17
|
+
class File
|
18
|
+
class << self
|
19
|
+
alias :original_basename :basename
|
20
|
+
def File.basename *args
|
21
|
+
original_basename(*args).dup
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
end
|
28
|
+
|
29
|
+
|
30
|
+
=begin
|
31
|
+
rubydoctest: non frozen
|
32
|
+
>> File.basename(__FILE__).frozen?
|
33
|
+
=> false
|
34
|
+
|
35
|
+
=end
|
@@ -0,0 +1,161 @@
|
|
1
|
+
module Enumerable
|
2
|
+
EXTRA_VERSION = '0.1.0'
|
3
|
+
|
4
|
+
alias old_map map
|
5
|
+
alias old_collect collect
|
6
|
+
=begin unused as it clashes with rails' own #sum
|
7
|
+
apparently
|
8
|
+
C:\dev\ruby\bridal>ruby test\functional\store_controller_test.rb
|
9
|
+
test/functional/../test_helper
|
10
|
+
C:/dev/ruby/bridal/config/../lib/sane-0.1.4/lib/enumerable-extra.rb:12:in `+': can't convert String into Array (TypeError)
|
11
|
+
from C:/dev/ruby/bridal/config/../lib/sane-0.1.4/lib/enumerable-extra.rb:12:in `sum'
|
12
|
+
from C:/dev/ruby/bridal/config/../lib/sane-0.1.4/lib/enumerable-extra.rb:12:in `each'
|
13
|
+
from C:/dev/ruby/bridal/config/../lib/sane-0.1.4/lib/enumerable-extra.rb:12:in `sum'
|
14
|
+
from C:/dev/ruby/bridal/vendor/rails/actionpack/lib/action_controller/layout.rb:189:in `layout_list'
|
15
|
+
|
16
|
+
2.1
|
17
|
+
|
18
|
+
# Returns the numeric total of the elements of +enum+, using +total+ as
|
19
|
+
# an accumulator (0 by default). Raises an error if any of the elements
|
20
|
+
# are non-numeric.
|
21
|
+
#
|
22
|
+
def sum(total = 0)
|
23
|
+
each{ |val| total += val }
|
24
|
+
total
|
25
|
+
end
|
26
|
+
=end
|
27
|
+
|
28
|
+
# Returns a new array containing the results of running +method+ once for
|
29
|
+
# every element in the enumerable object. If both arguments and a block
|
30
|
+
# are provided the arguments are processed first, then passed to
|
31
|
+
# the block.
|
32
|
+
#
|
33
|
+
# If no method is provided, then it behaves as the standard MRI method.
|
34
|
+
#
|
35
|
+
# Examples:
|
36
|
+
#
|
37
|
+
# array = ['foo', 'bar']
|
38
|
+
#
|
39
|
+
# # No arguments
|
40
|
+
# array.map(:capitalize) => ['Foo', 'Bar']
|
41
|
+
#
|
42
|
+
# # With arguments
|
43
|
+
# array.map(:+, 'x') => ['foox', 'barx']
|
44
|
+
#
|
45
|
+
# # With arguments and a block
|
46
|
+
# array.map(:capitalize){ |e| e + 'x' } => ['Foox', 'Barx']
|
47
|
+
#
|
48
|
+
def map(method=nil, *args, &block)
|
49
|
+
if method
|
50
|
+
array = []
|
51
|
+
method = method.to_sym unless method.is_a?(Symbol)
|
52
|
+
|
53
|
+
each{ |obj|
|
54
|
+
temp = obj.send(method, *args)
|
55
|
+
if block
|
56
|
+
array << block.call(temp)
|
57
|
+
else
|
58
|
+
array << temp
|
59
|
+
end
|
60
|
+
}
|
61
|
+
|
62
|
+
array
|
63
|
+
else
|
64
|
+
old_map(&block)
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
# Reset the aliases
|
69
|
+
alias collect map
|
70
|
+
end
|
71
|
+
|
72
|
+
class Array
|
73
|
+
alias old_map map
|
74
|
+
alias old_map! map!
|
75
|
+
alias old_collect collect
|
76
|
+
alias old_collect! collect!
|
77
|
+
#alias old_select select
|
78
|
+
|
79
|
+
# Returns a new array containing the results of running +block+ once for
|
80
|
+
# every element in the +array+.
|
81
|
+
#
|
82
|
+
# Examples:
|
83
|
+
#
|
84
|
+
# array = ['foo', 'bar']
|
85
|
+
#
|
86
|
+
# # No arguments
|
87
|
+
# array.map(:capitalize) => ['Foo', 'Bar']
|
88
|
+
#
|
89
|
+
# # With arguments
|
90
|
+
# array.map(:+, 'x') => ['foox', 'barx']
|
91
|
+
#
|
92
|
+
# # With arguments and a block
|
93
|
+
# array.map(:capitalize){ |e| e + 'x' } => ['Foox', 'Barx']
|
94
|
+
#--
|
95
|
+
# The Array class actually has its own implementation of the +map+ method,
|
96
|
+
# hence the duplication.
|
97
|
+
#
|
98
|
+
def map(method=nil, *args, &block)
|
99
|
+
if method
|
100
|
+
array = []
|
101
|
+
method = method.to_sym unless method.is_a?(Symbol)
|
102
|
+
|
103
|
+
each{ |obj|
|
104
|
+
temp = obj.send(method, *args)
|
105
|
+
if block
|
106
|
+
array << block.call(temp)
|
107
|
+
else
|
108
|
+
array << temp
|
109
|
+
end
|
110
|
+
}
|
111
|
+
array
|
112
|
+
else
|
113
|
+
old_map(&block)
|
114
|
+
end
|
115
|
+
end
|
116
|
+
|
117
|
+
# Same as Array#map, but modifies the receiver in place. Also note that
|
118
|
+
# a block is _not_ required. If no block is given, an array of values
|
119
|
+
# is returned instead
|
120
|
+
#
|
121
|
+
def map!(method=nil, *args, &block)
|
122
|
+
self.replace(map(method, *args, &block))
|
123
|
+
end
|
124
|
+
|
125
|
+
=begin
|
126
|
+
def select(method=nil, condition = nil, *args, &block)
|
127
|
+
array = [] unless block
|
128
|
+
if method
|
129
|
+
if block
|
130
|
+
warn 'block ignored when arguments provided'
|
131
|
+
end
|
132
|
+
|
133
|
+
if condition.nil?
|
134
|
+
raise 'condition must be provided if method is provided'
|
135
|
+
end
|
136
|
+
|
137
|
+
method = method.to_sym unless method.is_a?(Symbol)
|
138
|
+
|
139
|
+
each{ |obj|
|
140
|
+
if args.length > 0
|
141
|
+
if obj.send(method, condition, *args)
|
142
|
+
array << obj
|
143
|
+
end
|
144
|
+
else
|
145
|
+
if obj.send(method, condition)
|
146
|
+
array << obj
|
147
|
+
end
|
148
|
+
end
|
149
|
+
}
|
150
|
+
|
151
|
+
return array
|
152
|
+
else
|
153
|
+
old_select(&block)
|
154
|
+
end
|
155
|
+
end
|
156
|
+
=end
|
157
|
+
|
158
|
+
# Reset the aliases
|
159
|
+
alias collect map
|
160
|
+
alias collect! map!
|
161
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
# extracted from from http://blog.playlouder.com/2008/05/07/an-interesting-ruby-hash-semantics-gotcha/
|
2
|
+
|
3
|
+
if RUBY_VERSION < '1.9' # not sure if this is needed for 1.8.7 or not...
|
4
|
+
# see http://kpumuk.info/ruby-on-rails/memo-5-use-ary-uniq-method-carefully-in-ruby and test it :)
|
5
|
+
|
6
|
+
class Hash
|
7
|
+
def hash
|
8
|
+
inject(0) {|hash,pair| hash ^ pair.hash}
|
9
|
+
end
|
10
|
+
|
11
|
+
def eql?(other)
|
12
|
+
self == other
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
if defined? IRB
|
2
|
+
|
3
|
+
begin
|
4
|
+
require 'irb/completion'
|
5
|
# this one can fail if readline isn't installed
|
6
|
+
rescue Exception
|
7
|
+
end
|
8
|
+
begin
|
9
|
+
IRB.conf[:AUTO_INDENT] = true
|
10
|
+
IRB.conf[:PROMPT_MODE] = :SIMPLE
|
11
|
+
#require 'irb/ext/save-history' # this one might mess with peoples' local settings of it tho...
|
12
|
+
rescue Exception
|
13
|
+
# guess this was some *other* IRB module? defined elsewhere?
|
14
|
+
end
|
15
|
+
|
16
|
+
end
|
@@ -0,0 +1,91 @@
|
|
1
|
+
require 'require_all' # a necessary gem
|
2
|
+
|
3
|
+
Thread.abort_on_exception = true # typically you *want* to know when a thread dies unexpectedly.
|
4
|
+
|
5
|
+
require 'socket'
|
6
|
+
BasicSocket.do_not_reverse_lookup = true
|
7
|
+
|
8
|
+
# abstracted from require 'facets/file' ===>
|
9
|
+
class File
|
10
|
+
|
11
|
+
# Writes the given data to the given path and closes the file. This is
|
12
|
+
# done in binary mode, complementing <tt>IO.read</tt> in standard Ruby.
|
13
|
+
#
|
14
|
+
# Returns the number of bytes written.
|
15
|
+
#
|
16
|
+
# CREDIT: facets/Gavin Sinclair
|
17
|
+
|
18
|
+
def self.write(path, data)
|
19
|
+
File.open(path, "w") do |file|
|
20
|
+
return file.write(data)
|
21
|
+
end
|
22
|
+
end unless self.respond_to?(:write)
|
23
|
+
|
24
|
+
def self.binwrite(path, data)
|
25
|
+
File.open(path, "wb") do |file|
|
26
|
+
return file.write(data)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
end
|
31
|
+
|
32
|
+
# more helpers
|
33
|
+
class Object
|
34
|
+
|
35
|
+
# a helper for collection.include?
|
36
|
+
def in? collection
|
37
|
+
collection.include?(self)
|
38
|
+
end unless respond_to? :in
|
39
|
+
|
40
|
+
# ex: assert(some statement)
|
41
|
+
# or
|
42
|
+
# assert(some statement, "some helper string")
|
43
|
+
def assert(should_be_true, string = nil)
|
44
|
+
if(!should_be_true)
|
45
|
+
raise "assertion failed #{string}"
|
46
|
+
end
|
47
|
+
end unless respond_to? :assert
|
48
|
+
|
49
|
+
# helper to bring up a debugger
|
50
|
+
def _dbg
|
51
|
+
require 'rubygems'
|
52
|
+
require 'pp' # who would want debug without pp? not I
|
53
|
+
begin
|
54
|
+
require 'ruby-debug'
|
55
|
+
debugger
|
56
|
+
rescue LoadError => e
|
57
|
+
throw "unable to load ruby-debug gem for _dbg... #{e}"
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
# a method like puts but all on one line--very much like java's println
|
62
|
+
def sprint *args
|
63
|
+
print(*args)
|
64
|
+
puts
|
65
|
+
end
|
66
|
+
|
67
|
+
def alias_h hash
|
68
|
+
hash.each_pair {|new, old|
|
69
|
+
alias_method new, old
|
70
|
+
}
|
71
|
+
end
|
72
|
+
|
73
|
+
def singleton_class
|
74
|
+
class << self; self; end
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
# taken from http://oldrcrs.rubypal.com/rcr/show/309
|
79
|
+
|
80
|
+
module Kernel
|
81
|
+
BASE_DIR = Dir.getwd
|
82
|
+
def __DIR__
|
83
|
+
dir = (/^(.+)?:\d+/ =~ caller[0]) ? File.expand_path(File.dirname($1), BASE_DIR) : nil
|
84
|
+
dir += '/' if dir
|
85
|
+
dir
|
86
|
+
end unless defined?(__DIR__)
|
87
|
+
end
|
88
|
+
|
89
|
+
if RUBY_VERSION >= '1.9.2'
|
90
|
+
$: << '.' # for some reason loading files from the cwd was taken out. That is not sane.
|
91
|
+
end
|
data/sane.gemspec
ADDED
@@ -0,0 +1,62 @@
|
|
1
|
+
# Generated by jeweler
|
2
|
+
# DO NOT EDIT THIS FILE
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run `rake gemspec`
|
4
|
+
# -*- encoding: utf-8 -*-
|
5
|
+
|
6
|
+
Gem::Specification.new do |s|
|
7
|
+
s.name = %q{sane}
|
8
|
+
s.version = "0.8.0"
|
9
|
+
|
10
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
+
s.authors = ["Roger Pack"]
|
12
|
+
s.date = %q{2009-10-28}
|
13
|
+
s.description = %q{Helper methods for ruby to make it easier to work with out of the box--things that are missing from core but should be there}
|
14
|
+
s.email = ["rogerdpack@gmail.com"]
|
15
|
+
s.extra_rdoc_files = [
|
16
|
+
"ChangeLog",
|
17
|
+
"README"
|
18
|
+
]
|
19
|
+
s.files = [
|
20
|
+
"ChangeLog",
|
21
|
+
"README",
|
22
|
+
"Rakefile",
|
23
|
+
"VERSION",
|
24
|
+
"lib/_dbg.rb",
|
25
|
+
"lib/sane.rb",
|
26
|
+
"lib/sane_ruby/add_regexes.rb",
|
27
|
+
"lib/sane_ruby/bugs.rb",
|
28
|
+
"lib/sane_ruby/enumerable-extra.rb",
|
29
|
+
"lib/sane_ruby/enumerable_brackets.rb",
|
30
|
+
"lib/sane_ruby/hash_hashes.rb",
|
31
|
+
"lib/sane_ruby/hash_set_operators_bug_fix.rb",
|
32
|
+
"lib/sane_ruby/irb_startup_options.rb",
|
33
|
+
"lib/sane_ruby/sane_random.rb",
|
34
|
+
"sane.gemspec",
|
35
|
+
"spec/test_sane.spec",
|
36
|
+
"todo"
|
37
|
+
]
|
38
|
+
s.homepage = %q{http://github.com/rogerdpack/sane_ruby}
|
39
|
+
s.rdoc_options = ["--charset=UTF-8"]
|
40
|
+
s.require_paths = ["lib"]
|
41
|
+
s.rubygems_version = %q{1.3.5}
|
42
|
+
s.summary = %q{Helper methods for ruby to make it easier to work with out of the box--things that are missing from core but should be there}
|
43
|
+
|
44
|
+
if s.respond_to? :specification_version then
|
45
|
+
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
46
|
+
s.specification_version = 3
|
47
|
+
|
48
|
+
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
|
49
|
+
s.add_runtime_dependency(%q<require_all>, [">= 0"])
|
50
|
+
s.add_runtime_dependency(%q<backports>, [">= 0"])
|
51
|
+
s.add_runtime_dependency(%q<hash_set_operators>, [">= 0"])
|
52
|
+
else
|
53
|
+
s.add_dependency(%q<require_all>, [">= 0"])
|
54
|
+
s.add_dependency(%q<backports>, [">= 0"])
|
55
|
+
s.add_dependency(%q<hash_set_operators>, [">= 0"])
|
56
|
+
end
|
57
|
+
else
|
58
|
+
s.add_dependency(%q<require_all>, [">= 0"])
|
59
|
+
s.add_dependency(%q<backports>, [">= 0"])
|
60
|
+
s.add_dependency(%q<hash_set_operators>, [">= 0"])
|
61
|
+
end
|
62
|
+
end
|
data/spec/test_sane.spec
ADDED
@@ -0,0 +1,72 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../lib/sane'
|
2
|
+
require 'rubygems'
|
3
|
+
class TestSane; end
|
4
|
+
|
5
|
+
describe TestSane do
|
6
|
+
|
7
|
+
before do
|
8
|
+
#Object.send(:remove_const, 'Klass') rescue nil
|
9
|
+
end
|
10
|
+
|
11
|
+
it "should have working __DIR__" do
|
12
|
+
__DIR__.should_not == nil
|
13
|
+
end
|
14
|
+
|
15
|
+
it "should write to files" do
|
16
|
+
filename = __DIR__ + '/test'
|
17
|
+
File.write(filename, "abc\n")
|
18
|
+
assert(File.exist?(filename))
|
19
|
+
if RUBY_PLATFORM =~ /mswin|mingw/
|
20
|
+
assert(File.binread(filename) == "abc\r\n") # it should have written it out *not* in binary mode
|
21
|
+
end
|
22
|
+
File.delete filename
|
23
|
+
end
|
24
|
+
|
25
|
+
class A
|
26
|
+
def go; 3; end
|
27
|
+
alias_h :go2 => :go
|
28
|
+
end
|
29
|
+
|
30
|
+
it "should aliaz right" do
|
31
|
+
A.new.go2.should == 3
|
32
|
+
end
|
33
|
+
|
34
|
+
it "should have a singleton_class method" do
|
35
|
+
class A; end
|
36
|
+
A.singleton_class.module_eval { def go; end }
|
37
|
+
A.go
|
38
|
+
end
|
39
|
+
|
40
|
+
it "should have a binread method" do
|
41
|
+
File.open("bin_test", "wb") do |f|; f.write "a\r\n"; end
|
42
|
+
assert File.binread("bin_test") == "a\r\n"
|
43
|
+
end
|
44
|
+
|
45
|
+
it "should have a binwrite method" do
|
46
|
+
File.binwrite 'bin_test', "a\r\n"
|
47
|
+
assert File.binread("bin_test") == "a\r\n"
|
48
|
+
end
|
49
|
+
|
50
|
+
it "should hash hashes right" do
|
51
|
+
a = {}
|
52
|
+
|
53
|
+
a[{:a => 3, :b => 4}] = 3
|
54
|
+
assert a[{:b => 4, :a => 3}] == 3
|
55
|
+
assert a[{:b => 3, :a => 4}] == nil
|
56
|
+
a = {:a => 3}
|
57
|
+
a - {:a => 4}
|
58
|
+
assert a.length == 1
|
59
|
+
|
60
|
+
end
|
61
|
+
|
62
|
+
it "should allow regexes to be added" do
|
63
|
+
/a/ + /b/
|
64
|
+
end
|
65
|
+
|
66
|
+
it "should allow for brackets on enumerators" do
|
67
|
+
require 'backports' # ugh
|
68
|
+
assert "ab\r\nc".lines[0] == "ab\r\n"
|
69
|
+
end
|
70
|
+
|
71
|
+
|
72
|
+
end
|
metadata
ADDED
@@ -0,0 +1,102 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: sane
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.8.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Roger Pack
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2009-10-28 00:00:00 -06:00
|
13
|
+
default_executable:
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: require_all
|
17
|
+
type: :runtime
|
18
|
+
version_requirement:
|
19
|
+
version_requirements: !ruby/object:Gem::Requirement
|
20
|
+
requirements:
|
21
|
+
- - ">="
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: "0"
|
24
|
+
version:
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: backports
|
27
|
+
type: :runtime
|
28
|
+
version_requirement:
|
29
|
+
version_requirements: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: "0"
|
34
|
+
version:
|
35
|
+
- !ruby/object:Gem::Dependency
|
36
|
+
name: hash_set_operators
|
37
|
+
type: :runtime
|
38
|
+
version_requirement:
|
39
|
+
version_requirements: !ruby/object:Gem::Requirement
|
40
|
+
requirements:
|
41
|
+
- - ">="
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: "0"
|
44
|
+
version:
|
45
|
+
description: Helper methods for ruby to make it easier to work with out of the box--things that are missing from core but should be there
|
46
|
+
email:
|
47
|
+
- rogerdpack@gmail.com
|
48
|
+
executables: []
|
49
|
+
|
50
|
+
extensions: []
|
51
|
+
|
52
|
+
extra_rdoc_files:
|
53
|
+
- ChangeLog
|
54
|
+
- README
|
55
|
+
files:
|
56
|
+
- ChangeLog
|
57
|
+
- README
|
58
|
+
- Rakefile
|
59
|
+
- VERSION
|
60
|
+
- lib/_dbg.rb
|
61
|
+
- lib/sane.rb
|
62
|
+
- lib/sane_ruby/add_regexes.rb
|
63
|
+
- lib/sane_ruby/bugs.rb
|
64
|
+
- lib/sane_ruby/enumerable-extra.rb
|
65
|
+
- lib/sane_ruby/enumerable_brackets.rb
|
66
|
+
- lib/sane_ruby/hash_hashes.rb
|
67
|
+
- lib/sane_ruby/hash_set_operators_bug_fix.rb
|
68
|
+
- lib/sane_ruby/irb_startup_options.rb
|
69
|
+
- lib/sane_ruby/sane_random.rb
|
70
|
+
- sane.gemspec
|
71
|
+
- spec/test_sane.spec
|
72
|
+
- todo
|
73
|
+
has_rdoc: true
|
74
|
+
homepage: http://github.com/rogerdpack/sane_ruby
|
75
|
+
licenses: []
|
76
|
+
|
77
|
+
post_install_message:
|
78
|
+
rdoc_options:
|
79
|
+
- --charset=UTF-8
|
80
|
+
require_paths:
|
81
|
+
- lib
|
82
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
83
|
+
requirements:
|
84
|
+
- - ">="
|
85
|
+
- !ruby/object:Gem::Version
|
86
|
+
version: "0"
|
87
|
+
version:
|
88
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
89
|
+
requirements:
|
90
|
+
- - ">="
|
91
|
+
- !ruby/object:Gem::Version
|
92
|
+
version: "0"
|
93
|
+
version:
|
94
|
+
requirements: []
|
95
|
+
|
96
|
+
rubyforge_project:
|
97
|
+
rubygems_version: 1.3.5
|
98
|
+
signing_key:
|
99
|
+
specification_version: 3
|
100
|
+
summary: Helper methods for ruby to make it easier to work with out of the box--things that are missing from core but should be there
|
101
|
+
test_files: []
|
102
|
+
|