Stationed
Introduction
Stationed is an extensive Rails application generator, providing you with a
starter app full standard goodies such as testing, authentication,
authorization, decorators, tasks and styles. But as an engine it also provides
you with customized scaffold generators including proper tests. Finally, it
provides some basic view helpers that every project tends to need. All in all,
stationed is pretty sweet.
Installation
In order to use Stationed to generate applications, install the gem:
% gem install stationed
To use it as an engine in your Rails application, include it in your Gemfile:
gem 'stationed'
Run bundle install
and you're all set.
Application generator
The application generator is invoked using the stationed
command:
% stationed my_app
This will generate a default Rails application with the following additions:
- Rubocop for automated style guide testing.
- Pry for debugging.
- Guard for auto-running tests.
- Rspec with Simplecov for testing.
- FactoryGirl for object factories.
- DatabaseCleaner as transaction replacement.
- Capybara for feature testing.
- CapybaraWebkit for headless browser testing.
- Pundit for authorization.
- Yard for API documentation.
- Foreman for process management.
- Bourbon, Neat and Bitters and normalize.css for styling.
- Draper for decorators.
- Gollum for a built-in development wiki.
- Devise for authentication.
- Turbolinks removed.
- Kaminari for pagination.
- SimpleForm for awesome form markup.
- Haml for pretty view templates.
- Webmock to disallow external HTTP requests in tests.
- I18nSpec for automated validation of locale files.
- Responders for DRY controllers.
...and some other minor configurations and goodies.
All these additions are stand-alone "plugins" for the base application
generator, so it is easy to adapt them or add others. Plugins have their own CLI
options, so you can easily enable or disable them. To see the available options,
run:
% stationed -h
Helpers
Page title
The page title helper allows you to set a page title based on a string,
translation key or by a resource. You can easily output it on your page and in
your layout.
- When given no argument, this will return the currently set page title or
the site-wide default.
- When given a string argument, that will be used in the formatted page
title (for example with a site-wide suffix).
- When given an ActiveModel-compliant object, its singular and plural human
names will be interpolated into the model-based title template, along
with the record's ID.
You can provide templates for page titles using I18n
in three broad
categories: the model
, formatted
and standard
keys. These will be used
when you set a page title via a model, string or nothing at all, respectively.
You can specify these translation keys on a global default level, per controller
or per controller action. The more specific key will take precedence.
CRUD link helpers
A collection of helper methods to generate links to CRUD operations with labels
and URLs generated by resources.
For example:
link_to_new(Post) # => <a href="/posts/new">New Post</a>
link_to_edit(@product) # => <a href="/products/1/edit">Edit Product 1</a>
You can use I18n to fully customize the labels on these links. There are helper
methods for new
, edit
, show
, destroy
and index
, in the variants
link_to
, button_to
and button_link_to
(for links with a button
class
name).
Placeholders
Display a placeholder message using standardized markup and a message defined
through I18n.
When in a controller PostsController and action index, this will try to look up
the following placeholder keys:
- placeholders.posts.index
- placeholders.posts.default
- placeholders.defaults.index
You can also provide an argument to set the placeholder message. When given a
string, it will be used directly as the placeholder message. When given a
symbol, that key will be looked up in the placeholders.defaults
namespace
using I18n.
For example:
placeholder('Nothing found') # => '<p class="placeholder">Nothing found</p>'
Templates
Stationed includes customized scaffold templates for Haml, Rspec and
controllers. These work out of the box, but you can use a generator to install
the templates into your application for easy customization:
rails generate stationed:templates
Other
Note on Patches/Pull Requests
- Fork the project.
- Make your feature addition or bug fix.
- Add tests for it. This is important so I don't break it in a future version
unintentionally.
- Commit, do not mess with rakefile, version, or history. (if you want to have
your own version, that is fine but bump version in a commit by itself I can
ignore when I pull)
- Send me a pull request. Bonus points for topic branches.
Issues
Please report any issues, defects or suggestions in the Github issue
tracker.
What has changed?
See the HISTORY file for a detailed changelog.
Credits
Created by: Arjan van der Gaag
URL: http://arjanvandergaag.nl
Project homepage:
http://avdgaag.github.com/stationed
Date: april 2014
License: MIT-license (same as Ruby)