Class: Redata::Task
- Inherits:
-
Object
- Object
- Redata::Task
- Defined in:
- lib/redata/tasks.rb
Constant Summary collapse
- @@schema =
Schema.new
Class Method Summary collapse
- .checkout_datasource(key) ⇒ Object
- .create_datasource(key) ⇒ Object
- .delete_datasource(key) ⇒ Object
- .deploy_datasource(key, stage) ⇒ Object
- .schema ⇒ Object
Class Method Details
.checkout_datasource(key) ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/redata/tasks.rb', line 34 def self.checkout_datasource(key) self.parse_key(key, [:view]).each do |config| config.tmp_mkdir Parser.gen_checkout_query config Log.action "CHECKOUT<#{config.category}>: to bucket [#{config.bucket_file}]" DATABASE.connect_redshift config bucket = S3Bucket.new bucket.move "#{config.bucket_file}000", config.bucket_file config.tmp_rmdir end end |
.create_datasource(key) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/redata/tasks.rb', line 9 def self.create_datasource(key) self.parse_key(key, [:table, :view]).each do |config| config.tmp_mkdir Parser.gen_create_query config if RED.is_append Log.action "APPEND<#{config.type}>: data(#{RED.start_time} ~ #{RED.end_time}) into [#{config.source_name}]" else Log.action "CREATE<#{config.type}>: [#{config.source_name}]" end DATABASE.connect_redshift config config.tmp_rmdir end end |
.delete_datasource(key) ⇒ Object
23 24 25 26 27 28 29 30 31 32 |
# File 'lib/redata/tasks.rb', line 23 def self.delete_datasource(key) self.parse_key(key, [:table, :view]).reverse.each do |config| config.tmp_mkdir Parser.gen_delete_query config Log.action "DROP<#{config.type}>: [#{config.source_name}]" Log.warning "WARNING: CASCADE mode will also drop other views that depend on this" if RED.is_forced DATABASE.connect_redshift config config.tmp_rmdir end end |
.deploy_datasource(key, stage) ⇒ Object
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/redata/tasks.rb', line 47 def self.deploy_datasource(key, stage) self.parse_key(key, [:view]).each do |config| config.tmp_mkdir bucket = S3Bucket.new bucket.make_public config.bucket_file, true Log.action "DOWNLOAD<bucket>: from [#{config.bucket_file}]" system "wget #{RED.s3['host']}/#{config.bucket_file} -O #{config.tmp_data_file} --quiet" bucket.make_public config.bucket_file, false Log.action "INJECT<#{config.category}>: with [#{config.name}] #{stage ? 'for stage '+stage : ''}" DATABASE.inject_data config, stage config.tmp_rmdir end end |
.schema ⇒ Object
5 6 7 |
# File 'lib/redata/tasks.rb', line 5 def self.schema @@schema end |