lite-ruby 1.0.29 → 1.0.30
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/CHANGELOG.md +4 -0
- data/Gemfile.lock +1 -1
- data/lib/lite/ruby/string.rb +12 -7
- data/lib/lite/ruby/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 497a85ac4bea67a37f713e049589a1825e1ea9c2cb157ad5b9aba5b89ed0c37e
|
4
|
+
data.tar.gz: 7f4747cdcff9975cec2d43cb929223bb26ca43939ab60a3dee46d378252fdabe
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4f63e2c228b2e4eb349a4b9c14187e906f3bb5803ea7188a352c4bbc6f82ac2867148b68acd92e8c5a758d9e57943f9410c72d380295953fa8e741b0734e3260
|
7
|
+
data.tar.gz: c1416d519e4ec7d8a3c0fad863145789cc55a262d293bacc9df6927ecc92d04b3464eee778dede669a33ecafdca6e2c4f51b725ffdc76735ec16c7a730447eac
|
data/CHANGELOG.md
CHANGED
data/Gemfile.lock
CHANGED
data/lib/lite/ruby/string.rb
CHANGED
@@ -163,8 +163,8 @@ if Lite::Ruby.configuration.monkey_patches.include?('string')
|
|
163
163
|
replace(headerize)
|
164
164
|
end
|
165
165
|
|
166
|
-
def humanize(
|
167
|
-
dup.humanize!(
|
166
|
+
def humanize(capitalize: true)
|
167
|
+
dup.humanize!(capitalize: capitalize)
|
168
168
|
end
|
169
169
|
|
170
170
|
def humanize!(capitalize: true)
|
@@ -530,8 +530,9 @@ if Lite::Ruby.configuration.monkey_patches.include?('string')
|
|
530
530
|
def truncate(truncate_at, options = {})
|
531
531
|
return dup unless length > truncate_at
|
532
532
|
|
533
|
-
seperator = options[:separator]
|
534
533
|
omission = options[:omission] || '...'
|
534
|
+
seperator = options[:separator]
|
535
|
+
|
535
536
|
size_with_room_for_omission = truncate_at - omission.length
|
536
537
|
|
537
538
|
stop = if seperator
|
@@ -543,13 +544,17 @@ if Lite::Ruby.configuration.monkey_patches.include?('string')
|
|
543
544
|
"#{self[0, stop]}#{omission}"
|
544
545
|
end
|
545
546
|
|
547
|
+
# rubocop:disable Layout/LineLength
|
546
548
|
def truncate_words(words_count, options = {})
|
547
|
-
|
548
|
-
|
549
|
-
|
549
|
+
omission = options[:omission] || '...'
|
550
|
+
seperator = options[:separator] || /\s+/
|
551
|
+
|
552
|
+
seperator = Regexp.escape(seperator.to_s) unless seperator.is_a(Regexp)
|
553
|
+
return self unless /\A((?:.+?#{seperator}){#{words_count - 1}}.+?)#{seperator}.*/m.match?(self)
|
550
554
|
|
551
|
-
"#{::Regexp.last_match(1)}#{
|
555
|
+
"#{::Regexp.last_match(1)}#{omission}"
|
552
556
|
end
|
557
|
+
# rubocop:enable Layout/LineLength
|
553
558
|
|
554
559
|
def underscore
|
555
560
|
dup.underscore!
|
data/lib/lite/ruby/version.rb
CHANGED