truthiness 0.0.1 → 0.1.1

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.
@@ -0,0 +1 @@
1
+ *.gem
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- truthiness (0.0.1)
4
+ truthiness (0.1.1)
5
5
 
6
6
  GEM
7
7
  remote: http://rubygems.org/
@@ -1,13 +1,20 @@
1
1
  module Truthiness
2
2
 
3
3
  def truthy?
4
- !!self
4
+ self.to_s.match(/true|yes|1/i) != nil
5
5
  end
6
6
 
7
7
  def not_truthy?
8
- !self
8
+ !truthy?
9
+ end
10
+
11
+ def falsey?
12
+ self.to_s.match(/false|no|0/i) != nil
13
+ end
14
+
15
+ def not_falsey?
16
+ !falsey?
9
17
  end
10
- alias_method :falsey?, :not_truthy?
11
18
 
12
19
  def true?
13
20
  self == true
@@ -1,3 +1,3 @@
1
1
  module Truthiness
2
- VERSION = "0.0.1"
2
+ VERSION = "0.1.1"
3
3
  end
@@ -9,9 +9,27 @@ class TruthinessTest < Test::Unit::TestCase
9
9
  subject { Object.new }
10
10
 
11
11
  should "respond to truthy methods" do
12
- [:truthy?, :not_truthy?, :falsey?,
13
- :true?, :not_true?, :false?, :not_false?].each do |m|
14
- assert subject.respond_to?(m)
12
+ %w[truthy? not_truthy? falsey? not_falsey?
13
+ true? not_true? false? not_false?].each do |m|
14
+ assert subject.respond_to?(m), "Not responding to ##{m}"
15
+ end
16
+ end
17
+
18
+ context "#truthy?" do
19
+ should "be true for string and integer representations of truth" do
20
+ assert "true".truthy?
21
+ assert "yes".truthy?
22
+ assert 1.truthy?
23
+ assert true.truthy?
24
+ end
25
+ end
26
+
27
+ context "#falsey?" do
28
+ should "be false for string and integer representations of false" do
29
+ assert "false".falsey?
30
+ assert "no".falsey?
31
+ assert 0.falsey?
32
+ assert false.falsey?
15
33
  end
16
34
  end
17
35
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: truthiness
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.1.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-03-18 00:00:00.000000000Z
12
+ date: 2012-04-30 00:00:00.000000000Z
13
13
  dependencies: []
14
14
  description: ! "Evaluate the truthiness of an object without getting out\n the
15
15
  logical expressions"
@@ -19,6 +19,7 @@ executables: []
19
19
  extensions: []
20
20
  extra_rdoc_files: []
21
21
  files:
22
+ - .gitignore
22
23
  - Gemfile
23
24
  - Gemfile.lock
24
25
  - README
@@ -39,12 +40,18 @@ required_ruby_version: !ruby/object:Gem::Requirement
39
40
  - - ! '>='
40
41
  - !ruby/object:Gem::Version
41
42
  version: '0'
43
+ segments:
44
+ - 0
45
+ hash: 4512647541418362539
42
46
  required_rubygems_version: !ruby/object:Gem::Requirement
43
47
  none: false
44
48
  requirements:
45
49
  - - ! '>='
46
50
  - !ruby/object:Gem::Version
47
51
  version: '0'
52
+ segments:
53
+ - 0
54
+ hash: 4512647541418362539
48
55
  requirements: []
49
56
  rubyforge_project: truthiness
50
57
  rubygems_version: 1.8.10