Skip to content
This repository has been archived by the owner on Feb 29, 2024. It is now read-only.

Add asset_sync gem #67

Merged
merged 3 commits into from
Oct 19, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 21 additions & 3 deletions recipes/carrier_wave.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,19 @@ class CarrierWave < Base

def gems
@template.gem 'carrierwave'
@template.gem 'asset_sync'
@template.gem 'fog-aws'
end

def cook
add_initializer
add_application_config
add_production_env_config
end

private

def add_initializer
@template.initializer 'carrierwave.rb', <<~CODE
require 'carrierwave/storage/fog'
CarrierWave.configure do |config|
Expand All @@ -29,14 +38,23 @@ def cook
}
end
CODE
end

def add_application_config
@template.append_file '.env.sample', "\nAWS_ACCESS_KEY=''"
@template.append_file '.env', "\nAWS_ACCESS_KEY=''"
@template.append_file '.env.sample', "\nAWS_SECRET_KEY=''"
@template.append_file '.env', "\nAWS_SECRET_KEY=''"
@template.append_file '.env.sample', "\nAWS_S3_BUCKET=''"
@template.append_file '.env.sample', "\nFOG_DIRECTORY=''"
@template.append_file '.env', "\nAWS_ACCESS_KEY=''"
@template.append_file '.env', "\nAWS_SECRET_KEY=''"
@template.append_file '.env', "\nAWS_S3_BUCKET=''"
end
@template.append_file '.env', "\nFOG_DIRECTORY=''"
end

def add_production_env_config
@template.gsub_file 'config/environments/production.rb',
'# config.action_controller.asset_host = \'http://assets.example.com\'',
'config.action_controller.asset_host = "//#{ENV[\'FOG_DIRECTORY\']}.s3.amazonaws.com"'
end
end
end