ProductPromotion
Logo

Elixir

made by https://0x3d.site

GitHub - ufirstgroup/ymlr: A YAML encoder for Elixir.
A YAML encoder for Elixir. Contribute to ufirstgroup/ymlr development by creating an account on GitHub.
Visit Site

GitHub - ufirstgroup/ymlr: A YAML encoder for Elixir.

GitHub - ufirstgroup/ymlr: A YAML encoder for Elixir.

ymlr - A YAML Encoder for Elixir

ymlr - A YAML encoder for Elixir.

Module Version Coverage Status Last Updated

Build Status Code Qualits Build Status Elixir

Hex Docs Total Download License

Installation

The package can be installed by adding ymlr to your list of dependencies in mix.exs:

def deps do
  [
    {:ymlr, "~> 5.0"}
  ]
end

Examples

See The usage livebook usage.livemd for more detailed examples.

Encode a single document - optionally with comments:

  iex> Ymlr.document!(%{a: 1})
  """
  ---
  a: 1
  """

  iex> Ymlr.document!({"comment", %{a: 1}})
  """
  ---
  # comment
  a: 1
  """

  iex> Ymlr.document!({["comment 1", "comment 2"], %{"a" => "a", "b" => :b, "c" => "true", "d" => "100"}})
  """
  ---
  # comment 1
  # comment 2
  a: a
  b: b
  c: 'true'
  d: '100'
  """

Encode a multiple documents

iex> Ymlr.documents!([%{a: 1}, %{b: 2}])
"""
---
a: 1

---
b: 2
"""

Support for atoms

By default, atoms as map keys are encoded as strings (without the leading colon). If you want atoms to be encoded with a leading colon in order to be able to parse it later using YamlElixir's atoms option, you can pass atoms: true as second argument to any of the Ymlr module's functions:

iex> Ymlr.document!(%{a: 1}, atoms: true)
"""
---
:a: 1
"""

Encode maps with keys sorted

Maps in elixir, implemented by erlang :maps, internally are flatmaps or hashmaps by size. Large maps will be encoded in strange order.

iex> 1..33 |> Map.new(&{&1, &1})|> Ymlr.document!() |> IO.puts
---
4: 4
25: 25
8: 8
...

By using :sort_maps option, ymlr will encode all entries sorted.

iex> 1..33 |> Map.new(&{&1, &1})|> Ymlr.document!(sort_maps: true) |> IO.puts
---
1: 1
2: 2
3: 3
...

Benchmark

This library does not claim to be particularly performant. We do have a script to benchmark encoding so we know if performance gets better or worse with changes.

You can find the last Benchmark in BENCHMARK.md

Running the script

cd benchmark/
elixir run.exs

Articles
to learn more about the elixir concepts.

Resources
which are currently available to browse on.

mail [email protected] to add your project or resources here 🔥.

FAQ's
to know more about the topic.

mail [email protected] to add your project or resources here 🔥.

Queries
or most google FAQ's about Elixir.

mail [email protected] to add more queries here 🔍.

More Sites
to check out once you're finished browsing here.

0x3d
https://www.0x3d.site/
0x3d is designed for aggregating information.
NodeJS
https://nodejs.0x3d.site/
NodeJS Online Directory
Cross Platform
https://cross-platform.0x3d.site/
Cross Platform Online Directory
Open Source
https://open-source.0x3d.site/
Open Source Online Directory
Analytics
https://analytics.0x3d.site/
Analytics Online Directory
JavaScript
https://javascript.0x3d.site/
JavaScript Online Directory
GoLang
https://golang.0x3d.site/
GoLang Online Directory
Python
https://python.0x3d.site/
Python Online Directory
Swift
https://swift.0x3d.site/
Swift Online Directory
Rust
https://rust.0x3d.site/
Rust Online Directory
Scala
https://scala.0x3d.site/
Scala Online Directory
Ruby
https://ruby.0x3d.site/
Ruby Online Directory
Clojure
https://clojure.0x3d.site/
Clojure Online Directory
Elixir
https://elixir.0x3d.site/
Elixir Online Directory
Elm
https://elm.0x3d.site/
Elm Online Directory
Lua
https://lua.0x3d.site/
Lua Online Directory
C Programming
https://c-programming.0x3d.site/
C Programming Online Directory
C++ Programming
https://cpp-programming.0x3d.site/
C++ Programming Online Directory
R Programming
https://r-programming.0x3d.site/
R Programming Online Directory
Perl
https://perl.0x3d.site/
Perl Online Directory
Java
https://java.0x3d.site/
Java Online Directory
Kotlin
https://kotlin.0x3d.site/
Kotlin Online Directory
PHP
https://php.0x3d.site/
PHP Online Directory
React JS
https://react.0x3d.site/
React JS Online Directory
Angular
https://angular.0x3d.site/
Angular JS Online Directory