Class: Stoplight::Generators::InstallGenerator
- Inherits:
-
Rails::Generators::Base
- Object
- Rails::Generators::Base
- Stoplight::Generators::InstallGenerator
- Defined in:
- lib/generators/stoplight/install/install_generator.rb,
sig/_private/generators/stoplight/install/install_generator.rbs
Overview
:nodoc:
Constant Summary collapse
- ROUTES_PATH =
"config/routes.rb"- STOPLIGHT_CONFIG_TEMPLATE =
"stoplight.rb.erb"- INITIALIZERS_PATH =
"config/initializers"- AFTER_INSTALL_NOTIFICATION =
<<~TEXT \nThank you for using stoplight! Now to finish configuration: * Run `bundle` from the project root to install new gems * Go to 'config/initializers/stoplight.rb' to set up connection to Redis.\n TEXT
- STOPLIGHT_ADMIN_ROUTE =
<<-RUBY mount Stoplight::Admin => '/stoplights' RUBY
- STOPLIGHT_AUTH =
<<-RUBY Stoplight::Admin.use(Rack::Auth::Basic) do |username, password| username == ENV["STOPLIGHT_ADMIN_USERNAME"] && password == ENV["STOPLIGHT_ADMIN_PASSWORD"] end RUBY
Instance Method Summary collapse
- #copy_file ⇒ void
- #generate_admin_panel ⇒ void
- #generate_initializer ⇒ void
- #generate_redis_gem ⇒ void
- #generate_sinatra_deps ⇒ void
- #inject_into_file ⇒ void
- #options ⇒ Hash[Symbol, untyped]
- #redis_configuration_notification ⇒ void
Instance Method Details
#copy_file ⇒ void
This method returns an undefined value.
18 |
# File 'sig/_private/generators/stoplight/install/install_generator.rbs', line 18
def copy_file: (String, String) -> void
|
#generate_admin_panel ⇒ void
This method returns an undefined value.
67 68 69 70 71 72 73 |
# File 'lib/generators/stoplight/install/install_generator.rb', line 67 def generate_admin_panel if [:with_admin_panel] route_config = "#{STOPLIGHT_AUTH}#{STOPLIGHT_ADMIN_ROUTE}\n" inject_into_file ROUTES_PATH, route_config, after: ".application.routes.draw do\n" end end |
#generate_initializer ⇒ void
This method returns an undefined value.
62 63 64 65 |
# File 'lib/generators/stoplight/install/install_generator.rb', line 62 def generate_initializer initializer_template = STOPLIGHT_CONFIG_TEMPLATE copy_file initializer_template, "#{INITIALIZERS_PATH}/stoplight.rb" end |
#generate_redis_gem ⇒ void
This method returns an undefined value.
44 45 46 47 48 49 |
# File 'lib/generators/stoplight/install/install_generator.rb', line 44 def generate_redis_gem if [:with_admin_panel] conf = "\ngem 'redis'" inject_into_file "Gemfile", conf end end |
#generate_sinatra_deps ⇒ void
This method returns an undefined value.
51 52 53 54 55 56 57 58 59 60 |
# File 'lib/generators/stoplight/install/install_generator.rb', line 51 def generate_sinatra_deps if [:with_admin_panel] conf = <<~RUBY gem 'sinatra', require: false gem 'sinatra-contrib', require: false RUBY inject_into_file "Gemfile", "\n#{conf}" end end |
#inject_into_file ⇒ void
This method returns an undefined value.
19 |
# File 'sig/_private/generators/stoplight/install/install_generator.rbs', line 19
def inject_into_file: (String path, String what, ?after: String) -> void
|
#options ⇒ Hash[Symbol, untyped]
11 |
# File 'sig/_private/generators/stoplight/install/install_generator.rbs', line 11
def options: -> Hash[Symbol, untyped]
|
#redis_configuration_notification ⇒ void
This method returns an undefined value.
75 76 77 |
# File 'lib/generators/stoplight/install/install_generator.rb', line 75 def redis_configuration_notification print AFTER_INSTALL_NOTIFICATION end |