Sha256: 464b0127cfec642be746172ddfd9f8d964dd4302616453457a83d48427765b07
Contents?: true
Size: 854 Bytes
Versions: 3
Compression:
Stored size: 854 Bytes
Contents
module SchemaPlus module Core module SqlStruct IndexComponents = KeyStruct[:name, :type, :columns, :options, :algorithm, :using] class Table < KeyStruct[:command, :name, :body, :options, :quotechar] def parse!(sql) m = sql.strip.match %r{ ^ (?<command>.*\bTABLE\b) \s* (?<quote>['"`])(?<name>\S+)\k<quote> \s* \( \s* (?<body>.*) \s* \) \s* (?<options> \S.*)? $ }mxi self.command = m[:command] self.quotechar = m[:quote] self.name = m[:name] self.body = m[:body] self.options = m[:options] end def assemble ["#{command} #{quotechar}#{name}#{quotechar} (#{body})", options].reject(&:blank?).join(" ") end end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
schema_plus_core-0.6.1 | lib/schema_plus/core/sql_struct.rb |
schema_plus_core-0.6.0 | lib/schema_plus/core/sql_struct.rb |
schema_plus_core-0.5.1 | lib/schema_plus/core/sql_struct.rb |