lucky_case 0.2.2 → 0.2.3
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/README.md +8 -2
- data/lib/lucky_case/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: bfe36f3ecf272ce46d7350964f6396949e54b49544e2d4a886b27cba698acedd
|
4
|
+
data.tar.gz: 99e2745316e403bd0c1258bfc5db260da120b3215f224d38efee03a5bcc46392
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 704d45b0cd6df44c2097b467759a0a4ec58d42b0fdbeed78b3cf11f8012b68aae9fd9beb2bb23fa25224338d876e93daf1001b7616491665224c6ebe45dcdbd1
|
7
|
+
data.tar.gz: 60d487477cf8d5515ec135a370aaa97b78665ad6ec060f63a29e0190858ea7ddc5eb09dd1642d15da2ff3bc03c378878e41e2a228649bb646ecd5dbb70f901df
|
data/README.md
CHANGED
@@ -25,7 +25,7 @@ Useful when working with conventions, where class names, method names and file n
|
|
25
25
|
|
26
26
|
You can either use the static LuckyCase class with its method or optionally monkey patch the String class.
|
27
27
|
|
28
|
-
###
|
28
|
+
### Approach 1: Using the static class
|
29
29
|
```ruby
|
30
30
|
require 'lucky_case'
|
31
31
|
|
@@ -42,8 +42,10 @@ LuckyCase.upper_word_case('PascalToUpperWord') # => 'PASCAL TO UPPER WOR
|
|
42
42
|
LuckyCase.capital_word_case('snake_to_capital_word') # => 'Snake To Capital Word'
|
43
43
|
LuckyCase.sentence_case('snake_to_sentence_case') # => 'Snake to sentence case'
|
44
44
|
LuckyCase.mixed_case('example_snake_string') # => 'Example-snake_STRING'
|
45
|
+
|
45
46
|
# converter by type
|
46
47
|
LuckyCase.convert_case('some_snake', :pascal_case) # => 'SomeSnake'
|
48
|
+
|
47
49
|
# transformers
|
48
50
|
LuckyCase.lower_case('Some_FuckingShit') # => 'some_fuckingshit'
|
49
51
|
LuckyCase.upper_case('Some_FuckingShit') # => 'SOME_FUCKINGSHIT'
|
@@ -55,9 +57,11 @@ LuckyCase.constantize('SOME_CONSTANT') # => SomeConstant
|
|
55
57
|
LuckyCase.constantize('some/path_example/folder') # => Some::PathExample::Folder
|
56
58
|
LuckyCase.deconstantize(SomeConstant) # => 'some_constant'
|
57
59
|
LuckyCase.deconstantize(Some::PathExample::Folder, case_type: :camel_case) # => 'some/pathExample/folder'
|
60
|
+
|
58
61
|
# identifiers
|
59
62
|
LuckyCase.case('this_can_only_be_snake_case') # => :snake_case
|
60
63
|
LuckyCase.cases('validformultiple') # => [ :snake_case, :camel_case, :dash_case, :word_case ]
|
64
|
+
|
61
65
|
# checkers
|
62
66
|
LuckyCase.snake_case?('valid_snake_case') # => true
|
63
67
|
LuckyCase.upper_snake_case?('UPPER_SNAKE') # => true
|
@@ -81,7 +85,7 @@ LuckyCase.valid_case_string?('validString') # => true
|
|
81
85
|
LuckyCase.valid_case_string?('1nV4lid$tring') # => false
|
82
86
|
```
|
83
87
|
|
84
|
-
### Monkey patch the string class
|
88
|
+
### Approach 2: Monkey patch the string class
|
85
89
|
|
86
90
|
With monkey patching you can access the same methods (except deconstantize, valid_case_type?) of LuckyCase directly from strings.
|
87
91
|
Additionally they provide versions with exclamation mark for direct manipulation.
|
@@ -96,10 +100,12 @@ a = 'ExampleString'
|
|
96
100
|
a.pascal_case? # => true
|
97
101
|
a.snake_case # => 'example_string'
|
98
102
|
a # => 'ExampleString'
|
103
|
+
|
99
104
|
# string variable manipulation
|
100
105
|
a.snake_case! # => 'example_string'
|
101
106
|
a # => 'example_string'
|
102
107
|
...
|
108
|
+
|
103
109
|
# identifiers
|
104
110
|
# got a other method name here because 'case' might be to common and cause conflicts
|
105
111
|
b = 'example'
|
data/lib/lucky_case/version.rb
CHANGED