Sha256: ac744f02f7ce582f5eb8e343e63c0e740ebb949a35395438be70a179aa2a874b

Contents?: true

Size: 874 Bytes

Versions: 3

Compression:

Stored size: 874 Bytes

Contents

module Backup
  class S3Generator < Rails::Generators::NamedBase
    source_root File.expand_path('../templates', __FILE__)
    argument :name, type: :string, default: ""

    def copy_initializer_file
      template 's3_backup.rake', "lib/tasks/s3_backup.rake"
      template 'schedule.rb', "config/schedule.rb"

      append_file 'config/deploy.rb' do
        <<-RUBY


set :whenever_command, "bundle exec whenever"
require "whenever/capistrano"
        RUBY
      end

      inject_into_file 'config/deploy/production.rb', before: "load 'deploy/assets'" do
        <<-RUBY
set :whenever_environment, 'production'

        RUBY
      end

      append_file 'Gemfile' do
        <<-RUBY

# Backup
gem 'aws-sdk', '~> 2'

# Crontab
gem 'whenever', require: false
        RUBY
      end
      Bundler.with_clean_env do
        run "bundle install"
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
raro_generator-0.2.1 lib/generators/backup/s3/s3_generator.rb
raro_generator-0.1.1 lib/generators/backup/s3/s3_generator.rb
raro_generator-0.1.0 lib/generators/backup/s3/s3_generator.rb