Class: Jekyll::S3::Upload

Inherits:
Object
  • Object
show all
Defined in:
lib/jekyll-s3/upload.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(path, s3, config, site_dir) ⇒ Upload

Returns a new instance of Upload.



9
10
11
12
13
14
15
# File 'lib/jekyll-s3/upload.rb', line 9

def initialize(path, s3, config, site_dir)
  @path = path
  @full_path = "#{site_dir}/#{path}"
  @file = File.open("#{site_dir}/#{path}")
  @s3 = s3
  @config = config
end

Instance Attribute Details

#configObject (readonly)

Returns the value of attribute config.



7
8
9
# File 'lib/jekyll-s3/upload.rb', line 7

def config
  @config
end

#fileObject (readonly)

Returns the value of attribute file.



7
8
9
# File 'lib/jekyll-s3/upload.rb', line 7

def file
  @file
end

#full_pathObject (readonly)

Returns the value of attribute full_path.



7
8
9
# File 'lib/jekyll-s3/upload.rb', line 7

def full_path
  @full_path
end

#pathObject (readonly)

Returns the value of attribute path.



7
8
9
# File 'lib/jekyll-s3/upload.rb', line 7

def path
  @path
end

#s3Object (readonly)

Returns the value of attribute s3.



7
8
9
# File 'lib/jekyll-s3/upload.rb', line 7

def s3
  @s3
end

Instance Method Details

#detailsObject



23
24
25
# File 'lib/jekyll-s3/upload.rb', line 23

def details
  "#{path}#{" [gzipped]" if gzip?}#{" [max-age=#{max_age}]" if cache_control?}"
end

#perform!Object



17
18
19
20
21
# File 'lib/jekyll-s3/upload.rb', line 17

def perform!
  success = s3.buckets[config['s3_bucket']].objects[path].write(upload_file, upload_options)
  upload_file.close
  success
end