Class: WideEvents::Generators::InstallGenerator
- Inherits:
-
Rails::Generators::Base
- Object
- Rails::Generators::Base
- WideEvents::Generators::InstallGenerator
- Defined in:
- lib/generators/wide_events/install/install_generator.rb
Instance Method Summary collapse
- #add_agents_section ⇒ Object
- #create_initializer ⇒ Object
- #create_registry ⇒ Object
- #wire_test_helper ⇒ Object
Instance Method Details
#add_agents_section ⇒ Object
16 17 18 19 20 21 22 23 |
# File 'lib/generators/wide_events/install/install_generator.rb', line 16 def add_agents_section section = File.read(File.("templates/agents_md_section.md", __dir__)) if File.exist?(File.join(destination_root, "AGENTS.md")) append_to_file "AGENTS.md", "\n#{section}" else create_file "AGENTS.md", section end end |
#create_initializer ⇒ Object
8 9 10 |
# File 'lib/generators/wide_events/install/install_generator.rb', line 8 def create_initializer copy_file "initializer.rb", "config/initializers/wide_events.rb" end |
#create_registry ⇒ Object
12 13 14 |
# File 'lib/generators/wide_events/install/install_generator.rb', line 12 def create_registry copy_file "registry.yml", "config/wide_event/registry.yml" end |
#wire_test_helper ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/generators/wide_events/install/install_generator.rb', line 25 def wire_test_helper path = File.join(destination_root, "test/test_helper.rb") content = File.exist?(path) ? File.read(path) : "" if content.match?(%r{require "rails/test_help"\n}) && content.match?(/class TestCase\n/) inject_into_file "test/test_helper.rb", "require \"wide_event/test_helper\"\n", after: %r{require "rails/test_help"\n} inject_into_file "test/test_helper.rb", " include WideEvent::TestHelper\n", after: /class TestCase\n/ else say_status :skip, "test/test_helper.rb (not found or unrecognized) - wire the test helper manually:", :yellow say <<~MSG require "wide_event/test_helper" # after rails/test_help include WideEvent::TestHelper # inside ActiveSupport::TestCase MSG end end |