Class: Glass::Generators::InstallGenerator
- Inherits:
-
Rails::Generators::Base
- Object
- Rails::Generators::Base
- Glass::Generators::InstallGenerator
- Includes:
- Rails::Generators::Migration
- Defined in:
- lib/generators/glass/install/install_generator.rb
Class Method Summary collapse
Instance Method Summary collapse
- #copy_glass_templates ⇒ Object
- #create_configuration_file ⇒ Object
- #create_glass_account_migration ⇒ Object
- #create_initializer ⇒ Object
- #create_subscription_notifications_controller ⇒ Object
- #create_timeline_items_migration ⇒ Object
Class Method Details
.next_migration_number(path) ⇒ Object
25 26 27 |
# File 'lib/generators/glass/install/install_generator.rb', line 25 def self.next_migration_number(path) (Time.now.utc.strftime("%Y%m%d%H%M%S").to_i + 1).to_s end |
.source_root ⇒ Object
11 12 13 |
# File 'lib/generators/glass/install/install_generator.rb', line 11 def self.source_root @source_root ||= File.(File.join(File.dirname(__FILE__), 'templates')) end |
Instance Method Details
#copy_glass_templates ⇒ Object
40 41 42 |
# File 'lib/generators/glass/install/install_generator.rb', line 40 def copy_glass_templates directory("glass_templates", "app/views/glass") end |
#create_configuration_file ⇒ Object
15 16 17 |
# File 'lib/generators/glass/install/install_generator.rb', line 15 def create_configuration_file copy_file("google-oauth.yml", "config/google-api-keys.yml") end |
#create_glass_account_migration ⇒ Object
19 20 21 22 23 24 |
# File 'lib/generators/glass/install/install_generator.rb', line 19 def create_glass_account_migration generate("model", "google_account token refresh_token expires_at:integer email name id_token:text verification_secret #{user_model.underscore.singularize}:references") remove_file("app/models/google_account.rb") template("google_account.rb", "app/models/google_account.rb") insert_into_file("app/models/#{user_model.underscore.singularize}.rb", "\n\s\shas_one :google_account\n\n", after: "ActiveRecord::Base\n") end |
#create_initializer ⇒ Object
37 38 39 |
# File 'lib/generators/glass/install/install_generator.rb', line 37 def create_initializer copy_file "initializer.rb", "config/initializers/glass.rb" end |
#create_subscription_notifications_controller ⇒ Object
31 32 33 34 35 36 |
# File 'lib/generators/glass/install/install_generator.rb', line 31 def create_subscription_notifications_controller generate("controller", "glass/notifications") remove_file("app/controllers/glass/notifications_controller.rb") template("notifications_controller.rb", "app/controllers/glass/notifications_controller.rb") insert_into_file("config/routes.rb", "\n\s\spost 'glass/notifications', to: 'glass/notifications#callback', as: 'glass_notifications_callback'\n\n", after: "routes.draw\sdo\n") end |
#create_timeline_items_migration ⇒ Object
28 29 30 |
# File 'lib/generators/glass/install/install_generator.rb', line 28 def create_timeline_items_migration migration_template "glass_timeline_item_migration.rb", "db/migrate/create_glass_timeline_items.rb" end |