Sha256: 080c434b1f8b1e05ecf4b7a729217cb9354ccce25177d82c02c0e75d3d4cd279

Contents?: true

Size: 1.1 KB

Versions: 1

Compression:

Stored size: 1.1 KB

Contents

class Recipes::Paperclip < Rails::AppBuilder
  def ask
    paperclip = answer(:paperclip) { Ask.confirm("Do you want to use Paperclip for uploads?") }
    set(:paperclip, paperclip)
  end

  def create
    return unless selected?(:paperclip)
    add_paperclip
    config_rspec
  end

  def install
    add_paperclip
    config_rspec if gem_exists?(/rspec-rails/)
  end

  def installed?
    gem_exists?(/paperclip/)
  end

  private

  def add_paperclip
    gather_gem 'paperclip', '~> 4.3'
    paperclip_config =
      <<-RUBY.gsub(/^ {7}/, '')
         config.paperclip_defaults = {
           storage: :s3,
           s3_credentials: {
             bucket: ENV['S3_BUCKET']
           }
         }
         RUBY
    application paperclip_config.strip, env: 'production'
    append_to_file '.env.development', "S3_BUCKET=\n"
    append_to_file '.gitignore', "/public/system/*\n"
    add_readme_section :internal_dependencies, :paperclip
  end

  def config_rspec
    copy_file '../assets/testing/platanus.png', 'spec/assets/platanus.png'
    copy_file '../assets/testing/paperclip.rb', 'spec/support/paperclip.rb'
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
potassium-2.3.0 lib/potassium/recipes/paperclip.rb