nidhindamodaran / acts_as_pluggable

Make a rails app into pluggable

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

ActsAsPluggable

Make a rails app pluggable

Installation

Add this line to your application's Gemfile:

gem 'acts_as_pluggable'

And then execute:

$ bundle

Or install it yourself as:

$ gem install acts_as_pluggable

Usage

Add following line in Gemfile

  gem 'acts_as_pluggable',github: 'tachyons/acts_as_pluggable'
  Dir[File.join(File.dirname(__FILE__), '/plugins/*')].each do |plugin_dir|
    gem(File.basename(plugin_dir), path: plugin_dir)
  end
rails plugin new 'plugins/sample_plugin --full'

Now register plugin from engine.rb Eg,

module SamplePlugin
  class Engine < ::Rails::Engine
    if defined?(ActsAsPluggable)
      ::ActsAsPluggable::Plugin.register(:sample_plugin,:sample_tag,{
        :engine=>self,
        :description=>"sample description",
        :website=> "https://github.com/tachyons/acts_as_pluggable",
        :author=> "Aboobacker MK",
        :version=>SamplePlugin::VERSION,
        :settings=>{
          :display_in_topbar=>true
        }
        })
    end
  end
end

Features

  • Loading plugins from plugin folder
  • Registering plugins using hash
  • Iterate through plugins
  • Activate/Inactivate plugins
  • Configuration to select list of plugins to be loaded
  • Testing the plugin on the context of main app
  • DSL for registering the plugin
  • Generic way for making and registering application hooks

Development

After checking out the repo, run bin/setup to install dependencies. Then, run rake spec to run the tests. You can also run bin/console for an interactive prompt that will allow you to experiment.

To install this gem onto your local machine, run bundle exec rake install. To release a new version, update the version number in version.rb, and then run bundle exec rake release, which will create a git tag for the version, push git commits and tags, and push the .gem file to rubygems.org.

Contributing

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

About

Make a rails app into pluggable

License:MIT License


Languages

Language:Ruby 97.3%Language:Shell 2.7%