Sha256: cc81ffa19d6f0f83073bdd2f7304edaf4af18db2886ccb7076e091299fc15531

Contents?: true

Size: 536 Bytes

Versions: 14

Compression:

Stored size: 536 Bytes

Contents

class Baza::Commands::Importer
  def initialize(args)
    @db = args.fetch(:db)
    @debug = args[:debug]
    @io = args.fetch(:io)
  end

  def execute
    sql = ""

    @io.each_line do |line|
      next if line.strip.blank?
      next if line.start_with?("--")

      debug "Add line to SQL: #{line}" if @debug
      sql << line

      next unless line.end_with?(";\n")

      debug "Execute SQL: #{sql}" if @debug
      @db.query(sql)
      sql = ""
    end
  end

private

  def debug(message)
    puts message if @debug
  end
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
baza-0.0.38 lib/baza/commands/importer.rb
baza-0.0.37 lib/baza/commands/importer.rb
baza-0.0.36 lib/baza/commands/importer.rb
baza-0.0.35 lib/baza/commands/importer.rb
baza-0.0.34 lib/baza/commands/importer.rb
baza-0.0.33 lib/baza/commands/importer.rb
baza-0.0.32 lib/baza/commands/importer.rb
baza-0.0.31 lib/baza/commands/importer.rb
baza-0.0.30 lib/baza/commands/importer.rb
baza-0.0.29 lib/baza/commands/importer.rb
baza-0.0.28 lib/baza/commands/importer.rb
baza-0.0.27 lib/baza/commands/importer.rb
baza-0.0.26 lib/baza/commands/importer.rb
baza-0.0.25 lib/baza/commands/importer.rb