render-text-helper 0.2.0 → 0.3.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: cdefeb74f5cc8c0757071203881ea156d45e126c5006c04afbd02233d2aa6196
4
- data.tar.gz: 82aba1c3a82dfcbe9f1179a091a674243da9e255f7ebd5500eee919faec6a4c5
3
+ metadata.gz: e58ee7a37f97f1926b022eeacbdc250da3edd0d06f168089319a1340137eb7dc
4
+ data.tar.gz: ef6be5462f64aa6a9d2191245b5bba9c8028ba4364092499202ed5aeaf211a23
5
5
  SHA512:
6
- metadata.gz: f2864cad96f2ad569c8ddf5938f03407701393881f1927aabe6bca4121d2d0700482031543e2fff8fa619b56d6d3806503d6c5f77daf46e79f8e35be70399172
7
- data.tar.gz: 8edeb432377b5395aa56298f152298f423595bbc53061673211442a8bd12c24224035b80ede4b6abcbcac7fc67969e4183ac516ea2ef791c0bb6481e3ec15453
6
+ metadata.gz: 6278202b3b758d3aa1229a748e0eed12c45a127a3dd4ba9cad1a7793c04348f5d35cb5f484d4281910635716089c3f7a1fbe2a5387c26b9b3859895aa6e3edfb
7
+ data.tar.gz: 2e81e29d670ff5e158e35ca329989eef65bd3f26077cf3f84b863f2027b9154312cf8fed5c7ae35347c9aa338bfecec44ee2520d559fc7b42d2de8f8f1c10387
data/.rubocop.yml CHANGED
@@ -1,5 +1,6 @@
1
1
  AllCops:
2
- TargetRubyVersion: 2.6
2
+ NewCops: enable
3
+ TargetRubyVersion: 3.1
3
4
 
4
5
  Style/StringLiterals:
5
6
  Enabled: true
data/CHANGELOG.md CHANGED
@@ -1,5 +1,16 @@
1
1
  ## Changelog
2
2
 
3
+ ## [0.3.1] - 2023-11-3
4
+
5
+ - Added to_smart_array
6
+
7
+ ## [0.3.0] - 2022-08-18
8
+
9
+ - Added the params "more_indicator" to "limit_print"
10
+ - Added function: to_i to Boolean
11
+ - Updated RBS
12
+ - Added function
13
+
3
14
  ## [0.2.0] - 2022-08-17
4
15
 
5
16
  - to_yes_no function can now handle diffident casing
@@ -7,6 +18,6 @@
7
18
  ## [0.1.0] - 2022-08-14
8
19
 
9
20
  - Initial release
10
- - Added function: to_yn
11
- - Added function: to_yes_no
12
- - Added function: limit_print
21
+ - Added function: to_yn to Boolean
22
+ - Added function: to_yes_no to Boolean
23
+ - Added function: limit_print to String
data/Gemfile CHANGED
@@ -7,6 +7,6 @@ gemspec
7
7
 
8
8
  gem 'rake', '~> 13.0'
9
9
 
10
- gem 'rspec', '~> 3.0'
10
+ gem 'rspec', '~> 3.11'
11
11
 
12
- gem 'rubocop', '~> 1.21'
12
+ gem 'rubocop', '~> 1.5'
data/Gemfile.lock CHANGED
@@ -1,48 +1,52 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- render-text-helper (0.2.0)
4
+ render-text-helper (0.3.1)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
8
8
  specs:
9
9
  ast (2.4.2)
10
10
  diff-lcs (1.5.0)
11
- json (2.6.2)
12
- parallel (1.22.1)
13
- parser (3.1.2.1)
11
+ json (2.6.3)
12
+ language_server-protocol (3.17.0.3)
13
+ parallel (1.23.0)
14
+ parser (3.2.2.4)
14
15
  ast (~> 2.4.1)
16
+ racc
17
+ racc (1.7.2)
15
18
  rainbow (3.1.1)
16
- rake (13.0.6)
17
- regexp_parser (2.5.0)
18
- rexml (3.2.5)
19
- rspec (3.11.0)
20
- rspec-core (~> 3.11.0)
21
- rspec-expectations (~> 3.11.0)
22
- rspec-mocks (~> 3.11.0)
23
- rspec-core (3.11.0)
24
- rspec-support (~> 3.11.0)
25
- rspec-expectations (3.11.0)
19
+ rake (13.1.0)
20
+ regexp_parser (2.8.2)
21
+ rexml (3.2.6)
22
+ rspec (3.12.0)
23
+ rspec-core (~> 3.12.0)
24
+ rspec-expectations (~> 3.12.0)
25
+ rspec-mocks (~> 3.12.0)
26
+ rspec-core (3.12.2)
27
+ rspec-support (~> 3.12.0)
28
+ rspec-expectations (3.12.3)
26
29
  diff-lcs (>= 1.2.0, < 2.0)
