Class: LlmCostTracker::Generators::InstallGenerator
- Inherits:
-
Rails::Generators::Base
- Object
- Rails::Generators::Base
- LlmCostTracker::Generators::InstallGenerator
- Includes:
- ActiveRecord::Generators::Migration
- Defined in:
- lib/llm_cost_tracker/generators/llm_cost_tracker/install_generator.rb
Instance Method Summary collapse
- #create_initializer ⇒ Object
- #create_migration_file ⇒ Object
- #create_prices_file ⇒ Object
- #mount_engine ⇒ Object
Instance Method Details
#create_initializer ⇒ Object
28 29 30 31 32 33 |
# File 'lib/llm_cost_tracker/generators/llm_cost_tracker/install_generator.rb', line 28 def create_initializer destination = "config/initializers/llm_cost_tracker.rb" return if File.exist?(File.join(destination_root, destination)) template("initializer.rb.erb", destination) end |
#create_migration_file ⇒ Object
21 22 23 24 25 26 |
# File 'lib/llm_cost_tracker/generators/llm_cost_tracker/install_generator.rb', line 21 def create_migration_file migration_template( "create_llm_cost_tracker_calls.rb.erb", "db/migrate/create_llm_cost_tracker_calls.rb" ) end |
#create_prices_file ⇒ Object
35 36 37 38 39 40 |
# File 'lib/llm_cost_tracker/generators/llm_cost_tracker/install_generator.rb', line 35 def create_prices_file return unless [:prices] require_relative "prices_generator" invoke LlmCostTracker::Generators::PricesGenerator end |
#mount_engine ⇒ Object
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/llm_cost_tracker/generators/llm_cost_tracker/install_generator.rb', line 42 def mount_engine return unless [:dashboard] say(<<~MSG, :yellow) The LLM Cost Tracker dashboard ships without authentication. Mount it in config/routes.rb behind your app's admin auth, e.g.: authenticate :admin do mount LlmCostTracker::Engine => "/llm-costs" end The generator does NOT add a route automatically — leaving the dashboard unauthenticated would expose spend, tags, and provider IDs to anyone. MSG end |