render-text-helper 0.3.2 → 0.4.1
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 +4 -4
- data/.rubocop.yml +2 -0
- data/CHANGELOG.md +8 -0
- data/Gemfile.lock +28 -23
- data/README.md +27 -0
- data/lib/render/text/helper/float.rb +10 -0
- data/lib/render/text/helper/string.rb +10 -3
- data/lib/render/text/helper/version.rb +1 -1
- data/lib/render/text/helper.rb +1 -0
- data/sig/boolean_helper.rbs +5 -0
- data/sig/render/text/helper/float.rbs +3 -0
- data/sig/render/text/helper/string.rbs +3 -0
- data/sig/string.rbs +6 -0
- metadata +7 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b7cde7c2690826b2c8a735bb088254f4cac6e7fd818f3f2605cf16a5a1b82e3e
|
4
|
+
data.tar.gz: 5e09fd32cbf9028e9d3ee0846a5f76dabd914302e369072c1faa815660fcc36b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5551f2993778b2ef40550bf3d711ef011553bd08873a1cdea4c83ce6ae0e3da4a6c6bf37ec603d40f6dc4a483426c34471167a8ec74eade4c378a9439a9d3fa0
|
7
|
+
data.tar.gz: 942d652b160aa69a4f91e41bd4122cf4d9a88ad66ee1b3e98e7db8dbf65c1301b0be46b2db5004bab73129432b21eb7cb0d9f903cf1262f0df6b58d2541b595b
|
data/.rubocop.yml
CHANGED
data/CHANGELOG.md
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,54 +1,59 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
render-text-helper (0.
|
4
|
+
render-text-helper (0.4.1)
|
5
5
|
|
6
6
|
GEM
|
7
7
|
remote: https://rubygems.org/
|
8
8
|
specs:
|
9
|
-
ast (2.4.
|
10
|
-
diff-lcs (1.
|
11
|
-
json (2.
|
12
|
-
language_server-protocol (3.17.0.
|
13
|
-
|
14
|
-
|
9
|
+
ast (2.4.3)
|
10
|
+
diff-lcs (1.6.2)
|
11
|
+
json (2.15.1)
|
12
|
+
language_server-protocol (3.17.0.5)
|
13
|
+
lint_roller (1.1.0)
|
14
|
+
parallel (1.27.0)
|
15
|
+
parser (3.3.9.0)
|
15
16
|
ast (~> 2.4.1)
|
16
17
|
racc
|
18
|
+
prism (1.5.2)
|
17
19
|
racc (1.8.1)
|
18
20
|
rainbow (3.1.1)
|
19
|
-
rake (13.
|
20
|
-
regexp_parser (2.
|
21
|
-
rspec (3.13.
|
21
|
+
rake (13.3.0)
|
22
|
+
regexp_parser (2.11.3)
|
23
|
+
rspec (3.13.1)
|
22
24
|
rspec-core (~> 3.13.0)
|
23
25
|
rspec-expectations (~> 3.13.0)
|
24
26
|
rspec-mocks (~> 3.13.0)
|
25
|
-
rspec-core (3.13.
|
27
|
+
rspec-core (3.13.5)
|
26
28
|
rspec-support (~> 3.13.0)
|
27
|
-
rspec-expectations (3.13.
|
29
|
+
rspec-expectations (3.13.5)
|
28
30
|
diff-lcs (>= 1.2.0, < 2.0)
|
29
31
|
rspec-support (~> 3.13.0)
|
30
|
-
rspec-mocks (3.13.
|
32
|
+
rspec-mocks (3.13.6)
|
31
33
|
diff-lcs (>= 1.2.0, < 2.0)
|
32
34
|
rspec-support (~> 3.13.0)
|
33
|
-
rspec-support (3.13.
|
34
|
-
rubocop (1.
|
35
|
+
rspec-support (3.13.6)
|
36
|
+
rubocop (1.81.1)
|
35
37
|
json (~> 2.3)
|
36
|
-
language_server-protocol (
|
38
|
+
language_server-protocol (~> 3.17.0.2)
|
39
|
+
lint_roller (~> 1.1.0)
|
37
40
|
parallel (~> 1.10)
|
38
41
|
parser (>= 3.3.0.2)
|
39
42
|
rainbow (>= 2.2.2, < 4.0)
|
40
43
|
regexp_parser (>= 2.9.3, < 3.0)
|
41
|
-
rubocop-ast (>= 1.
|
44
|
+
rubocop-ast (>= 1.47.1, < 2.0)
|
42
45
|
ruby-progressbar (~> 1.7)
|
43
46
|
unicode-display_width (>= 2.4.0, < 4.0)
|
44
|
-
rubocop-ast (1.
|
45
|
-
parser (>= 3.3.
|
47
|
+
rubocop-ast (1.47.1)
|
48
|
+
parser (>= 3.3.7.2)
|
49
|
+
prism (~> 1.4)
|
46
50
|
ruby-progressbar (1.13.0)
|
47
|
-
unicode-display_width (3.
|
48
|
-
unicode-emoji (~> 4.
|
49
|
-
unicode-emoji (4.0
|
51
|
+
unicode-display_width (3.2.0)
|
52
|
+
unicode-emoji (~> 4.1)
|
53
|
+
unicode-emoji (4.1.0)
|
50
54
|
|
51
55
|
PLATFORMS
|
56
|
+
arm64-darwin-24
|
52
57
|
x86_64-linux
|
53
58
|
|
54
59
|
DEPENDENCIES
|
@@ -58,4 +63,4 @@ DEPENDENCIES
|
|
58
63
|
rubocop (~> 1.5)
|
59
64
|
|
60
65
|
BUNDLED WITH
|
61
|
-
2.
|
66
|
+
2.7.2
|
data/README.md
CHANGED
@@ -58,6 +58,24 @@ It also strips whitespace.
|
|
58
58
|
['cat', 'dog', 'matt', 'pat']
|
59
59
|
```
|
60
60
|
|
61
|
+
### To Titleize
|
62
|
+
|
63
|
+
Titleize for none rails project. It also removes unnecessary white spaces and converts "_" to spaces.
|
64
|
+
|
65
|
+
```ruby
|
66
|
+
'hello world!'.to_titleize
|
67
|
+
"Hello World!"
|
68
|
+
|
69
|
+
'HELLO WORLD!'.to_titleize
|
70
|
+
"Hello World!"
|
71
|
+
|
72
|
+
'hello_world!'.to_titleize
|
73
|
+
"Hello World!"
|
74
|
+
|
75
|
+
' hello world! '.to_titleize
|
76
|
+
"Hello World!"
|
77
|
+
```
|
78
|
+
|
61
79
|
### to yes no
|
62
80
|
|
63
81
|
This function returns a string from a boolean to yes or no.
|
@@ -100,6 +118,15 @@ false.to_yn(capital_letter: false)
|
|
100
118
|
|
101
119
|
Returns 1 for true and 0 for false on a boolean object.
|
102
120
|
|
121
|
+
### add_percent_sign
|
122
|
+
|
123
|
+
It takes float and adds percentage to it.
|
124
|
+
|
125
|
+
```ruby
|
126
|
+
25.75.add_percent_sign
|
127
|
+
'25.75%'
|
128
|
+
```
|
129
|
+
|
103
130
|
## Contributing
|
104
131
|
|
105
132
|
Bug reports and pull requests are welcome on GitHub at https://github.com/SaimonL/render-text-helper
|
@@ -2,6 +2,11 @@
|
|
2
2
|
|
3
3
|
# Adds function to existing String class
|
4
4
|
class String
|
5
|
+
# outputs string where it replaces \n or \r with actual return
|
6
|
+
def escaped_newline_to_newline
|
7
|
+
gsub('\n', "\n").gsub('\r', "\n")
|
8
|
+
end
|
9
|
+
|
5
10
|
# output the string giving the limit. It does not touch the string
|
6
11
|
def limit_print(limit: 32, more_indicator: '.', indicator_length: 3)
|
7
12
|
return self if size < limit
|
@@ -19,8 +24,10 @@ class String
|
|
19
24
|
split.map(&:strip)
|
20
25
|
end
|
21
26
|
|
22
|
-
|
23
|
-
|
24
|
-
|
27
|
+
def to_titleize
|
28
|
+
return '' if self == ''
|
29
|
+
return upcase if length == 1
|
30
|
+
|
31
|
+
gsub('_', ' ').strip.split.map(&:capitalize).join(' ')
|
25
32
|
end
|
26
33
|
end
|
data/lib/render/text/helper.rb
CHANGED
@@ -2,7 +2,10 @@ module Render
|
|
2
2
|
module Text
|
3
3
|
module Helper
|
4
4
|
class String
|
5
|
+
def escaped_newline_to_newline: -> String
|
5
6
|
def limit_print: (limit: Integer, more_indicator: String, indicator_length: Integer) -> String
|
7
|
+
def to_smart_array:(separator: String | nil) -> [String]
|
8
|
+
def to_titleize: -> String
|
6
9
|
end
|
7
10
|
end
|
8
11
|
end
|
data/sig/string.rbs
ADDED
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: render-text-helper
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Saimon Lovell
|
8
8
|
bindir: exe
|
9
9
|
cert_chain: []
|
10
|
-
date:
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
11
11
|
dependencies: []
|
12
12
|
description: Add some more functionality to string and booleans
|
13
13
|
email:
|
@@ -26,12 +26,16 @@ files:
|
|
26
26
|
- Rakefile
|
27
27
|
- lib/render/text/helper.rb
|
28
28
|
- lib/render/text/helper/boolean.rb
|
29
|
+
- lib/render/text/helper/float.rb
|
29
30
|
- lib/render/text/helper/string.rb
|
30
31
|
- lib/render/text/helper/version.rb
|
31
32
|
- render-text-helper.gemspec
|
33
|
+
- sig/boolean_helper.rbs
|
32
34
|
- sig/render/text/helper.rbs
|
33
35
|
- sig/render/text/helper/boolean.rbs
|
36
|
+
- sig/render/text/helper/float.rbs
|
34
37
|
- sig/render/text/helper/string.rbs
|
38
|
+
- sig/string.rbs
|
35
39
|
homepage: https://github.com/SaimonL/render-text-helper
|
36
40
|
licenses:
|
37
41
|
- MIT
|
@@ -55,7 +59,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
55
59
|
- !ruby/object:Gem::Version
|
56
60
|
version: '0'
|
57
61
|
requirements: []
|
58
|
-
rubygems_version: 3.
|
62
|
+
rubygems_version: 3.7.2
|
59
63
|
specification_version: 4
|
60
64
|
summary: Does some string manipulation
|
61
65
|
test_files: []
|