Sha256: b8ccf8f5a5f5a1fc3454cbd94e78113c1886165553ac323df1c048866ee168d5
Contents?: true
Size: 1.37 KB
Versions: 1
Compression:
Stored size: 1.37 KB
Contents
class Loco::FileInjectorGenerator < Rails::Generators::Base source_root File.expand_path('../templates', __FILE__) def routes file_path = File.join Rails.root, 'config', 'routes.rb' line = %Q{ mount Loco::Engine => '/notification-center'\n\n} inject_into_file file_path, line, after: "Rails.application.routes.draw do\n" end def application_helper file_path = File.join Rails.root, 'app', 'helpers', 'application_helper.rb' line = %Q{ include Loco::Helpers\n} inject_into_file file_path, line, after: "module ApplicationHelper\n" end def layout file_path = File.join Rails.root, 'app', 'views', 'layouts', 'application.html.erb' gsub_file file_path, '<body>', '<%= content_tag :body, loco_body_data do %>' gsub_file file_path, '</body>', '<% end %>' end def application_controller file_path = File.join Rails.root, 'app', 'controllers', 'application_controller.rb' data = File.read find_in_source_paths('application_controller.rb') after_line = "class ApplicationController < ActionController::Base\n" inject_into_file file_path, data, after: after_line end def connection return if Rails.version.to_f < 5 file_path = File.join Rails.root, 'app', 'channels', 'application_cable', 'connection.rb' data = File.read find_in_source_paths('connection.rb') inject_into_class file_path, 'Connection', data end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
loco-rails-3.0.0 | lib/generators/loco/file_injector/file_injector_generator.rb |