Granule

Boilerplate/template/generator for Rails app

Rails (6.0.2) template with useful gems, configs and features. Ready for development out of the box. Dockerized for development.

Installing / Getting started

A quick introduction of the minimal setup you need to get a hello world up & running.

gem install granule

Initial Configuration

granule new my-rails-app

Executes rails new --skip-test --skip-bundle --database=postgresql --webpack=react --skip-turbolinks my-rails-app under the hood.

Gems

Core

  • bootsnap - library that plugs into Ruby, with optional support for ActiveSupport and YAML, to optimize and cache expensive computations
  • devise - Authentication
  • dry-matcher - Pattern matching for ruby. Used to unify controller handlers
  • dry-monads - Set of common monads for Ruby. Service Object/Interactor.
  • dry-validation - Validation library with type-safe schemas and rules.
  • i18n-js - Small library to provide the I18n translations on the Javascript
  • mini_magick - mini replacement for RMagick
  • pg - A PostgreSQL client library for Ruby
  • data_migrate - Migrate and update data alongside your database structure.
  • puma - A Ruby/Rack web server built for concurrency
  • rolify - Role management library with resource scoping
  • webpacker - Bundling JavaScript assets

Development

  • better_errors - Replaces the standard Rails error page with a much better and more useful error page
  • letter_opener_web - A web interface for browsing Ruby on Rails sent emails
  • listen (default) - Listens to file modifications and notifies you about the changes. (Used for spring)
  • spring (default) - Rails application preloader
  • spring-watcher-listen (default) - Makes Spring watch the filesystem for changes using Listen rather than by polling the filesystem.
  • web-console (default) - Web Console is a debugging tool for your Ruby on Rails applications.

Development + Test

  • brakeman - A static analysis security vulnerability scanner for Ruby on Rails applications
  • bullet - Helps to kill N+1 queries and unused eager loading
  • bundler-audit - Patch-level verification for Bundler
  • factory_bot_rails - fixtures replacement with a straightforward definition syntax, support for multiple build strategies (saved instances, unsaved instances, attribute hashes, and stubbed objects), and support for multiple factories for the same class (user, admin_user, and so on), including factory inheritance.
  • fasterer - Fasterer will suggest some speed improvements which you can check in detail at the fast-ruby repo.
  • ffaker - Used to easily generate fake data: names, addresses, phone numbers, etc.
  • i18n-tasks - Manage translation and localization with static analysis, for Ruby i18n
  • lol_dba - small package of rake tasks that scan your application models and displays a list of columns that probably should be indexed. Also, it can generate .sql migration scripts
  • pry-rails - Causes rails console to open pry. It therefore depends on pry.
  • pry-rescue - Whenever an exception is raised, but not rescued, pry-rescue will automatically open Pry for you:
  • pry-stack_explorer - plugin for the Pry REPL that enables the user to navigate the call-stack
  • rails_best_practices - code metric tool to check the quality of Rails code.
  • reek - Code smell detector for Ruby
  • rubocop - A Ruby static code analyzer and formatter, based on the community Ruby style guide.
  • rubocop-performance - An extension of RuboCop focused on code performance checks.
  • rubocop-rspec - Code style checking for RSpec files
  • rubycritic - A Ruby code quality reporter

Test

  • capybara - Acceptance test framework for web applications
  • rspec-rails - RSpec for Rails-3+
  • selenium-webdriver - Provides Ruby bindings for WebDriver
  • shoulda-matchers - Provides RSpec- and Minitest-compatible one-liners to test common Rails functionality that, if written by hand, would be much longer, more complex, and error-prone.
  • simplecov - Code coverage for Ruby 1.9+ with a powerful configuration library and automatic merging of coverage across test suites
  • webdrivers - Keep your Selenium WebDrivers updated automatically

Conventions

Folder structure

feature folders is convenient way to split business logic regarding controller actions.

.
├── app
│   ├── controllers
│   │   ├── applications_controller.rb      # Default
│   │   ├── fallback_controller.rb          # Controller with predefined handlers
│   │   └── pages_controller.rb             # Typical rails controller
│   ├── core
│   │   ├── application_interactor.rb       # Parent interactor class
│   │   └── pages                           # Feature folder (controller name plural)
│   │       ├── index                       # action name
│   │       ... ├── contract.rb             # params validations
│   │           ├── interactor.rb           # business logic
│   │           ├── policy.rb               # authorization layer
│   │           ├── serializer.rb           # json presenter
│   │           └── you_name_it.rb          # custom logic
│   ...
├── spec
│   ├── core
│   │   ├── pages_index_spec.rb             # Unit tests input/output
│   │   ...
│   ├── request
│   │   ├── sessions_request_spec.rb        # Integration tests (SUCCESS/FAIL)
│   │   ...
│   └── system
│       ├── login_spec.rb                   # Rails System specs (using browser driver)
│       ...

Bug reports and pull requests are welcome on GitHub at https://github.com/leksster/granule. 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.