Sha256: 5e2f0397ad72fe4493beb01df3e6fffda7c79a3c3f2008356e1adc2a78b38fa8

Contents?: true

Size: 716 Bytes

Versions: 14

Compression:

Stored size: 716 Bytes

Contents

require 'English'

module S3Repo
  ##
  # Base object, used to provide common attributes
  class Base
    def initialize(params = {})
      @options = params
    end

    private

    def run(cmd)
      results = `#{cmd} 2>&1`
      return results if $CHILD_STATUS.success?
      fail "Failed running #{cmd}:\n#{results}"
    end

    def bucket
      @bucket ||= @options[:bucket] || ENV['S3_BUCKET']
      return @bucket if @bucket
      fail('No bucket given')
    end

    def client
      @client ||= @options[:client] || Client.new(bucket: bucket)
    end

    def file_cache
      @file_cache ||= @options[:file_cache] || Cache.new(
        client: client, tmpdir: @options[:tmpdir]
      )
    end
  end
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
s3repo-1.0.0 lib/s3repo/base.rb
s3repo-0.3.4 lib/s3repo/base.rb
s3repo-0.3.3 lib/s3repo/base.rb
s3repo-0.3.2 lib/s3repo/base.rb
s3repo-0.3.1 lib/s3repo/base.rb
s3repo-0.3.0 lib/s3repo/base.rb
s3repo-0.2.0 lib/s3repo/base.rb
s3repo-0.1.7 lib/s3repo/base.rb
s3repo-0.1.5 lib/s3repo/base.rb
s3repo-0.1.4 lib/s3repo/base.rb
s3repo-0.1.3 lib/s3repo/base.rb
s3repo-0.1.2 lib/s3repo/base.rb
s3repo-0.1.1 lib/s3repo/base.rb
s3repo-0.1.0 lib/s3repo/base.rb