All Projects → amatsuda → Motorhead

amatsuda / Motorhead

Licence: mit
A Rails Engine framework that helps safe and rapid feature prototyping

Programming Languages

ruby
36898 projects - #4 most used programming language

Projects that are alternatives of or similar to Motorhead

Test track
Server app for the TestTrack multi-platform split-testing and feature-gating system
Stars: ✭ 100 (-45.05%)
Mutual labels:  rails, ab-testing
Erd
A Rails engine for drawing your app's ER diagram
Stars: ✭ 296 (+62.64%)
Mutual labels:  rails, engine
Split
📈 The Rack Based A/B testing framework
Stars: ✭ 2,539 (+1295.05%)
Mutual labels:  rails, ab-testing
Passwordless
🗝 Authentication for your Rails app without the icky-ness of passwords
Stars: ✭ 638 (+250.55%)
Mutual labels:  rails, engine
Decidim
The participatory democracy framework. A generator and multiple gems made with Ruby on Rails
Stars: ✭ 894 (+391.21%)
Mutual labels:  rails, engine
Pay
Payments for Ruby on Rails apps
Stars: ✭ 759 (+317.03%)
Mutual labels:  rails, engine
Maktoub
A simple newsletter engine for Rails
Stars: ✭ 308 (+69.23%)
Mutual labels:  rails, engine
Heavens door
Capybara test scenario recorder for Rails
Stars: ✭ 857 (+370.88%)
Mutual labels:  rails, engine
Sabisu Rails
Simple and powerful engine for exploring your Rails api application
Stars: ✭ 129 (-29.12%)
Mutual labels:  rails, engine
Cve 2019 5418
CVE-2019-5418 - File Content Disclosure on Ruby on Rails
Stars: ✭ 169 (-7.14%)
Mutual labels:  rails
Wei
微信服务号裂变引擎,提供一套简单明了的DSL,快速配置和接入服务号裂变。 wechat fission platform, for technological dimensionality reduction.
Stars: ✭ 177 (-2.75%)
Mutual labels:  rails
Foreman
an application that automates the lifecycle of servers
Stars: ✭ 2,102 (+1054.95%)
Mutual labels:  rails
Baumeister
👷 The aim of this project is to help you to build your things. From Bootstrap themes over static websites to single page applications.
Stars: ✭ 171 (-6.04%)
Mutual labels:  prototyping
React Native Turbolinks
React Native adapter for building hybrid apps with Turbolinks 5
Stars: ✭ 177 (-2.75%)
Mutual labels:  rails
Acli
Action Cable command-line client
Stars: ✭ 169 (-7.14%)
Mutual labels:  rails
Google Optimize Module
SSR friendly Google Optimize module for Nuxt.js
Stars: ✭ 180 (-1.1%)
Mutual labels:  ab-testing
Turbolinks render
Support for `render` with Turbolinks in Rails controllers
Stars: ✭ 168 (-7.69%)
Mutual labels:  rails
Monogame.forms
MonoGame.Forms is the easiest way of integrating a MonoGame render window into your Windows Forms project. It should make your life much easier, when you want to create your own editor environment.
Stars: ✭ 165 (-9.34%)
Mutual labels:  engine
Vxr
General purpose engine written in C++ with emphasis on materials rendering (PBR, clear coat, anisotropy, iridescence)
Stars: ✭ 181 (-0.55%)
Mutual labels:  engine
Eshop Prices
Nintendo Switch - Full game list with prices
Stars: ✭ 179 (-1.65%)
Mutual labels:  rails

Motorhead

Motorhead is a prototyping framework for Rails. It's something akin to "feature toggle". It can be used for "A/B testing" as well. But essentially, the main purpose of this framework is to provide a way to rapidly and safely deliver new features to the production environment.

Installation

Bundle into your Rails app.

Features

Isolated Engine

Motorhead helps you mounting specially creafted Isolated Engines onto the main Rails app. An engine can contain whole MVC components, which means that you can encapsulate everything that are needed for your new feature under one single directory. This helps your team creating multiple new features simultaneously without causing code conflict.

Conditional Execution

Each Motorhead engine can be configured to be enabled/disabled. The condition is not just a flag but can be a Ruby Proc which will be dynamically evaluated on each request in the controller context.

Error-proof

If any RuntimeError happens inside an engine on the production environment, Motorhead absorbs the error and executes the appropriate fallback code so that the end users would never even notice the occurrence of the error.

Extending Action Methods in the Main App

Motorhead provides an interface to override the main app's controller actions.

Partially Extending Views in the Main App

Motorhead provides a hook to partially overwrite any part of your existing view.

Structure

