Class: AwsS3Export::Export

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

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Export

Returns a new instance of Export.



4
5
6
# File 'lib/aws_s3_export/export.rb', line 4

def initialize(options = {})
  @config = Config.new(options)
end

Instance Method Details

#runObject



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/aws_s3_export/export.rb', line 8

def run
  set_config

  # Create the basic S3 object
  @s3 = AWS::S3.new

  # Load up the 'bucket' we want to store things in
  @bucket = @s3.buckets[@config.bucket_name]

  # If the bucket doesn't exist, create it
  unless @bucket.exists?
    puts "Need to make bucket #{@config.bucket_name}.."
    @s3.buckets.create(@config.bucket_name)
  end

  Dir.entries(@config.export_dir).each do |dir_or_file|
    puts "Work in #{dir_or_file}"
    save_file_or_dir(dir_or_file)
  end

end