From 8469be198d52586fa606f57d233c6a50dd3b0339 Mon Sep 17 00:00:00 2001
From: Kieran Trezona-le Comte <trezona-lecomte@gmail.com>
Date: Fri, 17 Jul 2015 11:48:18 +1200
Subject: [PATCH] Make linter results a lazy collection

---
 lib/sqlint/linter.rb | 2 +-
 spec/sqlint_spec.rb  | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/lib/sqlint/linter.rb b/lib/sqlint/linter.rb
index 262a906..432383a 100644
--- a/lib/sqlint/linter.rb
+++ b/lib/sqlint/linter.rb
@@ -12,7 +12,7 @@ module SQLint
     end
 
     def run
-      [].tap do |results|
+      Enumerator.new do |results|
         state = ParseState.new(@input, 0)
         while state != END_PARSE
           error, new_parse_state = parse_next_error(state)
diff --git a/spec/sqlint_spec.rb b/spec/sqlint_spec.rb
index dfb2f49..cf63d47 100644
--- a/spec/sqlint_spec.rb
+++ b/spec/sqlint_spec.rb
@@ -7,7 +7,7 @@ RSpec.describe SQLint do
   let(:input) { "SELECT 1" }
   let(:input_stream) { StringIO.new(input) }
   subject(:linter) { SQLint::Linter.new(filename, input_stream) }
-  let(:results) { linter.run }
+  let(:results) { linter.run.to_a }
 
   def error(line, col, msg)
     SQLint::Linter::Lint.new(filename, line, col, :error, msg)
-- 
GitLab