27
- rspec-support (~> 3.11.0)
28
- rspec-mocks (3.11.1)
30
+ rspec-support (~> 3.12.0)
31
+ rspec-mocks (3.12.6)
29
32
  diff-lcs (>= 1.2.0, < 2.0)
30
- rspec-support (~> 3.11.0)
31
- rspec-support (3.11.0)
32
- rubocop (1.35.0)
33
+ rspec-support (~> 3.12.0)
34
+ rspec-support (3.12.1)
35
+ rubocop (1.57.2)
33
36
  json (~> 2.3)
37
+ language_server-protocol (>= 3.17.0)
34
38
  parallel (~> 1.10)
35
- parser (>= 3.1.2.1)
39
+ parser (>= 3.2.2.4)
36
40
  rainbow (>= 2.2.2, < 4.0)
37
41
  regexp_parser (>= 1.8, < 3.0)
38
42
  rexml (>= 3.2.5, < 4.0)
39
- rubocop-ast (>= 1.20.1, < 2.0)
43
+ rubocop-ast (>= 1.28.1, < 2.0)
40
44
  ruby-progressbar (~> 1.7)
41
- unicode-display_width (>= 1.4.0, < 3.0)
42
- rubocop-ast (1.21.0)
43
- parser (>= 3.1.1.0)
44
- ruby-progressbar (1.11.0)
45
- unicode-display_width (2.2.0)
45
+ unicode-display_width (>= 2.4.0, < 3.0)
46
+ rubocop-ast (1.30.0)
47
+ parser (>= 3.2.1.0)
48
+ ruby-progressbar (1.13.0)
49
+ unicode-display_width (2.5.0)
46
50
 
47
51
  PLATFORMS
48
52
  x86_64-linux
@@ -50,8 +54,8 @@ PLATFORMS
50
54
  DEPENDENCIES
51
55
  rake (~> 13.0)
52
56
  render-text-helper!
53
- rspec (~> 3.0)
54
- rubocop (~> 1.21)
57
+ rspec (~> 3.11)
58
+ rubocop (~> 1.5)
55
59
 
56
60
  BUNDLED WITH
57
- 2.3.20
61
+ 2.4.17
data/README.md CHANGED
@@ -17,8 +17,10 @@ If bundler is not being used to manage dependencies, install the gem by executin
17
17
  ### Limit Print
18
18
 
19
19
  This function makes sure that the string does not go over a specific given limit.
20
- It has two parameters "limit" which is defaulted to 32 and "more_indicator" which
21
- defaults to "."
20
+ It has three parameters.
21
+ "limit" which is defaulted to 32 and controls how far to show the characters.
22
+ "more_indicator" which defaults to "." and controls which character to use to indicate there are more.
23
+ "indicator_length" which defaults to 3 and controls how many times to show the more indicator.
22
24
 
23
25
  ```ruby
24
26
  'hello'.limit_print
@@ -27,11 +29,33 @@ defaults to "."
27
29
  'elephant'.limit_print(limit: 2)
28
30
  'el...'
29
31
 
30
- 'elephant'.limit_print(limit: 2, more_indicator: '')
32
+ 'elephant'.limit_print(limit: 2, indicator_length: 0)
31
33
  'el'
32
34
 
33
35
  'elephant'.limit_print(limit: 3, more_indicator: '_')
34
36
  'ele___'
37
+
38
+ 'elephant'.limit_print(limit: 4, more_indicator: '*', indicator_length: 2)
39
+ 'elep**'
40
+ ```
41
+
42
+ ### To Smart Array
43
+
44
+ Take a string and splits it to an array by ",", "|", space, or by a passed parameter.
45
+ It also strips whitespace.
46
+
47
+ ```ruby
48
+ 'cat, dog, matt'.to_smart_array
49
+ ['cat', 'dog', 'matt']
50
+
51
+ ' cat , dog, matt,pat '.to_smart_array
52
+ ['cat', 'dog', 'matt', 'pat']
53
+
54
+ ' cat dog matt pat '.to_smart_array
55
+ ['cat', 'dog', 'matt', 'pat']
56
+
57
+ ' cat # dog# matt#pat '.to_smart_array('#')
58
+ ['cat', 'dog', 'matt', 'pat']
35
59
  ```
36
60
 
37
61
  ### to yes no
@@ -72,6 +96,10 @@ false.to_yn(capital_letter: false)
72
96
  'n'
