Sha256: 98a1ba5f5495cc7d6e92b81a35c39f5b00563f68717758dcb315d2c61ef065ce

Contents?: true

Size: 1.15 KB

Versions: 13

Compression:

Stored size: 1.15 KB

Contents

module Responders
  module Generators
    class InstallGenerator < Rails::Generators::Base
      source_root File.expand_path("..", __FILE__)

      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

  # Uncomment this responder if you want your resources to redirect to the collection
  # path (index action) instead of the resource path for POST/PUT/DELETE requests.
  # include Responders::CollectionResponder
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

13 entries across 13 versions & 1 rubygems

Version Path
responders-1.1.0 lib/generators/responders/install_generator.rb
responders-1.0.0 lib/generators/responders/install_generator.rb
responders-1.0.0.rc lib/generators/responders/install_generator.rb
responders-0.9.3 lib/generators/responders/install_generator.rb
responders-0.9.2 lib/generators/responders/install_generator.rb
responders-0.9.1 lib/generators/responders/install_generator.rb
responders-0.9.0 lib/generators/responders/install_generator.rb
responders-0.8.0 lib/generators/responders/install_generator.rb
responders-0.7.0 lib/generators/responders/install_generator.rb
responders-0.6.5 lib/generators/responders/install_generator.rb
responders-0.6.4 lib/generators/responders/install_generator.rb
responders-0.6.3 lib/generators/responders/install_generator.rb
responders-0.6.2 lib/generators/responders/install_generator.rb