GithubHelp home page GithubHelp logo

ventup-it / digger Goto Github PK

View Code? Open in Web Editor NEW

This project forked from treble37/digger

0.0 0.0 0.0 128 KB

Influenced by Rails Activesupport::Inflector, Digger uses protocols to handle some common data transformation operations such as snake_casing, camelCasing, lower/upper casing the first letter, converting strings to atoms and other operations I've found myself doing in Elixir

Home Page: https://github.com/treble37/digger

License: MIT License

Elixir 100.00%

digger's Introduction

Digger

Build Status Coverage Status Test Coverage Maintainability Hex.pm Hex.pm Downloads Inline docs GitHub stars GitHub license

Description

Digger is a collection of helpers to help you operate on nested maps (it will also work on non-nested maps). Elixir gives you a great collection of map methods, but sometimes I find myself having to rewrite the same operations specifically for nested maps.

This library is intended to help your code stay DRY.

Possible Future Work

This library is a work in progress. I'm thinking about extending it to lists and/or tuples.

Here is a list of helper modules/methods Digger gives you:

1 - Digger.Atomizer

The Problem

You have a valid data type that needs to be "atomized" This can be a string, number, or nested map with string keys.

The Solution: Digger.Atomizer

Digger.Atomizer drills down into a nested map and converts (most) keys which are not atoms into atoms.

2 - Digger.Stringifier

The Problem

You have a nested map (or a struct that you converted to a nested map) with keys that are atoms and you want to convert those keys to strings.

You have a valid data type that needs to be "stringified" This can be an atom, number, or nested map with atom keys.

The Solution: Digger.Stringifier

Digger.Stringifier drills down into a nested map and converts (most) keys which are not strings into strings.

3 - Digger.CamelCaser

The Problem

You have a valid data type that needs to be camel-cased. This can be an atom, string, or nested map (or a struct that you converted to a nested map) with string or atom keys.

The Solution: Digger.CamelCaser

Digger.CamelCaser "camel cases" your valid data type according to the rules defined by its protocol.

4 - Digger.SnakeCaser

The Problem

You have a valid data type that needs to be snake-cased. This can be an atom, string, or nested map (or a struct that you converted to a nested map) with string or atom keys.

The Solution: Digger.SnakeCaser

Digger.SnakeCaser "snake cases" your valid data type according to the rules defined by its protocol.

5 - Digger.Dasher

The Problem

You have a valid data type that needs the underscores transformed to dashes. This can be a string, or nested map (or a struct that you converted to a nested map) with string keys.

The Solution: Digger.Dasher

Digger.Dasher "dasherizes" your valid data type according to the rules defined by its protocol.

6 - Digger.LowerCaser

The Problem

You have a valid data type that needs the first letter to be lowercase. This can be a string or atom or nested map with string or atom keys.

The Solution: Digger.LowerCaser

Digger.Dasher "lowercases" your valid data type according to the rules defined by its protocol.

7 - Digger.UpperCaser

The Problem

You have a valid data type that needs the first letter to be upper case. This can be a string or atom or nested map with string or atom keys.

The Solution: Digger.UpperCaser

Digger.Dasher "upcases" your valid data type according to the rules defined by its protocol.

Questions?

The tests in the test folder show you the data types that are handled. The protocol implementations in lib/impl also show you the various data types are handled.

Installation

If available in Hex, the package can be installed by adding digger to your list of dependencies in mix.exs:

def deps do
  [
    {:digger, "~> 3.0.0"}
  ]
end

Documentation can be generated with ExDoc and published on HexDocs. Once published, the docs can be found at https://hexdocs.pm/digger.

digger's People

Contributors

treble37 avatar dependabot-support avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.