each_sql 0.2.1 → 0.2.2
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.rdoc +3 -0
- data/VERSION +1 -1
- data/lib/each_sql/each_sql.rb +2 -2
- data/test/test_each_sql.rb +7 -0
- metadata +1 -1
data/CHANGELOG.rdoc
CHANGED
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.2.
|
1
|
+
0.2.2
|
data/lib/each_sql/each_sql.rb
CHANGED
@@ -8,7 +8,7 @@ class EachSQL
|
|
8
8
|
def initialize input, options
|
9
9
|
raise NotImplementedError.new if options.nil?
|
10
10
|
# immutables
|
11
|
-
@org_input = input.sub(/\A#{[65279].pack('U*')}/, '') # BOM
|
11
|
+
@org_input = input && input.sub(/\A#{[65279].pack('U*')}/, '') # BOM
|
12
12
|
@options = options
|
13
13
|
@blocks = @options[:blocks]
|
14
14
|
@nblocks = @options[:nesting_blocks]
|
@@ -16,8 +16,8 @@ class EachSQL
|
|
16
16
|
end
|
17
17
|
|
18
18
|
def each
|
19
|
+
return nil if @org_input.nil? || @org_input.empty?
|
19
20
|
@input = @org_input.dup
|
20
|
-
return nil if @input.nil? || @input.empty?
|
21
21
|
|
22
22
|
# Zero out comments and string literals to simplify subsequent parsing
|
23
23
|
@input_c = zero_out @org_input
|
data/test/test_each_sql.rb
CHANGED
@@ -218,6 +218,13 @@ select
|
|
218
218
|
end
|
219
219
|
|
220
220
|
def test_sql
|
221
|
+
[nil, "", " \n" * 10].each do |input|
|
222
|
+
EachSQL(input).each do |sql|
|
223
|
+
assert false, 'Should not enumerate'
|
224
|
+
end
|
225
|
+
assert true, 'No error expected'
|
226
|
+
end
|
227
|
+
|
221
228
|
script = @sql.map { |e| e.strip + ';' }.join $/
|
222
229
|
EachSQL(script).each_with_index do |sql,idx|
|
223
230
|
puts sql
|