utilise 0.4.0.pre.27 → 0.4.0.pre.29

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- ZGM5MTE4M2VhMWJiY2FlMTkyZjE2YjA3MDcwOGM0YjM3MTQ3ZTYyNQ==
4
+ MTdlZWEzMGYyZmJmMDU0M2I1YzZiOGY2M2Q2MWUyNjEzOTZjYTBkYg==
5
5
  data.tar.gz: !binary |-
6
- ZWIxZjZjNDUzYWU4YmQwMzQzYjU4NzhiZWY5OGE5ZmMwZDhhMmE4NA==
6
+ ZWZhZTkzMThkNzZlMzIxMTFkYzcyNzM2YmUwNzMyOTY1NGY2YWU3MQ==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- MzVjZjgyNzk0MWU3YTgzNzdlNWI0ZjczNjI1ZTExODExYWY1ODAyNjJlNTNm
10
- ZTU2YzM4NGFmMzExODJlMmU2Yzg3MzVlMzRkZGI1MDQzYjgxMTkxYTMxZmJj
11
- ZjdhY2YyOGM5YzRlM2MyNDJlYTIxZDQ3MjI0NzdhOTgyMmUyZDk=
9
+ NjNjMmRhZWZlY2I2NmVlNjQ4ZmQzYmEzY2MyNzVhNWJmM2VjNGZkZGNkZDlm
10
+ ZGEzOTVlYmQ3NDY3YjNjMDEyNTM4ZjYyZjdhYTAzZDliMDEzNDQxODUwMzNk
11
+ YzAzZWU5ZmZkZTg3NzQwMzdjMzQ0NTkyNWY5ZTYwNWIyZDAwMWU=
12
12
  data.tar.gz: !binary |-
13
- N2U4NTRmMjdlZDFlNzM5YzJlNDQ2ODFiZTVlYjc5YjllNDlkMjllM2RkZTBm
14
- NTRiMTFkMzQ5NTM0YWY3Y2Y1ZjdlODhhNDFlM2U5MThjYzczYWNjYmNjN2Q5
15
- MTNjMThkZjkxNDI5YWI3NWY2NGUxMGFjMzJmOTZjZTE0MmYzZWY=
13
+ YTEzNzM1NjY1NGI4NjYzODUxYjI0Y2QxZTFhYmE4NDRjNWFlNzJkZGMwYTlm
14
+ NTE4ZTMyMWQzNzMxZmVjOTY2N2VjMGFiZGQyZWNmYjcyMWE5MzU2YTZjODE5
15
+ Y2I1NWYzNWExOGNiODIwZGFlZTQ1ZjM4ZjNjMmM1NDQwMWQ5N2Y=
data/README.md CHANGED
@@ -67,15 +67,15 @@ Time.unique
67
67
  ```
68
68
 
69
69
  ```ruby
70
- true.is_bool?
70
+ true.bool?
71
71
  => true
72
72
 
73
- false.is_bool?
73
+ false.bool?
74
74
  => true
75
75
 
76
- 1.is_bool?
76
+ 1.bool?
77
77
  => false
78
78
 
79
- "true".is_bool?
79
+ "true".bool?
80
80
  => false
81
- ```
81
+ ```
@@ -1,12 +1,12 @@
1
1
  module Utilise
2
2
  module Augment
3
+ # Extends classes that could be treated as a boolean
3
4
  module Bool
4
-
5
5
  # Returns bool based on object passed
6
6
  #
7
7
  # @param object [Object] the object
8
8
  # @return [Object] returns object boolean
9
- def to_bool object = self
9
+ def to_bool(object = self)
10
10
  case object
11
11
  when String, Fixnum, Symbol
12
12
  bool_it object
@@ -21,10 +21,10 @@ module Utilise
21
21
  # value to a boolean if it matches rules
22
22
  #
23
23
  # @param hash [Hash] the hash
24
- def bool_hash hash
25
- hash.each do |k,v|
26
- val = to_bool(hash[k])
27
- hash[k] = val unless val.nil?
24
+ def bool_hash(hash)
25
+ hash.each do |key, val|
26
+ val = to_bool(val)
27
+ hash[key] = val unless val.nil?
28
28
  end
29
29
  end
30
30
 
@@ -32,10 +32,10 @@ module Utilise
32
32
  # element to a boolean if it matches rules
33
33
  #
34
34
  # @param array [Array] the array
35
- def bool_array array
36
- array.each_index do |i|
37
- val = to_bool(array[i])
38
- array[i] = val unless val.nil?
35
+ def bool_array(array)
36
+ array.each_index do |index|
37
+ val = to_bool(array[index])
38
+ array[index] = val unless val.nil?
39
39
  end
40
40
  end
41
41
 
@@ -43,7 +43,7 @@ module Utilise
43
43
  #
44
44
  # @param array [Array] the array
45
45
  # @returns [Boolean] true/false returned
46
- def bool_it object
46
+ def bool_it(object)
47
47
  case object.to_s
