lucky_case 0.2.4 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/lucky_case.rb +20 -8
- data/lib/lucky_case/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c7c4dc263bc163972145a81df6aee8c9f95326618965c5fae6f499be6d90aad7
|
4
|
+
data.tar.gz: 28397c3898961a0651a518ecfcf22750f54646433b032cb1a61148e0953bdea8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3bee15287a4859b58818ba57c602afe70623c8020177b6af654f08059325f64fc03cce898d7ae97d7d33a6acdf9ee81afd47a5251049f05e25bffb51125a4bf6
|
7
|
+
data.tar.gz: 68ffb0cc620c65ce3bca6f0ec5c14d582ad01cab8477be6afdfafa67728888989b15f28bc851c409c622f86fd0aab2cbc5520397b221b3845fdd2589b6bd8214
|
data/lib/lucky_case.rb
CHANGED
@@ -120,7 +120,7 @@ module LuckyCase
|
|
120
120
|
def self.valid_case_string?(string)
|
121
121
|
self.case(string) != nil
|
122
122
|
end
|
123
|
-
|
123
|
+
|
124
124
|
#----------------------------------------------------------------------------------------------------
|
125
125
|
# UPPER CASE
|
126
126
|
#----------------------------------------------------------------------------------------------------
|
@@ -616,7 +616,9 @@ module LuckyCase
|
|
616
616
|
#----------------------------------------------------------------------------------------------------
|
617
617
|
|
618
618
|
# Convert the given string from any case
|
619
|
-
# into mixed case
|
619
|
+
# into mixed case.
|
620
|
+
#
|
621
|
+
# The new string is ensured to be different from the input.
|
620
622
|
#
|
621
623
|
# @example conversion
|
622
624
|
# 'this-isAnExample_string' => 'This-Is_anExample-string'
|
@@ -626,9 +628,14 @@ module LuckyCase
|
|
626
628
|
# @return [String]
|
627
629
|
def self.mixed_case(string, preserve_prefixed_underscores: true)
|
628
630
|
a = split_case_string string
|
629
|
-
converted =
|
630
|
-
|
631
|
-
converted
|
631
|
+
converted = nil
|
632
|
+
loop do
|
633
|
+
converted = ''
|
634
|
+
a.each do |part|
|
635
|
+
converted += self.send CASES.keys.sample, part
|
636
|
+
end
|
637
|
+
converted = self.send CASES.keys.sample, converted
|
638
|
+
break if converted != string && underscores_at_start(string) + converted != string
|
632
639
|
end
|
633
640
|
if preserve_prefixed_underscores
|
634
641
|
underscores_at_start(string) + converted
|
@@ -641,8 +648,13 @@ module LuckyCase
|
|
641
648
|
#
|
642
649
|
# @param [String] string to check
|
643
650
|
# @return [Boolean]
|
644
|
-
def self.mixed_case?(string)
|
645
|
-
|
651
|
+
def self.mixed_case?(string, allow_prefixed_underscores: true)
|
652
|
+
s = if allow_prefixed_underscores
|
653
|
+
cut_underscores_at_start string
|
654
|
+
else
|
655
|
+
string
|
656
|
+
end
|
657
|
+
_case_match? s, :mixed_case
|
646
658
|
end
|
647
659
|
|
648
660
|
#----------------------------------------------------------------------------------------------------
|
@@ -750,7 +762,7 @@ module LuckyCase
|
|
750
762
|
#----------------------------------------------------------------------------------------------------
|
751
763
|
# HELPERS
|
752
764
|
#----------------------------------------------------------------------------------------------------
|
753
|
-
|
765
|
+
|
754
766
|
# Return string without underscores at the start
|
755
767
|
#
|
756
768
|
# @param [String] string
|
data/lib/lucky_case/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: lucky_case
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Matthäus J. N. Beyrle
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-11-
|
11
|
+
date: 2020-11-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|