8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
|
# File 'lib/generators/lookout/install_generator.rb', line 8
def copy_templates
insert_into_file ::Rails.root.join("app/models/ahoy/event.rb").to_s, " include Lookout::Ahoy::EventMethods\n", after: "class Ahoy::Event < ApplicationRecord\n"
insert_into_file ::Rails.root.join("app/models/ahoy/visit.rb").to_s, " include Lookout::Ahoy::VisitMethods\n", after: "class Ahoy::Visit < ApplicationRecord\n"
template "config.rb", "config/initializers/lookout.rb"
route "mount Lookout::Engine => '/lookout'"
importmap_path = ::Rails.root.join("config/importmap.rb")
if File.exist?(importmap_path)
content = File.read(importmap_path)
unless content.include?("Lookout.importmap(self)")
append_to_file importmap_path.to_s, <<~RUBY
# Lookout (analytics dashboard)
Lookout.importmap(self)
RUBY
end
end
end
|