Class: Solidstats::Generators::InstallGenerator
- Inherits:
-
Rails::Generators::Base
- Object
- Rails::Generators::Base
- Solidstats::Generators::InstallGenerator
- Defined in:
- lib/generators/solidstats/install/install_generator.rb
Overview
This generator installs Solidstats in the host application
This will:
-
Add the Solidstats routes to the host application’s config/routes.rb
-
Create a solidstats directory for data storage
-
Add the solidstats directory to .gitignore
-
Show a helpful README with next steps
Instance Method Summary collapse
- #add_routes ⇒ Object
- #add_to_gitignore ⇒ Object
- #create_solidstats_directory ⇒ Object
- #show_next_steps ⇒ Object
Instance Method Details
#add_routes ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/generators/solidstats/install/install_generator.rb', line 19 def add_routes route_string = %Q(mount Solidstats::Engine => "/solidstats") route_code = %Q( # Solidstats Routes (development only) #{route_string} if Rails.env.development? ) # Check if the route already exists if File.read(File.join(destination_root, "config", "routes.rb")).include?(route_string) say_status :skip, "Solidstats route already exists", :yellow else route route_code.strip say_status :routes, "Mounting Solidstats engine at /solidstats (development only)", :green end end |
#add_to_gitignore ⇒ Object
41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/generators/solidstats/install/install_generator.rb', line 41 def add_to_gitignore gitignore_path = File.join(destination_root, ".gitignore") gitignore_content = "\n# Solidstats data directory\nsolidstats/\n" if File.exist?(gitignore_path) append_to_file ".gitignore", gitignore_content unless File.read(gitignore_path).include?("solidstats/") else create_file ".gitignore", gitignore_content.strip end say_status :update, ".gitignore to exclude solidstats directory", :green end |
#create_solidstats_directory ⇒ Object
35 36 37 38 39 |
# File 'lib/generators/solidstats/install/install_generator.rb', line 35 def create_solidstats_directory empty_directory "solidstats" create_file "solidstats/.keep", "" say_status :create, "solidstats directory for data storage", :green end |
#show_next_steps ⇒ Object
53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 |
# File 'lib/generators/solidstats/install/install_generator.rb', line 53 def show_next_steps say "" say "✅ Solidstats has been installed successfully!", :green say "" say "To get started, you need to prime the data for the dashboard." say "You can prime data for all services at once by running:", :yellow say " rake solidstats:prime:all", :cyan say "" say "Or, you can run them individually:", :yellow say " rake solidstats:prime:log_size" say " rake solidstats:prime:bundler_audit" say " rake solidstats:prime:todos" say " rake solidstats:prime:style_patrol" say " rake solidstats:prime:coverage" say " rake solidstats:prime:load_lens" say "" say "After the tasks complete, start your server and visit http://localhost:3000/solidstats to see the dashboard." end |