Sha256: 98920f09ce022679fd8da24380941af90bf6b72a1daa517e225d097310a3f5cb
Contents?: true
Size: 1.35 KB
Versions: 1
Compression:
Stored size: 1.35 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, opts.merge(:inline => (tok != '\G'))) 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, $stdout, opts) end elsif (tok = ss.scan /./) buf << tok # 落ち穂拾い end end src.replace(buf.strip) buf end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
ddbcli-0.2.5 | lib/ddbcli/cli/evaluate.rb |