Class: TokenHawk::Generators::InstallGenerator
- Inherits:
-
Rails::Generators::Base
- Object
- Rails::Generators::Base
- TokenHawk::Generators::InstallGenerator
- Includes:
- Rails::Generators::Migration
- Defined in:
- lib/generators/token_hawk/install/install_generator.rb
Class Method Summary collapse
Instance Method Summary collapse
- #create_initializer ⇒ Object
- #create_migrations ⇒ Object
- #mount_engine ⇒ Object
- #show_readme ⇒ Object
Class Method Details
.next_migration_number(path) ⇒ Object
15 16 17 18 |
# File 'lib/generators/token_hawk/install/install_generator.rb', line 15 def self.next_migration_number(path) next_migration_number = current_migration_number(path) + 1 ActiveRecord::Migration.next_migration_number(next_migration_number) end |
Instance Method Details
#create_initializer ⇒ Object
24 25 26 |
# File 'lib/generators/token_hawk/install/install_generator.rb', line 24 def create_initializer template "token_hawk.rb", "config/initializers/token_hawk.rb" end |
#create_migrations ⇒ Object
20 21 22 |
# File 'lib/generators/token_hawk/install/install_generator.rb', line 20 def create_migrations migration_template "create_token_hawk_calls.rb", "db/migrate/create_token_hawk_calls.rb" end |
#mount_engine ⇒ Object
28 29 30 |
# File 'lib/generators/token_hawk/install/install_generator.rb', line 28 def mount_engine route 'mount TokenHawk::Engine => "/token_hawk"' end |
#show_readme ⇒ Object
32 33 34 35 36 37 38 39 |
# File 'lib/generators/token_hawk/install/install_generator.rb', line 32 def show_readme say "\n✅ TokenHawk installed. Next steps:", :green say " 1. bin/rails db:migrate" say " 2. Attribute LLM calls — two interfaces:" say " TokenHawk.track(domain: :my_feature) { client.messages.create(...) }" say " TokenHawk.record(domain: :my_feature, model: \"...\", input_tokens: N, output_tokens: N, latency_ms: N)" say " 3. Visit /token_hawk for the dashboard\n" end |