Project

senro

0.0
Low commit activity in last 3 years
No release in over a year
Library for RESTful API
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

>= 0
>= 5
>= 12.3.3

Runtime

 Project Readme

Senro

Build Status Gem Version

Installation

Add this line to your application's Gemfile:

gem 'senro'

And then execute:

$ bundle

Or install it yourself as:

$ gem install senro

Usage

in Rails

format sort

class ApplicationController < ActionController::Base # or ::API class
  include Senro::Controller
  before_action :query_params_formatter_sort
end


pp params['sort']
# => { id: 'asc', name: 'desc' }
pp params['original_sort']
# => 'id,-name'

# e.g. in ActiveRecord
@items = Item.all.order(params['sort'])

# e.g. in Mongoid
@items = Item.all.order_by(params['sort'])

format query

class ApplicationController < ActionController::Base # or ::API class
  include Senro::Controller
  before_action :query_params_formatter_query
end


pp params['q']
# => { 'query' => 'senro gem', 'status' => { 'type' => ['pr'], 'is' => ['open'], 'label' => ['bug', 'ready'] } }
pp params['original_q']
# => 'type:pr is:open label:bug label:ready senro gem'

# e.g.
@items = Item.where(title: params['q']['query'],
                    type: params['q']['status']['type'],
                    status: params['q']['status']['is'])

Development

  • Run docker-compose up --build to set up.
  • Run docker-compose run ruby bundle exec rake spec to run the tests.
  • You can also run docker-compose run ruby bin/console for an interactive prompt that will allow you to experiment.

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/senro. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the Contributor Covenant code of conduct.

License

The gem is available as open source under the terms of the MIT License.

Code of Conduct

Everyone interacting in the Senro project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the code of conduct.