LoginSignup
6
6

More than 5 years have passed since last update.

Padrino の Plugin を使う

Last updated at Posted at 2013-01-22

Plugin Generator

Padrino にはテンプレートと同じような仕組みとして Plugin Generator がある。
利用できるプラグインはここで公開されている。

また、以下のコマンドで Plugin の一覧を参照できる。

$ padrino g plugin -l
Available plugins:
  - ["960"]
  - ["access"]
  - ["ar_permalink_i18n"]
  - ["ar_permalink"]
  - ["ar_textile"]
  - ["ar_translate"]
  - ["auto_locale"]
  - ["barista"]
  - ["better_errors"]
  - ["blueprint"]
  - ["bootstrap"]
  - ["bug"]
  - ["carrierwave"]
  - ["codehighlighter"]
  - ["coderay"]
  - ["coffee"]
  - ["deflect"]
  - ["disqus"]
  - ["dreamhost"]
  - ["exception_notifier"]
  - ["flash_session"]
  - ["fluxflex"]
  - ["googleanalytics"]
  - ["heroku"]
  - ["hoptoad"]
  - ["jammit"]
  - ["maintenance"]
  - ["omniauth"]
  - ["openid"]
  - ["payment"]
  - ["recaptcha"]
  - ["resque"]
  - ["rewrite"]
  - ["secure_only"]
  - ["tripoli"]
  - ["vcr"]
  - ["watchr"]
  - ["will_paginate"]

Plugin の適用

Plugin は作成したプロジェクトに適用することができる。

$ padrino g plugin [template_path]

今回は新規プロジェクトに better_errors を追加した。

$ padrino g plugin better_errors
       apply  https://github.com/padrino/padrino-recipes/raw/master/plugins/better_errors_plugin.rb
      append    Gemfile
      insert    config/boot.rb

それぞれのファイルの変更点を確認してみる。

# Better Errors
group :development do
  gem "better_errors"
  gem "binding_of_caller"
end
config/boot.rb
# Setup better_errors
if Padrino.env == :development
  require 'better_errors'
  Padrino::Application.use BetterErrors::Middleware
  BetterErrors.application_root = PADRINO_ROOT
  BetterErrors.logger = Padrino.logger
end

この状態で

$ bundle install

すると利用できるようになる。

おわりに

便利。

6
6
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
6
6