naught_check 0.2.0 → 0.3.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.
@@ -4,6 +4,10 @@
4
4
 
5
5
  Got tired of string.empty? checks in a project blowing up on nil strings.
6
6
 
7
+ On a Rails project where numeric fields are declared NOT NULL, you can use ActiveSupport's .blank? and Numeric's .zero? instead.
8
+
9
+ But .zero? isn't nil-safe, so if you have possibly-nil numerics you would have to require 'andand' and remember to do number.andand.zero? for every zero-check. Or reopen Numeric.zero? in the project and add the nil-check. Or use something like this.
10
+
7
11
  == Usage:
8
12
 
9
13
  require 'naught_check'
@@ -17,6 +21,8 @@ Got tired of string.empty? checks in a project blowing up on nil strings.
17
21
  0.naught? => true
18
22
  0.00.naught? => true
19
23
 
24
+ .aught? does the reverse, so you don't need the double-negative of !value.naught? (value-not-naught sounds silly)
25
+
20
26
  == Compared to ActiveSupport .blank?
21
27
 
22
28
  In a Rails project, ActiveSupport .blank? would do almost the same thing,
data/Rakefile CHANGED
@@ -6,7 +6,7 @@ begin
6
6
  Jeweler::Tasks.new do |gem|
7
7
  gem.name = "naught_check"
8
8
  gem.summary = %Q{Adds .naught? method: tests if value is nil, .blank?, .zero?}
9
- gem.description = %Q{Usage: require 'naught_check'; include Naught}
9
+ gem.description = %Q{.naught? like ActiveSupport .blank? and nil-safe Numeric .zero?}
10
10
  gem.email = "sean@seanmiller.ca"
11
11
  gem.homepage = "http://github.com/smiller/naught_check"
12
12
  gem.authors = ["Sean Miller"]
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.2.0
1
+ 0.3.0
@@ -32,9 +32,7 @@ module Naught
32
32
  # aliases .naught?
33
33
  def nowt?; naught?; end
34
34
 
35
- # aliases .naught?
36
- def vacant?; naught?; end
37
-
35
+
38
36
  # inverts naught?
39
37
  def aught?; !naught?; end
40
38
 
@@ -7,7 +7,6 @@ class TestNaughtCheck < Test::Unit::TestCase
7
7
  assert_equal true, nil.naught?
8
8
  assert_equal true, nil.nought?
9
9
  assert_equal true, nil.nowt?
10
- assert_equal true, nil.vacant?
11
10
  assert_equal false, nil.aught?
12
11
  assert_equal false, nil.ought?
13
12
  assert_equal false, nil.owt?
@@ -20,7 +19,6 @@ class TestNaughtCheck < Test::Unit::TestCase
20
19
  assert_equal true, "".naught?
21
20
  assert_equal true, "".nought?
22
21
  assert_equal true, "".nowt?
23
- assert_equal true, "".vacant?
24
22
  assert_equal false, "".aught?
25
23
  assert_equal false, "".ought?
26
24
  assert_equal false, "".owt?
@@ -30,7 +28,6 @@ class TestNaughtCheck < Test::Unit::TestCase
30
28
  assert_equal true, " ".naught?
31
29
  assert_equal true, " ".nought?
32
30
  assert_equal true, " ".nowt?
33
- assert_equal true, " ".vacant?
34
31
  assert_equal false, " ".aught?
35
32
  assert_equal false, " ".ought?
36
33
  assert_equal false, " ".owt?
@@ -40,7 +37,6 @@ class TestNaughtCheck < Test::Unit::TestCase
40
37
  assert_equal false, "gilgamesh".naught?
41
38
  assert_equal false, "gilgamesh".nought?
42
39
  assert_equal false, "gilgamesh".nowt?
43
- assert_equal false, "gilgamesh".vacant?
44
40
  assert_equal true, "gilgamesh".aught?
45
41
  assert_equal true, "gilgamesh".ought?
46
42
  assert_equal true, "gilgamesh".owt?
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: naught_check
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sean Miller
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2010-02-06 00:00:00 -05:00
12
+ date: 2010-02-09 00:00:00 -05:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -22,7 +22,7 @@ dependencies:
22
22
  - !ruby/object:Gem::Version
23
23
  version: "0"
24
24
  version:
25
- description: "Usage: require 'naught_check'; include Naught"
25
+ description: .naught? like ActiveSupport .blank? and nil-safe Numeric .zero?
26
26
  email: sean@seanmiller.ca
27
27
  executables: []
28
28