finishing_moves 0.17 → 0.18
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +4 -1
- data/lib/finishing_moves/hash.rb +12 -0
- data/lib/finishing_moves/object.rb +10 -0
- data/lib/finishing_moves/version.rb +1 -1
- data/spec/object_spec.rb +23 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ea386064f3ddd76587cfc19a0f3fa451bc5df6fe
|
4
|
+
data.tar.gz: 68de87aee88555b846024b4edcbad5a6872c3f64
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2577531144756e18069014d715f319e3512e028840ae6a255de0bd0c51816c6714613cfaba67379c08316b36ec3d96266d8625473d2c2b6ebc7ecacbb3ae1ebb
|
7
|
+
data.tar.gz: be79b56034b36aadb87fd36f1a35156134be6aef557d35a14c4d9f6f499d4fe4e9ba68977fe584754797bb73dff61b36bf3f4372d5bd033a576e2d42c9f4e13f
|
data/README.md
CHANGED
@@ -19,7 +19,7 @@ Command line
|
|
19
19
|
gem install 'finishing_moves'
|
20
20
|
```
|
21
21
|
|
22
|
-
##
|
22
|
+
## Documentation
|
23
23
|
|
24
24
|
**Not sure if this gem is for you?** Check out the methods marked with a :boom: first.
|
25
25
|
|
@@ -44,11 +44,14 @@ gem install 'finishing_moves'
|
|
44
44
|
- [`Object#true?`](https://github.com/forgecrafted/finishing_moves/wiki/Object#objecttruefalsebool)
|
45
45
|
- [`Object#false?`](https://github.com/forgecrafted/finishing_moves/wiki/Object#objecttruefalsebool)
|
46
46
|
- [`Object#bool?`](https://github.com/forgecrafted/finishing_moves/wiki/Object#objecttruefalsebool)
|
47
|
+
- [`Object#true_?`](https://github.com/forgecrafted/finishing_moves/wiki/Object#objecttrue_-objectfalse_)
|
48
|
+
- [`Object#false_?`](https://github.com/forgecrafted/finishing_moves/wiki/Object#objecttrue_-objectfalse_)
|
47
49
|
- [`String#dedupe`](https://github.com/forgecrafted/finishing_moves/wiki/String#stringdedupe)
|
48
50
|
- [`String#keyify`](https://github.com/forgecrafted/finishing_moves/wiki/String#stringkeyify)
|
49
51
|
- [`String#slugify`](https://github.com/forgecrafted/finishing_moves/wiki/String#stringslugify)
|
50
52
|
- [`String#match?`](https://github.com/forgecrafted/finishing_moves/wiki/String#stringmatch)
|
51
53
|
- [`String#nl2br`](https://github.com/forgecrafted/finishing_moves/wiki/String#stringnl2br)
|
54
|
+
- [`String#newline_to`](https://github.com/forgecrafted/finishing_moves/wiki/String#stringnewline_to)
|
52
55
|
- [`String#numeric?`](https://github.com/forgecrafted/finishing_moves/wiki/String#stringnumeric) :boom:
|
53
56
|
- [`String#remove_whitespace`](https://github.com/forgecrafted/finishing_moves/wiki/String#stringremove_whitespace)
|
54
57
|
- [`String#replace_whitespace`](https://github.com/forgecrafted/finishing_moves/wiki/String#stringreplace_whitespace)
|
data/lib/finishing_moves/hash.rb
CHANGED
@@ -24,4 +24,16 @@ class Hash
|
|
24
24
|
return self
|
25
25
|
end
|
26
26
|
|
27
|
+
# auto-nesting hashes
|
28
|
+
# https://dzone.com/articles/create-nested-hashes-ruby
|
29
|
+
# Goal:
|
30
|
+
# a = {}
|
31
|
+
# a[2][1] = 2
|
32
|
+
# a[2][2][3] = 4
|
33
|
+
# a[3][1][1][1] = 1
|
34
|
+
def Hash.new_nested_hash
|
35
|
+
Hash.new{ |h,k| h[k] = Hash.new(&h.default_proc) }
|
36
|
+
end
|
37
|
+
|
38
|
+
|
27
39
|
end
|
@@ -45,6 +45,16 @@ class Object
|
|
45
45
|
return false
|
46
46
|
end
|
47
47
|
|
48
|
+
def false_?
|
49
|
+
raise "value is not a boolean class (#{self.class.name})" if !bool?
|
50
|
+
false?
|
51
|
+
end
|
52
|
+
|
53
|
+
def true_?
|
54
|
+
raise "value is not a boolean class (#{self.class.name})" if !bool?
|
55
|
+
true?
|
56
|
+
end
|
57
|
+
|
48
58
|
def is_one_of?( *klasses )
|
49
59
|
klasses.each do |klass|
|
50
60
|
return true if is_a? klass
|
data/spec/object_spec.rb
CHANGED
@@ -83,4 +83,27 @@ describe Object do
|
|
83
83
|
expect(:symbol.is_one_of? String, Float, Object).to eq true
|
84
84
|
end
|
85
85
|
|
86
|
+
it "#true_?" do
|
87
|
+
expect(true.true_?).to eq true
|
88
|
+
expect(false.true_?).to eq false
|
89
|
+
expect{ nil.true_? }.to raise_error(RuntimeError)
|
90
|
+
expect{ 1.true_? }.to raise_error(RuntimeError)
|
91
|
+
expect{ [:ar, :ray].true_? }.to raise_error(RuntimeError)
|
92
|
+
expect{ {ha: :sh}.true_? }.to raise_error(RuntimeError)
|
93
|
+
expect{ 'string'.true_? }.to raise_error(RuntimeError)
|
94
|
+
expect{ :symbol.true_? }.to raise_error(RuntimeError)
|
95
|
+
end
|
96
|
+
|
97
|
+
it "#false_?" do
|
98
|
+
expect(false.false_?).to eq true
|
99
|
+
expect(true.false_?).to eq false
|
100
|
+
expect{ nil.false_? }.to raise_error(RuntimeError)
|
101
|
+
expect{ 0.false_? }.to raise_error(RuntimeError)
|
102
|
+
expect{ [:ar, :ray].false_? }.to raise_error(RuntimeError)
|
103
|
+
expect{ {ha: :sh}.false_? }.to raise_error(RuntimeError)
|
104
|
+
expect{ 'string'.false_? }.to raise_error(RuntimeError)
|
105
|
+
expect{ :symbol.false_? }.to raise_error(RuntimeError)
|
106
|
+
end
|
107
|
+
|
108
|
+
|
86
109
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: finishing_moves
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: '0.
|
4
|
+
version: '0.18'
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Frank Koehl
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2017-
|
12
|
+
date: 2017-03-22 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rb-readline
|