render-text-helper 0.4.0 → 0.4.2

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: 976a5049554652256d97459fad88c7aa9df80eb039ce8d1afe886b08c54282f2
4
- data.tar.gz: 969f89a11f8a039984cc99ee6838454b3af07dd12fbe4335269c9a618dadd706
3
+ metadata.gz: 1953be6530d232e70bdf8669f1c222a4bfd71d472098b1b00c04ecaaa1a6d59e
4
+ data.tar.gz: 7d471ee6d810d1f16943d6c26374d85d72e477e15f35d6a4ec7888422cdb8b8f
5
5
  SHA512:
6
- metadata.gz: 047de4cedc9dac79094b1eb50739e2081a9d6f61df68bbe142138c39516efce06bbf487e1d8ad8b4e4dce3787b3c4415e75b92c69375be56fc16670da49ba844
7
- data.tar.gz: a2bc1a496320d5b525d414aae15bcfa7cb4ab09c574babd5c87db6b340594700880cc3e7fdf61e59e5d3e4e32ebdfe3f674bd2d97c4c4ccbb4d07a911fa240dc
6
+ metadata.gz: 1e44425ae9e4139360b0f280bb8d82c72df2facc44c83bcc110a8b97bda48f8c9587d53e392b230d820f3af1630cd8b23597dc0ca970ced0e58c1fc020e7ba6c
7
+ data.tar.gz: 6f5b67dcc4339dbef74220aea965e2676dd771266d5b8e4f78c716f97b98a4e8f41da3c0f2930736c99faa4853b4db534498e01297a38f3fd4561a952dc0185f
data/CHANGELOG.md CHANGED
@@ -1,5 +1,13 @@
1
1
  # Changelog
2
2
 
3
+ ## [0.4.2] - 2025-20-11
4
+
5
+ - Added to_letters_and_numbers method to string that removes all but letters and numbers
6
+
7
+ ## [0.4.1] - 2025-14-10
8
+
9
+ - Added add_percent_sign method that adds percentage to float
10
+
3
11
  ## [0.4.0] - 2025-17-02
4
12
 
5
13
  - Added to_titleize
data/Gemfile.lock CHANGED
@@ -1,38 +1,39 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- render-text-helper (0.4.0)
4
+ render-text-helper (0.4.2)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
8
8
  specs:
9
- ast (2.4.2)
10
- diff-lcs (1.6.0)
11
- json (2.10.1)
12
- language_server-protocol (3.17.0.4)
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
13
  lint_roller (1.1.0)
14
- parallel (1.26.3)
15
- parser (3.3.7.1)
14
+ parallel (1.27.0)
15
+ parser (3.3.9.0)
16
16
  ast (~> 2.4.1)
17
17
  racc
18
+ prism (1.5.2)
18
19
  racc (1.8.1)
19
20
  rainbow (3.1.1)
20
- rake (13.2.1)
21
- regexp_parser (2.10.0)
22
- rspec (3.13.0)
21
+ rake (13.3.0)
22
+ regexp_parser (2.11.3)
23
+ rspec (3.13.1)
23
24
  rspec-core (~> 3.13.0)
24
25
  rspec-expectations (~> 3.13.0)
25
26
  rspec-mocks (~> 3.13.0)
26
- rspec-core (3.13.3)
27
+ rspec-core (3.13.5)
27
28
  rspec-support (~> 3.13.0)
28
- rspec-expectations (3.13.3)
29
+ rspec-expectations (3.13.5)
29
30
  diff-lcs (>= 1.2.0, < 2.0)
30
31
  rspec-support (~> 3.13.0)
31
- rspec-mocks (3.13.2)
32
+ rspec-mocks (3.13.6)
32
33
  diff-lcs (>= 1.2.0, < 2.0)
33
34
  rspec-support (~> 3.13.0)
34
- rspec-support (3.13.2)
35
- rubocop (1.72.1)
35
+ rspec-support (3.13.6)
36
+ rubocop (1.81.1)
36
37
  json (~> 2.3)
37
38
  language_server-protocol (~> 3.17.0.2)
38
39
  lint_roller (~> 1.1.0)
@@ -40,17 +41,19 @@ GEM
40
41
  parser (>= 3.3.0.2)
41
42
  rainbow (>= 2.2.2, < 4.0)
42
43
  regexp_parser (>= 2.9.3, < 3.0)
43
- rubocop-ast (>= 1.38.0, < 2.0)
44
+ rubocop-ast (>= 1.47.1, < 2.0)
44
45
  ruby-progressbar (~> 1.7)
45
46
  unicode-display_width (>= 2.4.0, < 4.0)
46
- rubocop-ast (1.38.0)
47
- parser (>= 3.3.1.0)
47
+ rubocop-ast (1.47.1)
48
+ parser (>= 3.3.7.2)
49
+ prism (~> 1.4)
48
50
  ruby-progressbar (1.13.0)
49
- unicode-display_width (3.1.4)
50
- unicode-emoji (~> 4.0, >= 4.0.4)
51
- unicode-emoji (4.0.4)
51
+ unicode-display_width (3.2.0)
52
+ unicode-emoji (~> 4.1)
53
+ unicode-emoji (4.1.0)
52
54
 
53
55
  PLATFORMS
56
+ arm64-darwin-24
54
57
  x86_64-linux
55
58
 
56
59
  DEPENDENCIES
