flash_extensions 1.0.0 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +38 -0
- data/lib/flash_extensions/extensions/numeric_extension.rb +79 -0
- data/lib/flash_extensions/version.rb +2 -2
- data/spec/lib/hash_extension_spec.rb +5 -19
- data/spec/lib/numeric_extension_spec.rb +113 -0
- data/spec/lib/string_extension_spec.rb +26 -94
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 84e33f32740d184881ab80b16d847d22e8effbeb
|
4
|
+
data.tar.gz: 8ddffe7c316ce91abdbbc05451fee2c1e418dbb3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 342e1badd913766af4feea7a837f4e5a456c5359ff7573a2a50ab8291843e10b312d46982d28d63751f26a767efd0ae665b5e2aa62387c94e1c9aabaf1910e68
|
7
|
+
data.tar.gz: bacebfbfc43a678f3b802669b8273e930673406b40f6c9d770f28cc45a1aeb1e0c8698dee18791d16695f36cf1ef9a94f22005489024f37399fac81d765dab2d
|
data/README.md
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
# FlashExtensions
|
2
2
|
|
3
|
+
[![Gem Version](https://badge.fury.io/rb/flash_extentions.svg)](http://badge.fury.io/rb/flash_extensions)
|
3
4
|
[![Build Status](https://travis-ci.org/drexed/flash_extensions.svg?branch=master)](https://travis-ci.org/drexed/flash_extensions)
|
4
5
|
[![Coverage Status](https://coveralls.io/repos/drexed/flash_extensions/badge.png)](https://coveralls.io/r/drexed/flash_extensions)
|
5
6
|
[![Code Climate](https://codeclimate.com/github/drexed/flash_extensions.png)](https://codeclimate.com/github/drexed/flash_extensions)
|
@@ -244,6 +245,43 @@ Use the `positive?` method to check if a number is positive.
|
|
244
245
|
-1.positive? #=> false
|
245
246
|
```
|
246
247
|
|
248
|
+
####To Byte:####
|
249
|
+
Use the `to_byte` method to convert a byte size from one unit to another unit.
|
250
|
+
|
251
|
+
```ruby
|
252
|
+
1024.to_byte #=> 1 #KB
|
253
|
+
5120.to_byte(:kb, :mb) #=> 5 #MB
|
254
|
+
1.to_byte(:mb, :kb) #=> 1024 #KB
|
255
|
+
80.to_byte(:mb, :gb) #=> 0.1 #GB
|
256
|
+
```
|
257
|
+
|
258
|
+
####To Length:####
|
259
|
+
Use the `to_length` method to convert a length from one unit to another unit.
|
260
|
+
|
261
|
+
```ruby
|
262
|
+
1.to_length #=> 0.039370078740157 #IN
|
263
|
+
10.to_length(:mm, :cm) #=> 1 #CM
|
264
|
+
2.to_length(:mi, :yd) #=> 3520 #IN
|
265
|
+
```
|
266
|
+
|
267
|
+
####To Temperature:####
|
268
|
+
Use the `to_temperature` method to convert a temperature from one unit to another unit.
|
269
|
+
|
270
|
+
```ruby
|
271
|
+
100.to_temperature #=> 212 #F
|
272
|
+
212.to_temperature(:f, :c) #=> 100 #C
|
273
|
+
212.to_temperature(:fahrenheit, :kelvin) #=> 373.15 #K
|
274
|
+
```
|
275
|
+
|
276
|
+
####To Weight:####
|
277
|
+
Use the `to_weight` method to convert a weight from one unit to another unit.
|
278
|
+
|
279
|
+
```ruby
|
280
|
+
1.to_weight #=> 0.035273961949580004 #OZ
|
281
|
+
2.to_weight(:kg, :lb) #=> 4.4092452436976 #LB
|
282
|
+
3.to_weight(:lb, :kg) #=> 1.3607771100000001 #LB
|
283
|
+
```
|
284
|
+
|
247
285
|
### StringExtensions
|
248
286
|
|
249
287
|
####Camelize:####
|
@@ -14,4 +14,83 @@ class Numeric
|
|
14
14
|
self > 0
|
15
15
|
end
|
16
16
|
|
17
|
+
def to_byte(from=:b, to=:kb)
|
18
|
+
scalers = { b: 1, kb: 1024 ** 1, mb: 1024 ** 2, gb: 1024 ** 3, tb: 1024 ** 4, pb: 1024 ** 5, eb: 1024 ** 6 }
|
19
|
+
|
20
|
+
self.to_f * scalers[from] / scalers[to]
|
21
|
+
end
|
22
|
+
|
23
|
+
def to_length(from=:mm, to=:in)
|
24
|
+
imperical_scalers = {
|
25
|
+
mm: 25.4, cm: 2.54, m: 0.0254, km: 0.0000254,
|
26
|
+
in: 1, ft: 12, yd: 36, mi: 63360, nm: 72913.4
|
27
|
+
}
|
28
|
+
metric_scalers = {
|
29
|
+
mm: 1, cm: 10, m: 1000, km: 1000000,
|
30
|
+
in: 0.039370078740157, ft: 0.0032808398950131, yd: 0.0010936132983377, mi: 0.00000062137119223733, nm: 0.00000053995680345572
|
31
|
+
}
|
32
|
+
|
33
|
+
case to
|
34
|
+
when from
|
35
|
+
self
|
36
|
+
when :mm, :cm, :m, :km
|
37
|
+
if [:in, :ft, :yd, :mi, :nm].include?(from)
|
38
|
+
self.to_f * imperical_scalers[from] * imperical_scalers[to]
|
39
|
+
else
|
40
|
+
self.to_f * metric_scalers[from] / metric_scalers[to]
|
41
|
+
end
|
42
|
+
when :in, :ft, :yd, :mi, :nm
|
43
|
+
if [:mm, :cm, :m, :km].include?(from)
|
44
|
+
self.to_f * metric_scalers[from] * metric_scalers[to]
|
45
|
+
else
|
46
|
+
self.to_f * imperical_scalers[from] / imperical_scalers[to]
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
def to_temperature(from=:c, to=:f)
|
52
|
+
case to
|
53
|
+
when from
|
54
|
+
self
|
55
|
+
when :c, :celsius
|
56
|
+
(self.to_f - 32) * 5 / 9
|
57
|
+
when :f, :fahrenheit
|
58
|
+
(self.to_f * 9 / 5) + 32
|
59
|
+
when :k, :kelvin
|
60
|
+
if [:c, :celsius].include?(from)
|
61
|
+
self.to_f + 273.15
|
62
|
+
else
|
63
|
+
((self.to_f - 32) * 5 / 9) + 273.15
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
def to_weight(from=:g, to=:oz)
|
69
|
+
imperical_scalers = {
|
70
|
+
mg: 28349.523125, cg: 2834.9523125, g: 28.349523125, kg: 0.028349523125, mt: 0.000028349523125,
|
71
|
+
oz: 1, lb: 16, tn: 32000
|
72
|
+
}
|
73
|
+
metric_scalers = {
|
74
|
+
mg: 1, cg: 10, g: 1000, kg: 1000000, mt: 1000000000,
|
75
|
+
oz: 0.00003527396194958, lb: 0.0000022046226218488, tn: 0.0000000011023113109244
|
76
|
+
}
|
77
|
+
|
78
|
+
case to
|
79
|
+
when from
|
80
|
+
self
|
81
|
+
when :mg, :cg, :g, :kg, :mt
|
82
|
+
if [:oz, :lb, :tn].include?(from)
|
83
|
+
self.to_f * imperical_scalers[from] * imperical_scalers[to]
|
84
|
+
else
|
85
|
+
self.to_f * metric_scalers[from] / metric_scalers[to]
|
86
|
+
end
|
87
|
+
when :oz, :lb, :tn
|
88
|
+
if [:mg, :cg, :g, :kg, :mt].include?(from)
|
89
|
+
self.to_f * metric_scalers[from] * metric_scalers[to]
|
90
|
+
else
|
91
|
+
self.to_f * imperical_scalers[from] / imperical_scalers[to]
|
92
|
+
end
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
17
96
|
end
|
@@ -1,3 +1,3 @@
|
|
1
1
|
module FlashExtensions
|
2
|
-
VERSION = "1.
|
3
|
-
end
|
2
|
+
VERSION = "1.1.0"
|
3
|
+
end
|
@@ -34,38 +34,24 @@ describe Hash do
|
|
34
34
|
end
|
35
35
|
end
|
36
36
|
|
37
|
-
describe "#rename_keys" do
|
37
|
+
describe "#rename_keys(!)" do
|
38
38
|
it "to be [:baz, :bar]" do
|
39
39
|
expect({ foo: 'foo', baz: 'baz' }.rename_keys(foo: :bar).keys).to eq([:baz, :bar])
|
40
|
-
end
|
41
|
-
|
42
|
-
it "to be [:foo, 'tick']" do
|
43
|
-
expect({ foo: 'foo', 'baz' => 'baz' }.rename_keys('baz' => 'tick').keys).to eq([:foo, 'tick'])
|
44
|
-
end
|
45
|
-
|
46
|
-
it "to be [:bar, :tick]" do
|
47
|
-
expect({ foo: 'foo', baz: 'baz' }.rename_keys(foo: :bar, baz: :tick).keys).to eq([:bar, :tick])
|
48
|
-
end
|
49
|
-
|
50
|
-
it "to be [:bar, 'tick']" do
|
51
|
-
expect({ foo: 'foo', 'baz' => 'baz' }.rename_keys(foo: :bar, 'baz' => 'tick').keys).to eq([:bar, 'tick'])
|
52
|
-
end
|
53
|
-
end
|
54
|
-
|
55
|
-
describe "#rename_keys!" do
|
56
|
-
it "to be [:baz, :bar]" do
|
57
40
|
expect({ foo: 'foo', baz: 'baz' }.rename_keys!(foo: :bar).keys).to eq([:baz, :bar])
|
58
41
|
end
|
59
42
|
|
60
43
|
it "to be [:foo, 'tick']" do
|
44
|
+
expect({ foo: 'foo', 'baz' => 'baz' }.rename_keys('baz' => 'tick').keys).to eq([:foo, 'tick'])
|
61
45
|
expect({ foo: 'foo', 'baz' => 'baz' }.rename_keys!('baz' => 'tick').keys).to eq([:foo, 'tick'])
|
62
46
|
end
|
63
47
|
|
64
48
|
it "to be [:bar, :tick]" do
|
49
|
+
expect({ foo: 'foo', baz: 'baz' }.rename_keys(foo: :bar, baz: :tick).keys).to eq([:bar, :tick])
|
65
50
|
expect({ foo: 'foo', baz: 'baz' }.rename_keys!(foo: :bar, baz: :tick).keys).to eq([:bar, :tick])
|
66
51
|
end
|
67
52
|
|
68
53
|
it "to be [:bar, 'tick']" do
|
54
|
+
expect({ foo: 'foo', 'baz' => 'baz' }.rename_keys(foo: :bar, 'baz' => 'tick').keys).to eq([:bar, 'tick'])
|
69
55
|
expect({ foo: 'foo', 'baz' => 'baz' }.rename_keys!(foo: :bar, 'baz' => 'tick').keys).to eq([:bar, 'tick'])
|
70
56
|
end
|
71
57
|
end
|
@@ -87,7 +73,7 @@ describe Hash do
|
|
87
73
|
describe "#symbolize_and_underscore_keys(!)" do
|
88
74
|
it "to be [:foo_bar, :baz_bar]" do
|
89
75
|
expect({ 'foo_Bar' => 'example', bazBar: 'string' }.symbolize_and_underscore_keys.keys).to eq([:foo_bar, :baz_bar])
|
90
|
-
expect({ 'foo_Bar' => 'example', bazBar: 'string' }.symbolize_and_underscore_keys
|
76
|
+
expect({ 'foo_Bar' => 'example', bazBar: 'string' }.symbolize_and_underscore_keys!.keys).to eq([:foo_bar, :baz_bar])
|
91
77
|
end
|
92
78
|
end
|
93
79
|
|
@@ -32,4 +32,117 @@ describe Numeric do
|
|
32
32
|
end
|
33
33
|
end
|
34
34
|
|
35
|
+
describe "#to_byte" do
|
36
|
+
it "to be 1" do
|
37
|
+
expect(1024.to_byte).to eq(1)
|
38
|
+
expect(1024.to_byte(:kb, :mb)).to eq(1)
|
39
|
+
end
|
40
|
+
|
41
|
+
it "to be 5" do
|
42
|
+
expect(5120.to_byte).to eq(5)
|
43
|
+
expect(5120.to_byte(:kb, :mb)).to eq(5)
|
44
|
+
end
|
45
|
+
|
46
|
+
it "to be 1024" do
|
47
|
+
expect(1024.to_byte(:kb, :kb)).to eq(1024)
|
48
|
+
expect(1.to_byte(:mb, :kb)).to eq(1024)
|
49
|
+
end
|
50
|
+
|
51
|
+
it "to be 1048576" do
|
52
|
+
expect(1.to_byte(:gb, :kb)).to eq(1048576)
|
53
|
+
end
|
54
|
+
|
55
|
+
it "to be 0.078125" do
|
56
|
+
expect(80.to_byte(:mb, :gb)).to eq(0.078125)
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
describe "#to_length" do
|
61
|
+
it "to be 0.039370078740157" do
|
62
|
+
expect(1.to_length).to eq(0.039370078740157)
|
63
|
+
end
|
64
|
+
|
65
|
+
it "to be 1" do
|
66
|
+
expect(1.to_length(:mm, :mm)).to eq(1)
|
67
|
+
expect(1.to_length(:in, :in)).to eq(1)
|
68
|
+
expect(10.to_length(:mm, :cm)).to eq(1)
|
69
|
+
expect(12.to_length(:in, :ft)).to eq(1)
|
70
|
+
end
|
71
|
+
|
72
|
+
it "to be 10" do
|
73
|
+
expect(1.to_length(:cm, :mm)).to eq(10)
|
74
|
+
end
|
75
|
+
|
76
|
+
it "to be 12" do
|
77
|
+
expect(1.to_length(:ft, :in)).to eq(12)
|
78
|
+
end
|
79
|
+
|
80
|
+
it "to be 30.48" do
|
81
|
+
expect(1.to_length(:ft, :cm)).to eq(30.48)
|
82
|
+
end
|
83
|
+
|
84
|
+
it "to be 1093.6132983377001" do
|
85
|
+
expect(1.to_length(:km, :yd)).to eq(1093.6132983377001)
|
86
|
+
end
|
87
|
+
|
88
|
+
it "to be 6076.116666666666" do
|
89
|
+
expect(1.to_length(:nm, :ft)).to eq(6076.116666666666)
|
90
|
+
end
|
91
|
+
end
|
92
|
+
|
93
|
+
describe "#to_temperature" do
|
94
|
+
it "to be 212" do
|
95
|
+
expect(100.to_temperature).to eq(212)
|
96
|
+
expect(100.to_temperature(:c, :f)).to eq(212)
|
97
|
+
expect(100.to_temperature(:celcius, :fahrenheit)).to eq(212)
|
98
|
+
end
|
99
|
+
|
100
|
+
it "to be 100" do
|
101
|
+
expect(100.to_temperature(:c, :c)).to eq(100)
|
102
|
+
expect(212.to_temperature(:f, :c)).to eq(100)
|
103
|
+
end
|
104
|
+
|
105
|
+
it "to be 373.15" do
|
106
|
+
expect(100.to_temperature(:c, :k)).to eq(373.15)
|
107
|
+
expect(212.to_temperature(:f, :k)).to eq(373.15)
|
108
|
+
end
|
109
|
+
end
|
110
|
+
|
111
|
+
describe "#to_weight" do
|
112
|
+
it "to be 0.035273961949580004" do
|
113
|
+
expect(1.to_weight).to eq(0.035273961949580004)
|
114
|
+
end
|
115
|
+
|
116
|
+
it "to be 1" do
|
117
|
+
expect(1.to_weight(:mg, :mg)).to eq(1)
|
118
|
+
expect(1.to_weight(:oz, :oz)).to eq(1)
|
119
|
+
expect(10.to_weight(:mg, :cg)).to eq(1)
|
120
|
+
expect(16.to_weight(:oz, :lb)).to eq(1)
|
121
|
+
end
|
122
|
+
|
123
|
+
it "to be 1.3607771100000001" do
|
124
|
+
expect(3.to_weight(:lb, :kg)).to eq(1.3607771100000001)
|
125
|
+
end
|
126
|
+
|
127
|
+
it "to be 1.1023113109243998" do
|
128
|
+
expect(1.to_weight(:mt, :tn)).to eq(1.1023113109243998)
|
129
|
+
end
|
130
|
+
|
131
|
+
it "to be 2.2046226218488" do
|
132
|
+
expect(1.to_weight(:kg, :lb)).to eq(2.2046226218488)
|
133
|
+
end
|
134
|
+
|
135
|
+
it "to be 10" do
|
136
|
+
expect(1.to_weight(:cg, :mg)).to eq(10)
|
137
|
+
end
|
138
|
+
|
139
|
+
it "to be 16" do
|
140
|
+
expect(1.to_weight(:lb, :oz)).to eq(16)
|
141
|
+
end
|
142
|
+
|
143
|
+
it "to be 64000" do
|
144
|
+
expect(2.to_weight(:tn, :lb)).to eq(4000)
|
145
|
+
end
|
146
|
+
end
|
147
|
+
|
35
148
|
end
|
@@ -2,22 +2,14 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
describe String do
|
4
4
|
|
5
|
-
describe "#camelize" do
|
5
|
+
describe "#camelize(!)" do
|
6
6
|
it "to be ExampleString" do
|
7
7
|
expect("example_string".camelize).to eq("ExampleString")
|
8
|
-
end
|
9
|
-
|
10
|
-
it "to be exampleString" do
|
11
|
-
expect("example_string".camelize(:lower)).to eq("exampleString")
|
12
|
-
end
|
13
|
-
end
|
14
|
-
|
15
|
-
describe "#camelize!" do
|
16
|
-
it "to be ExampleString" do
|
17
8
|
expect("example_string".camelize!).to eq("ExampleString")
|
18
9
|
end
|
19
10
|
|
20
11
|
it "to be exampleString" do
|
12
|
+
expect("example_string".camelize(:lower)).to eq("exampleString")
|
21
13
|
expect("example_string".camelize!(:lower)).to eq("exampleString")
|
22
14
|
end
|
23
15
|
end
|
@@ -38,18 +30,13 @@ describe String do
|
|
38
30
|
end
|
39
31
|
end
|
40
32
|
|
41
|
-
describe "#humanize" do
|
33
|
+
describe "#humanize(!)" do
|
42
34
|
it "to be Example string test" do
|
43
35
|
expect("example_string_test".humanize).to eq("Example string test")
|
44
|
-
expect("exampleStringTest".humanize).to eq("Example string test")
|
45
|
-
expect("ExampleStringTest".humanize).to eq("Example string test")
|
46
|
-
end
|
47
|
-
end
|
48
|
-
|
49
|
-
describe "#humanize!" do
|
50
|
-
it "to be Example string test" do
|
51
36
|
expect("example_string_test".humanize!).to eq("Example string test")
|
37
|
+
expect("exampleStringTest".humanize).to eq("Example string test")
|
52
38
|
expect("exampleStringTest".humanize!).to eq("Example string test")
|
39
|
+
expect("ExampleStringTest".humanize).to eq("Example string test")
|
53
40
|
expect("ExampleStringTest".humanize!).to eq("Example string test")
|
54
41
|
end
|
55
42
|
end
|
@@ -70,38 +57,28 @@ describe String do
|
|
70
57
|
end
|
71
58
|
end
|
72
59
|
|
73
|
-
describe "#titleize" do
|
60
|
+
describe "#titleize(!)" do
|
74
61
|
it "to be Example String Test" do
|
75
62
|
expect("example string test".titleize).to eq("Example String Test")
|
76
|
-
expect("Example string Test".titleize).to eq("Example String Test")
|
77
|
-
expect("ExampleStringTest".titleize).to eq("Example String Test")
|
78
|
-
expect("Example_string_test".titleize).to eq("Example String Test")
|
79
|
-
end
|
80
|
-
end
|
81
|
-
|
82
|
-
describe "#titleize!" do
|
83
|
-
it "to be Example String Test" do
|
84
63
|
expect("example string test".titleize!).to eq("Example String Test")
|
64
|
+
expect("Example string Test".titleize).to eq("Example String Test")
|
85
65
|
expect("Example string Test".titleize!).to eq("Example String Test")
|
66
|
+
expect("ExampleStringTest".titleize).to eq("Example String Test")
|
86
67
|
expect("ExampleStringTest".titleize!).to eq("Example String Test")
|
68
|
+
expect("Example_string_test".titleize).to eq("Example String Test")
|
87
69
|
expect("Example_string_test".titleize!).to eq("Example String Test")
|
88
70
|
end
|
89
71
|
end
|
90
72
|
|
91
|
-
describe "#underscore" do
|
73
|
+
describe "#underscore(!)" do
|
92
74
|
it "to be example_string" do
|
93
75
|
expect("ExampleString".underscore).to eq("example_string")
|
94
|
-
expect("exampleString".underscore).to eq("example_string")
|
95
|
-
expect("example_string".underscore).to eq("example_string")
|
96
|
-
expect("example_String".underscore).to eq("example_string")
|
97
|
-
end
|
98
|
-
end
|
99
|
-
|
100
|
-
describe "#underscore!" do
|
101
|
-
it "to be example_string" do
|
102
76
|
expect("ExampleString".underscore!).to eq("example_string")
|
77
|
+
expect("exampleString".underscore).to eq("example_string")
|
103
78
|
expect("exampleString".underscore!).to eq("example_string")
|
79
|
+
expect("example_string".underscore).to eq("example_string")
|
104
80
|
expect("example_string".underscore!).to eq("example_string")
|
81
|
+
expect("example_String".underscore).to eq("example_string")
|
105
82
|
expect("example_String".underscore!).to eq("example_string")
|
106
83
|
end
|
107
84
|
end
|
@@ -151,14 +128,9 @@ describe String do
|
|
151
128
|
end
|
152
129
|
end
|
153
130
|
|
154
|
-
describe "#gnix" do
|
131
|
+
describe "#gnix(!)" do
|
155
132
|
it "to be this that " do
|
156
133
|
expect("this thing that thing".gnix("thing")).to eq("this that ")
|
157
|
-
end
|
158
|
-
end
|
159
|
-
|
160
|
-
describe "#gnix!" do
|
161
|
-
it "to be this that " do
|
162
134
|
expect("this thing that thing".gnix!("thing")).to eq("this that ")
|
163
135
|
end
|
164
136
|
end
|
@@ -175,14 +147,9 @@ describe String do
|
|
175
147
|
end
|
176
148
|
end
|
177
149
|
|
178
|
-
describe "#nix" do
|
150
|
+
describe "#nix(!)" do
|
179
151
|
it "to be this that thing" do
|
180
152
|
expect("this thing that thing".nix("thing")).to eq("this that thing")
|
181
|
-
end
|
182
|
-
end
|
183
|
-
|
184
|
-
describe "#nix!" do
|
185
|
-
it "to be this that thing" do
|
186
153
|
expect("this thing that thing".nix!("thing")).to eq("this that thing")
|
187
154
|
end
|
188
155
|
end
|
@@ -217,94 +184,59 @@ describe String do
|
|
217
184
|
end
|
218
185
|
end
|
219
186
|
|
220
|
-
describe "#slugify" do
|
187
|
+
describe "#slugify(!)" do
|
221
188
|
it "to be example" do
|
222
189
|
expect("example".slugify).to eq("example")
|
223
|
-
end
|
224
|
-
|
225
|
-
it "to be example-string" do
|
226
|
-
expect("example string".slugify).to eq("example-string")
|
227
|
-
end
|
228
|
-
|
229
|
-
it "to be example-string-test" do
|
230
|
-
expect("Example string @@@ test!".slugify).to eq("example-string-test")
|
231
|
-
end
|
232
|
-
|
233
|
-
it "to be a-real-doozie" do
|
234
|
-
expect(" A REal Doozi\"e? \' ".slugify).to eq("a-real-doozie")
|
235
|
-
end
|
236
|
-
end
|
237
|
-
|
238
|
-
describe "#slugify!" do
|
239
|
-
it "to be example" do
|
240
190
|
expect("example".slugify!).to eq("example")
|
241
191
|
end
|
242
192
|
|
243
193
|
it "to be example-string" do
|
194
|
+
expect("example string".slugify).to eq("example-string")
|
244
195
|
expect("example string".slugify!).to eq("example-string")
|
245
196
|
end
|
246
197
|
|
247
198
|
it "to be example-string-test" do
|
199
|
+
expect("Example string @@@ test!".slugify).to eq("example-string-test")
|
248
200
|
expect("Example string @@@ test!".slugify!).to eq("example-string-test")
|
249
201
|
end
|
250
202
|
|
251
203
|
it "to be a-real-doozie" do
|
204
|
+
expect(" A REal Doozi\"e? \' ".slugify).to eq("a-real-doozie")
|
252
205
|
expect(" A REal Doozi\"e? \' ".slugify!).to eq("a-real-doozie")
|
253
206
|
end
|
254
207
|
end
|
255
208
|
|
256
|
-
describe "#squish" do
|
209
|
+
describe "#squish(!)" do
|
257
210
|
it "to be example test" do
|
258
211
|
expect("example test".squish).to eq("example test")
|
259
|
-
expect(" example test ".squish).to eq("example test")
|
260
|
-
end
|
261
|
-
end
|
262
|
-
|
263
|
-
describe "#squish!" do
|
264
|
-
it "to be example test" do
|
265
212
|
expect("example test".squish!).to eq("example test")
|
213
|
+
expect(" example test ".squish).to eq("example test")
|
266
214
|
expect(" example test ".squish!).to eq("example test")
|
267
215
|
end
|
268
216
|
end
|
269
217
|
|
270
|
-
describe "#strip_tags" do
|
218
|
+
describe "#strip_tags(!)" do
|
271
219
|
it "to be example" do
|
272
220
|
expect("example".strip_tags).to eq("example")
|
273
|
-
end
|
274
|
-
|
275
|
-
it "to be click" do
|
276
|
-
expect("<a href='http://example.com'>click</a>".strip_tags).to eq("click")
|
277
|
-
end
|
278
|
-
|
279
|
-
it "to be this is bold and emphatic" do
|
280
|
-
expect("this is <b>bold</b> and <em>emphatic</em>".strip_tags).to eq("this is bold and emphatic")
|
281
|
-
end
|
282
|
-
end
|
283
|
-
|
284
|
-
describe "#strip_tags!" do
|
285
|
-
it "to be example" do
|
286
221
|
expect("example".strip_tags!).to eq("example")
|
287
222
|
end
|
288
223
|
|
289
224
|
it "to be click" do
|
225
|
+
expect("<a href='http://example.com'>click</a>".strip_tags).to eq("click")
|
290
226
|
expect("<a href='http://example.com'>click</a>".strip_tags!).to eq("click")
|
291
227
|
end
|
292
228
|
|
293
229
|
it "to be this is bold and emphatic" do
|
230
|
+
expect("this is <b>bold</b> and <em>emphatic</em>".strip_tags).to eq("this is bold and emphatic")
|
294
231
|
expect("this is <b>bold</b> and <em>emphatic</em>".strip_tags!).to eq("this is bold and emphatic")
|
295
232
|
end
|
296
233
|
end
|
297
234
|
|
298
|
-
describe "#strip_whitespace" do
|
235
|
+
describe "#strip_whitespace(!)" do
|
299
236
|
it "to be example" do
|
300
237
|
expect("example string test".strip_whitespace).to eq("example string test")
|
301
|
-
expect(" this \t is also a test ".strip_whitespace).to eq("this is also a test")
|
302
|
-
end
|
303
|
-
end
|
304
|
-
|
305
|
-
describe "#strip_whitespace!" do
|
306
|
-
it "to be example" do
|
307
238
|
expect("example string test".strip_whitespace!).to eq("example string test")
|
239
|
+
expect(" this \t is also a test ".strip_whitespace).to eq("this is also a test")
|
308
240
|
expect(" this \t is also a test ".strip_whitespace!).to eq("this is also a test")
|
309
241
|
end
|
310
242
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: flash_extensions
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Juan Gomez
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-08-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -119,7 +119,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
119
119
|
version: '0'
|
120
120
|
requirements: []
|
121
121
|
rubyforge_project:
|
122
|
-
rubygems_version: 2.
|
122
|
+
rubygems_version: 2.4.1
|
123
123
|
signing_key:
|
124
124
|
specification_version: 4
|
125
125
|
summary: Commonly used object helpers
|