README.md in alba-0.11.0 vs README.md in alba-0.11.1

- old
+ new

@@ -1,27 +1,29 @@ [![Gem Version](https://badge.fury.io/rb/alba.svg)](https://badge.fury.io/rb/alba) [![Build Status](https://travis-ci.com/okuramasafumi/alba.svg?branch=master)](https://travis-ci.com/okuramasafumi/alba) [![Coverage Status](https://coveralls.io/repos/github/okuramasafumi/alba/badge.svg?branch=master)](https://coveralls.io/github/okuramasafumi/alba?branch=master) [![Maintainability](https://api.codeclimate.com/v1/badges/fdab4cc0de0b9addcfe8/maintainability)](https://codeclimate.com/github/okuramasafumi/alba/maintainability) +![GitHub code size in bytes](https://img.shields.io/github/languages/code-size/okuramasafumi/alba) +![GitHub](https://img.shields.io/github/license/okuramasafumi/alba) # Alba `Alba` is the fastest JSON serializer for Ruby. -# Why yet another JSON serializer? +## Why yet another JSON serializer? We know that there are several other JSON serializers for Ruby around, but none of them made us satisfied. Alba has some advantages over other JSON serializers which we've wanted to have. -## Easy to understand +### Easy to understand DSL is great. It makes the coding experience natural and intuitive. However, remembering lots of DSL requires us a lot of effort. Unfortunately, most of the existing libraries have implemented their features via DSL and it's not easy to understand how they behave entirely. Alba's core DSL are only four (`attributes`, `attribute`, `one` and `many`) so it's easy to understand how to use. Alba is also understandable internally. The codebase is much smaller than the alternatives. In fact, it's less than 300 lines of code. Look at the code on [GitHub](https://github.com/okuramasafumi/alba/tree/master/lib) and you'll be surprised how simple it is! -## Performance +### Performance Alba is faster than most of the alternatives. We have a [benchmark](https://gist.github.com/okuramasafumi/4e375525bd3a28e4ca812d2a3b3e5829). ## Installation @@ -41,10 +43,36 @@ ## Supported Ruby versions Alba supports CRuby 2.5.7 and higher and latest TruffleRuby. +## Documentation + +You can find the documentation on [RubyDoc](https://rubydoc.info/gems/alba). + +## Features + +* Resource-based serialization +* Arbitrary attribute definition +* One and many association with the ability to define them inline +* Adding condition and filter to association +* Parameters can be injected and used in attributes and associations +* Setting root key separately in Serializer +* Adding metadata +* Selectable backend +* No runtime dependencies + +## Anti features + +* Sorting keys +* Class level support of parameters +* Supporting all existing JSON encoder/decoder +* Cache +* [JSON:API](https://jsonapi.org) support +* Association name inflection +* And many others + ## Usage ### Configuration Alba's configuration is fairly simple. @@ -127,11 +155,11 @@ include Alba::Resource attributes :title end -class UserResource1 +class UserResource include Alba::Resource attributes :id many :articles, resource: ArticleResource @@ -141,10 +169,10 @@ article1 = Article.new(1, 'Hello World!', 'Hello World!!!') user.articles << article1 article2 = Article.new(2, 'Super nice', 'Really nice!') user.articles << article2 -UserResource1.new(user).serialize +UserResource.new(user).serialize # => '{"id":1,"articles":[{"title":"Hello World!"},{"title":"Super nice"}]}' ``` ### Inline definition with `Alba.serialize`