73
97
  ```
74
98
 
99
+ ### to_i
100
+
101
+ Returns 1 for true and 0 for false on a boolean object.
102
+
75
103
  ## Contributing
76
104
 
77
105
  Bug reports and pull requests are welcome on GitHub at https://github.com/SaimonL/render-text-helper
@@ -18,6 +18,10 @@ module BooleanHelper
18
18
  'no'.send(casting.to_sym)
19
19
  end
20
20
  end
21
+
22
+ def to_i
23
+ self ? 1 : 0
24
+ end
21
25
  end
22
26
 
23
27
  class TrueClass
@@ -3,9 +3,19 @@
3
3
  # Adds function to existing String class
4
4
  class String
5
5
  # output the string giving the limit. It does not touch the string
6
- def limit_print(limit: 32, more_indicator: '.')
6
+ def limit_print(limit: 32, more_indicator: '.', indicator_length: 3)
7
7
  return self if size < limit
8
8
 
9
- [self[0...limit], more_indicator, more_indicator, more_indicator].join
9
+ [self[0...limit], (more_indicator * indicator_length)].join
10
+ end
11
+
12
+ # outputs an array
13
+ def to_smart_array(separator = nil)
14
+ return [] if nil?
15
+
16
+ return split(separator).map(&:strip) unless separator.nil?
17
+ return split(',').map(&:strip) if include?(',')
18
+
19
+ split.map(&:strip)
10
20
  end
11
21
  end
@@ -3,7 +3,7 @@
3
3
  module Render
4
4
  module Text
5
5
  module Helper
6
- VERSION = '0.2.0'
6
+ VERSION = '0.3.1'
7
7
  end
8
8
  end
9
9
  end
@@ -8,11 +8,11 @@ Gem::Specification.new do |spec|
8
8
  spec.authors = ['Saimon Lovell']
9
9
  spec.email = ['staysynchronize@gmail.com']
10
10
 
11
- spec.summary = 'Does some string malnutrition'
12
- spec.description = 'Limit the render text, convert boolean to text etc'
11
+ spec.summary = 'Does some string manipulation'
12
+ spec.description = 'Add some more functionality to string and booleans'
13
13
  spec.homepage = 'https://github.com/SaimonL/render-text-helper'
14
14
  spec.license = 'MIT'
15
- spec.required_ruby_version = '>= 2.6.0'
15
+ spec.required_ruby_version = '>= 3.1'
16
16
 
17
17
  spec.metadata['allowed_push_host'] = 'https://rubygems.org'
18
18
 
@@ -28,4 +28,5 @@ Gem::Specification.new do |spec|
28
28
  spec.bindir = 'exe'
29
29
  spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
30
30
  spec.require_paths = ['lib']
31
+ spec.metadata['rubygems_mfa_required'] = 'true'
31
32
  end
@@ -4,13 +4,17 @@ module Render
4
4
  class TrueClass
5
5
  def to_yn: (capital_letter: bool) -> String
6
6
 
7
- def to_yes_no: (capital_letter: bool) -> String
7
+ def to_yes_no: (casting: Symbol) -> String
8
+
9
+ def to_i: -> Integer
8
10
  end
9
11
 
10
12
  class FalseClass
11
13
  def to_yn: (capital_letter: bool) -> String
12
14
 
13
- def to_yes_no: (capital_letter: bool) -> String
15
+ def to_yes_no: (casting: Symbol) -> String
16
+
17
+ def to_i: -> Integer
14
18
  end
15
19
  end
16
20
  end
@@ -2,7 +2,7 @@ module Render
2
2
  module Text
3
3
  module Helper
4
4
  class String
5
- def limit_print: (limit: Integer, more_indicator: String) -> String
5
+ def limit_print: (limit: Integer, more_indicator: String, indicator_length: Integer) -> String
6
6
  end
7
7
  end
8
8
  end
metadata CHANGED
@@ -1,16 +1,16 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: render-text-helper
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Saimon Lovell
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-08-17 00:00:00.000000000 Z
11
+ date: 2023-11-03 00:00:00.000000000 Z
12
12
  dependencies: []
13
- description: Limit the render text, convert boolean to text etc
13
+ description: Add some more functionality to string and booleans
14
14
  email:
15
15
  - staysynchronize@gmail.com
16
16
  executables: []
@@ -41,6 +41,7 @@ metadata:
41
41
  homepage_uri: https://github.com/SaimonL/render-text-helper
42
42
  source_code_uri: https://github.com/SaimonL/render-text-helper
43
43
  changelog_uri: https://github.com/SaimonL/render-text-helper/blob/master/CHANGELOG.md
44
+ rubygems_mfa_required: 'true'
44
45
  post_install_message:
45
46
  rdoc_options: []
46
47
  require_paths:
@@ -49,15 +50,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
49
50
  requirements:
50
51
  - - ">="
51
52
  - !ruby/object:Gem::Version
52
- version: 2.6.0
53
+ version: '3.1'
53
54
  required_rubygems_version: !ruby/object:Gem::Requirement
54
55
  requirements:
55
56
  - - ">="
56
57
  - !ruby/object:Gem::Version
57
58
  version: '0'
58
59
  requirements: []
59
- rubygems_version: 3.3.20
60
+ rubygems_version: 3.4.21
60
61
  signing_key:
61
62
  specification_version: 4
62
- summary: Does some string malnutrition
63
+ summary: Does some string manipulation
63
64
  test_files: []