ifrit

Crystal lib with different useful stuff
0.1.3 Latest release released

Ifrit Latest Release

Set of useful classes, patches and hacks. Some of them are not "good" enough so be ready to make a deal with Ifrit.

Installation

Add this to your application's shard.yml:

dependencies:
  ifrit:
    github: imdrasil/ifrit

Usage

This lib provides modular approach so you should specify what exactly you want to require:

require "ifrit/core" # for basic methods
require "ifrit/inheritable_json" # for particular pact like InheritableJSON
require "ifrit" # to load everything

Pacts

Core

require "ifrit/core"

Includes next methods:

  • #blank? - behaves same way as rails one;
  • #present? - opposite to #blank?;
  • #to_bool - parses string or integer for boolean value interpretation.

Converter

require "ifrit/converter"

Ifrit.typed_hash({"a" => 1, "b" => "asd"}, String, String | Int32) # Hash(String, String | Int32)

Symbol Table

require "ifrit/symbol_table"

include SymbolTable::Methods

a = s(:asd)
# ...
"asd".to_sym # :asd

Inheritable JSON

require "ifrit/inheritable_json"

class A
  extend InheritableJSON

  json_mapping({
    a:               String,
    b:               {type: Int32},
    nillable_field1: {type: String?},
    nillable_field2: {type: String?},
  })
end

private class B < A
end

private class C < B
  json_mapping({
    with_default: {type: String?, default: "default"},
  })
end

Hash with indifferent access

require "ifrit/hash_with_indifferent_access"

h = HashWithIndifferentAccess(Int32).new
h[:asd] = 23
h["asd"] # 23

Contributing

Before start working on any new feature please create an issue to discuss it.

  1. Fork it ( https://github.com/imdrasil/ifrit/fork )
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request

Contributors

  • imdrasil Roman Kalnytskyi - creator, maintainer
ifrit:
  github: imdrasil/ifrit
  version: ~> 0.1.3
License MIT
Crystal >= 0.28.0

Authors

Dependencies 0

Development Dependencies 1

  • ameba = 0.14.3
    {'github' => 'crystal-ameba/ameba', 'version' => '= 0.14.3'}

Dependents 1

Last synced .
search fire star recently