@@ -60,4 +63,4 @@ DEPENDENCIES
60
63
  rubocop (~> 1.5)
61
64
 
62
65
  BUNDLED WITH
63
- 2.6.3
66
+ 2.7.2
data/README.md CHANGED
@@ -76,6 +76,21 @@ Titleize for none rails project. It also removes unnecessary white spaces and co
76
76
  "Hello World!"
77
77
  ```
78
78
 
79
+ ### To Letters And Numbers
80
+
81
+ Strips all characters instead of letters, numbers and space.
82
+ It also trims spaces at the beginning and the end.
83
+ You have the option to disallow spaces as well.
84
+ This is good for common input like name, address, other standard writings.
85
+
86
+ ```ruby
87
+ ' A1!2@3#4$ 5%6^S7&8*9 F(0)-_=+Z|/?.>rlq<,*/ '.to_letters_and_numbers
88
+ "A1234 56S789 F0Zrlq"
89
+
90
+ ' A1!2@3#4$ 5%6^S7&8*9 F(0)-_=+Z|/?.>rlq<,*/ '.to_letters_and_numbers(allow_space: false)
91
+ "A123456S789F0Zrlq"
92
+ ```
93
+
79
94
  ### to yes no
80
95
 
81
96
  This function returns a string from a boolean to yes or no.
@@ -118,6 +133,15 @@ false.to_yn(capital_letter: false)
118
133
 
119
134
  Returns 1 for true and 0 for false on a boolean object.
120
135
 
136
+ ### add_percent_sign
137
+
138
+ It takes float and adds percentage to it.
139
+
140
+ ```ruby
141
+ 25.75.add_percent_sign
142
+ '25.75%'
143
+ ```
144
+
121
145
  ## Contributing
122
146
 
123
147
  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 nil?
7
+
8
+ to_s.concat('%')
9
+ end
10
+ end
@@ -30,4 +30,14 @@ class String
30
30
 
31
31
  gsub('_', ' ').strip.split.map(&:capitalize).join(' ')
32
32
  end
33
+
34
+ def to_letters_and_numbers(allow_space: true)
35
+ return '' if self == ''
36
+
37
+ if allow_space
38
+ gsub(/[^a-zA-Z0-9 ]/, '').strip
39
+ else
40
+ gsub(/[^a-zA-Z0-9]/, '').strip
41
+ end
42
+ end
33
43
  end
@@ -3,7 +3,7 @@
3
3
  module Render
4
4
  module Text
5
5
  module Helper
6
- VERSION = '0.4.0'
6
+ VERSION = '0.4.2'
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,32 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'lib/render/text/helper/version'
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = 'render-text-helper'
7
+ spec.version = Render::Text::Helper::VERSION
8
+ spec.authors = ['Saimon Lovell']
9
+ spec.email = ['staysynchronize@gmail.com']
10
+
11
+ spec.summary = 'Does some string manipulation'
12
+ spec.description = 'Add some more functionality to string and booleans'
13
+ spec.homepage = 'https://github.com/SaimonL/render-text-helper'
14
+ spec.license = 'MIT'
15
+ spec.required_ruby_version = '>= 3.1'
16
+
17
+ spec.metadata['allowed_push_host'] = 'https://rubygems.org'
18
+
19
+ spec.metadata['homepage_uri'] = spec.homepage
20
+ spec.metadata['source_code_uri'] = 'https://github.com/SaimonL/render-text-helper'
21
+ spec.metadata['changelog_uri'] = 'https://github.com/SaimonL/render-text-helper/blob/master/CHANGELOG.md'
22
+
23
+ spec.files = Dir.chdir(__dir__) do
24
+ `git ls-files -z`.split("\x0").reject do |f|
25
+ (f == __FILE__) || f.match(%r{\A(?:(?:bin|test|spec|features)/|\.(?:git|travis|circleci)|appveyor)})
26
+ end
27
+ end
28
+ spec.bindir = 'exe'
29
+ spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
30
+ spec.require_paths = ['lib']
31
+ spec.metadata['rubygems_mfa_required'] = 'true'
32
+ end
@@ -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,8 @@
1
+ class String
2
+ def escaped_newline_to_newline: -> String
3
+ def limit_print:(limit: Integer, more_indicator: String, indicator_length: Integer) -> String
4
+
5
+ def to_letters_and_numbers:(allow_space: bool) -> String
6
+ def to_smart_array:(separator: String | nil) -> [String]
7
+ def to_titleize: -> String
8
+ 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.4.0
4
+ version: 0.4.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Saimon Lovell
8
8
  bindir: exe
9
9
  cert_chain: []
10
- date: 2025-02-17 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,11 +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
32
+ - render-text-helper.gemspec
33
+ - sig/boolean_helper.rbs
31
34
  - sig/render/text/helper.rbs
32
35
  - sig/render/text/helper/boolean.rbs
36
+ - sig/render/text/helper/float.rbs
33
37
  - sig/render/text/helper/string.rbs
38
+ - sig/string.rbs
34
39
  homepage: https://github.com/SaimonL/render-text-helper
35
40
  licenses:
36
41
  - MIT
@@ -54,7 +59,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
54
59
  - !ruby/object:Gem::Version
55
60
  version: '0'
56
61
  requirements: []
57
- rubygems_version: 3.6.3
62
+ rubygems_version: 3.7.2
58
63
  specification_version: 4
59
64
  summary: Does some string manipulation
60
65
  test_files: []