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 CHANGED
@@ -1,3 +1,6 @@
1
+ === 0.2.2 / 2011/06/21
2
+ * Bug fix: Error on nil/empty input
3
+
1
4
  === 0.2.1 / 2011/06/20
2
5
  * Fixed invalid gem packaging
3
6
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.2.1
1
+ 0.2.2
@@ -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
@@ -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
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: each_sql
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.2.1
5
+ version: 0.2.2
6
6
  platform: ruby
7
7
  authors:
8
8
  - Junegunn Choi