Class: Boring::ActiveStorage::Azure::InstallGenerator

Inherits:
Rails::Generators::Base
  • Object
show all
Defined in:
lib/generators/boring/active_storage/azure/install/install_generator.rb

Instance Method Summary collapse

Instance Method Details

#add_active_storageObject



10
11
12
13
14
15
# File 'lib/generators/boring/active_storage/azure/install/install_generator.rb', line 10

def add_active_storage
  unless options[:skip_active_storage]
    say "Adding ActiveStorage", :green
    run "bin/rails active_storage:install"
  end
end

#add_azure_storage_configurationObject



36
37
38
39
40
41
42
43
44
45
46
# File 'lib/generators/boring/active_storage/azure/install/install_generator.rb', line 36

def add_azure_storage_configuration
  microsoft_storage_config_content = "    microsoft:\n      service: AzureStorage\n      storage_account_name: your_account_name\n      storage_access_key: <%= Rails.application.credentials.dig(:azure_storage, :storage_access_key) %>\n      container: your_container_name\n  RUBY\n\n  append_to_file \"config/storage.yml\", microsoft_storage_config_content\nend\n"

#add_azure_to_the_applicationObject



17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/generators/boring/active_storage/azure/install/install_generator.rb', line 17

def add_azure_to_the_application
  say "Adding mircosoft azure gem", :green
  Bundler.with_unbundled_env do
    azure_gem_content = "      \\n\n      # for Azure Service\n      gem \"azure-storage-blob\", require: false\n    RUBY\n    append_to_file \"Gemfile\", azure_gem_content\n    run \"bundle install\"\n  end\nend\n"

#add_configuration_to_productionObject



30
31
32
33
34
# File 'lib/generators/boring/active_storage/azure/install/install_generator.rb', line 30

def add_configuration_to_production
  gsub_file "config/environments/production.rb",
            "config.active_storage.service = :local",
            "config.active_storage.service = :microsoft"
end