wemake-services / recase Goto Github PK
View Code? Open in Web Editor NEW:recycle: Convert strings to any case.
Home Page: https://hexdocs.pm/recase/readme.html
License: MIT License
:recycle: Convert strings to any case.
Home Page: https://hexdocs.pm/recase/readme.html
License: MIT License
Sentence case works like so:
Some Random Value
-> Some random value
some_random_value
-> Some random value
It probably should be constant_cast_test.exs
What do you think about also handling atom inputs? I'm happy to make a PR to implement this enhancement if you're on board.
Hello!
When using Recase.Enumerable.convert_keys, it tries to recursively convert keys in maps. The problem is that not every map
has Enumerable
protocol implementation, so it raises if it finds for example DateTime
struct.
Guess we could check if Enumerable
is implemented?
Hello! I am a graphic designer. I contribute to open source software. I saw the logo in the Readme File. I wanted to customize the logo. You can be sure I can do better. Do you want to see my new logo idea?
I will wait for feedback. Have a nice day!
to_camel
produces unexpected output when given an existing camel case string. This seems to happen when the given string has more than 2 words in it:
Recase.to_camel("fooBar")
> "fooBar" # Correct
Recase.to_camel("fooBarBaz")
> "foobarBaz" # Incorrect, this should be "fooBarBaz"
Recase.to_camel("fooBarBazBiz")
> "foobarbazBiz" # Incorrect, this should be "fooBarBazBiz"
to_upper/1
could be misleading. Since upper case is SOME-VALUE
.
I guess it should be renamed to to_pascal/1
.
From the Wikipedia page linked from kebab_case.ex it says "As per snake_case above" and in the snake_case section above it says "Punctuation is removed and spaces are replaced..." However it looks like in this project's tests for kebab_case it seems to intentionally test for preservation of punctuation https://github.com/sobolevn/recase/blob/master/test/recase_test/kebab_case_test.exs#L18
My understanding of kebab case (and other cases) is that punctation should be removed and consecutive punctation is collapsed into one hyphen. This is for example what lodash does for their string conversion suite and this definition of kebab case seems supported by this project's own comment link to Wikipedia.
So for one I wanted to ask to clarify on what is the correct behavior. If punctuation should be preserved then the link to Wikipedia should be removed as it does not describe the functionality of the functions implemented by this project. If they should be removed then I'm happy to submit a PR changing this and updating the tests.
In case it is helpful the use case I have is generating urls for titles (user generated) and preserving punctation is of course problematic for urls.
We have seen a compatibility break from versions 0.5.0+ in Recase.to_snake/1
. This happens when there are multiple uppercase letters followed by lowercase ones as you can see in the example with "CurrencyISOCode"
:
Versions 0.5+
iex(2)> Recase.to_snake("CurrencyISOCode")
"currency_isocode"
Previos versions <= 0.4
iex(2)> Recase.to_snake("CurrencyISOCode")
"currency_iso_code"
Is that intended? For the moment we are pinning the dependency to v0.4.0
This is really baffling. Obviously I see both here on Github, but if add the {:recase, "~> 0.4"}
dependency, fetch it with mix deps.get
, and then go spelunking into the deps/recase/...
directory both the function and module are missing. Is this some kind of hex bug?
This one for example: https://github.com/pragdave/quixir
Recase.to_pascal(%{"camel_case" => 123, "PascalCase" => 456}) # %{"CamelCase" => 123, "PascalCase" => 456}
Hi @sobolevn,
Can you tag the current master version ? is there a specific reason not publish a new tag ?
Thanks
Here's a good list: https://github.com/okunishinishi/python-stringcase/blob/master/stringcase.py
For some reason travis
relies on elixir 1.4
. It should be fixed.
https://github.com/sobolevn/recase/blob/master/.travis.yml
Current version we want to support is the latest one (now it is 1.5
).
Related: #6
I came here because Macro has the same problem, and it's frustrating with how it's used inside Absinthe but isn't circular. I was hoping to find another lib that did it right, but...alas, this lib has the same broken functionality when you have acronyms with mulitiple cases in a row:
iex> "power1VA" |> Recase.to_snake |> Recase.to_camel
"power1Va"
What I'd expect is Recase.to_snake converts it to "power1_v_a"
Is this something this library would like to fix? I can look into the code if so.
convert_keys
works fine, atomize_keys
is undefined or private.
Currently digits do not break up tokens in snake case and other (kebab case, dot case, constant case) so SnakeCase.convert("g2g") == "g2g"
. This is different from other implementations such as Lodash where _.lodash("g2g") === "g_2_g"
. I could not find an authoritative description of snake case as to which is the expected behavior but given the prevalence of Lodash, following its behavior might end up causing less surprise for developers/users.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.