lucky_case 0.2.1 → 0.2.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 +4 -4
- data/README.md +14 -2
- data/lib/lucky_case.rb +55 -35
- data/lib/lucky_case/string.rb +40 -33
- 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: 8a436c523f2a63b7411b894d146a89725c153dfd3970f3f22d49be49dbd35882
         | 
| 4 | 
            +
              data.tar.gz: 3b3faaac0ec66f6f47e82b3a802cdd2ce71b666a70ae01f6fea5c4e344303b37
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: 146fee7851d89d9e1dacba0dac0012cf223285fb94e2d723270fe0111af0c4b366714bb8ffdc2836387b48a1046421cf45bdaca5c3822409f800b602554a1afd
         | 
| 7 | 
            +
              data.tar.gz: a5c74f03bb733a25a3a246bdebdc27c04c1ee187bc973356e9893f678c50d4ef72c5fb149633319e0bc5649f133502b22aa224b6c64947363edcd9c0da8ae4b6
         | 
    
        data/README.md
    CHANGED
    
    | @@ -55,7 +55,7 @@ LuckyCase.constantize('SOME_CONSTANT')                 # => SomeConstant | |
| 55 55 | 
             
            LuckyCase.constantize('some/path_example/folder')      # => Some::PathExample::Folder
         | 
| 56 56 | 
             
            LuckyCase.deconstantize(SomeConstant)                  # => 'some_constant'
         | 
| 57 57 | 
             
            LuckyCase.deconstantize(Some::PathExample::Folder, case_type: :camel_case)     # => 'some/pathExample/folder'
         | 
| 58 | 
            -
            #  | 
| 58 | 
            +
            # identifiers
         | 
| 59 59 | 
             
            LuckyCase.case('this_can_only_be_snake_case')          # => :snake_case
         | 
| 60 60 | 
             
            LuckyCase.cases('validformultiple')                    # => [ :snake_case, :camel_case, :dash_case, :word_case ]
         | 
| 61 61 | 
             
            # checkers
         | 
| @@ -75,13 +75,19 @@ LuckyCase.upper_case?('UPPER50984')                    # => true | |
| 75 75 | 
             
            LuckyCase.lower_case?('lower_cheese')                  # => true
         | 
| 76 76 | 
             
            LuckyCase.capital?('Some')                             # => true
         | 
| 77 77 | 
             
            LuckyCase.capitalized?('some')                         # => false
         | 
| 78 | 
            +
            LuckyCase.valid_case_type?(:snake_case)                # => true
         | 
| 79 | 
            +
            LuckyCase.valid_case_type?(:apple_case)                # => false
         | 
| 80 | 
            +
            LuckyCase.valid_case_string?('validString')            # => true
         | 
| 81 | 
            +
            LuckyCase.valid_case_string?('1nV4lid$tring')          # => false
         | 
| 78 82 | 
             
            ```
         | 
| 79 83 |  | 
| 80 84 | 
             
            ### Monkey patch the string class
         | 
| 81 85 |  | 
| 82 | 
            -
            With monkey patching you can access the same methods (except deconstantize) of LuckyCase directly from strings.
         | 
| 86 | 
            +
            With monkey patching you can access the same methods (except deconstantize, valid_case_type?) of LuckyCase directly from strings.
         | 
| 83 87 | 
             
            Additionally they provide versions with exclamation mark for direct manipulation.
         | 
| 84 88 |  | 
| 89 | 
            +
            Because the method #case is so general and could lead to conflicts, it is called #letter_case here.
         | 
| 90 | 
            +
             | 
| 85 91 | 
             
            ```ruby
         | 
| 86 92 | 
             
            require 'lucky_case/string'
         | 
| 87 93 |  | 
| @@ -93,6 +99,12 @@ a                                       # => 'ExampleString' | |
| 93 99 | 
             
            # string variable manipulation
         | 
| 94 100 | 
             
            a.snake_case!                           # => 'example_string'
         | 
| 95 101 | 
             
            a                                       # => 'example_string'
         | 
| 102 | 
            +
            ...
         | 
| 103 | 
            +
            # identifiers
         | 
| 104 | 
            +
            # got a other method name here because 'case' might be to common and cause conflicts
         | 
| 105 | 
            +
            b = 'example'
         | 
| 106 | 
            +
            b.letter_case                           # => :snake_case
         | 
| 107 | 
            +
            b.letter_cases                          # => [ :snake_case, :camel_case, :dash_case, :word_case ]
         | 
