each_sql 0.2.0 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.rdoc +3 -0
- data/Rakefile +2 -2
- data/VERSION +1 -1
- data/lib/each_sql/each_sql.rb +10 -11
- metadata +85 -77
data/CHANGELOG.rdoc
CHANGED
data/Rakefile
CHANGED
@@ -17,8 +17,8 @@ Jeweler::Tasks.new do |gem|
|
|
17
17
|
gem.name = "each_sql"
|
18
18
|
gem.homepage = "http://github.com/junegunn/each_sql"
|
19
19
|
gem.license = "MIT"
|
20
|
-
gem.summary = %Q{Enumerate
|
21
|
-
gem.description = %Q{Enumerate
|
20
|
+
gem.summary = %Q{Enumerate each SQL statement in SQL scripts.}
|
21
|
+
gem.description = %Q{Enumerate each SQL statement in SQL scripts.}
|
22
22
|
gem.email = "junegunn.c@gmail.com"
|
23
23
|
gem.authors = ["Junegunn Choi"]
|
24
24
|
# dependencies defined in Gemfile
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.2.
|
1
|
+
0.2.1
|
data/lib/each_sql/each_sql.rb
CHANGED
@@ -16,14 +16,13 @@ class EachSQL
|
|
16
16
|
end
|
17
17
|
|
18
18
|
def each
|
19
|
-
# Phase 1: comment out input
|
20
19
|
@input = @org_input.dup
|
21
|
-
@input_c = zero_out @org_input
|
22
|
-
|
23
20
|
return nil if @input.nil? || @input.empty?
|
24
21
|
|
25
|
-
|
22
|
+
# Zero out comments and string literals to simplify subsequent parsing
|
23
|
+
@input_c = zero_out @org_input
|
26
24
|
|
25
|
+
@delimiter = @options[:delimiter]
|
27
26
|
while @input && @input.length > 0
|
28
27
|
# Extract a statement
|
29
28
|
statement = next_statement
|
@@ -44,8 +43,7 @@ class EachSQL
|
|
44
43
|
end
|
45
44
|
|
46
45
|
# Ignore
|
47
|
-
if
|
48
|
-
(@options[:ignore] || []).all? { |ipat| statement !~ ipat }
|
46
|
+
if (@options[:ignore] || []).all? { |ipat| statement !~ ipat }
|
49
47
|
yield statement
|
50
48
|
@prev_statement = statement
|
51
49
|
end
|
@@ -54,7 +52,9 @@ class EachSQL
|
|
54
52
|
nil
|
55
53
|
end
|
56
54
|
|
55
|
+
# To change delimiter while parsing the input
|
57
56
|
attr_accessor :delimiter, :delimiter_string
|
57
|
+
|
58
58
|
private
|
59
59
|
def zero_out input
|
60
60
|
output = input.dup
|
@@ -82,7 +82,7 @@ private
|
|
82
82
|
end
|
83
83
|
|
84
84
|
ret = @input[0...@cur].strip
|
85
|
-
@input =
|
85
|
+
@input = @input[@cur..-1]
|
86
86
|
@input_c = @input_c[@cur..-1]
|
87
87
|
return ret
|
88
88
|
end
|
@@ -91,9 +91,9 @@ private
|
|
91
91
|
# Look for the closest delimiter
|
92
92
|
md = match @input_c, @delimiter, @cur
|
93
93
|
delim_start = md ? md[:begin] : @input.length
|
94
|
-
delim_end = md ? md[:end]
|
94
|
+
delim_end = md ? md[:end] : @input.length
|
95
95
|
|
96
|
-
# Look for the closest block
|
96
|
+
# Look for the closest block depending on the current context
|
97
97
|
target_blocks =
|
98
98
|
if @options[:nesting_context].any? {|pat| @input_c.match pat }
|
99
99
|
@all_blocks
|
@@ -121,8 +121,6 @@ private
|
|
121
121
|
return :done
|
122
122
|
end
|
123
123
|
|
124
|
-
# #####################################
|
125
|
-
|
126
124
|
# We found a block. Look for the end of it
|
127
125
|
@cur = body_start
|
128
126
|
|
@@ -143,6 +141,7 @@ private
|
|
143
141
|
return :continue
|
144
142
|
end
|
145
143
|
|
144
|
+
# For Ruby 1.8 compatibility
|
146
145
|
def match str, pat, idx
|
147
146
|
md = str[idx..-1].match(pat)
|
148
147
|
return nil if md.nil?
|
metadata
CHANGED
@@ -1,96 +1,104 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: each_sql
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.0
|
3
|
+
version: !ruby/object:Gem::Version
|
5
4
|
prerelease:
|
5
|
+
version: 0.2.1
|
6
6
|
platform: ruby
|
7
|
-
authors:
|
8
|
-
- Junegunn Choi
|
7
|
+
authors:
|
8
|
+
- Junegunn Choi
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
12
|
+
|
13
|
+
date: 2011-06-20 00:00:00 +09:00
|
14
|
+
default_executable:
|
15
|
+
dependencies:
|
16
|
+
- !ruby/object:Gem::Dependency
|
17
|
+
name: bundler
|
18
|
+
version_requirements: &id001 !ruby/object:Gem::Requirement
|
19
|
+
none: false
|
20
|
+
requirements:
|
21
|
+
- - ~>
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: 1.0.0
|
24
|
+
requirement: *id001
|
25
|
+
prerelease: false
|
26
|
+
type: :development
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: jeweler
|
29
|
+
version_requirements: &id002 !ruby/object:Gem::Requirement
|
30
|
+
none: false
|
31
|
+
requirements:
|
32
|
+
- - ~>
|
33
|
+
- !ruby/object:Gem::Version
|
34
|
+
version: 1.6.2
|
35
|
+
requirement: *id002
|
36
|
+
prerelease: false
|
37
|
+
type: :development
|
38
|
+
- !ruby/object:Gem::Dependency
|
39
|
+
name: rcov
|
40
|
+
version_requirements: &id003 !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ">="
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: "0"
|
46
|
+
requirement: *id003
|
47
|
+
prerelease: false
|
48
|
+
type: :development
|
49
|
+
description: Enumerate each SQL statement in SQL scripts.
|
48
50
|
email: junegunn.c@gmail.com
|
49
51
|
executables: []
|
52
|
+
|
50
53
|
extensions: []
|
51
|
-
|
52
|
-
|
53
|
-
-
|
54
|
-
|
55
|
-
|
56
|
-
-
|
57
|
-
-
|
58
|
-
- Gemfile
|
59
|
-
-
|
60
|
-
-
|
61
|
-
-
|
62
|
-
-
|
63
|
-
-
|
64
|
-
- lib/each_sql
|
65
|
-
-
|
66
|
-
- test/
|
67
|
-
- test/
|
54
|
+
|
55
|
+
extra_rdoc_files:
|
56
|
+
- LICENSE.txt
|
57
|
+
- README.rdoc
|
58
|
+
files:
|
59
|
+
- .document
|
60
|
+
- CHANGELOG.rdoc
|
61
|
+
- Gemfile
|
62
|
+
- Gemfile.lock
|
63
|
+
- LICENSE.txt
|
64
|
+
- README.rdoc
|
65
|
+
- Rakefile
|
66
|
+
- VERSION
|
67
|
+
- lib/each_sql.rb
|
68
|
+
- lib/each_sql/each_sql.rb
|
69
|
+
- test/helper.rb
|
70
|
+
- test/postgres.sql
|
71
|
+
- test/test_each_sql.rb
|
72
|
+
has_rdoc: true
|
68
73
|
homepage: http://github.com/junegunn/each_sql
|
69
|
-
licenses:
|
70
|
-
- MIT
|
74
|
+
licenses:
|
75
|
+
- MIT
|
71
76
|
post_install_message:
|
72
77
|
rdoc_options: []
|
73
|
-
|
74
|
-
|
75
|
-
|
78
|
+
|
79
|
+
require_paths:
|
80
|
+
- lib
|
81
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
76
82
|
none: false
|
77
|
-
requirements:
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
83
|
+
requirements:
|
84
|
+
- - ">="
|
85
|
+
- !ruby/object:Gem::Version
|
86
|
+
hash: 2
|
87
|
+
segments:
|
88
|
+
- 0
|
89
|
+
version: "0"
|
90
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
85
91
|
none: false
|
86
|
-
requirements:
|
87
|
-
|
88
|
-
|
89
|
-
|
92
|
+
requirements:
|
93
|
+
- - ">="
|
94
|
+
- !ruby/object:Gem::Version
|
95
|
+
version: "0"
|
90
96
|
requirements: []
|
97
|
+
|
91
98
|
rubyforge_project:
|
92
|
-
rubygems_version: 1.
|
99
|
+
rubygems_version: 1.5.1
|
93
100
|
signing_key:
|
94
101
|
specification_version: 3
|
95
|
-
summary: Enumerate
|
102
|
+
summary: Enumerate each SQL statement in SQL scripts.
|
96
103
|
test_files: []
|
104
|
+
|