Module: Takenoko

Extended by:
Takenoko
Included in:
Takenoko
Defined in:
lib/takenoko/s3.rb,
lib/takenoko/s3/client.rb,
lib/takenoko/s3/version.rb,
lib/takenoko/s3/takenoko.rb,
lib/takenoko/s3/attach_helper.rb,
lib/takenoko/s3/mapping_generator.rb

Defined Under Namespace

Modules: AttachHelper, MappingGenerator, S3 Classes: Railtie

Instance Method Summary collapse

Instance Method Details

#download_and_upload_all_to_s3Object



34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/takenoko/s3/takenoko.rb', line 34

def download_and_upload_all_to_s3
  errors = []
  mapping_config[:tables].each do |table,conf|
    next if conf[:attach_files].blank?
    begin
      download_and_upload_table_to_s3 table
    rescue Exception => e
      errors << e.to_s
    end
  end
  raise errors.join("\n") unless errors.empty?
  return true
end

#download_and_upload_table_to_s3(table_name) ⇒ Object



27
28
29
30
31
32
# File 'lib/takenoko/s3/takenoko.rb', line 27

def download_and_upload_table_to_s3(table_name)
  table_data = google_client.get_table(table_name)
  raise "attach_files not set" unless table_data[:attach_files].present?
  AttachHelper.download table_data
  AttachHelper.upload_to_s3 table_data 
end

#s3Object



3
4
5
# File 'lib/takenoko/s3/takenoko.rb', line 3

def s3
  S3
end

#upload_all_to_s3Object



13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/takenoko/s3/takenoko.rb', line 13

def upload_all_to_s3
  errors = []
  mapping_config[:tables].each do |table,conf|
    next if conf[:attach_files].blank?
    begin
      upload_table_to_s3 table
    rescue Exception => e
      errors << e.to_s
    end
  end
  raise errors.join("\n") unless errors.empty?
  return true
end

#upload_table_to_s3(table_name) ⇒ Object



7
8
9
10
11
# File 'lib/takenoko/s3/takenoko.rb', line 7

def upload_table_to_s3(table_name)
  table_data = google_client.get_table(table_name)
  raise "attach_files not set" unless table_data[:attach_files].present?
  AttachHelper.upload_to_s3 table_data
end