Class: Ruport::SqlSplit

Inherits:
Array
  • Object
show all
Defined in:
lib/ruport/util/query.rb

Overview

Created by Francis Hwang, 2005.12.31 Copyright © 2005, All Rights Reserved. ++

Instance Method Summary collapse

Constructor Details

#initialize(sql) ⇒ SqlSplit

:nodoc:



247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
# File 'lib/ruport/util/query.rb', line 247

def initialize( sql )
  super()
  next_sql = ''
  sql.each do |line|
    unless line =~ /^--/ or line =~ %r{^/\*.*\*/;} or line =~ /^\s*$/
      next_sql << line
      if line =~ /;$/
        next_sql.gsub!( /;\s$/, '' )
        self << next_sql
        next_sql = ''
      end
    end
  end
  self << next_sql if next_sql != ''
end