Sha256: c772a88d7c87b2afe547dabd4b76d6be9d2048c7799e790af2e97a9d5e91b435

Contents?: true

Size: 1009 Bytes

Versions: 1

Compression:

Stored size: 1009 Bytes

Contents

module Responders
  module Generators
    class InstallGenerator < Rails::Generators::Base
      def self.source_root
        @_source_root ||= File.expand_path("..", __FILE__)
      end

      desc "Creates an initializer with default responder configuration and copy locale file"

      def create_responder_file
        create_file "lib/application_responder.rb", <<-RUBY
class ApplicationResponder < ActionController::Responder
  include Responders::FlashResponder
  include Responders::HttpCacheResponder
end
        RUBY
      end

      def update_application_controller
        prepend_file "app/controllers/application_controller.rb", %{require "application_responder"\n\n}
        inject_into_class "app/controllers/application_controller.rb", "ApplicationController", <<-RUBY
  self.responder = ApplicationResponder
  respond_to :html

        RUBY
      end

      def copy_locale
        copy_file "../../responders/locales/en.yml", "config/locales/responders.en.yml"
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
responders-0.6.1 lib/generators/responders/install_generator.rb