Sha256: c0ba62f353265a0d56066872e836e829ae6a646110fc8899cc4e823498b3ab8f

Contents?: true

Size: 1.26 KB

Versions: 5

Compression:

Stored size: 1.26 KB

Contents

# frozen_string_literal: true

module Cybele
  module Helpers
    module Responders
      def configure_responders
        # Add gems
        append_file('Gemfile', template_content('responders/responders_Gemfile.erb'))
        run_bundle

        # Add initializers
        bundle_command 'exec rails generate responders:install'

        replace_responders_file_contents
      end

      private

      def replace_responders_file_contents
        # Add js and json to respond :html
        replace_in_file 'app/controllers/application_controller.rb',
                        'respond_to :html',
                        'respond_to :html, :js, :json'
        comment_lines 'app/controllers/application_controller.rb',
                      /self.responder = ApplicationResponder/
        replace_in_file 'app/controllers/application_controller.rb',
                        'require "application_responder"',
                        "require 'application_responder'"
        # Remove comments in locale/responders.yml
        remove_file 'config/locales/responders.en.yml', force: true
        copy_file 'config/locales/responders.tr.yml', 'config/locales/responders.tr.yml'
        copy_file 'config/locales/responders.en.yml', 'config/locales/responders.en.yml'
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
cybele-2.3.2 lib/cybele/helpers/responders.rb
cybele-2.3.1 lib/cybele/helpers/responders.rb
cybele-2.2.0 lib/cybele/helpers/responders.rb
cybele-2.1.0 lib/cybele/helpers/responders.rb
cybele-2.0.0 lib/cybele/helpers/responders.rb