Class: AwsS3Export::Config

Inherits:
Object
  • Object
show all
Defined in:
lib/aws_s3_export/config.rb

Overview

Set config for export: s3_config = AwsS3Export::Config.new(:export_dir => ‘/your/dir/’, :bucket_name =>‘your_bucker_name’, :prefix => “dir”, :access_key => xxx, :secret_access_key => xxx )

:export_dir - directory of files or directories for export :prefix - prefix for saving to s3 :bucket_name - name of bucket s3 :access_key - access key id of s3 :secret_access_key - secret access key of s3 :rewrite_existing_files - if you want to rewrite set as true :acl - access controll like in docs.amazonwebservices.com/AWSRubySDK/latest/AWS/S3/S3Object.html#write-instance_method in aws-sdk default as public_read

Get config for example the export_dir: s3_config.export_dir #=> /your/dir/

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Config

Returns a new instance of Config.

Raises:



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/aws_s3_export/config.rb', line 22

def initialize(options = {})
  validation_options.each do |o|
    raise NoParams.new if options[o].empty?
  end

  raise NotDir.new unless File.stat(options[:export_dir]).directory?

  @access_key = options[:access_key]
  @secret_access_key = options[:secret_access_key]
  @export_dir = options[:export_dir] || "./" # the current directory
  @bucket_name = options[:bucket_name]
  @prefix = options[:prefix] || ""
  @rewrite_existing_files = options[:rewrite_existing_files] || false 
  @acl = options[:acl] || :public_read 
end

Instance Attribute Details

#access_keyObject (readonly)

Returns the value of attribute access_key.



20
21
22
# File 'lib/aws_s3_export/config.rb', line 20

def access_key
  @access_key
end

#aclObject (readonly)

Returns the value of attribute acl.



20
21
22
# File 'lib/aws_s3_export/config.rb', line 20

def acl
  @acl
end

#bucket_nameObject (readonly)

Returns the value of attribute bucket_name.



20
21
22
# File 'lib/aws_s3_export/config.rb', line 20

def bucket_name
  @bucket_name
end

#export_dirObject (readonly)

Returns the value of attribute export_dir.



20
21
22
# File 'lib/aws_s3_export/config.rb', line 20

def export_dir
  @export_dir
end

#prefixObject (readonly)

Returns the value of attribute prefix.



20
21
22
# File 'lib/aws_s3_export/config.rb', line 20

def prefix
  @prefix
end

#rewrite_existing_filesObject (readonly)

Returns the value of attribute rewrite_existing_files.



20
21
22
# File 'lib/aws_s3_export/config.rb', line 20

def rewrite_existing_files
  @rewrite_existing_files
end

#secret_access_keyObject (readonly)

Returns the value of attribute secret_access_key.



20
21
22
# File 'lib/aws_s3_export/config.rb', line 20

def secret_access_key
  @secret_access_key
end