epitools 0.1.10 → 0.1.11
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/epitools.gemspec +8 -8
- data/lib/epitools/basetypes.rb +17 -5
- data/spec/basetypes_spec.rb +9 -0
- metadata +8 -8
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.11
|
data/epitools.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{epitools}
|
8
|
-
s.version = "0.1.
|
8
|
+
s.version = "0.1.11"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["epitron"]
|
12
|
-
s.date = %q{2010-09-
|
12
|
+
s.date = %q{2010-09-25}
|
13
13
|
s.description = %q{Miscellaneous utility libraries to make my life easier.}
|
14
14
|
s.email = %q{chris@ill-logic.com}
|
15
15
|
s.extra_rdoc_files = [
|
@@ -54,14 +54,14 @@ Gem::Specification.new do |s|
|
|
54
54
|
s.rubygems_version = %q{1.3.7}
|
55
55
|
s.summary = %q{NOT UTILS... METILS!}
|
56
56
|
s.test_files = [
|
57
|
-
"spec/
|
58
|
-
"spec/
|
57
|
+
"spec/rash_spec.rb",
|
58
|
+
"spec/ratio_spec.rb",
|
59
59
|
"spec/metaclass_spec.rb",
|
60
|
+
"spec/basetypes_spec.rb",
|
61
|
+
"spec/lcs_spec.rb",
|
62
|
+
"spec/zopen_spec.rb",
|
60
63
|
"spec/permutations_spec.rb",
|
61
|
-
"spec/
|
62
|
-
"spec/ratio_spec.rb",
|
63
|
-
"spec/spec_helper.rb",
|
64
|
-
"spec/zopen_spec.rb"
|
64
|
+
"spec/spec_helper.rb"
|
65
65
|
]
|
66
66
|
|
67
67
|
if s.respond_to? :specification_version then
|
data/lib/epitools/basetypes.rb
CHANGED
@@ -1,7 +1,15 @@
|
|
1
1
|
require 'pp'
|
2
2
|
|
3
3
|
# Alias "Enumerable::Enumerator" to "Enum"
|
4
|
-
|
4
|
+
unless defined? Enum
|
5
|
+
if defined? Enumerable::Enumerator
|
6
|
+
Enum = Enumerable::Enumerator
|
7
|
+
elsif defined? Enumerator
|
8
|
+
Enum = Enumerator
|
9
|
+
else
|
10
|
+
$stderr.puts "WARNING: Couldn't find the Enumerator class. Enum will not be available."
|
11
|
+
end
|
12
|
+
end
|
5
13
|
|
6
14
|
class Object
|
7
15
|
# Default "integer?" behaviour.
|
@@ -165,7 +173,8 @@ module Enumerable
|
|
165
173
|
#
|
166
174
|
# Split the array into chunks, with the boundaries being after the element to split on.
|
167
175
|
#
|
168
|
-
#
|
176
|
+
# Example:
|
177
|
+
# [1,2,3,4].split_after{|e| e == 3 } #=> [ [1,2,3], [4] ]
|
169
178
|
#
|
170
179
|
def split_after(matcher=nil, options={}, &block)
|
171
180
|
options[:after] ||= true
|
@@ -176,7 +185,8 @@ module Enumerable
|
|
176
185
|
#
|
177
186
|
# Split the array into chunks. The boundaries will lie before the element to split on.
|
178
187
|
#
|
179
|
-
#
|
188
|
+
# Example:
|
189
|
+
# [1,2,3,4].split_before{|e| e == 3 } #=> [ [1,2], [3,4] ]
|
180
190
|
#
|
181
191
|
def split_before(matcher=nil, options={}, &block)
|
182
192
|
options[:include_boundary] ||= true
|
@@ -203,7 +213,8 @@ module Enumerable
|
|
203
213
|
# The same as "map", except that if an element is an Array or Enumerable, map is called
|
204
214
|
# recursively on that element.
|
205
215
|
#
|
206
|
-
#
|
216
|
+
# Example:
|
217
|
+
# [ [1,2], [3,4] ].map_recursively{|e| e ** 2 } #=> [ [1,4], [9,16] ]
|
207
218
|
#
|
208
219
|
def recursive_map(*args, &block)
|
209
220
|
map(*args) do |e|
|
@@ -481,8 +492,9 @@ end
|
|
481
492
|
class Object
|
482
493
|
|
483
494
|
#
|
484
|
-
# Negates a boolean, chained-method style
|
495
|
+
# Negates a boolean, chained-method style.
|
485
496
|
#
|
497
|
+
# Example:
|
486
498
|
# >> 10.even?
|
487
499
|
# => true
|
488
500
|
# >> 10.not.even?
|
data/spec/basetypes_spec.rb
CHANGED
@@ -2,6 +2,15 @@ require 'epitools/basetypes'
|
|
2
2
|
|
3
3
|
|
4
4
|
describe Object do
|
5
|
+
|
6
|
+
it "has Enum" do
|
7
|
+
defined?(Enum).should_not == nil
|
8
|
+
end
|
9
|
+
|
10
|
+
it "enums" do
|
11
|
+
generator = enum { |y| y.yield 1 }
|
12
|
+
generator.next.should == 1
|
13
|
+
end
|
5
14
|
|
6
15
|
it "in?" do
|
7
16
|
5.in?([1,2,3,4,5,6]).should == true
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: epitools
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 13
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 1
|
9
|
-
-
|
10
|
-
version: 0.1.
|
9
|
+
- 11
|
10
|
+
version: 0.1.11
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- epitron
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2010-09-
|
18
|
+
date: 2010-09-25 00:00:00 -04:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
@@ -109,11 +109,11 @@ signing_key:
|
|
109
109
|
specification_version: 3
|
110
110
|
summary: NOT UTILS... METILS!
|
111
111
|
test_files:
|
112
|
+
- spec/rash_spec.rb
|
113
|
+
- spec/ratio_spec.rb
|
114
|
+
- spec/metaclass_spec.rb
|
112
115
|
- spec/basetypes_spec.rb
|
113
116
|
- spec/lcs_spec.rb
|
114
|
-
- spec/
|
117
|
+
- spec/zopen_spec.rb
|
115
118
|
- spec/permutations_spec.rb
|
116
|
-
- spec/rash_spec.rb
|
117
|
-
- spec/ratio_spec.rb
|
118
119
|
- spec/spec_helper.rb
|
119
|
-
- spec/zopen_spec.rb
|