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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3a16d3ef03a33b4763eeb84d7e72162eef89b34c3d138792b2f21af0b503f211
4
- data.tar.gz: 1a5f5f19b1261d873a703d45feb3704509754e64aa92ec6e922bb12471d823f6
3
+ metadata.gz: b7cde7c2690826b2c8a735bb088254f4cac6e7fd818f3f2605cf16a5a1b82e3e
4
+ data.tar.gz: 5e09fd32cbf9028e9d3ee0846a5f76dabd914302e369072c1faa815660fcc36b
5
5
  SHA512:
6
- metadata.gz: 17eef48dab9ff66109a80e8c985d259632dab92410a7a74e23790ddba9283b721d7a17fb01a144f829652a8e5aaed1b7ea5f9506f1fe93da1874e8d4fe77a6b1
7
- data.tar.gz: e45e71e62432bf2a5e892e78ed466ca510e5e7610ce963b6b079b17d56df8879ad95f6d7b0cc669a8dd8c47031c4ea292b0278ee6548e6c0314ac2414f5d23a7
6
+ metadata.gz: 5551f2993778b2ef40550bf3d711ef011553bd08873a1cdea4c83ce6ae0e3da4a6c6bf37ec603d40f6dc4a483426c34471167a8ec74eade4c378a9439a9d3fa0
7
+ data.tar.gz: 942d652b160aa69a4f91e41bd4122cf4d9a88ad66ee1b3e98e7db8dbf65c1301b0be46b2db5004bab73129432b21eb7cb0d9f903cf1262f0df6b58d2541b595b
data/.rubocop.yml CHANGED
@@ -15,6 +15,8 @@ Layout/LineLength:
15
15
 
16
16
  Metrics/BlockLength:
17
17
  Max: 50
18
+ Exclude:
19
+ - spec/render/text/helper/*.rb
18
20
 
19
21
  Layout/CaseIndentation:
20
22
  EnforcedStyle: end
data/CHANGELOG.md CHANGED
@@ -1,5 +1,13 @@
1
1
  # Changelog
2
2
 
3
+ ## [0.4.1] - 2025-14-10
4
+
5
+ - Added add_percent_sign method that adds percentage to float
6
+
7
+ ## [0.4.0] - 2025-17-02
8
+
9
+ - Added to_titleize
10
+
3
11
  ## [0.3.2] - 2024-12-26
4
12
 
5
13
  - Replaces escaped return with actual return
data/Gemfile.lock CHANGED
@@ -1,54 +1,59 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- render-text-helper (0.3.2)
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.2)
10
- diff-lcs (1.5.1)
11
- json (2.9.1)
12
- language_server-protocol (3.17.0.3)
13
- parallel (1.26.3)
14
- parser (3.3.6.0)
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.2.1)
20
- regexp_parser (2.10.0)
21
- rspec (3.13.0)
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.2)
27
+ rspec-core (3.13.5)
26
28
  rspec-support (~> 3.13.0)
27
- rspec-expectations (3.13.3)
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.2)
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.2)
34
- rubocop (1.69.2)
35
+ rspec-support (3.13.6)
36
+ rubocop (1.81.1)
35
37
  json (~> 2.3)
36
- language_server-protocol (>= 3.17.0)
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.36.2, < 2.0)
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.37.0)
45
- parser (>= 3.3.1.0)
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.1.2)
48
- unicode-emoji (~> 4.0, >= 4.0.4)
49
- unicode-emoji (4.0.4)
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.6.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
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Added methods to float
4
+ class Float
5
+ def add_percent_sign
6
+ return nil if self.nil?
7
+
8
+ self.to_s.concat('%')
9
+ end
10
+ end
@@ -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
- # outputs string where it replaces \n or \r with actual return
23
- def escaped_newline_to_newline
24
- self.gsub('\n', "\n").gsub('\r', "\n")
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
@@ -3,7 +3,7 @@
3
3
  module Render
4
4
  module Text
5
5
  module Helper
6
- VERSION = '0.3.2'
6
+ VERSION = '0.4.1'
7
7
  end
8
8
  end
9
9
  end
@@ -3,6 +3,7 @@
3
3
  require_relative 'helper/version'
4
4
  require_relative 'helper/string'
5
5
  require_relative 'helper/boolean'
6
+ require_relative 'helper/float'
6
7
 
7
8
  module Render
8
9
  module Text
@@ -0,0 +1,5 @@
1
+ module BooleanHelper
2
+ def to_yn:(capital_letter: bool) -> String
3
+ def to_yes_no:(casting: Symbol) -> String
4
+ def to_i: -> Integer
5
+ end
@@ -0,0 +1,3 @@
1
+ class Float
2
+ def add_percent_sign: -> String
3
+ end
@@ -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
@@ -0,0 +1,6 @@
1
+ class String
2
+ def escaped_newline_to_newline: -> String
3
+ def limit_print:(limit: Integer, more_indicator: String, indicator_length: Integer) -> String
4
+ def to_smart_array:(separator: String | nil) -> [String]
5
+ def to_titleize: -> String
6
+ end
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.3.2
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: 2024-12-26 00:00:00.000000000 Z
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.6.2
62
+ rubygems_version: 3.7.2
59
63
  specification_version: 4
60
64
  summary: Does some string manipulation
61
65
  test_files: []