Sha256: 1623dc4a5af8c9f19a3d25a1038901fad5acc10b983edd8bf3905bb41de68538

Contents?: true

Size: 1.16 KB

Versions: 3

Compression:

Stored size: 1.16 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', '~> 5.0'
    paperclip_config =
      <<~RUBY
        config.paperclip_defaults = {
          storage: :s3,
          s3_protocol: 'https',
          s3_region: ENV.fetch('AWS_REGION', 'us-east-1'),
          s3_credentials: {
            bucket: ENV['S3_BUCKET']
          }
        }
      RUBY
    application paperclip_config, 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

3 entries across 3 versions & 1 rubygems

Version Path
potassium-5.2.2 lib/potassium/recipes/paperclip.rb
potassium-5.2.1 lib/potassium/recipes/paperclip.rb
potassium-5.2.0 lib/potassium/recipes/paperclip.rb