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.



42
43
44
# File 'lib/aws_s3_export/export.rb', line 42

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

Instance Method Details

#runObject



46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
# File 'lib/aws_s3_export/export.rb', line 46

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