Class: Vehicles::Generators::InstallGenerator
- Inherits:
-
Rails::Generators::Base
- Object
- Rails::Generators::Base
- Vehicles::Generators::InstallGenerator
- Defined in:
- lib/generators/vehicles/install_generator.rb
Overview
‘rails generate vehicles:install`
Writes a configuration initializer and an optional refresh job. There is deliberately NO migration: ‘vehicles` ships its dataset bundled in the gem and reads it from memory, so there’s no table to create and nothing to seed. The gem works the moment it’s in your Gemfile; this generator gives you a place to set a region / API key, and a job to keep the data current without waiting for a gem upgrade.
Instance Method Summary collapse
Instance Method Details
#create_initializer ⇒ Object
18 19 20 |
# File 'lib/generators/vehicles/install_generator.rb', line 18 def create_initializer template "initializer.rb", "config/initializers/vehicles.rb" end |
#create_refresh_job ⇒ Object
22 23 24 |
# File 'lib/generators/vehicles/install_generator.rb', line 22 def create_refresh_job template "vehicles_refresh_job.rb", "app/jobs/vehicles_refresh_job.rb" end |
#display_post_install_message ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/generators/vehicles/install_generator.rb', line 26 def say "\n🚗 vehicles installed!", :green say "\nNo migration needed — the dataset ships inside the gem and just works." say "\nTry it now:" say " Vehicles.makes # => [\"Alfa Romeo\", \"Audi\", ...]", :cyan say " Vehicles.models(\"VW\") # => [\"Golf\", \"Polo\", ...]", :cyan say " Vehicles.make_options # => [[\"Audi\", \"audi\"], ...] (for select)", :cyan say "\nConfig (optional) lives in config/initializers/vehicles.rb." say "Add a VehiclesDB API key there to unlock years, images, and segments." say "\nStay current WITHOUT a gem upgrade: schedule VehiclesRefreshJob", :yellow say "(e.g. daily in config/recurring.yml) to pull the latest published data.\n" end |