| 96 108 | 
             
            ```
         | 
| 97 109 |  | 
| 98 110 |  | 
    
        data/lib/lucky_case.rb
    CHANGED
    
    | @@ -22,7 +22,7 @@ module LuckyCase | |
| 22 22 | 
             
                  upper_word_case: /^[[:upper:]]{1}[[:upper:] 0-9]+$/,
         | 
| 23 23 | 
             
                  capital_word_case: /^([[:upper:]][[:lower:]0-9]*\ |[0-9]+\ )*([[:upper:]][[:lower:]0-9]*)$/,
         | 
| 24 24 | 
             
                  sentence_case: /^[[:upper:]]{1}[[:lower:] 0-9]+$/,
         | 
| 25 | 
            -
                  mixed_case: /^[[:upper:][:lower:]][[:upper:][:lower:]_\-0-9]*$/,
         | 
| 25 | 
            +
                  mixed_case: /^[[:upper:][:lower:]][[:upper:][:lower:]_\-0-9 ]*$/,
         | 
| 26 26 | 
             
              }
         | 
| 27 27 |  | 
| 28 28 | 
             
              FORMATS = {
         | 
| @@ -101,11 +101,31 @@ module LuckyCase | |
| 101 101 | 
             
                raise InvalidCaseError.new error_message
         | 
| 102 102 | 
             
              end
         | 
| 103 103 |  | 
| 104 | 
            +
              # Check if given case type is a valid case type
         | 
| 105 | 
            +
              # 
         | 
| 106 | 
            +
              # @param [Symbol, String] case_type
         | 
| 107 | 
            +
              # @return [Boolean]
         | 
| 108 | 
            +
              def self.valid_case_type?(case_type)
         | 
| 109 | 
            +
                if CASES.keys.include? case_type.to_sym
         | 
| 110 | 
            +
                  true
         | 
| 111 | 
            +
                else
         | 
| 112 | 
            +
                  false
         | 
| 113 | 
            +
                end
         | 
| 114 | 
            +
              end
         | 
| 115 | 
            +
             | 
| 116 | 
            +
              # Check if the string matches any of the available cases
         | 
| 117 | 
            +
              # 
         | 
| 118 | 
            +
              # @param [String] case_type
         | 
| 119 | 
            +
              # @return [Boolean]
         | 
| 120 | 
            +
              def self.valid_case_string?(string)
         | 
| 121 | 
            +
                self.case(string) != nil
         | 
| 122 | 
            +
              end
         | 
| 123 | 
            +
              
         | 
| 104 124 | 
             
              #----------------------------------------------------------------------------------------------------
         | 
| 105 125 | 
             
              # UPPER CASE
         | 
| 106 126 | 
             
              #----------------------------------------------------------------------------------------------------
         | 
| 107 127 |  | 
| 108 | 
            -
              #  | 
| 128 | 
            +
              # Convert all characters inside the string
         | 
| 109 129 | 
             
              # into upper case
         | 
| 110 130 | 
             
              #
         | 
| 111 131 | 
             
              # @example conversion
         | 
| @@ -117,7 +137,7 @@ module LuckyCase | |
| 117 137 | 
             
                string.upcase
         | 
| 118 138 | 
             
              end
         | 
| 119 139 |  | 
| 120 | 
            -
              #  | 
| 140 | 
            +
              # Check if all characters inside the string are upper case
         | 
| 121 141 | 
             
              #
         | 
| 122 142 | 
             
              # @param [String] string to check
         | 
| 123 143 | 
             
              # @return [Boolean]
         | 
| @@ -129,7 +149,7 @@ module LuckyCase | |
| 129 149 | 
             
              # LOWER CASE
         | 
| 130 150 | 
             
              #----------------------------------------------------------------------------------------------------
         | 
| 131 151 |  | 
| 132 | 
            -
              #  | 
| 152 | 
            +
              # Convert all characters inside the string
         | 
| 133 153 | 
             
              # into lower case
         | 
| 134 154 | 
             
              #
         | 
| 135 155 | 
             
              # @example conversion
         | 
| @@ -141,7 +161,7 @@ module LuckyCase | |
| 141 161 | 
             
                string.downcase
         | 
| 142 162 | 
             
              end
         | 
| 143 163 |  | 
| 144 | 
            -
              #  | 
| 164 | 
            +
              # Check if all characters inside the string are lower case
         | 
| 145 165 | 
             
              #
         | 
| 146 166 | 
             
              # @param [String] string to check
         | 
| 147 167 | 
             
              # @return [Boolean]
         | 
| @@ -153,7 +173,7 @@ module LuckyCase | |
| 153 173 | 
             
              # SNAKE CASE
         | 
| 154 174 | 
             
              #----------------------------------------------------------------------------------------------------
         | 
| 155 175 |  | 
| 156 | 
            -
              #  | 
| 176 | 
            +
              # Convert the given string from any case
         | 
| 157 177 | 
             
              # into snake case
         | 
| 158 178 | 
             
              #
         | 
| 159 179 | 
             
              # @example conversion
         | 
| @@ -172,7 +192,7 @@ module LuckyCase | |
| 172 192 | 
             
                end
         | 
| 173 193 | 
             
              end
         | 
| 174 194 |  | 
| 175 | 
            -
              #  | 
| 195 | 
            +
              # Check if the string is snake case
         | 
| 176 196 | 
             
              #
         | 
| 177 197 | 
             
              # @param [String] string to check
         | 
| 178 198 | 
             
              # @param [Boolean] allow_prefixed_underscores
         | 
| @@ -186,7 +206,7 @@ module LuckyCase | |
| 186 206 | 
             
                _case_match? s, :snake_case
         | 
| 187 207 | 
             
              end
         | 
| 188 208 |  | 
| 189 | 
            -
              #  | 
| 209 | 
            +
              # Convert the given string from any case
         | 
| 190 210 | 
             
              # into upper snake case
         | 
| 191 211 | 
             
              #
         | 
| 192 212 | 
             
              # @example conversion
         | 
| @@ -205,7 +225,7 @@ module LuckyCase | |
| 205 225 | 
             
                end
         | 
| 206 226 | 
             
              end
         | 
| 207 227 |  | 
| 208 | 
            -
              #  | 
| 228 | 
            +
              # Check if the string is upper snake case
         | 
| 209 229 | 
             
              #
         | 
| 210 230 | 
             
              # @param [String] string to check
         | 
| 211 231 | 
             
              # @param [Boolean] allow_prefixed_underscores
         | 
| @@ -223,7 +243,7 @@ module LuckyCase | |
| 223 243 | 
             
              # PASCAL CASE
         | 
| 224 244 | 
             
              #----------------------------------------------------------------------------------------------------
         | 
| 225 245 |  | 
| 226 | 
            -
              #  | 
| 246 | 
            +
              # Convert the given string from any case
         | 
| 227 247 | 
             
              # into pascal case
         | 
| 228 248 | 
             
              #
         | 
| 229 249 | 
             
              # @example conversion
         | 
| @@ -242,7 +262,7 @@ module LuckyCase | |
| 242 262 | 
             
                end
         | 
| 243 263 | 
             
              end
         | 
| 244 264 |  | 
| 245 | 
            -
              #  | 
| 265 | 
            +
              # Check if the string is upper pascal case
         | 
| 246 266 | 
             
              #
         | 
| 247 267 | 
             
              # @param [String] string to check
         | 
| 248 268 | 
             
              # @param [Boolean] allow_prefixed_underscores
         | 
| @@ -260,7 +280,7 @@ module LuckyCase | |
| 260 280 | 
             
              # CAMEL CASE
         | 
| 261 281 | 
             
              #----------------------------------------------------------------------------------------------------
         | 
| 262 282 |  | 
| 263 | 
            -
              #  | 
| 283 | 
            +
              # Convert the given string from any case
         | 
| 264 284 | 
             
              # into camel case
         | 
| 265 285 | 
             
              #
         | 
| 266 286 | 
             
              # @example conversion
         | 
| @@ -279,7 +299,7 @@ module LuckyCase | |
| 279 299 | 
             
                end
         | 
| 280 300 | 
             
              end
         | 
| 281 301 |  | 
| 282 | 
            -
              #  | 
| 302 | 
            +
              # Check if the string is camel case
         | 
| 283 303 | 
             
              #
         | 
| 284 304 | 
             
              # @param [String] string to check
         | 
| 285 305 | 
             
              # @param [Boolean] allow_prefixed_underscores
         | 
| @@ -297,7 +317,7 @@ module LuckyCase | |
| 297 317 | 
             
              # DASH CASE
         | 
| 298 318 | 
             
              #----------------------------------------------------------------------------------------------------
         | 
| 299 319 |  | 
| 300 | 
            -
              #  | 
| 320 | 
            +
              # Convert the given string from any case
         | 
| 301 321 | 
             
              # into dash case
         | 
| 302 322 | 
             
              #
         | 
| 303 323 | 
             
              # @example conversion
         | 
| @@ -316,7 +336,7 @@ module LuckyCase | |
| 316 336 | 
             
                end
         | 
| 317 337 | 
             
              end
         | 
| 318 338 |  | 
| 319 | 
            -
              #  | 
| 339 | 
            +
              # Check if the string is dash case
         | 
| 320 340 | 
             
              #
         | 
| 321 341 | 
             
              # @param [String] string to check
         | 
| 322 342 | 
             
              # @param [Boolean] allow_prefixed_underscores
         | 
| @@ -330,7 +350,7 @@ module LuckyCase | |
| 330 350 | 
             
                _case_match? s, :dash_case
         | 
| 331 351 | 
             
              end
         | 
| 332 352 |  | 
| 333 | 
            -
              #  | 
| 353 | 
            +
              # Convert the given string from any case
         | 
| 334 354 | 
             
              # into upper dash case
         | 
| 335 355 | 
             
              #
         | 
| 336 356 | 
             
              # @example conversion
         | 
| @@ -344,7 +364,7 @@ module LuckyCase | |
| 344 364 | 
             
                upper_case s
         | 
| 345 365 | 
             
              end
         | 
| 346 366 |  | 
| 347 | 
            -
              #  | 
| 367 | 
            +
              # Check if the string is upper dash case
         | 
| 348 368 | 
             
              #
         | 
| 349 369 | 
             
              # @param [String] string to check
         | 
| 350 370 | 
             
              # @param [Boolean] allow_prefixed_underscores
         | 
| @@ -362,7 +382,7 @@ module LuckyCase | |
| 362 382 | 
             
              # TRAIN CASE
         | 
| 363 383 | 
             
              #----------------------------------------------------------------------------------------------------
         | 
| 364 384 |  | 
| 365 | 
            -
              #  | 
| 385 | 
            +
              # Convert the given string from any case
         | 
| 366 386 | 
             
              # into train case
         | 
| 367 387 | 
             
              #
         | 
| 368 388 | 
             
              # @example conversion
         | 
| @@ -381,7 +401,7 @@ module LuckyCase | |
| 381 401 | 
             
                end
         | 
| 382 402 | 
             
              end
         | 
| 383 403 |  | 
| 384 | 
            -
              #  | 
| 404 | 
            +
              # Check if the string is train case
         | 
| 385 405 | 
             
              #
         | 
| 386 406 | 
             
              # @param [String] string to check
         | 
| 387 407 | 
             
              # @param [Boolean] allow_prefixed_underscores
         | 
| @@ -399,7 +419,7 @@ module LuckyCase | |
| 399 419 | 
             
              # WORD CASE
         | 
| 400 420 | 
             
              #----------------------------------------------------------------------------------------------------
         | 
| 401 421 |  | 
| 402 | 
            -
              #  | 
| 422 | 
            +
              # Convert the given string from any case
         | 
| 403 423 | 
             
              # into word case
         | 
| 404 424 | 
             
              #
         | 
| 405 425 | 
             
              # @example conversion
         | 
| @@ -418,7 +438,7 @@ module LuckyCase | |
| 418 438 | 
             
                end
         | 
| 419 439 | 
             
              end
         | 
| 420 440 |  | 
| 421 | 
            -
              #  | 
| 441 | 
            +
              # Check if the string is word case
         | 
| 422 442 | 
             
              #
         | 
| 423 443 | 
             
              # @param [String] string to check
         | 
| 424 444 | 
             
              # @param [Boolean] allow_prefixed_underscores
         | 
| @@ -432,7 +452,7 @@ module LuckyCase | |
| 432 452 | 
             
                _case_match? s, :word_case
         | 
| 433 453 | 
             
              end
         | 
| 434 454 |  | 
| 435 | 
            -
              #  | 
| 455 | 
            +
              # Convert the given string from any case
         | 
| 436 456 | 
             
              # into upper word case
         | 
| 437 457 | 
             
              #
         | 
| 438 458 | 
             
              # @example conversion
         | 
| @@ -451,7 +471,7 @@ module LuckyCase | |
| 451 471 | 
             
                end
         | 
| 452 472 | 
             
              end
         | 
| 453 473 |  | 
| 454 | 
            -
              #  | 
| 474 | 
            +
              # Check if the string is upper word case
         | 
| 455 475 | 
             
              #
         | 
| 456 476 | 
             
              # @param [String] string to check
         | 
| 457 477 | 
             
              # @param [Boolean] allow_prefixed_underscores
         | 
| @@ -465,7 +485,7 @@ module LuckyCase | |
| 465 485 | 
             
                _case_match? s, :upper_word_case
         | 
| 466 486 | 
             
              end
         | 
| 467 487 |  | 
| 468 | 
            -
              #  | 
| 488 | 
            +
              # Convert the given string from any case
         | 
| 469 489 | 
             
              # into capital word case
         | 
| 470 490 | 
             
              #
         | 
| 471 491 | 
             
              # @example conversion
         | 
| @@ -484,7 +504,7 @@ module LuckyCase | |
| 484 504 | 
             
                end
         | 
| 485 505 | 
             
              end
         | 
| 486 506 |  | 
| 487 | 
            -
              #  | 
| 507 | 
            +
              # Check if the string is capital word case
         | 
| 488 508 | 
             
              #
         | 
| 489 509 | 
             
              # @param [String] string to check
         | 
| 490 510 | 
             
              # @param [Boolean] allow_prefixed_underscores
         | 
| @@ -502,7 +522,7 @@ module LuckyCase | |
| 502 522 | 
             
              # SENTENCE CASE
         | 
| 503 523 | 
             
              #----------------------------------------------------------------------------------------------------
         | 
| 504 524 |  | 
| 505 | 
            -
              #  | 
| 525 | 
            +
              # Convert the given string from any case
         | 
| 506 526 | 
             
              # into sentence case
         | 
| 507 527 | 
             
              #
         | 
| 508 528 | 
             
              # @example conversion
         | 
| @@ -521,7 +541,7 @@ module LuckyCase | |
| 521 541 | 
             
                end
         | 
| 522 542 | 
             
              end
         | 
| 523 543 |  | 
| 524 | 
            -
              #  | 
| 544 | 
            +
              # Check if the string is sentence case
         | 
| 525 545 | 
             
              #
         | 
| 526 546 | 
             
              # @param [String] string to check
         | 
| 527 547 | 
             
              # @param [Boolean] allow_prefixed_underscores
         | 
| @@ -539,7 +559,7 @@ module LuckyCase | |
| 539 559 | 
             
              # CAPITALIZE
         | 
| 540 560 | 
             
              #----------------------------------------------------------------------------------------------------
         | 
| 541 561 |  | 
| 542 | 
            -
              #  | 
| 562 | 
            +
              # Convert the first character to capital
         | 
| 543 563 | 
             
              #
         | 
| 544 564 | 
             
              # @param [String] string to convert
         | 
| 545 565 | 
             
              # @param [Boolean] skip_prefixed_underscores
         | 
| @@ -559,7 +579,7 @@ module LuckyCase | |
| 559 579 | 
             
                end
         | 
| 560 580 | 
             
              end
         | 
| 561 581 |  | 
| 562 | 
            -
              #  | 
| 582 | 
            +
              # Convert the first character to capital
         | 
| 563 583 | 
             
              #
         | 
| 564 584 | 
             
              # @param [String] string to convert
         | 
| 565 585 | 
             
              # @param [Boolean] skip_prefixed_underscores
         | 
| @@ -568,7 +588,7 @@ module LuckyCase | |
| 568 588 | 
             
                capital string, skip_prefixed_underscores: skip_prefixed_underscores
         | 
| 569 589 | 
             
              end
         | 
| 570 590 |  | 
| 571 | 
            -
              #  | 
| 591 | 
            +
              # Check if the strings first character is a capital letter
         | 
| 572 592 | 
             
              #
         | 
| 573 593 | 
             
              # @param [String] string to check
         | 
| 574 594 | 
             
              # @param [Boolean] skip_prefixed_underscores
         | 
| @@ -582,7 +602,7 @@ module LuckyCase | |
| 582 602 | 
             
                _case_match? s, :capital
         | 
| 583 603 | 
             
              end
         | 
| 584 604 |  | 
| 585 | 
            -
              #  | 
| 605 | 
            +
              # Check if the strings first character is a capital letter
         | 
| 586 606 | 
             
              #
         | 
| 587 607 | 
             
              # @param [String] string to check
         | 
| 588 608 | 
             
              # @param [Boolean] skip_prefixed_underscores
         | 
| @@ -595,7 +615,7 @@ module LuckyCase | |
| 595 615 | 
             
              # MIXED CASE
         | 
| 596 616 | 
             
              #----------------------------------------------------------------------------------------------------
         | 
| 597 617 |  | 
| 598 | 
            -
              #  | 
| 618 | 
            +
              # Convert the given string from any case
         | 
| 599 619 | 
             
              # into mixed case
         | 
| 600 620 | 
             
              #
         | 
| 601 621 | 
             
              # @example conversion
         | 
| @@ -617,7 +637,7 @@ module LuckyCase | |
| 617 637 | 
             
                end
         | 
| 618 638 | 
             
              end
         | 
| 619 639 |  | 
| 620 | 
            -
              #  | 
| 640 | 
            +
              # Check if the string is a valid mixed case (without special characters!)
         | 
| 621 641 | 
             
              #
         | 
| 622 642 | 
             
              # @param [String] string to check
         | 
| 623 643 | 
             
              # @return [Boolean]
         | 
| @@ -672,7 +692,7 @@ module LuckyCase | |
| 672 692 | 
             
              # CONSTANTIZE
         | 
| 673 693 | 
             
              #----------------------------------------------------------------------------------------------------
         | 
| 674 694 |  | 
| 675 | 
            -
              #  | 
| 695 | 
            +
              # Convert the string from any case
         | 
| 676 696 | 
             
              # into pascal case and casts it into a constant
         | 
| 677 697 | 
             
              #
         | 
| 678 698 | 
             
              # @example conversion
         | 
| @@ -730,7 +750,7 @@ module LuckyCase | |
| 730 750 | 
             
              #----------------------------------------------------------------------------------------------------
         | 
| 731 751 | 
             
              # HELPERS
         | 
| 732 752 | 
             
              #----------------------------------------------------------------------------------------------------
         | 
| 733 | 
            -
             | 
| 753 | 
            +
              
         | 
| 734 754 | 
             
              # Return string without underscores at the start
         | 
| 735 755 | 
             
              #
         | 
| 736 756 | 
             
              # @param [String] string
         | 
    
        data/lib/lucky_case/string.rb
    CHANGED
    
    | @@ -46,11 +46,18 @@ class String | |
| 46 46 | 
             
                set_self_value self.convert_case(case_type, preserve_prefixed_underscores: preserve_prefixed_underscores)
         | 
| 47 47 | 
             
              end
         | 
| 48 48 |  | 
| 49 | 
            +
              # Check if the string matches any of the available cases
         | 
| 50 | 
            +
              #
         | 
| 51 | 
            +
              # @return [Boolean]
         | 
| 52 | 
            +
              def valid_case_string?()
         | 
| 53 | 
            +
                LuckyCase.case(self) != nil
         | 
| 54 | 
            +
              end
         | 
| 55 | 
            +
             | 
| 49 56 | 
             
              #----------------------------------------------------------------------------------------------------
         | 
| 50 57 | 
             
              # UPPER CASE
         | 
| 51 58 | 
             
              #----------------------------------------------------------------------------------------------------
         | 
| 52 59 |  | 
| 53 | 
            -
              #  | 
| 60 | 
            +
              # Convert all characters inside the string
         | 
| 54 61 | 
             
              # into upper case
         | 
| 55 62 | 
             
              #
         | 
| 56 63 | 
             
              # @example conversion
         | 
| @@ -65,7 +72,7 @@ class String | |
| 65 72 | 
             
                set_self_value self.upper_case
         | 
| 66 73 | 
             
              end
         | 
| 67 74 |  | 
| 68 | 
            -
              #  | 
| 75 | 
            +
              # Check if all characters inside the string are upper case
         | 
| 69 76 | 
             
              #
         | 
| 70 77 | 
             
              # @return [Boolean]
         | 
| 71 78 | 
             
              def upper_case?()
         | 
| @@ -76,7 +83,7 @@ class String | |
| 76 83 | 
             
              # LOWER CASE
         | 
| 77 84 | 
             
              #----------------------------------------------------------------------------------------------------
         | 
| 78 85 |  | 
| 79 | 
            -
              #  | 
| 86 | 
            +
              # Convert all characters inside the string
         | 
| 80 87 | 
             
              # into lower case
         | 
| 81 88 | 
             
              #
         | 
| 82 89 | 
             
              # @example conversion
         | 
| @@ -91,7 +98,7 @@ class String | |
| 91 98 | 
             
                set_self_value self.lower_case
         | 
| 92 99 | 
             
              end
         | 
| 93 100 |  | 
| 94 | 
            -
              #  | 
| 101 | 
            +
              # Check if all characters inside the string are lower case
         | 
| 95 102 | 
             
              #
         | 
| 96 103 | 
             
              # @return [Boolean]
         | 
| 97 104 | 
             
              def lower_case?()
         | 
| @@ -102,7 +109,7 @@ class String | |
| 102 109 | 
             
              # SNAKE CASE
         | 
| 103 110 | 
             
              #----------------------------------------------------------------------------------------------------
         | 
| 104 111 |  | 
| 105 | 
            -
              #  | 
| 112 | 
            +
              # Convert the given string from any case
         | 
| 106 113 | 
             
              # into snake case
         | 
| 107 114 | 
             
              #
         | 
| 108 115 | 
             
              # @example conversion
         | 
| @@ -118,7 +125,7 @@ class String | |
| 118 125 | 
             
                set_self_value self.snake_case preserve_prefixed_underscores: preserve_prefixed_underscores
         | 
| 119 126 | 
             
              end
         | 
| 120 127 |  | 
| 121 | 
            -
              #  | 
| 128 | 
            +
              # Check if the string is snake case
         | 
| 122 129 | 
             
              #
         | 
| 123 130 | 
             
              # @param [Boolean] allow_prefixed_underscores
         | 
| 124 131 | 
             
              # @return [Boolean]
         | 
| @@ -126,7 +133,7 @@ class String | |
| 126 133 | 
             
                LuckyCase.snake_case? self, allow_prefixed_underscores: allow_prefixed_underscores
         | 
| 127 134 | 
             
              end
         | 
| 128 135 |  | 
| 129 | 
            -
              #  | 
| 136 | 
            +
              # Convert the given string from any case
         | 
| 130 137 | 
             
              # into upper snake case
         | 
| 131 138 | 
             
              #
         | 
| 132 139 | 
             
              # @example conversion
         | 
| @@ -142,7 +149,7 @@ class String | |
| 142 149 | 
             
                set_self_value self.upper_snake_case preserve_prefixed_underscores: preserve_prefixed_underscores
         | 
| 143 150 | 
             
              end
         | 
| 144 151 |  | 
| 145 | 
            -
              #  | 
| 152 | 
            +
              # Check if the string is upper snake case
         | 
| 146 153 | 
             
              #
         | 
| 147 154 | 
             
              # @param [Boolean] allow_prefixed_underscores
         | 
| 148 155 | 
             
              # @return [Boolean]
         | 
| @@ -154,7 +161,7 @@ class String | |
| 154 161 | 
             
              # PASCAL CASE
         | 
| 155 162 | 
             
              #----------------------------------------------------------------------------------------------------
         | 
| 156 163 |  | 
| 157 | 
            -
              #  | 
| 164 | 
            +
              # Convert the given string from any case
         | 
| 158 165 | 
             
              # into pascal case
         | 
| 159 166 | 
             
              #
         | 
| 160 167 | 
             
              # @example conversion
         | 
| @@ -170,7 +177,7 @@ class String | |
| 170 177 | 
             
                set_self_value self.pascal_case preserve_prefixed_underscores: preserve_prefixed_underscores
         | 
| 171 178 | 
             
              end
         | 
| 172 179 |  | 
| 173 | 
            -
              #  | 
| 180 | 
            +
              # Check if the string is upper pascal case
         | 
| 174 181 | 
             
              #
         | 
| 175 182 | 
             
              # @param [Boolean] allow_prefixed_underscores
         | 
| 176 183 | 
             
              # @return [Boolean]
         | 
| @@ -182,7 +189,7 @@ class String | |
| 182 189 | 
             
              # CAMEL CASE
         | 
| 183 190 | 
             
              #----------------------------------------------------------------------------------------------------
         | 
| 184 191 |  | 
| 185 | 
            -
              #  | 
| 192 | 
            +
              # Convert the given string from any case
         | 
| 186 193 | 
             
              # into camel case
         | 
| 187 194 | 
             
              #
         | 
| 188 195 | 
             
              # @example conversion
         | 
| @@ -198,7 +205,7 @@ class String | |
| 198 205 | 
             
                set_self_value self.camel_case preserve_prefixed_underscores: preserve_prefixed_underscores
         | 
| 199 206 | 
             
              end
         | 
| 200 207 |  | 
| 201 | 
            -
              #  | 
| 208 | 
            +
              # Check if the string is camel case
         | 
| 202 209 | 
             
              #
         | 
| 203 210 | 
             
              # @param [Boolean] allow_prefixed_underscores
         | 
| 204 211 | 
             
              # @return [Boolean]
         | 
| @@ -210,7 +217,7 @@ class String | |
| 210 217 | 
             
              # DASH CASE
         | 
| 211 218 | 
             
              #----------------------------------------------------------------------------------------------------
         | 
| 212 219 |  | 
| 213 | 
            -
              #  | 
| 220 | 
            +
              # Convert the given string from any case
         | 
| 214 221 | 
             
              # into dash case
         | 
| 215 222 | 
             
              #
         | 
| 216 223 | 
             
              # @example conversion
         | 
| @@ -226,7 +233,7 @@ class String | |
| 226 233 | 
             
                set_self_value self.dash_case preserve_prefixed_underscores: preserve_prefixed_underscores
         | 
| 227 234 | 
             
              end
         | 
| 228 235 |  | 
| 229 | 
            -
              #  | 
| 236 | 
            +
              # Check if the string is dash case
         | 
| 230 237 | 
             
              #
         | 
| 231 238 | 
             
              # @param [Boolean] allow_prefixed_underscores
         | 
| 232 239 | 
             
              # @return [Boolean]
         | 
| @@ -234,7 +241,7 @@ class String | |
| 234 241 | 
             
                LuckyCase.dash_case? self, allow_prefixed_underscores: allow_prefixed_underscores
         | 
| 235 242 | 
             
              end
         | 
| 236 243 |  | 
| 237 | 
            -
              #  | 
| 244 | 
            +
              # Convert the given string from any case
         | 
| 238 245 | 
             
              # into upper dash case
         | 
| 239 246 | 
             
              #
         | 
| 240 247 | 
             
              # @example conversion
         | 
| @@ -250,7 +257,7 @@ class String | |
| 250 257 | 
             
                set_self_value self.upper_dash_case preserve_prefixed_underscores: preserve_prefixed_underscores
         | 
| 251 258 | 
             
              end
         | 
| 252 259 |  | 
| 253 | 
            -
              #  | 
| 260 | 
            +
              # Check if the string is upper dash case
         | 
| 254 261 | 
             
              #
         | 
| 255 262 | 
             
              # @param [Boolean] allow_prefixed_underscores
         | 
| 256 263 | 
             
              # @return [Boolean]
         | 
| @@ -262,7 +269,7 @@ class String | |
| 262 269 | 
             
              # TRAIN CASE
         | 
| 263 270 | 
             
              #----------------------------------------------------------------------------------------------------
         | 
| 264 271 |  | 
| 265 | 
            -
              #  | 
| 272 | 
            +
              # Convert the given string from any case
         | 
| 266 273 | 
             
              # into train case
         | 
| 267 274 | 
             
              #
         | 
| 268 275 | 
             
              # @example conversion
         | 
| @@ -278,7 +285,7 @@ class String | |
| 278 285 | 
             
                set_self_value self.train_case preserve_prefixed_underscores: preserve_prefixed_underscores
         | 
| 279 286 | 
             
              end
         | 
| 280 287 |  | 
| 281 | 
            -
              #  | 
| 288 | 
            +
              # Check if the string is train case
         | 
| 282 289 | 
             
              #
         | 
| 283 290 | 
             
              # @param [Boolean] allow_prefixed_underscores
         | 
| 284 291 | 
             
              # @return [Boolean]
         | 
| @@ -290,7 +297,7 @@ class String | |
| 290 297 | 
             
              # WORD CASE
         | 
| 291 298 | 
             
              #----------------------------------------------------------------------------------------------------
         | 
| 292 299 |  | 
| 293 | 
            -
              #  | 
| 300 | 
            +
              # Convert the given string from any case
         | 
| 294 301 | 
             
              # into word case
         | 
| 295 302 | 
             
              #
         | 
| 296 303 | 
             
              # @example conversion
         | 
| @@ -306,7 +313,7 @@ class String | |
| 306 313 | 
             
                set_self_value self.word_case preserve_prefixed_underscores: preserve_prefixed_underscores
         | 
| 307 314 | 
             
              end
         | 
| 308 315 |  | 
| 309 | 
            -
              #  | 
| 316 | 
            +
              # Check if the string is word case
         | 
| 310 317 | 
             
              #
         | 
| 311 318 | 
             
              # @param [Boolean] allow_prefixed_underscores
         | 
| 312 319 | 
             
              # @return [Boolean]
         | 
| @@ -314,7 +321,7 @@ class String | |
| 314 321 | 
             
                LuckyCase.word_case? self, allow_prefixed_underscores: allow_prefixed_underscores
         | 
| 315 322 | 
             
              end
         | 
| 316 323 |  | 
| 317 | 
            -
              #  | 
| 324 | 
            +
              # Convert the given string from any case
         | 
| 318 325 | 
             
              # into upper word case
         | 
| 319 326 | 
             
              #
         | 
| 320 327 | 
             
              # @example conversion
         | 
| @@ -330,7 +337,7 @@ class String | |
| 330 337 | 
             
                set_self_value self.upper_word_case preserve_prefixed_underscores: preserve_prefixed_underscores
         | 
| 331 338 | 
             
              end
         | 
| 332 339 |  | 
| 333 | 
            -
              #  | 
| 340 | 
            +
              # Check if the string is upper word case
         | 
| 334 341 | 
             
              #
         | 
| 335 342 | 
             
              # @param [Boolean] allow_prefixed_underscores
         | 
| 336 343 | 
             
              # @return [Boolean]
         | 
| @@ -338,7 +345,7 @@ class String | |
| 338 345 | 
             
                LuckyCase.upper_word_case? self, allow_prefixed_underscores: allow_prefixed_underscores
         | 
| 339 346 | 
             
              end
         | 
| 340 347 |  | 
| 341 | 
            -
              #  | 
| 348 | 
            +
              # Convert the given string from any case
         | 
| 342 349 | 
             
              # into capital word case
         | 
| 343 350 | 
             
              #
         | 
| 344 351 | 
             
              # @example conversion
         | 
| @@ -354,7 +361,7 @@ class String | |
| 354 361 | 
             
                set_self_value self.capital_word_case preserve_prefixed_underscores: preserve_prefixed_underscores
         | 
| 355 362 | 
             
              end
         | 
| 356 363 |  | 
| 357 | 
            -
              #  | 
| 364 | 
            +
              # Check if the string is capital word case
         | 
| 358 365 | 
             
              #
         | 
| 359 366 | 
             
              # @param [Boolean] allow_prefixed_underscores
         | 
| 360 367 | 
             
              # @return [Boolean]
         | 
| @@ -366,7 +373,7 @@ class String | |
| 366 373 | 
             
              # SENTENCE CASE
         | 
| 367 374 | 
             
              #----------------------------------------------------------------------------------------------------
         | 
| 368 375 |  | 
| 369 | 
            -
              #  | 
| 376 | 
            +
              # Convert the given string from any case
         | 
| 370 377 | 
             
              # into sentence case
         | 
| 371 378 | 
             
              #
         | 
| 372 379 | 
             
              # @example conversion
         | 
| @@ -382,7 +389,7 @@ class String | |
| 382 389 | 
             
                set_self_value self.sentence_case preserve_prefixed_underscores: preserve_prefixed_underscores
         | 
| 383 390 | 
             
              end
         | 
| 384 391 |  | 
| 385 | 
            -
              #  | 
| 392 | 
            +
              # Check if the string is sentence case
         | 
| 386 393 | 
             
              #
         | 
| 387 394 | 
             
              # @param [Boolean] allow_prefixed_underscores
         | 
| 388 395 | 
             
              # @return [Boolean]
         | 
| @@ -394,7 +401,7 @@ class String | |
| 394 401 | 
             
              # CAPITALIZE
         | 
| 395 402 | 
             
              #----------------------------------------------------------------------------------------------------
         | 
| 396 403 |  | 
| 397 | 
            -
              #  | 
| 404 | 
            +
              # Convert the first character to capital
         | 
| 398 405 | 
             
              #
         | 
| 399 406 | 
             
              # @param [Boolean] skip_prefixed_underscores
         | 
| 400 407 | 
             
              # @return [String]
         | 
| @@ -402,7 +409,7 @@ class String | |
| 402 409 | 
             
                LuckyCase.capitalize self, skip_prefixed_underscores: skip_prefixed_underscores
         | 
| 403 410 | 
             
              end
         | 
| 404 411 |  | 
| 405 | 
            -
              #  | 
| 412 | 
            +
              # Convert the first character to capital
         | 
| 406 413 | 
             
              #
         | 
| 407 414 | 
             
              # @param [Boolean] skip_prefixed_underscores
         | 
| 408 415 | 
             
              # @return [String]
         | 
| @@ -418,7 +425,7 @@ class String | |
| 418 425 | 
             
                self.capital! skip_prefixed_underscores: skip_prefixed_underscores
         | 
| 419 426 | 
             
              end
         | 
| 420 427 |  | 
| 421 | 
            -
              #  | 
| 428 | 
            +
              # Check if the strings first character is a capital letter
         | 
| 422 429 | 
             
              #
         | 
| 423 430 | 
             
              # @param [Boolean] skip_prefixed_underscores
         | 
| 424 431 | 
             
              # @return [Boolean]
         | 
| @@ -426,7 +433,7 @@ class String | |
| 426 433 | 
             
                LuckyCase.capital? self, skip_prefixed_underscores: skip_prefixed_underscores
         | 
| 427 434 | 
             
              end
         | 
| 428 435 |  | 
| 429 | 
            -
              #  | 
| 436 | 
            +
              # Check if the strings first character is a capital letter
         | 
| 430 437 | 
             
              #
         | 
| 431 438 | 
             
              # @param [Boolean] skip_prefixed_underscores
         | 
| 432 439 | 
             
              # @return [Boolean]
         | 
| @@ -438,7 +445,7 @@ class String | |
| 438 445 | 
             
              # MIXED CASE
         | 
| 439 446 | 
             
              #----------------------------------------------------------------------------------------------------
         | 
| 440 447 |  | 
| 441 | 
            -
              #  | 
| 448 | 
            +
              # Convert the given string from any case
         | 
| 442 449 | 
             
              # into mixed case
         | 
| 443 450 | 
             
              #
         | 
| 444 451 | 
             
              # @example conversion
         | 
| @@ -454,7 +461,7 @@ class String | |
| 454 461 | 
             
                set_self_value self.mixed_case preserve_prefixed_underscores: preserve_prefixed_underscores
         | 
| 455 462 | 
             
              end
         | 
| 456 463 |  | 
| 457 | 
            -
              #  | 
| 464 | 
            +
              # Check if the string is a valid mixed case (without special characters!)
         | 
| 458 465 | 
             
              #
         | 
| 459 466 | 
             
              # @return [Boolean]
         | 
| 460 467 | 
             
              def mixed_case?()
         | 
| @@ -491,7 +498,7 @@ class String | |
| 491 498 | 
             
              # CONSTANTIZE
         | 
| 492 499 | 
             
              #----------------------------------------------------------------------------------------------------
         | 
| 493 500 |  | 
| 494 | 
            -
              #  | 
| 501 | 
            +
              # Convert the string from any case
         | 
| 495 502 | 
             
              # into pascal case and casts it into a constant
         | 
| 496 503 | 
             
              #
         | 
| 497 504 | 
             
              # @example conversion
         | 
    
        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.2. | 
| 4 | 
            +
              version: 0.2.2
         | 
| 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-08- | 
| 11 | 
            +
            date: 2020-08-14 00:00:00.000000000 Z
         | 
| 12 12 | 
             
            dependencies:
         | 
| 13 13 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 14 14 | 
             
              name: bundler
         |