string-utility 2.7.1 → 2.7.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- metadata +3 -5
- data/spec/benchmark.rb +0 -85
- data/spec/testcases.rb +0 -47
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6e462553b6a77784d686ffad8ffbfc7ccd9b1959
|
4
|
+
data.tar.gz: 28208aab108398aefb3bbd5ac5c10fd05e144776
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 85f2d11d7b1428287c9a0ed6f15b58313d876bd152f29b261b02084325848f95aa6e682792eecf2d4653ca4a89e5e369d9afd4d32942fe2eb0ddab390253a6d3
|
7
|
+
data.tar.gz: 119bd520fdac35064f8a5756016b42815680937bbca8c3f3a20dba34e0136c1a6a30bf8d58d823b1d6f425ca9d43c611b5dddc2719d160020fd3c37246d3cae4
|
data/CHANGELOG.md
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: string-utility
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.7.
|
4
|
+
version: 2.7.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Eli Foster
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-03-23 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: " Some simple but handy methods to interact with string objects.\n"
|
14
14
|
email: elifosterwy@gmail.com
|
@@ -19,11 +19,9 @@ files:
|
|
19
19
|
- CHANGELOG.md
|
20
20
|
- lib/string-utility.rb
|
21
21
|
- lib/utils.rb
|
22
|
-
- spec/benchmark.rb
|
23
|
-
- spec/testcases.rb
|
24
22
|
homepage: https://github.com/elifoster/string-utility-ruby
|
25
23
|
licenses:
|
26
|
-
-
|
24
|
+
- MIT
|
27
25
|
metadata:
|
28
26
|
issue_tracker: https://github.com/elifoster/string-utility-ruby/issues
|
29
27
|
post_install_message:
|
data/spec/benchmark.rb
DELETED
@@ -1,85 +0,0 @@
|
|
1
|
-
require 'benchmark'
|
2
|
-
if ARGV.include?('--gem')
|
3
|
-
require 'string-utility'
|
4
|
-
else
|
5
|
-
require_relative '../lib/utils'
|
6
|
-
end
|
7
|
-
|
8
|
-
TIMES = 100_000
|
9
|
-
using StringUtility
|
10
|
-
Benchmark.bm do |b|
|
11
|
-
b.report('separate') do
|
12
|
-
TIMES.times do
|
13
|
-
'1000'.separate
|
14
|
-
end
|
15
|
-
end
|
16
|
-
|
17
|
-
b.report('to_i_separated') do
|
18
|
-
TIMES.times do
|
19
|
-
'1,000'.to_i_separated
|
20
|
-
end
|
21
|
-
end
|
22
|
-
|
23
|
-
b.report('underscorify') do
|
24
|
-
TIMES.times do
|
25
|
-
' '.underscorify
|
26
|
-
end
|
27
|
-
end
|
28
|
-
|
29
|
-
b.report('spacify') do
|
30
|
-
TIMES.times do
|
31
|
-
'_____'.spacify
|
32
|
-
end
|
33
|
-
end
|
34
|
-
|
35
|
-
b.report('random_line') do
|
36
|
-
TIMES.times do
|
37
|
-
StringUtility.random_line("#{Dir.pwd}/README.md")
|
38
|
-
end
|
39
|
-
end
|
40
|
-
|
41
|
-
b.report('color 3') do
|
42
|
-
TIMES.times do
|
43
|
-
StringUtility.random_color_three
|
44
|
-
end
|
45
|
-
end
|
46
|
-
|
47
|
-
b.report('color 6') do
|
48
|
-
TIMES.times do
|
49
|
-
StringUtility.random_color_six
|
50
|
-
end
|
51
|
-
end
|
52
|
-
end
|
53
|
-
|
54
|
-
Benchmark.bm do |b|
|
55
|
-
b.report('gsub! success') do
|
56
|
-
TIMES.times do
|
57
|
-
'ABC'.gsub!('ABC', '123')
|
58
|
-
end
|
59
|
-
end
|
60
|
-
|
61
|
-
b.report('safely_gsub! success') do
|
62
|
-
TIMES.times do
|
63
|
-
'ABC'.safely_gsub!('ABC', '123')
|
64
|
-
end
|
65
|
-
end
|
66
|
-
|
67
|
-
b.report('gsub! fail') do
|
68
|
-
TIMES.times do
|
69
|
-
'ABC'.gsub!('DEF', '456')
|
70
|
-
end
|
71
|
-
end
|
72
|
-
|
73
|
-
b.report('gsub! fail safe') do
|
74
|
-
TIMES.times do
|
75
|
-
str = 'ABC'
|
76
|
-
str.gsub!('DEF', '456') || str
|
77
|
-
end
|
78
|
-
end
|
79
|
-
|
80
|
-
b.report('safely_gsub! fail') do
|
81
|
-
TIMES.times do
|
82
|
-
'ABC'.safely_gsub!('DEF', '456')
|
83
|
-
end
|
84
|
-
end
|
85
|
-
end
|
data/spec/testcases.rb
DELETED
@@ -1,47 +0,0 @@
|
|
1
|
-
require 'test/unit'
|
2
|
-
require_relative '../lib/utils'
|
3
|
-
|
4
|
-
class TestStringUtility < Test::Unit::TestCase
|
5
|
-
using StringUtility
|
6
|
-
def test_separate
|
7
|
-
assert_equal('1,000', '1000'.separate)
|
8
|
-
assert_equal('10,00', '1000'.separate(2))
|
9
|
-
assert_equal('1:000', '1000'.separate(3, ':'))
|
10
|
-
assert_equal('10:00', '1000'.separate(2, ':'))
|
11
|
-
assert_equal('100', '100'.separate)
|
12
|
-
end
|
13
|
-
|
14
|
-
def test_to_i_sparated
|
15
|
-
assert_equal(1000, '1,000'.to_i_separated)
|
16
|
-
assert_equal(1000, '1000'.to_i_separated)
|
17
|
-
end
|
18
|
-
|
19
|
-
def test_underscorify
|
20
|
-
assert_equal('_', ' '.underscorify)
|
21
|
-
assert_equal('Test', 'Test'.underscorify)
|
22
|
-
end
|
23
|
-
|
24
|
-
def test_spacify
|
25
|
-
assert_equal(' ', '_'.spacify)
|
26
|
-
assert_equal('Test', 'Test'.spacify)
|
27
|
-
end
|
28
|
-
|
29
|
-
def test_random_line
|
30
|
-
assert_instance_of(String, StringUtility.random_line("#{Dir.pwd}/" \
|
31
|
-
'spec/testcases.rb'))
|
32
|
-
end
|
33
|
-
|
34
|
-
def test_random_color_three
|
35
|
-
assert_instance_of(String, StringUtility.random_color_three)
|
36
|
-
end
|
37
|
-
|
38
|
-
def test_random_color_six
|
39
|
-
assert_instance_of(String, StringUtility.random_color_six)
|
40
|
-
end
|
41
|
-
|
42
|
-
def test_safely_gsub
|
43
|
-
assert_equal('b', 'b'.safely_gsub!('a', '1'))
|
44
|
-
assert_not_nil('b'.safely_gsub!('a', '1'))
|
45
|
-
assert_equal('bb', 'ab'.safely_gsub!('a', 'b'))
|
46
|
-
end
|
47
|
-
end
|