Class: Comodule::Deployment::Helper::Aws::S3::Service

Inherits:
Object
  • Object
show all
Includes:
Base
Defined in:
lib/comodule/deployment/helper/aws/s3.rb

Instance Method Summary collapse

Methods included from Base

included

Instance Method Details

#bucketObject



24
25
26
27
28
29
30
31
32
33
34
# File 'lib/comodule/deployment/helper/aws/s3.rb', line 24

def bucket
  return @bucket if @bucket

  bucket_obj = s3.buckets[bucket_name]
  @bucket =
    if bucket_obj.exists?
      bucket_obj
    else
      s3.buckets.create(bucket_name)
    end
end

#bucket_nameObject



20
21
22
# File 'lib/comodule/deployment/helper/aws/s3.rb', line 20

def bucket_name
  @bucket_name ||= config.s3_bucket
end

#cloud_to_local(s3_path) ⇒ Object



40
41
42
# File 'lib/comodule/deployment/helper/aws/s3.rb', line 40

def cloud_to_local(s3_path)
  s3_path.sub(%r|#{owner.name}/|, "#{owner.project_root}/")
end

#local_to_cloud(local_path) ⇒ Object



36
37
38
# File 'lib/comodule/deployment/helper/aws/s3.rb', line 36

def local_to_cloud(local_path)
  local_path.sub(%r|#{owner.project_root}/|, "#{owner.name}/")
end

#local_to_public_url(local_path) ⇒ Object



48
49
50
# File 'lib/comodule/deployment/helper/aws/s3.rb', line 48

def local_to_public_url(local_path)
  public_url local_to_cloud(local_path)
end

#public_url(s3_path) ⇒ Object



44
45
46
# File 'lib/comodule/deployment/helper/aws/s3.rb', line 44

def public_url(s3_path)
  s3.bucket[s3_path].public_url secure: true
end

#s3Object



16
17
18
# File 'lib/comodule/deployment/helper/aws/s3.rb', line 16

def s3
  @s3 ||= aws.s3
end