Class: Redata::Parser
- Inherits:
-
Object
- Object
- Redata::Parser
- Defined in:
- lib/redata/parser.rb
Constant Summary collapse
- COMMENT_REGEX =
/-{2}.*/
- LOAD_REGEX =
/#load (.*)->([^,]*),?/
- LOAD_PARAMS_REGEX =
/,([^,>]*)>([^,>]*)/
- IF_REGEX =
/\[\s*if ([^\s]*) is ([^\]]*)\]/
- IFNUL_REGEX =
/\[\s*if ([^\s]*) is null\s*\]/
- ENDIF_REGEX =
/\[\s*endif\s*\]/
- START_TIME_REGEX =
/\[start_time\]/
- END_TIME_REGEX =
/\[end_time\]/
- TIME_OFFSET_REGEX =
/\[(\d+) days ago\]/
- CURRENT_TIME_REGEX =
/\[current_time\]/
- LOCALS_REGEX =
/\[([^\[\]<>\s]+)\]/
- LOCALS_LIST_REGEX =
/\[<([^\[\]<>\s]+)>\]/
Class Method Summary collapse
- .gen_adjust_query(config) ⇒ Object
- .gen_checkout_query(config) ⇒ Object
- .gen_create_query(config) ⇒ Object
- .gen_delete_query(config) ⇒ Object
Class Method Details
.gen_adjust_query(config) ⇒ Object
42 43 44 |
# File 'lib/redata/parser.rb', line 42 def self.gen_adjust_query(config) self.parse config.query_file, config.tmp_exec_file, '' end |
.gen_checkout_query(config) ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/redata/parser.rb', line 30 def self.gen_checkout_query(config) Log.error! "ERROR: Only could checkout data from view" unless config.type == :view File.open config.tmp_exec_file, 'w' do |f| f.puts "UNLOAD ('" f.puts "SELECT * FROM #{config.source_name}" f.puts "') to 's3://#{RED.s3['bucket']}/#{config.bucket_file}'" f.puts "CREDENTIALS 'aws_access_key_id=#{RED.s3['aws_access_key_id']};aws_secret_access_key=#{RED.s3['aws_secret_access_key']}'" f.puts "ESCAPE ALLOWOVERWRITE PARALLEL OFF DELIMITER AS '\\t';" end end |
.gen_create_query(config) ⇒ Object
16 17 18 19 20 21 22 |
# File 'lib/redata/parser.rb', line 16 def self.gen_create_query(config) if config.type == :table self.gen_table_query config elsif config.type == :view self.gen_view_query config end end |
.gen_delete_query(config) ⇒ Object
24 25 26 27 28 |
# File 'lib/redata/parser.rb', line 24 def self.gen_delete_query(config) File.open config.tmp_exec_file, 'w' do |f| f.puts "DROP #{config.type} #{config.source_name} #{RED.is_forced ? 'CASCADE' : 'RESTRICT'};" end end |