48
48
  when /^true$/i, /^yes$/i, /^t$/i, /^1$/i
49
49
  true
@@ -1,9 +1,13 @@
1
1
  module Utilise
2
2
  module Augment
3
+ # Extends classes that could be queried as a boolean
3
4
  module Matchers
4
- def is_bool?
5
+ def bool?
5
6
  self.is_a?(TrueClass) || self.is_a?(FalseClass)
6
7
  end
8
+
9
+ # NOTE: This keeps backwards compatability
10
+ alias_method :is_bool?, :bool?
7
11
  end
8
12
  end
9
13
  end
@@ -1,8 +1,9 @@
1
1
  module Utilise
2
2
  module Augment
3
+ # Extends time class to return a unique idetifier
3
4
  module Time
4
5
  def unique
5
- self.now.strftime("%s%3N")[-8..-1]
6
+ now.strftime('%s%3N')[-8..-1]
6
7
  end
7
8
  end
8
9
  end
@@ -2,30 +2,37 @@ require 'utilise/augment/bool.rb'
2
2
  require 'utilise/augment/matchers.rb'
3
3
  require 'utilise/augment/time.rb'
4
4
 
5
+ # Extend existing ruby class String
5
6
  class String
6
7
  include Utilise::Augment::Bool
7
8
  end
8
9
 
10
+ # Extend existing ruby class Fixnum
9
11
  class Fixnum
10
12
  include Utilise::Augment::Bool
11
13
  end
12
14
 
15
+ # Extend existing ruby class Symbol
13
16
  class Symbol
14
17
  include Utilise::Augment::Bool
15
18
  end
16
19
 
20
+ # Extend existing ruby class Object
17
21
  class Object
18
22
  include Utilise::Augment::Matchers
19
23
  end
20
24
 
25
+ # Extend existing ruby class Time
21
26
  class Time
22
27
  extend Utilise::Augment::Time
23
28
  end
24
29
 
30
+ # Extend existing ruby class Hash
25
31
  class Hash
26
32
  include Utilise::Augment::Bool
27
33
  end
28
34
 
35
+ # Extend existing ruby class Array
29
36
  class Array
30
37
  include Utilise::Augment::Bool
31
38
  end
@@ -1,4 +1,5 @@
1
+ # Utilise
1
2
  module Utilise
2
- VERSION = "0.4.0".freeze
3
- DATE = "2014-07-04".freeze
3
+ VERSION = '0.4.0'.freeze
4
+ DATE = '2014-07-04'.freeze
4
5
  end
@@ -1,27 +1,27 @@
1
1
  require 'helper'
2
2
 
3
3
  describe TrueClass do
4
- describe "#is_bool?" do
4
+ describe "#bool?" do
5
5
  it "returns true when matching" do
6
- expect(true.is_bool?).to be true
6
+ expect(true.bool?).to be true
7
7
  end
8
8
  end
9
9
  end
10
10
 
11
11
  describe FalseClass do
12
- describe "#is_bool?" do
12
+ describe "#bool?" do
13
13
  it "returns true when matching" do
14
- expect(false.is_bool?).to be true
14
+ expect(false.bool?).to be true
15
15
  end
16
16
  end
17
17
  end
18
18
 
19
19
  describe Object do
20
- describe "#is_bool?" do
20
+ describe "#bool?" do
21
21
  it "returns false when not matching" do
22
- expect("true".is_bool?).to be false
23
- expect(0.is_bool?).to be false
24
- expect(:false.is_bool?).to be false
22
+ expect("true".bool?).to be false
23
+ expect(0.bool?).to be false
24
+ expect(:false.bool?).to be false
25
25
  end
26
26
  end
27
- end
27
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: utilise
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0.pre.27
4
+ version: 0.4.0.pre.29
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ben Slaughter
@@ -56,16 +56,16 @@ dependencies:
56
56
  name: rspec
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - ~>
59
+ - - ! '>='
60
60
  - !ruby/object:Gem::Version
61
- version: 2.13.0
61
+ version: '0'
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - ~>
66
+ - - ! '>='
67
67
  - !ruby/object:Gem::Version
68
- version: 2.13.0
68
+ version: '0'
69
69
  description: ! 'Extends a few ruby classes with helpful tools, currently: X.to_bool'
70
70
  email: b.p.slaughter@gmail.com
71
71
  executables: []
@@ -113,11 +113,11 @@ signing_key:
113
113
  specification_version: 4
114
114
  summary: Utilises a few extra tools
115
115
  test_files:
116
- - spec/augment/object_spec.rb
117
116
  - spec/augment/string_spec.rb
118
- - spec/augment/symbol_spec.rb
119
117
  - spec/augment/time_spec.rb
120
- - spec/augment/hash_spec.rb
118
+ - spec/augment/symbol_spec.rb
121
119
  - spec/augment/array_spec.rb
120
+ - spec/augment/hash_spec.rb
122
121
  - spec/augment/fixnum_spec.rb
122
+ - spec/augment/object_spec.rb
123
123
  - spec/helper.rb