{"id":20010441,"url":"https://github.com/magynhard/lucky_case","last_synced_at":"2025-05-04T20:30:49.154Z","repository":{"id":56882352,"uuid":"286853906","full_name":"magynhard/lucky_case","owner":"magynhard","description":"The lucky ruby gem to identify and convert strings from any letter case to another","archived":false,"fork":false,"pushed_at":"2023-10-21T18:21:44.000Z","size":105,"stargazers_count":13,"open_issues_count":1,"forks_count":0,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-05-01T18:06:05.143Z","etag":null,"topics":["capitalize","case","constantize","convert-strings","letter-case","lower-case","monkey-patching","pascal-case","ruby","ruby-gem","snake-case","string-conversion","upper-case"],"latest_commit_sha":null,"homepage":"","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/magynhard.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2020-08-11T21:44:20.000Z","updated_at":"2025-03-07T04:27:06.000Z","dependencies_parsed_at":"2022-08-20T13:10:40.285Z","dependency_job_id":"d3192cf2-5f92-4691-a953-b62caf547a7d","html_url":"https://github.com/magynhard/lucky_case","commit_stats":{"total_commits":33,"total_committers":1,"mean_commits":33.0,"dds":0.0,"last_synced_commit":"5129202ec35f37c8fec2ace2a2c7cbf3c5340a0e"},"previous_names":[],"tags_count":15,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/magynhard%2Flucky_case","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/magynhard%2Flucky_case/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/magynhard%2Flucky_case/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/magynhard%2Flucky_case/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/magynhard","download_url":"https://codeload.github.com/magynhard/lucky_case/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252395187,"owners_count":21740980,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["capitalize","case","constantize","convert-strings","letter-case","lower-case","monkey-patching","pascal-case","ruby","ruby-gem","snake-case","string-conversion","upper-case"],"created_at":"2024-11-13T07:19:49.087Z","updated_at":"2025-05-04T20:30:48.837Z","avatar_url":"https://github.com/magynhard.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# lucky_case\n[![Gem](https://img.shields.io/gem/v/lucky_case?color=default\u0026style=plastic\u0026logo=ruby\u0026logoColor=red)](https://rubygems.org/gems/lucky_case)\n![downloads](https://img.shields.io/gem/dt/lucky_case?color=blue\u0026style=plastic)\n[![License: MIT](https://img.shields.io/badge/License-MIT-gold.svg?style=plastic\u0026logo=mit)](LICENSE)\n\n\u003e The lucky ruby gem to identify and convert strings from any letter case to another. Plus some extra functions.\n\nI also created a javascript port named [lucky-case](https://github.com/magynhard/lucky-case).\n\nUseful when working with conventions, where class names, method names and file names needs to be converted.\n\n* Converters: Only characters, numbers, dashes and underlines are allowed inside a string.\n* Must not start with dash or number, underlines at the beginning are allowed by default and can be allowed/removed/controlled by parameter (when used for private methods for example)\n\n\n\n\n# Contents\n\n* [Usage](#usage)\n* [Installation](#installation)\n* [Documentation](#documentation)\n* [Contributing](#contributing)\n\n\n\n\n\u003ca name=\"usage\"\u003e\u003c/a\u003e\n## Usage\n\nYou can either use the static LuckyCase class with its method or optionally monkey patch the String class.\n\n### Approach 1: Using the static class\n```ruby\nrequire 'lucky_case'\n\n# converters\nLuckyCase.snake_case('PascalToSnake')                  # =\u003e 'pascal_to_snake'\nLuckyCase.upper_snake_case('Train-To-Upper-Snake')     # =\u003e 'TRAIN_TO_UPPER_SNAKE'\nLuckyCase.pascal_case('snake_to_pascal')               # =\u003e 'SnakeToPascal'\nLuckyCase.camel_case('dash-to-camel-case')             # =\u003e 'dashToCamelCase'\nLuckyCase.dash_case('PascalToDashCase')                # =\u003e 'pascal-to-dash-case'\nLuckyCase.upper_dash_case('PascalToUpperDash')         # =\u003e 'PASCAL-TO-UPPER-DASH'\nLuckyCase.train_case('snake_to_train_case')            # =\u003e 'Snake-To-Train-Case'\nLuckyCase.word_case('PascalToWordCase')                # =\u003e 'pascal to word case'\nLuckyCase.upper_word_case('PascalToUpperWord')         # =\u003e 'PASCAL TO UPPER WORD'\nLuckyCase.capital_word_case('snake_to_capital_word')   # =\u003e 'Snake To Capital Word'\nLuckyCase.sentence_case('snake_to_sentence_case')      # =\u003e 'Snake to sentence case'\nLuckyCase.mixed_case('example_snake_string')           # =\u003e 'Example-snake_STRING'\n\n# converter by type\nLuckyCase.convert_case('some_snake', :pascal_case)     # =\u003e 'SomeSnake'\n\n# transformers\nLuckyCase.lower_case('Some_FuckingShit')               # =\u003e 'some_fuckingshit'\nLuckyCase.upper_case('Some_FuckingShit')               # =\u003e 'SOME_FUCKINGSHIT'\nLuckyCase.capital('example')                           # =\u003e 'Example'\nLuckyCase.capitalize('example')                        # =\u003e 'Example'\nLuckyCase.decapitalize('ExaMple')                      # =\u003e 'exaMple'\nLuckyCase.swap_case('SomeSwappy_Case-Example')         # =\u003e 'sOMEsWAPPY-cASE_eXAMPLE'\nLuckyCase.constantize('some_constant')                 # =\u003e SomeConstant\nLuckyCase.constantize('SOME_CONSTANT')                 # =\u003e SomeConstant\nLuckyCase.constantize('some/path_example/folder')      # =\u003e Some::PathExample::Folder\nLuckyCase.deconstantize(SomeConstant)                  # =\u003e 'some_constant' // default case_type: :snake_case\nLuckyCase.deconstantize(Some::PathExample::Folder, case_type: :camel_case)  # =\u003e 'some/pathExample/folder'\n\n# identifiers\nLuckyCase.case('this_can_only_be_snake_case')          # =\u003e :snake_case\nLuckyCase.cases('validformultiple')                    # =\u003e [ :snake_case, :camel_case, :dash_case, :word_case ]\n\n# checkers\nLuckyCase.snake_case?('valid_snake_case')              # =\u003e true\nLuckyCase.upper_snake_case?('UPPER_SNAKE')             # =\u003e true\nLuckyCase.pascal_case?('PascalCase')                   # =\u003e true\nLuckyCase.camel_case?('camelCase')                     # =\u003e true\nLuckyCase.dash_case?('dash-case')                      # =\u003e true\nLuckyCase.upper_dash_case?('DASH-CASE')                # =\u003e true\nLuckyCase.train_case?('Train-Case')                    # =\u003e true\nLuckyCase.word_case?('word case')                      # =\u003e true\nLuckyCase.upper_word_case?('UPPER WORD CASE')          # =\u003e true\nLuckyCase.capital_word_case?('Capital Word Case')      # =\u003e true\nLuckyCase.sentence_case?('Sentence case string')       # =\u003e true\nLuckyCase.mixed_case?('mixed_Case')                    # =\u003e true\nLuckyCase.upper_case?('UPPER50984')                    # =\u003e true\nLuckyCase.lower_case?('lower_cheese')                  # =\u003e true\nLuckyCase.capital?('Some')                             # =\u003e true\nLuckyCase.capitalized?('some')                         # =\u003e false\nLuckyCase.decapitalized?('soMe')                       # =\u003e true\nLuckyCase.not_capital?('Some')                         # =\u003e false\nLuckyCase.valid_case_type?(:snake_case)                # =\u003e true\nLuckyCase.valid_case_type?(:apple_case)                # =\u003e false\nLuckyCase.valid_case_string?('validString')            # =\u003e true\nLuckyCase.valid_case_string?('1nV4lid$tring')          # =\u003e false\n```\n\n### Approach 2: Monkey patch the string class\n\nWith monkey patching you can access the same methods (except `#deconstantize`, `#valid_case_type?`) of LuckyCase directly from strings.\nAdditionally they provide versions with exclamation mark for direct manipulation.\n\nBecause the methods `#case` and `#cases` are so general and could lead to conflicts, they are called `#letter_case` and `#letter_cases` at strings.\n\n```ruby\nrequire 'lucky_case/string'\n\na = 'ExampleString'\n\na.pascal_case?                          # =\u003e true\na.snake_case                            # =\u003e 'example_string'\na                                       # =\u003e 'ExampleString'\n\n# string variable manipulation\na.snake_case!                           # =\u003e 'example_string'\na                                       # =\u003e 'example_string'\n...\n\n# identifiers\n# got a other method name here because 'case' might be to common and cause conflicts\nb = 'example'\nb.letter_case                           # =\u003e :snake_case\nb.letter_cases                          # =\u003e [ :snake_case, :camel_case, :dash_case, :word_case ]\n```\n\n\n\n\n\n\u003ca name=\"installation\"\u003e\u003c/a\u003e\n## Installation\n\nAdd this line to your application's Gemfile:\n\n```ruby\ngem 'lucky_case'\n```\n\nAnd then execute:\n\n    $ bundle install\n\nOr install it yourself by:\n\n    $ gem install lucky_case\n\n\n\n\n  \n\u003ca name=\"documentation\"\u003e\u003c/a\u003e    \n## Documentation\nCheck out the doc at RubyDoc\n\u003ca href=\"https://www.rubydoc.info/gems/lucky_case\"\u003ehttps://www.rubydoc.info/gems/lucky_case\u003c/a\u003e\n\n\n\n\n\n\u003ca name=\"contributing\"\u003e\u003c/a\u003e    \n## Contributing\n\nBug reports and pull requests are welcome on GitHub at https://github.com/magynhard/lucky_case. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmagynhard%2Flucky_case","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmagynhard%2Flucky_case","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmagynhard%2Flucky_case/lists"}