Sha256: 70482fcb7f4f3aa44ab35071e39467c097d2516957286a67a6f88f3c957f7106
Contents?: true
Size: 690 Bytes
Versions: 2
Compression:
Stored size: 690 Bytes
Contents
module Dataclips class SQLQuery attr_accessor :configuration, :schema, :template def initialize(sqlfile) @template = parse_template(sqlfile) @configuration = parse_configuration(sqlfile) end def schema configuration["schema"] || {} end def variables configuration["variables"] || {} end def options @configuration["options"] || {} end private def parse_configuration(sqlfile) if matches = sqlfile.match(/\/\*\s+(.+)\s+\*\/\s+-- QUERY/m) YAML.load matches[1] else {} end end def parse_template(sqlfile) sqlfile.match(/(SELECT.+)/m)[1] end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
dataclips-0.0.2 | app/models/dataclips/sql_query.rb |
dataclips-0.0.1 | app/models/dataclips/sql_query.rb |