main_app
├── Gemfile
├── Gemfile.lock
├── Rakefile
├── app
│   ├── assets
│   ├── controllers
│   ├── engines
│   │   ├── my_awesome_new_feature
│   │   │   ├── app
│   │   │   │   ├── assets
│   │   │   │   ├── controllers
│   │   │   │   │   └── my_awesome_new_feature
│   │   │   │   │       └── welcome_controller.rb
│   │   │   │   ├── helpers
│   │   │   │   │   └── my_awesome_new_feature
│   │   │   │   │       └── welcome_helper.rb
│   │   │   │   ├── mailers
│   │   │   │   ├── models
│   │   │   │   └── views
│   │   │   │       ├── layouts
│   │   │   │       │   └── my_awesome_new_feature
│   │   │   │       │       └── application.html.erb
│   │   │   │       └── my_awesome_new_feature
│   │   │   │           └── welcome
│   │   │   ├── config
│   │   │   │   └── routes.rb
│   │   │   ├── lib
│   │   │   │   ├── my_awesome_new_feature
│   │   │   │   │   └── engine.rb
│   │   │   │   ├── my_awesome_new_feature.rb
│   │   │   │   └── tasks
│   │   │   ├── my_awesome_new_feature.gemspec
│   │   │   └── test
│   │   └── yet_another_new_feature
│   │       ├── app
│   │       ...
│   ├── helpers
│   ├── mailers
│   ├── models
│   └── views
├── bin
├── config
├── db
...

Components

lib/ENGINE_NAME/engine.rb

Put active_if directive inside the Engine class. The whole engine will only be executed if the block is evaluated to be truthy on runtime.

Example:

# app/engines/my_awesome_new_feature/config/routes.rb
module MyAwesomeNewFeature
  class Engine < ::Rails::Engine
    include Motorhead::Engine

    # this whole engine will be executed only when logged in as admin users
    active_if { current_user.admin? }
  end
end

You can configure a path to mount the Engine via mount_at directive. This value is defaulted to "/", which means the Engine routes will be mixed into the main app's routes.

Example:

# app/engines/my_awesome_new_feature/config/routes.rb
module MyAwesomeNewFeature
  class Engine < ::Rails::Engine
    include Motorhead::Engine

    # all routes inside this Engine will be prefixed by "/harley"
    mount_at 'harley'
  end
end

routes.rb

All routes in engines' routes.rb will be automatically prepended to the main app's Routes.

Controllers

Controllers can be a normal Engine controller. Or, you can craft a controller class inheriting a controller that exists in the main app, and overriding some action methods. From inside the actions in engines, you can call the main app's action via super.

Example:

# app/engines/my_awesome_new_feature/app/controllers/my_awesome_new_feature/welcome_controller.rb
class MyAwesomeNewFeature::WelcomeController < ::WelcomeController
  include Motorhead::Controller

  def index
    # invoking the main app's action first
    super

    # adding some more business logic
    @notifications = Notification.for current_user
  end
end

Views

When an engine renders the views, it looks up app/views/ENGINE_NAME/ directory first, then the main app's view directory next. This way you can overwrite views per template/partial file. Also, Motorhead adds new :engine option to render method, which enables you to explicitly inject a piece of HTML from an engine into any place of the app. render :engine takes an `ENGINE_NAME/view_path' parameter.

Example:

# app/engines/my_awesome_new_feature/app/views/my_awesome_new_feature/welcome/_index.html.haml
.new_feature
  Some contents for new feature

# app/views/welcome/index.html.haml
= render engine: 'my_awesome_new_feature/welcome/index' do
  Some contents that will be shown by default

Generators

Motorhead provides some handy code generators.

Generating an engine

% rails g motorhead ENGINE_NAME

Example:

% rails g motorhead my_awesome_new_feature

This generates a motorhead Engine in ~/app/engines/my_awesome_new_feature/ directory.

Generating an engine + a controller extension that extends an existing controller

% rails g motorhead ENGINE_NAME CONTROLLER_NAME [action action] [options]

Example:

% rails g motorhead my_awesome_new_feature welcome index

This generates a motorhead Engine in ~/app/engines/my_awesome_new_feature/ directory. Plus, a controller that extends WelcomeController and implements index action inside the Engine.

Managing Engines

Motorhead includes a tiny admin console Engine call "RoadCrew" through which you can easily enable/disable each mounted Engine. To use this, require 'motorhead/road_crew' when bundling motorhead gem in your Gemfile:

# Gemfile
gem 'motorhead', path: '~/src/motorhead', require: ['motorhead', 'motorhead/road_crew']

then render the road_crew/button Engine partial to put a button inside somewhere in your view (usually in the header or footer?):

# app/views/layouts/application.html.erb
<%= render engine: 'road_crew/button' %>

You might also want to configure the RoadCrew Engine's active_if directive for security.

# config/initializers/mh_road_crew.rb
RoadCrew::Engine.active_if { current_user.admin? }

Contributing

Pull requests are welcome on GitHub at https://github.com/amatsuda/motorhead.

Todo

  • Better generator

  • Model extension

  • Documentation

Special Thanks

This product is deeply inspired by Chanko.

License

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

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].