Class: Upkeep::InstallGenerator
- Inherits:
-
Rails::Generators::Base
- Object
- Rails::Generators::Base
- Upkeep::InstallGenerator
- Includes:
- Rails::Generators::Migration
- Defined in:
- lib/generators/upkeep/install/install_generator.rb
Class Method Summary collapse
Instance Method Summary collapse
- #create_browser_bootstrap ⇒ Object
- #create_initializer ⇒ Object
- #create_subscription_migration ⇒ Object
- #mount_action_cable ⇒ Object
- #show_identity_setup_guidance ⇒ Object
Class Method Details
.next_migration_number(dirname) ⇒ Object
13 14 15 |
# File 'lib/generators/upkeep/install/install_generator.rb', line 13 def self.next_migration_number(dirname) ActiveRecord::Generators::Base.next_migration_number(dirname) end |
Instance Method Details
#create_browser_bootstrap ⇒ Object
28 29 30 31 32 |
# File 'lib/generators/upkeep/install/install_generator.rb', line 28 def create_browser_bootstrap template "subscription.js", "app/javascript/upkeep/subscription.js" append_application_import pin_action_cable end |
#create_initializer ⇒ Object
24 25 26 |
# File 'lib/generators/upkeep/install/install_generator.rb', line 24 def create_initializer template "upkeep.rb", "config/initializers/upkeep.rb" end |
#create_subscription_migration ⇒ Object
17 18 19 20 21 22 |
# File 'lib/generators/upkeep/install/install_generator.rb', line 17 def create_subscription_migration return if migration_exists?("create_upkeep_subscriptions") @migration_version = ActiveRecord::Migration.current_version migration_template "create_upkeep_subscriptions.rb.erb", "db/migrate/create_upkeep_subscriptions.rb" end |
#mount_action_cable ⇒ Object
34 35 36 37 38 |
# File 'lib/generators/upkeep/install/install_generator.rb', line 34 def mount_action_cable return if routes_path.exist? && routes_path.read.include?("ActionCable.server") route %(mount ActionCable.server => "/cable") end |
#show_identity_setup_guidance ⇒ Object
40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/generators/upkeep/install/install_generator.rb', line 40 def show_identity_setup_guidance usages = detected_identity_usages return if usages.empty? say "\nIdentity setup required", :yellow say "Upkeep found request-side identity usage:" usages.each { |usage| say " #{usage}" } say "Upkeep does not infer subscriber identity by naming convention." say "Add an explicit Upkeep::Rails.configure identity mapping in config/initializers/upkeep.rb." say "Pages that depend on undeclared non-absent CurrentAttributes or Warden identities are refused for live updates." say "" end |