each_sql 0.3.1 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.markdown +4 -1
- data/README.markdown +1 -1
- data/VERSION +1 -1
- data/lib/each_sql/each_sql.rb +2 -0
- data/lib/each_sql/parser.rb +1 -1
- data/lib/each_sql.rb +5 -14
- data/test/test_each_sql.rb +3 -2
- metadata +4 -4
data/CHANGELOG.markdown
CHANGED
@@ -1,10 +1,13 @@
|
|
1
|
+
### 0.4.0 / 2013/05/15
|
2
|
+
* Returns an Enumerator instead of an Array when block is not given
|
3
|
+
|
1
4
|
### 0.3.1 / 2012/03/15
|
2
5
|
* Bug fix: `begin transaction`
|
3
6
|
* `EachSQL#clear`
|
4
7
|
|
5
8
|
### 0.3.0 / 2012/03/10
|
6
9
|
* Internal implementation revised.
|
7
|
-
* At first, I thought this would be trivial,
|
10
|
+
* At first, I thought this would be trivial,
|
8
11
|
that I didn't need a real parser for just breaking SQL scripts
|
9
12
|
into individual executable units.
|
10
13
|
I couldn't be more wrong. Codes for handling a few exceptional cases
|
data/README.markdown
CHANGED
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.4.0
|
data/lib/each_sql/each_sql.rb
CHANGED
data/lib/each_sql/parser.rb
CHANGED
data/lib/each_sql.rb
CHANGED
@@ -9,10 +9,11 @@ require 'each_sql/parser'
|
|
9
9
|
# @param[String] input Input script.
|
10
10
|
# @param[Symbol] The type of the input SQL script. :default, :mysql, and :oracle (or :plsql)
|
11
11
|
# @yield[String] Executable SQL statement or block.
|
12
|
-
# @return[
|
12
|
+
# @return[Enumerator] Enumerator of executable SQL statements and blocks.
|
13
13
|
def EachSQL input, type = :default
|
14
|
+
return enum_for(:EachSQL, input, type) unless block_given?
|
15
|
+
|
14
16
|
esql = EachSQL.new(type)
|
15
|
-
ret = []
|
16
17
|
result = {}
|
17
18
|
|
18
19
|
process = lambda {
|
@@ -20,11 +21,7 @@ def EachSQL input, type = :default
|
|
20
21
|
result = esql.shift
|
21
22
|
sqls = result[:sqls]
|
22
23
|
sqls.each do |sql|
|
23
|
-
|
24
|
-
yield sql
|
25
|
-
else
|
26
|
-
ret << sql
|
27
|
-
end
|
24
|
+
yield sql
|
28
25
|
end
|
29
26
|
}
|
30
27
|
|
@@ -50,13 +47,7 @@ def EachSQL input, type = :default
|
|
50
47
|
end
|
51
48
|
|
52
49
|
if sql = result[:leftover]
|
53
|
-
|
54
|
-
yield sql
|
55
|
-
else
|
56
|
-
ret << sql
|
57
|
-
end
|
50
|
+
yield sql
|
58
51
|
end
|
59
|
-
|
60
|
-
ret
|
61
52
|
end
|
62
53
|
|
data/test/test_each_sql.rb
CHANGED
@@ -43,7 +43,7 @@ class TestEachSql < Test::Unit::TestCase
|
|
43
43
|
def test_parser_cache
|
44
44
|
[:default, :mysql, :oracle, :postgres].each do |typ|
|
45
45
|
%w[';', '$$', '//'].each do |delim|
|
46
|
-
arr =
|
46
|
+
arr =
|
47
47
|
10.times.map {
|
48
48
|
EachSQL::Parser.parser_for typ, delim
|
49
49
|
}
|
@@ -88,7 +88,8 @@ class TestEachSql < Test::Unit::TestCase
|
|
88
88
|
end
|
89
89
|
assert_equal data['each'].length, cnt
|
90
90
|
assert_equal cnt, EachSQL(script, typ).to_a.length
|
91
|
-
assert_equal EachSQL(script, typ).to_a,
|
91
|
+
assert_equal EachSQL(script, typ).to_a,
|
92
|
+
EachSQL(script, typ).each.each.take_while { true }.map { |e| e }
|
92
93
|
end
|
93
94
|
end
|
94
95
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: each_sql
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2013-05-15 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: citrus
|
@@ -135,7 +135,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
135
135
|
version: '0'
|
136
136
|
segments:
|
137
137
|
- 0
|
138
|
-
hash:
|
138
|
+
hash: 3224767987852485011
|
139
139
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
140
140
|
none: false
|
141
141
|
requirements:
|
@@ -144,7 +144,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
144
144
|
version: '0'
|
145
145
|
requirements: []
|
146
146
|
rubyforge_project:
|
147
|
-
rubygems_version: 1.8.
|
147
|
+
rubygems_version: 1.8.25
|
148
148
|
signing_key:
|
149
149
|
specification_version: 3
|
150
150
|
summary: Enumerate each SQL statement in SQL scripts.
|