File: README.md

package info (click to toggle)
ruby-grape-msgpack 0.2.0-1
  • links: PTS, VCS
  • area: main
  • in suites: sid, stretch
  • size: 128 kB
  • ctags: 18
  • sloc: ruby: 146; makefile: 3
file content (54 lines) | stat: -rw-r--r-- 1,374 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# Grape::Msgpack

[![Gem Version](https://badge.fury.io/rb/grape-msgpack.svg)](http://badge.fury.io/rb/grape-msgpack) [![Build Status](https://travis-ci.org/rosylilly/grape-msgpack.svg?branch=master)](https://travis-ci.org/rosylilly/grape-msgpack) [![Coverage Status](https://coveralls.io/repos/rosylilly/grape-msgpack/badge.svg?branch=master)](https://coveralls.io/r/rosylilly/grape-msgpack?branch=master) [![Code Climate](https://codeclimate.com/github/rosylilly/grape-msgpack.svg)](https://codeclimate.com/github/rosylilly/grape-msgpack)

Message pack formatter for grape.

## Installation

Add this line to your application's Gemfile:

    gem 'grape-msgpack'

And then execute:

    $ bundle

Or install it yourself as:

    $ gem install grape-msgpack

## Usage

set default format msgpack:

```ruby
class TwitterAPI < Grape::API
  default_format :msgpack
end
```

and grape-msgpack supoorts grape-entity:

```ruby
class ModelEntity < Grape::Entity
  expose :id
end

class ModelAPI < Grape::API
  default_format :msgpack

  get ':id' do
    present Model.find(params[:id]), with: ModelEntity
    # => { 'id' => 1 }
  end
end
```

## Contributing

1. Fork it
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 new Pull Request