Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/interagent/pliny
An opinionated toolkit for writing excellent APIs in Ruby.
https://github.com/interagent/pliny
Last synced: 3 days ago
JSON representation
An opinionated toolkit for writing excellent APIs in Ruby.
- Host: GitHub
- URL: https://github.com/interagent/pliny
- Owner: interagent
- License: mit
- Created: 2014-04-24T07:22:09.000Z (over 10 years ago)
- Default Branch: main
- Last Pushed: 2024-05-24T13:19:31.000Z (8 months ago)
- Last Synced: 2025-01-01T05:10:11.148Z (10 days ago)
- Language: Ruby
- Homepage:
- Size: 720 KB
- Stars: 802
- Watchers: 25
- Forks: 74
- Open Issues: 21
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
Awesome Lists containing this project
- awesome-ruby - Pliny - Opinionated template Sinatra app for writing excellent APIs in Ruby. (API Builder and Discovery)
- awesome-ruby-cli-apps - pliny - Generates endpoints, models, schemas and other APIs. (Awesome Ruby CLIs / Generating)
README
# Pliny
[![Gem version](http://img.shields.io/gem/v/pliny.svg)](https://rubygems.org/gems/pliny)
[![Github Actions CI](https://github.com/interagent/pliny/actions/workflows/ruby.yml/badge.svg)](https://github.com/interagent/pliny/actions)Pliny helps Ruby developers write and maintain excellent APIs.
It bundles the best patterns, libraries and practices we've seen after writing a lot of APIs.
## Resources
- [Documentation](https://github.com/interagent/pliny/wiki)
- [Mailing list](https://groups.google.com/group/pliny-talk)## Getting started
Install gem:
```bash
$ gem install pliny
```And initialize your new API app:
```bash
$ pliny-new myapp
$ cd myapp && bin/setup
```Pliny bundles [generators](#generators) to help you get started:
```bash
$ bundle exec pliny-generate model artist
created model file ./lib/models/artist.rb
created migration ./db/migrate/1408995997_create_artists.rb
created test ./spec/models/artist_spec.rb$ bundle exec pliny-generate mediator artists/creator
created mediator file ./lib/mediators/artists/creator.rb
created test ./spec/mediators/artists/creator_spec.rb$ bundle exec pliny-generate endpoint artists
created endpoint file ./lib/endpoints/artists.rb
add the following to lib/routes.rb:
mount Endpoints::Artists
created test ./spec/endpoints/artists_spec.rb
created test ./spec/acceptance/artists_spec.rb$ bundle exec pliny-generate migration fix_something
created migration ./db/migrate/1395873228_fix_something.rb$ bundle exec pliny-generate schema artists
created schema file ./schema/schemata/artist.yaml
rebuilt ./schema/schema.json
```To test your application:
```bash
$ bundle exec rake
```Or to run a single test suite:
```bash
$ bundle exec rspec spec/acceptance/artists_spec.rb
```### Generators
```bash
$ bundle exec pliny-generate
``````
Commands:
pliny-generate endpoint NAME # Generates an endpoint
pliny-generate help [COMMAND] # Describe available commands or one specific command
pliny-generate mediator NAME # Generates a mediator
pliny-generate migration NAME # Generates a migration
pliny-generate model NAME # Generates a model
pliny-generate scaffold NAME # Generates a scaffold of endpoint, model, schema and serializer
pliny-generate schema NAME # Generates a schema
pliny-generate serializer NAME # Generates a serializer
```### Rake tasks
Pliny adds common Rake tasks to help maintain your app:
```bash
rake db:create # Create the database
rake db:drop # Drop the database
rake db:migrate # Run database migrations
rake db:rollback # Rollback last database migration
rake db:schema:dump # Dump the database schema
rake db:schema:load # Load the database schema
rake db:schema:merge # Merges migrations into schema and removes them
rake db:seed # Seed the database with data
rake db:setup # Setup the database
rake schema # Rebuild schema.json
```### Commands
And provides the following commands:
```bash
$ foreman start # Starts server
$ foreman run bin/console # IRB/Pry console
$ foreman run bin/run 'puts "hello world"' # Run automated code
```(hint: don't forget `foreman run` in development)
### Updating
Use `pliny-update` to update the Pliny app in the current directory.
This not only bumps the version dependency, but also applies any changes that happened in the template app (for instance: new initializer, tweaks in the base endpoint, etc).
## Development
Run tests:
```
$ bundle install
$ createdb pliny-gem-test
$ rake
```## Meta
Created by Brandur Leach and Pedro Belo.
MIT licensed.