Class: BraveSearch::InstallGenerator
- Inherits:
-
Rails::Generators::Base
- Object
- Rails::Generators::Base
- BraveSearch::InstallGenerator
- Defined in:
- lib/generators/brave_search/install_generator.rb
Instance Method Summary collapse
Instance Method Details
#create_initializer ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/generators/brave_search/install_generator.rb', line 9 def create_initializer create_file "config/initializers/brave_search.rb", <<~RUBY # frozen_string_literal: true BraveSearch.configure do |config| # Get your API key from https://brave.com/search/api/ config.api_key = Rails.application.credentials.brave_api_key #{' '} # Optional configuration # config.timeout = 30 # config.retry_attempts = 3 end RUBY end |
#show_instructions ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/generators/brave_search/install_generator.rb', line 24 def show_instructions say <<~TEXT BraveSearch has been installed! Next steps: 1. Get your API key from https://brave.com/search/api/ 2. Add it to your Rails credentials: rails credentials:edit #{' '} Add this line: brave_api_key: your_api_key_here 3. Use the client: client = BraveSearch::Client.new results = client.search(q: "ruby programming") TEXT end |