Sha256: 821c959b089bf59db6d912ab64b7b95c87291fffcc0d16a6b100a98c2c74fd48
Contents?: true
Size: 1.3 KB
Versions: 15
Compression:
Stored size: 1.3 KB
Contents
def evaluate_query(driver, src, opts = {}) ss = StringScanner.new(src.dup) buf = '' until ss.eos? if (tok = ss.scan %r{[^`'";\\/#]+}) #' buf << tok elsif (tok = ss.scan /`(?:[^`]|``)*`/) buf << tok elsif (tok = ss.scan /'(?:[^']|'')*'/) #' buf << tok elsif (tok = ss.scan /"(?:[^"]|"")*"/) #" buf << tok elsif (tok = ss.scan %r{/\*/?(?:\n|[^/]|[^*]/)*\*/}) # nothing to do elsif (tok = ss.scan /--[^\r\n]*(?:\r\n|\r|\n|\Z)/) # nothing to do elsif (tok = ss.scan /#[^\r\n]*(?:\r\n|\r|\n|\Z)/) # nothing to do elsif (tok = ss.scan /(?:\\;)/) buf << ';' # escape of ';' elsif (tok = ss.scan /(?:;|\\G)/) src.replace(ss.rest) query = buf buf = '' if query.strip.empty? print_error('No query specified') next end start_time = Time.new out = driver.execute(query) elapsed = Time.now - start_time if out.kind_of?(DynamoDB::Driver::Rownum) print_rownum(out, :time => elapsed) elsif out.kind_of?(String) puts out elsif out opts = opts.merge(:inline => (tok != '\G'), :time => elapsed) print_json(out, opts) end elsif (tok = ss.scan /./) buf << tok # 落ち穂拾い end end src.replace(buf.strip) buf end
Version data entries
15 entries across 15 versions & 1 rubygems