epitools 0.4.17 → 0.4.18

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.4.17
1
+ 0.4.18
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{epitools}
8
- s.version = "0.4.17"
8
+ s.version = "0.4.18"
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{2011-03-15}
12
+ s.date = %q{2011-03-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 = [
@@ -16,8 +16,23 @@ unless defined? Enum
16
16
  end
17
17
 
18
18
  class Object
19
+ #
19
20
  # Default "integer?" behaviour.
21
+ #
20
22
  def integer?; false; end
23
+
24
+ #
25
+ # `truthy?` means `not blank?`
26
+ #
27
+ def truthy?; not blank?; end
28
+ end
29
+
30
+ class TrueClass
31
+ def truthy?; true; end
32
+ end
33
+
34
+ class FalseClass
35
+ def truthy?; false; end
21
36
  end
22
37
 
23
38
  class Numeric
@@ -42,6 +57,13 @@ class NilClass
42
57
  def blank?; true; end
43
58
  end
44
59
 
60
+ class Symbol
61
+ #
62
+ # Symbols are never blank.
63
+ #
64
+ def blank?; false; end
65
+ end
66
+
45
67
  class String
46
68
 
47
69
  #
@@ -105,6 +127,9 @@ class Integer
105
127
  #
106
128
  def blank?; self == 0; end
107
129
 
130
+ #
131
+ # Convert the number into a hexadecimal string representation.
132
+ #
108
133
  def to_hex
109
134
  "%0.2x" % self
110
135
  end
@@ -152,11 +177,6 @@ end
152
177
 
153
178
  class Array
154
179
 
155
- #
156
- # 'true' if the Array is empty
157
- #
158
- def blank?; not self.any?; end
159
-
160
180
  #
161
181
  # flatten.compact.uniq
162
182
  #
@@ -210,9 +230,9 @@ module Enumerable
210
230
  # 'true' if the Enumerable has no elements
211
231
  #
212
232
  def blank?
213
- not self.any?
233
+ not any?
214
234
  end
215
-
235
+
216
236
  #
217
237
  # Split this enumerable into an array of pieces given some
218
238
  # boundary condition.
@@ -481,9 +501,9 @@ class Hash
481
501
  # 'true' if the Hash has no entries
482
502
  #
483
503
  def blank?
484
- not self.any?
504
+ not any?
485
505
  end
486
-
506
+
487
507
  #
488
508
  # Runs "remove_blank_values" on self.
489
509
  #
@@ -635,7 +655,6 @@ class NotWrapper < BlankSlate # :nodoc:
635
655
  end
636
656
  end
637
657
 
638
-
639
658
  class Object
640
659
 
641
660
  #
@@ -246,3 +246,27 @@ describe BlankSlate do
246
246
 
247
247
  end
248
248
 
249
+
250
+ describe "truthiness" do
251
+
252
+ it "is truthy!" do
253
+ {
254
+
255
+ # truthy things
256
+ true => [
257
+ "asdf", 1, 1.7, :blah, true, [1,2,3], Enumerator.new([1,2,3], :each),
258
+ 1938389127239847129803741980237498012374,
259
+ ],
260
+
261
+ # untruthy things
262
+ false => [
263
+ "", " ", 0, 0.0, false, nil, [], Enumerator.new([], :each),
264
+ ]
265
+
266
+ }.each do |truthiness, objs|
267
+ objs.each { |obj| obj.truthy?.should == truthiness }
268
+ end
269
+
270
+ end
271
+
272
+ end
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: epitools
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.4.17
5
+ version: 0.4.18
6
6
  platform: ruby
7
7
  authors:
8
8
  - epitron
@@ -10,7 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2011-03-15 00:00:00 -04:00
13
+ date: 2011-03-25 00:00:00 -04:00
14
14
  default_executable:
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency