finishing_moves 0.19 → 0.20

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 8d258c9fa2aa428c334917b3ed6f93e8e753cb22
4
- data.tar.gz: 66b42d8c9755e15f7ccd6f0039b688b5a20fea87
3
+ metadata.gz: e4efbdd6bdfc892e6ae09dc64b5617da8413ccf3
4
+ data.tar.gz: 340d5694613b94e1d7d3cea866d75e47525f1c64
5
5
  SHA512:
6
- metadata.gz: 8dbc5e8995eef233120cf390d4671087d39c1752845c69b988f5354fbe06b2b2b3c0549bc40eb8a62715b3e841907fec01576e9277b9769db814c8a3a995b106
7
- data.tar.gz: 4fe766497b240c4f6ad6793133c4bd7e87b32b0315f8978b368c1a511ca1de86a409f9a981ef47ce2bc12310eb7d3c06e7c62adc1861e336c31a9f87f462bc97
6
+ metadata.gz: ac8ce0578d278efa3b827aa7694e858bf1ff8cc2528af711a75da099aa0edf05aef6c126222c902796fe94a662ee01efc0600070a58b28001525bd20c8d27cdb
7
+ data.tar.gz: b0b454beb0eb14676f4100e01ef03cf4ce01b9d5b57f8b99a9a3f9e6648aa844b69c88e7009559ac52ffc300a33c86acdd32c4264f6bcea27d3330a96a50a592
data/README.md CHANGED
@@ -39,8 +39,10 @@ gem install 'finishing_moves'
39
39
  - [`Numeric#subtract_percent`](https://github.com/forgecrafted/finishing_moves/wiki/Numeric#numericsubtract_percent)
40
40
  - [`Object#same_as`](https://github.com/forgecrafted/finishing_moves/wiki/Object#objectsame_as)
41
41
  - [`Object#not_nil?`](https://github.com/forgecrafted/finishing_moves/wiki/Object#objectnot_nil)
42
+ - [`Object#numeric?`](https://github.com/forgecrafted/finishing_moves/wiki/Object#objectnumeric) :boom:
42
43
  - [`Object#is_an?`](https://github.com/forgecrafted/finishing_moves/wiki/Object#objectis_an)
43
44
  - [`Object#is_not_a?`](https://github.com/forgecrafted/finishing_moves/wiki/Object#objectis_not_a)
45
+ - [`Object#is_one_of?`](https://github.com/forgecrafted/finishing_moves/wiki/Object#objectis_one_of) :boom:
44
46
  - [`Object#true?`](https://github.com/forgecrafted/finishing_moves/wiki/Object#objecttruefalsebool)
45
47
  - [`Object#false?`](https://github.com/forgecrafted/finishing_moves/wiki/Object#objecttruefalsebool)
46
48
  - [`Object#bool?`](https://github.com/forgecrafted/finishing_moves/wiki/Object#objecttruefalsebool)
@@ -52,14 +54,13 @@ gem install 'finishing_moves'
52
54
  - [`String#match?`](https://github.com/forgecrafted/finishing_moves/wiki/String#stringmatch)
53
55
  - [`String#nl2br`](https://github.com/forgecrafted/finishing_moves/wiki/String#stringnl2br)
54
56
  - [`String#newline_to`](https://github.com/forgecrafted/finishing_moves/wiki/String#stringnewline_to)
55
- - [`String#numeric?`](https://github.com/forgecrafted/finishing_moves/wiki/String#stringnumeric) :boom:
56
57
  - [`String#remove_whitespace`](https://github.com/forgecrafted/finishing_moves/wiki/String#stringremove_whitespace)
57
58
  - [`String#replace_whitespace`](https://github.com/forgecrafted/finishing_moves/wiki/String#stringreplace_whitespace)
58
59
  - [`String#strip_all`](https://github.com/forgecrafted/finishing_moves/wiki/String#stringstrip_all) :boom:
59
60
 
60
61
  *Multi-class logic enhancements*
61
62
 
62
- - [Fiscal Calendar Calculations](https://github.com/forgecrafted/finishing_moves/wiki/Fiscal-Calendar-Calculations) :boom:
63
+ - ~Fiscal Calendar Calculations~ Moved to its own gem! [Check out Fiscally.](https://github.com/forgecrafted/fiscally)
63
64
  - [Boolean Typecasting](https://github.com/forgecrafted/finishing_moves/wiki/Boolean-Typecasting)
64
65
 
65
66
  ### Ruby Version
@@ -6,8 +6,7 @@ FQDN = "#{NAME}.example.com"
6
6
 
7
7
  Vagrant.configure("2") do |config|
8
8
  # "trusty" is 14.04
9
- config.vm.box = "trusty64"
10
- config.vm.box_url = "https://cloud-images.ubuntu.com/vagrant/trusty/current/trusty-server-cloudimg-amd64-vagrant-disk1.box"
9
+ config.vm.box = "ubuntu/trusty64"
11
10
 
12
11
  # Use the normal insecure key
13
12
  # https://github.com/mitchellh/vagrant/issues/2608
@@ -27,4 +27,13 @@ class Array
27
27
  end
28
28
  alias_method :to_hash_as_keys, :to_hash_keys
29
29
 
30
+ # remove all nil's and empty strings
31
+ def crush
32
+ reject { |item| item.nil? || bool_chain{item.strip.empty?} }
33
+ end
34
+
35
+ def crush!
36
+ reject! { |item| item.nil? || bool_chain{item.strip.empty?} }
37
+ end
38
+
30
39
  end
@@ -24,4 +24,13 @@ class Hash
24
24
  return self
25
25
  end
26
26
 
27
+ # remove all nil's and empty strings
28
+ def crush
29
+ reject { |item| item.nil? || bool_chain{item.strip.empty?} }
30
+ end
31
+
32
+ def crush!
33
+ reject! { |item| item.nil? || bool_chain{item.strip.empty?} }
34
+ end
35
+
27
36
  end
@@ -66,4 +66,12 @@ class Object
66
66
  return false
67
67
  end
68
68
 
69
+ # Sources:
70
+ # http://mentalized.net/journal/2011/04/14/ruby-how-to-check-if-a-string-is-numeric/
71
+ # http://rosettacode.org/wiki/Determine_if_a_string_is_numeric#Ruby
72
+ # http://stackoverflow.com/questions/5661466/test-if-string-is-a-number-in-ruby-on-rails/5661695
73
+ def numeric?
74
+ Float(self) != nil rescue false
75
+ end
76
+
69
77
  end
@@ -94,14 +94,6 @@ class String
94
94
  match(pattern, pos).not_nil?
95
95
  end
96
96
 
97
- # Sources:
98
- # http://mentalized.net/journal/2011/04/14/ruby-how-to-check-if-a-string-is-numeric/
99
- # http://rosettacode.org/wiki/Determine_if_a_string_is_numeric#Ruby
100
- # http://stackoverflow.com/questions/5661466/test-if-string-is-a-number-in-ruby-on-rails/5661695
101
- def numeric?
102
- Float(self) != nil rescue false
103
- end
104
-
105
97
  # TODO
106
98
  # def each_char_index(&block)
107
99
  # how to return enumerator if no block given?
@@ -1,3 +1,3 @@
1
1
  module FinishingMoves
2
- VERSION = "0.19"
2
+ VERSION = "0.20"
3
3
  end
@@ -105,6 +105,41 @@ describe Object do
105
105
  expect{ :symbol.false_? }.to raise_error(RuntimeError)
106
106
  end
107
107
 
108
+ it '#numeric?' do
109
+ expect("42".numeric?).to be true
110
+ expect("-42".numeric?).to be true
111
+ expect("1.2".numeric?).to be true
112
+ expect("0".numeric?).to be true
113
+ expect("1.2e34".numeric?).to be true
114
+ expect("1_000".numeric?).to be true
115
+ expect("".numeric?).to be false
116
+ expect(" ".numeric?).to be false
117
+ expect("a".numeric?).to be false
118
+ expect(:a.numeric?).to be false
119
+ expect("-".numeric?).to be false
120
+ expect(".".numeric?).to be false
121
+ expect("_".numeric?).to be false
122
+ expect("1.2.3".numeric?).to be false
123
+
124
+ expect(123.numeric?).to be true
125
+ expect(42.numeric?).to be true
126
+ expect(-42.numeric?).to be true
127
+ expect(1.2.numeric?).to be true
128
+ expect(0.numeric?).to be true
129
+ expect(-0.0.numeric?).to be true
130
+ expect(1.2e34.numeric?).to be true
131
+ expect(1_000.numeric?).to be true
132
+
133
+ expect([:foo, :bar].numeric?).to be false
134
+ hash = {:foo => :bar}
135
+ expect(hash.numeric?).to be false
136
+ expect(hash.each.numeric?).to be false
137
+ expect(ArgumentError.new.numeric?).to be false
138
+ expect(GC.numeric?).to be false
139
+ expect(NoStringObject.numeric?).to be false
140
+ expect(NoStringObject.new.numeric?).to be false
141
+ end
142
+
108
143
  end
109
144
 
110
145
  #############################
@@ -256,20 +256,4 @@ describe String do
256
256
  expect{ '12345678'.slugify! }.not_to raise_error
257
257
  end
258
258
 
259
- it '#numeric?' do
260
- expect("42".numeric?).to be true
261
- expect("-42".numeric?).to be true
262
- expect("1.2".numeric?).to be true
263
- expect("0".numeric?).to be true
264
- expect("1.2e34".numeric?).to be true
265
- expect("1_000".numeric?).to be true
266
- expect("".numeric?).to be false
267
- expect(" ".numeric?).to be false
268
- expect("a".numeric?).to be false
269
- expect("-".numeric?).to be false
270
- expect(".".numeric?).to be false
271
- expect("_".numeric?).to be false
272
- expect("1.2.3".numeric?).to be false
273
- end
274
-
275
259
  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.19'
4
+ version: '0.20'
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-06-27 00:00:00.000000000 Z
12
+ date: 2018-02-23 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rb-readline