Skip to content

Commit

Permalink
v1.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
lpil committed Dec 30, 2023
1 parent c6b813b commit e51a0a5
Show file tree
Hide file tree
Showing 4 changed files with 78 additions and 22 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Changelog

## v1.0.0 - 2023-12-30

- Initial release.
30 changes: 20 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,22 +1,32 @@
# justin

Convert between snake_case, camelCase, and other cases in Gleam.

[![Package Version](https://img.shields.io/hexpm/v/justin)](https://hex.pm/packages/justin)
[![Hex Docs](https://img.shields.io/badge/hex-docs-ffaff3)](https://hexdocs.pm/justin/)

## Quick start

```sh
gleam run # Run the project
gleam test # Run the tests
gleam shell # Run an Erlang shell
gleam add justin
```
```gleam
import justin
## Installation
pub fn main() {
justin.snake_case("Hello World")
// -> "hello_world"
If available on Hex this package can be added to your Gleam project:
justin.camel_case("Hello World")
// -> "helloWorld"
```sh
gleam add justin
justin.pascal_case("Hello World")
// -> "HelloWorld"
justin.kebab_case("Hello World")
// -> "hello-world
justin.sentence_case("hello-world")
// -> "Hello world"
}
```

and its documentation can be found at <https://hexdocs.pm/justin>.
Further documentation can be found at <https://hexdocs.pm/justin>.
15 changes: 8 additions & 7 deletions gleam.toml
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
name = "justin"
version = "1.0.0"
description = "Convert between snake_case, camelCase, and other cases in Gleam"
licences = ["Apache-2.0"]
repository = { type = "github", user = "lpil", repo = "justin" }
links = [
{ title = "Website", href = "https://gleam.run" },
{ title = "Sponsor", href = "https://github.com/sponsors/lpil" },
]
gleam = ">= 0.32.0"

# Fill out these fields if you intend to generate HTML documentation or publish
# your project to the Hex package manager.
#
# description = ""
# licences = ["Apache-2.0"]
# repository = { type = "github", user = "username", repo = "project" }
# links = [{ title = "Website", href = "https://gleam.run" }]

[dependencies]
gleam_stdlib = "~> 0.32"
Expand Down
50 changes: 45 additions & 5 deletions src/justin.gleam
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,31 @@ import gleam/string
import gleam/io
import gleam/list

// TODO: document
/// Convert a string to a `snake_case`.
///
/// # Examples
///
/// ```gleam
/// snake_case("Hello World")
/// // -> "hello_world"
/// ```
///
pub fn snake_case(text: String) -> String {
text
|> split_words
|> string.join("_")
|> string.lowercase
}

// TODO: document
/// Convert a string to a `camelCase`.
///
/// # Examples
///
/// ```gleam
/// camel_case("Hello World")
/// // -> "helloWorld"
/// ```
///
pub fn camel_case(text: String) -> String {
text
|> split_words
Expand All @@ -23,23 +39,47 @@ pub fn camel_case(text: String) -> String {
|> string.concat
}

// TODO: document
/// Convert a string to a `PascalCase`.
///
/// # Examples
///
/// ```gleam
/// pascal_case("Hello World")
/// // -> "HelloWorld"
/// ```
///
pub fn pascal_case(text: String) -> String {
text
|> split_words
|> list.map(string.capitalise)
|> string.concat
}

// TODO: document
/// Convert a string to a `kebab-case`.
///
/// # Examples
///
/// ```gleam
/// kabab_case("Hello World")
/// // -> "hello-world
/// ```
///
pub fn kebab_case(text: String) -> String {
text
|> split_words
|> string.join("-")
|> string.lowercase
}

// TODO: document
/// Convert a string to a `Sentence case`.
///
/// # Examples
///
/// ```gleam
/// sentence_case("hello-world")
/// // -> "Hello world
/// ```
///
pub fn sentence_case(text: String) -> String {
text
|> split_words
Expand Down

0 comments on commit e51a0a5

Please sign in to comment.