twowaysql 0.4.1 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.gitignore +7 -0
- data/Gemfile +4 -0
- data/History.txt +4 -0
- data/License.txt +4 -4
- data/README.rdoc +4 -4
- data/Rakefile +31 -0
- data/cucumber.yml +1 -0
- data/features/feature_helper.rb +3 -0
- data/features/simple/simple.feature +15 -0
- data/features/simple/steps/stories_steps.rb +29 -0
- data/issues/issue-0c8cb2854109cb31df8a09b4bb7272fa5af52848.yaml +30 -0
- data/issues/project.yaml +9 -0
- data/lib/twowaysql.rb +1 -4
- data/lib/twowaysql/parser.rb +295 -274
- data/lib/twowaysql/version.rb +3 -0
- data/spec/spec_helper.rb +1 -9
- data/twowaysql.gemspec +26 -0
- metadata +84 -59
- data/Manifest.txt +0 -36
data/.gitignore
ADDED
data/Gemfile
ADDED
data/History.txt
CHANGED
data/License.txt
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
Copyright
|
1
|
+
Copyright 2008-2012 Takuto Wada
|
2
2
|
|
3
3
|
Licensed under the Apache License, Version 2.0 (the "License");
|
4
4
|
you may not use this file except in compliance with the License.
|
@@ -8,6 +8,6 @@ You may obtain a copy of the License at
|
|
8
8
|
|
9
9
|
Unless required by applicable law or agreed to in writing, software
|
10
10
|
distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
-
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
|
12
|
-
|
13
|
-
|
11
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
+
See the License for the specific language governing permissions and
|
13
|
+
limitations under the License.
|
data/README.rdoc
CHANGED
@@ -447,7 +447,7 @@ Default is false. When true, parser preserves original actual comments. When fal
|
|
447
447
|
|
448
448
|
== LICENSE:
|
449
449
|
|
450
|
-
Copyright
|
450
|
+
Copyright 2008-2012 Takuto Wada
|
451
451
|
|
452
452
|
Licensed under the Apache License, Version 2.0 (the "License");
|
453
453
|
you may not use this file except in compliance with the License.
|
@@ -457,6 +457,6 @@ You may obtain a copy of the License at
|
|
457
457
|
|
458
458
|
Unless required by applicable law or agreed to in writing, software
|
459
459
|
distributed under the License is distributed on an "AS IS" BASIS,
|
460
|
-
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
|
461
|
-
|
462
|
-
|
460
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
461
|
+
See the License for the specific language governing permissions and
|
462
|
+
limitations under the License.
|
data/Rakefile
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
2
|
+
|
3
|
+
namespace :racc do
|
4
|
+
@grammar = "lib/twowaysql/parser"
|
5
|
+
@generate_parser = "racc -o #{@grammar}.rb #{@grammar}.y"
|
6
|
+
@debug_parser = "racc -v -o #{@grammar}.rb -g #{@grammar}.y"
|
7
|
+
@revert_generated = "git checkout #{@grammar}.rb"
|
8
|
+
|
9
|
+
desc 'Regenerate parser'
|
10
|
+
task :gen do
|
11
|
+
`#{@generate_parser}`
|
12
|
+
end
|
13
|
+
|
14
|
+
desc 'Debug parser'
|
15
|
+
task :debug do
|
16
|
+
`#{@debug_parser}`
|
17
|
+
|
18
|
+
$:.unshift(File.dirname(__FILE__) + '/../lib')
|
19
|
+
require 'twowaysql'
|
20
|
+
template = TwoWaySQL::Template.parse($stdin, :debug => true)
|
21
|
+
template.merge({})
|
22
|
+
|
23
|
+
`#{@revert_generated}`
|
24
|
+
end
|
25
|
+
|
26
|
+
desc 'Update tab file'
|
27
|
+
task :tab do
|
28
|
+
`#{@debug_parser}`
|
29
|
+
`#{@revert_generated}`
|
30
|
+
end
|
31
|
+
end
|
data/cucumber.yml
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
rest: --format pretty
|
@@ -0,0 +1,15 @@
|
|
1
|
+
Feature: Simple usage
|
2
|
+
TwoWaySQL simple feature description
|
3
|
+
|
4
|
+
Scenario Outline: merge context with template
|
5
|
+
Given template is <template>
|
6
|
+
And modify context <context>
|
7
|
+
When template merged with context
|
8
|
+
Then merged sql should be <sql>
|
9
|
+
And bound variables should be <bound_variables>
|
10
|
+
|
11
|
+
Examples:
|
12
|
+
| template | context | sql | bound_variables |
|
13
|
+
| SELECT * FROM emp | | SELECT * FROM emp | [] |
|
14
|
+
| SELECT * FROM emp WHERE job = /*ctx[:job]*/'CLERK' | ctx[:job] = 'MANAGER' | SELECT * FROM emp WHERE job = ? | ['MANAGER'] |
|
15
|
+
| SELECT * FROM emp WHERE age < /*ctx[:age]*/30 | ctx[:age] = 25 | SELECT * FROM emp WHERE age < ? | [25] |
|
@@ -0,0 +1,29 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../../feature_helper.rb'
|
2
|
+
|
3
|
+
Before do
|
4
|
+
@ctx = {}
|
5
|
+
end
|
6
|
+
|
7
|
+
After do
|
8
|
+
end
|
9
|
+
|
10
|
+
Given /template is (.*)/ do |text|
|
11
|
+
@template = TwoWaySQL::Template.parse(text)
|
12
|
+
end
|
13
|
+
|
14
|
+
Given /modify context (.*)/ do |exp|
|
15
|
+
ctx = @ctx
|
16
|
+
eval(exp)
|
17
|
+
end
|
18
|
+
|
19
|
+
When /template merged with context/ do
|
20
|
+
@result = @template.merge(@ctx)
|
21
|
+
end
|
22
|
+
|
23
|
+
Then /merged sql should be (.*)/ do |text|
|
24
|
+
@result.sql.should == text
|
25
|
+
end
|
26
|
+
|
27
|
+
Then /bound variables should be (.*)/ do |exp|
|
28
|
+
@result.bound_variables.should == eval(exp)
|
29
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
--- !ditz.rubyforge.org,2008-03-06/issue
|
2
|
+
title: use Cucumber to describe features
|
3
|
+
desc: use Cucumber to describe features
|
4
|
+
type: :task
|
5
|
+
component: twowaysql
|
6
|
+
release: release_0_4_2
|
7
|
+
reporter: takuto <takuto.wada@gmail.com>
|
8
|
+
status: :closed
|
9
|
+
disposition: :fixed
|
10
|
+
creation_time: 2008-11-01 09:49:10.745475 Z
|
11
|
+
references: []
|
12
|
+
|
13
|
+
id: 0c8cb2854109cb31df8a09b4bb7272fa5af52848
|
14
|
+
log_events:
|
15
|
+
- - 2008-11-01 09:49:12.136663 Z
|
16
|
+
- takuto <takuto.wada@gmail.com>
|
17
|
+
- created
|
18
|
+
- ""
|
19
|
+
- - 2008-11-03 04:51:12.548699 Z
|
20
|
+
- takuto <takuto.wada@gmail.com>
|
21
|
+
- changed status from unstarted to in_progress
|
22
|
+
- ""
|
23
|
+
- - 2008-11-03 06:44:22.905684 Z
|
24
|
+
- takuto <takuto.wada@gmail.com>
|
25
|
+
- closed with disposition fixed
|
26
|
+
- cucumberize spike finished. Migration from rspec should be a new task.
|
27
|
+
- - 2008-11-03 06:45:58.082688 Z
|
28
|
+
- takuto <takuto.wada@gmail.com>
|
29
|
+
- assigned to release release_0_4_2 from unassigned
|
30
|
+
- ""
|
data/issues/project.yaml
CHANGED
@@ -70,3 +70,12 @@ releases:
|
|
70
70
|
- takuto <takuto.wada@gmail.com>
|
71
71
|
- released
|
72
72
|
- ""
|
73
|
+
- !ditz.rubyforge.org,2008-03-06/release
|
74
|
+
name: release_0_4_2
|
75
|
+
status: :unreleased
|
76
|
+
release_time:
|
77
|
+
log_events:
|
78
|
+
- - 2008-11-03 06:45:18.083136 Z
|
79
|
+
- takuto <takuto.wada@gmail.com>
|
80
|
+
- created
|
81
|
+
- release_0_4_2 for cucumberization
|
data/lib/twowaysql.rb
CHANGED
@@ -1,10 +1,7 @@
|
|
1
|
-
|
2
|
-
$:.include?(File.dirname(__FILE__)) || $:.include?(File.expand_path(File.dirname(__FILE__)))
|
3
|
-
|
1
|
+
require "twowaysql/version"
|
4
2
|
require 'twowaysql/node'
|
5
3
|
require 'twowaysql/parser'
|
6
4
|
require 'twowaysql/template'
|
7
5
|
|
8
6
|
module TwoWaySQL
|
9
|
-
VERSION = '0.4.1'
|
10
7
|
end
|
data/lib/twowaysql/parser.rb
CHANGED
@@ -1,17 +1,14 @@
|
|
1
1
|
#
|
2
2
|
# DO NOT MODIFY!!!!
|
3
|
-
# This file is automatically generated by
|
4
|
-
# from
|
3
|
+
# This file is automatically generated by Racc 1.4.7
|
4
|
+
# from Racc grammer file "".
|
5
5
|
#
|
6
6
|
|
7
|
-
require 'racc/parser'
|
8
|
-
|
9
|
-
|
7
|
+
require 'racc/parser.rb'
|
10
8
|
module TwoWaySQL
|
11
|
-
|
12
9
|
class Parser < Racc::Parser
|
13
10
|
|
14
|
-
module_eval
|
11
|
+
module_eval(<<'...end parser.y/module_eval...', 'parser.y', 134)
|
15
12
|
|
16
13
|
require 'strscan'
|
17
14
|
|
@@ -143,393 +140,417 @@ def line_no(pos)
|
|
143
140
|
scanned.each_line { lines += 1 }
|
144
141
|
lines
|
145
142
|
end
|
146
|
-
|
147
|
-
|
148
|
-
##### racc 1.4.5 generates ###
|
149
|
-
|
150
|
-
racc_reduce_table = [
|
151
|
-
0, 0, :racc_error,
|
152
|
-
1, 20, :_reduce_1,
|
153
|
-
0, 21, :_reduce_2,
|
154
|
-
2, 21, :_reduce_3,
|
155
|
-
1, 22, :_reduce_none,
|
156
|
-
1, 22, :_reduce_none,
|
157
|
-
1, 22, :_reduce_none,
|
158
|
-
3, 25, :_reduce_7,
|
159
|
-
4, 24, :_reduce_8,
|
160
|
-
2, 27, :_reduce_9,
|
161
|
-
0, 27, :_reduce_10,
|
162
|
-
1, 26, :_reduce_none,
|
163
|
-
1, 26, :_reduce_none,
|
164
|
-
1, 26, :_reduce_none,
|
165
|
-
2, 28, :_reduce_14,
|
166
|
-
2, 29, :_reduce_15,
|
167
|
-
1, 23, :_reduce_16,
|
168
|
-
1, 23, :_reduce_17,
|
169
|
-
1, 23, :_reduce_18,
|
170
|
-
1, 23, :_reduce_19,
|
171
|
-
1, 23, :_reduce_20,
|
172
|
-
1, 23, :_reduce_21,
|
173
|
-
1, 23, :_reduce_22,
|
174
|
-
1, 23, :_reduce_23,
|
175
|
-
1, 23, :_reduce_24,
|
176
|
-
1, 23, :_reduce_25,
|
177
|
-
1, 23, :_reduce_none,
|
178
|
-
1, 23, :_reduce_none,
|
179
|
-
2, 30, :_reduce_28,
|
180
|
-
3, 30, :_reduce_29,
|
181
|
-
2, 30, :_reduce_30,
|
182
|
-
3, 30, :_reduce_31,
|
183
|
-
1, 30, :_reduce_32,
|
184
|
-
2, 31, :_reduce_33,
|
185
|
-
3, 31, :_reduce_34 ]
|
186
|
-
|
187
|
-
racc_reduce_n = 35
|
188
|
-
|
189
|
-
racc_shift_n = 48
|
143
|
+
...end parser.y/module_eval...
|
144
|
+
##### State transition tables begin ###
|
190
145
|
|
191
146
|
racc_action_table = [
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
147
|
+
8, 36, 9, 37, 12, 13, 10, 11, 14, 15,
|
148
|
+
16, 17, 18, 19, 22, 23, 24, 8, 45, 9,
|
149
|
+
46, 12, 13, 10, 11, 14, 15, 16, 17, 18,
|
150
|
+
19, 22, 23, 24, 8, 40, 9, 25, 12, 13,
|
151
|
+
10, 11, 14, 15, 16, 17, 18, 19, 22, 23,
|
152
|
+
24, 8, 38, 9, 3, 12, 13, 10, 11, 14,
|
153
|
+
15, 16, 17, 18, 19, 22, 23, 24, 8, nil,
|
154
|
+
9, nil, 12, 13, 10, 11, 14, 15, 16, 17,
|
155
|
+
18, 19, 22, 23, 24, 35, 33, 34, 31, 32,
|
156
|
+
31, 32, 44, 43 ]
|
202
157
|
|
203
158
|
racc_action_check = [
|
204
|
-
42,
|
205
|
-
42, 42, 42, 42, 42, 42, 42, 2,
|
206
|
-
|
207
|
-
2, 2, 2, 2, 41,
|
159
|
+
42, 24, 42, 24, 42, 42, 42, 42, 42, 42,
|
160
|
+
42, 42, 42, 42, 42, 42, 42, 2, 37, 2,
|
161
|
+
39, 2, 2, 2, 2, 2, 2, 2, 2, 2,
|
162
|
+
2, 2, 2, 2, 41, 28, 41, 3, 41, 41,
|
208
163
|
41, 41, 41, 41, 41, 41, 41, 41, 41, 41,
|
209
164
|
41, 26, 26, 26, 1, 26, 26, 26, 26, 26,
|
210
|
-
26, 26, 26, 26, 26, 26, 26, 26,
|
211
|
-
|
212
|
-
|
213
|
-
|
165
|
+
26, 26, 26, 26, 26, 26, 26, 26, 27, nil,
|
166
|
+
27, nil, 27, 27, 27, 27, 27, 27, 27, 27,
|
167
|
+
27, 27, 27, 27, 27, 22, 22, 22, 9, 9,
|
168
|
+
40, 40, 34, 34 ]
|
214
169
|
|
215
170
|
racc_action_pointer = [
|
216
|
-
nil, 54, 15, 37, nil, nil, nil, nil, nil,
|
217
|
-
nil, nil, nil, nil,
|
218
|
-
nil, nil,
|
219
|
-
nil, nil,
|
220
|
-
|
171
|
+
nil, 54, 15, 37, nil, nil, nil, nil, nil, 82,
|
172
|
+
nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
|
173
|
+
nil, nil, 77, nil, -7, nil, 49, 66, 30, nil,
|
174
|
+
nil, nil, nil, nil, 84, nil, nil, 10, nil, 17,
|
175
|
+
84, 32, -2, nil, nil, nil, nil, nil ]
|
221
176
|
|
222
177
|
racc_action_default = [
|
223
|
-
-2, -35, -1, -35,
|
224
|
-
|
225
|
-
-26, -
|
226
|
-
|
227
|
-
|
178
|
+
-2, -35, -1, -35, -3, -4, -5, -6, -2, -2,
|
179
|
+
-16, -17, -18, -19, -20, -21, -22, -23, -24, -25,
|
180
|
+
-26, -27, -35, -32, -35, 48, -35, -13, -10, -11,
|
181
|
+
-12, -2, -2, -28, -35, -30, -33, -35, -7, -35,
|
182
|
+
-2, -14, -15, -29, -31, -34, -8, -9 ]
|
228
183
|
|
229
184
|
racc_goto_table = [
|
230
|
-
2,
|
185
|
+
2, 1, 28, 39, nil, nil, nil, nil, 26, nil,
|
186
|
+
nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
|
231
187
|
nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
|
232
|
-
nil,
|
233
|
-
42 ]
|
188
|
+
nil, 41, 42, 47 ]
|
234
189
|
|
235
190
|
racc_goto_check = [
|
236
|
-
2,
|
191
|
+
2, 1, 7, 8, nil, nil, nil, nil, 2, nil,
|
192
|
+
nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
|
237
193
|
nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
|
238
|
-
nil,
|
239
|
-
2 ]
|
194
|
+
nil, 2, 2, 7 ]
|
240
195
|
|
241
196
|
racc_goto_pointer = [
|
242
|
-
nil,
|
197
|
+
nil, 1, 0, nil, nil, nil, nil, -7, -25, nil,
|
243
198
|
nil, nil, nil ]
|
244
199
|
|
245
200
|
racc_goto_default = [
|
246
|
-
nil, nil,
|
247
|
-
|
201
|
+
nil, nil, 27, 4, 5, 6, 7, nil, nil, 29,
|
202
|
+
30, 20, 21 ]
|
248
203
|
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
:
|
253
|
-
:
|
254
|
-
:
|
255
|
-
:
|
256
|
-
:
|
257
|
-
:
|
258
|
-
:
|
259
|
-
:
|
260
|
-
:
|
261
|
-
:
|
262
|
-
:
|
263
|
-
:
|
264
|
-
:
|
265
|
-
:
|
266
|
-
:
|
267
|
-
:
|
268
|
-
:
|
204
|
+
racc_reduce_table = [
|
205
|
+
0, 0, :racc_error,
|
206
|
+
1, 20, :_reduce_1,
|
207
|
+
0, 21, :_reduce_2,
|
208
|
+
2, 21, :_reduce_3,
|
209
|
+
1, 22, :_reduce_none,
|
210
|
+
1, 22, :_reduce_none,
|
211
|
+
1, 22, :_reduce_none,
|
212
|
+
3, 25, :_reduce_7,
|
213
|
+
4, 24, :_reduce_8,
|
214
|
+
2, 27, :_reduce_9,
|
215
|
+
0, 27, :_reduce_10,
|
216
|
+
1, 26, :_reduce_none,
|
217
|
+
1, 26, :_reduce_none,
|
218
|
+
1, 26, :_reduce_none,
|
219
|
+
2, 28, :_reduce_14,
|
220
|
+
2, 29, :_reduce_15,
|
221
|
+
1, 23, :_reduce_16,
|
222
|
+
1, 23, :_reduce_17,
|
223
|
+
1, 23, :_reduce_18,
|
224
|
+
1, 23, :_reduce_19,
|
225
|
+
1, 23, :_reduce_20,
|
226
|
+
1, 23, :_reduce_21,
|
227
|
+
1, 23, :_reduce_22,
|
228
|
+
1, 23, :_reduce_23,
|
229
|
+
1, 23, :_reduce_24,
|
230
|
+
1, 23, :_reduce_25,
|
231
|
+
1, 23, :_reduce_none,
|
232
|
+
1, 23, :_reduce_none,
|
233
|
+
2, 30, :_reduce_28,
|
234
|
+
3, 30, :_reduce_29,
|
235
|
+
2, 30, :_reduce_30,
|
236
|
+
3, 30, :_reduce_31,
|
237
|
+
1, 30, :_reduce_32,
|
238
|
+
2, 31, :_reduce_33,
|
239
|
+
3, 31, :_reduce_34 ]
|
269
240
|
|
270
|
-
|
241
|
+
racc_reduce_n = 35
|
242
|
+
|
243
|
+
racc_shift_n = 48
|
244
|
+
|
245
|
+
racc_token_table = {
|
246
|
+
false => 0,
|
247
|
+
:error => 1,
|
248
|
+
:BEGIN => 2,
|
249
|
+
:END => 3,
|
250
|
+
:IF => 4,
|
251
|
+
:ELSE => 5,
|
252
|
+
:AND => 6,
|
253
|
+
:OR => 7,
|
254
|
+
:IDENT => 8,
|
255
|
+
:STRING_LITERAL => 9,
|
256
|
+
:SPACES => 10,
|
257
|
+
:COMMA => 11,
|
258
|
+
:LPAREN => 12,
|
259
|
+
:RPAREN => 13,
|
260
|
+
:QUESTION => 14,
|
261
|
+
:ACTUAL_COMMENT => 15,
|
262
|
+
:BIND_VARIABLE => 16,
|
263
|
+
:PAREN_BIND_VARIABLE => 17,
|
264
|
+
:EMBED_VARIABLE => 18 }
|
271
265
|
|
272
266
|
racc_nt_base = 19
|
273
267
|
|
268
|
+
racc_use_result_var = true
|
269
|
+
|
274
270
|
Racc_arg = [
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
|
287
|
-
|
288
|
-
|
271
|
+
racc_action_table,
|
272
|
+
racc_action_check,
|
273
|
+
racc_action_default,
|
274
|
+
racc_action_pointer,
|
275
|
+
racc_goto_table,
|
276
|
+
racc_goto_check,
|
277
|
+
racc_goto_default,
|
278
|
+
racc_goto_pointer,
|
279
|
+
racc_nt_base,
|
280
|
+
racc_reduce_table,
|
281
|
+
racc_token_table,
|
282
|
+
racc_shift_n,
|
283
|
+
racc_reduce_n,
|
284
|
+
racc_use_result_var ]
|
289
285
|
|
290
286
|
Racc_token_to_s_table = [
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
|
302
|
-
|
303
|
-
|
304
|
-
|
305
|
-
|
306
|
-
|
307
|
-
|
308
|
-
|
309
|
-
|
310
|
-
|
311
|
-
|
312
|
-
|
313
|
-
|
314
|
-
|
315
|
-
|
316
|
-
|
317
|
-
|
318
|
-
|
319
|
-
|
320
|
-
|
321
|
-
|
322
|
-
|
287
|
+
"$end",
|
288
|
+
"error",
|
289
|
+
"BEGIN",
|
290
|
+
"END",
|
291
|
+
"IF",
|
292
|
+
"ELSE",
|
293
|
+
"AND",
|
294
|
+
"OR",
|
295
|
+
"IDENT",
|
296
|
+
"STRING_LITERAL",
|
297
|
+
"SPACES",
|
298
|
+
"COMMA",
|
299
|
+
"LPAREN",
|
300
|
+
"RPAREN",
|
301
|
+
"QUESTION",
|
302
|
+
"ACTUAL_COMMENT",
|
303
|
+
"BIND_VARIABLE",
|
304
|
+
"PAREN_BIND_VARIABLE",
|
305
|
+
"EMBED_VARIABLE",
|
306
|
+
"$start",
|
307
|
+
"sql",
|
308
|
+
"stmt_list",
|
309
|
+
"stmt",
|
310
|
+
"primary",
|
311
|
+
"if_stmt",
|
312
|
+
"begin_stmt",
|
313
|
+
"sub_stmt",
|
314
|
+
"else_stmt",
|
315
|
+
"and_stmt",
|
316
|
+
"or_stmt",
|
317
|
+
"bind_var",
|
318
|
+
"embed_var" ]
|
323
319
|
|
324
320
|
Racc_debug_parser = false
|
325
321
|
|
326
|
-
#####
|
322
|
+
##### State transition tables end #####
|
327
323
|
|
328
|
-
|
324
|
+
# reduce 0 omitted
|
329
325
|
|
330
|
-
module_eval
|
331
|
-
def _reduce_1(
|
332
|
-
|
333
|
-
|
326
|
+
module_eval(<<'.,.,', 'parser.y', 6)
|
327
|
+
def _reduce_1(val, _values, result)
|
328
|
+
result = RootNode.new( val[0] )
|
329
|
+
|
330
|
+
result
|
334
331
|
end
|
335
332
|
.,.,
|
336
333
|
|
337
|
-
module_eval
|
338
|
-
def _reduce_2(
|
339
|
-
|
340
|
-
|
334
|
+
module_eval(<<'.,.,', 'parser.y', 11)
|
335
|
+
def _reduce_2(val, _values, result)
|
336
|
+
result = []
|
337
|
+
|
338
|
+
result
|
341
339
|
end
|
342
340
|
.,.,
|
343
341
|
|
344
|
-
module_eval
|
345
|
-
def _reduce_3(
|
346
|
-
|
347
|
-
|
342
|
+
module_eval(<<'.,.,', 'parser.y', 15)
|
343
|
+
def _reduce_3(val, _values, result)
|
344
|
+
result.push val[1]
|
345
|
+
|
346
|
+
result
|
348
347
|
end
|
349
348
|
.,.,
|
350
349
|
|
351
|
-
|
350
|
+
# reduce 4 omitted
|
352
351
|
|
353
|
-
|
352
|
+
# reduce 5 omitted
|
354
353
|
|
355
|
-
|
354
|
+
# reduce 6 omitted
|
356
355
|
|
357
|
-
module_eval
|
358
|
-
def _reduce_7(
|
359
|
-
|
360
|
-
|
356
|
+
module_eval(<<'.,.,', 'parser.y', 24)
|
357
|
+
def _reduce_7(val, _values, result)
|
358
|
+
result = BeginNode.new( val[1] )
|
359
|
+
|
360
|
+
result
|
361
361
|
end
|
362
362
|
.,.,
|
363
363
|
|
364
|
-
module_eval
|
365
|
-
def _reduce_8(
|
366
|
-
|
367
|
-
|
364
|
+
module_eval(<<'.,.,', 'parser.y', 29)
|
365
|
+
def _reduce_8(val, _values, result)
|
366
|
+
result = IfNode.new( val[0][1], val[1], val[2] )
|
367
|
+
|
368
|
+
result
|
368
369
|
end
|
369
370
|
.,.,
|
370
371
|
|
371
|
-
module_eval
|
372
|
-
def _reduce_9(
|
373
|
-
|
374
|
-
|
372
|
+
module_eval(<<'.,.,', 'parser.y', 34)
|
373
|
+
def _reduce_9(val, _values, result)
|
374
|
+
result = val[1]
|
375
|
+
|
376
|
+
result
|
375
377
|
end
|
376
378
|
.,.,
|
377
379
|
|
378
|
-
module_eval
|
379
|
-
def _reduce_10(
|
380
|
-
|
381
|
-
|
380
|
+
module_eval(<<'.,.,', 'parser.y', 38)
|
381
|
+
def _reduce_10(val, _values, result)
|
382
|
+
result = nil
|
383
|
+
|
384
|
+
result
|
382
385
|
end
|
383
386
|
.,.,
|
384
387
|
|
385
|
-
|
388
|
+
# reduce 11 omitted
|
386
389
|
|
387
|
-
|
390
|
+
# reduce 12 omitted
|
388
391
|
|
389
|
-
|
392
|
+
# reduce 13 omitted
|
390
393
|
|
391
|
-
module_eval
|
392
|
-
def _reduce_14(
|
393
|
-
|
394
|
-
|
394
|
+
module_eval(<<'.,.,', 'parser.y', 47)
|
395
|
+
def _reduce_14(val, _values, result)
|
396
|
+
result = SubStatementNode.new( val[0][1], val[1] )
|
397
|
+
|
398
|
+
result
|
395
399
|
end
|
396
400
|
.,.,
|
397
401
|
|
398
|
-
module_eval
|
399
|
-
def _reduce_15(
|
400
|
-
|
401
|
-
|
402
|
+
module_eval(<<'.,.,', 'parser.y', 52)
|
403
|
+
def _reduce_15(val, _values, result)
|
404
|
+
result = SubStatementNode.new( val[0][1], val[1] )
|
405
|
+
|
406
|
+
result
|
402
407
|
end
|
403
408
|
.,.,
|
404
409
|
|
405
|
-
module_eval
|
406
|
-
def _reduce_16(
|
407
|
-
|
408
|
-
|
410
|
+
module_eval(<<'.,.,', 'parser.y', 57)
|
411
|
+
def _reduce_16(val, _values, result)
|
412
|
+
result = LiteralNode.new( val[0][1] )
|
413
|
+
|
414
|
+
result
|
409
415
|
end
|
410
416
|
.,.,
|
411
417
|
|
412
|
-
module_eval
|
413
|
-
def _reduce_17(
|
414
|
-
|
415
|
-
|
418
|
+
module_eval(<<'.,.,', 'parser.y', 61)
|
419
|
+
def _reduce_17(val, _values, result)
|
420
|
+
result = LiteralNode.new( val[0][1] )
|
421
|
+
|
422
|
+
result
|
416
423
|
end
|
417
424
|
.,.,
|
418
425
|
|
419
|
-
module_eval
|
420
|
-
def _reduce_18(
|
421
|
-
|
422
|
-
|
426
|
+
module_eval(<<'.,.,', 'parser.y', 65)
|
427
|
+
def _reduce_18(val, _values, result)
|
428
|
+
result = LiteralNode.new( val[0][1] )
|
429
|
+
|
430
|
+
result
|
423
431
|
end
|
424
432
|
.,.,
|
425
433
|
|
426
|
-
module_eval
|
427
|
-
def _reduce_19(
|
428
|
-
|
429
|
-
|
434
|
+
module_eval(<<'.,.,', 'parser.y', 69)
|
435
|
+
def _reduce_19(val, _values, result)
|
436
|
+
result = LiteralNode.new( val[0][1] )
|
437
|
+
|
438
|
+
result
|
430
439
|
end
|
431
440
|
.,.,
|
432
441
|
|
433
|
-
module_eval
|
434
|
-
def _reduce_20(
|
435
|
-
|
436
|
-
|
442
|
+
module_eval(<<'.,.,', 'parser.y', 73)
|
443
|
+
def _reduce_20(val, _values, result)
|
444
|
+
result = WhiteSpaceNode.new( val[0][1], @preserve_space )
|
445
|
+
|
446
|
+
result
|
437
447
|
end
|
438
448
|
.,.,
|
439
449
|
|
440
|
-
module_eval
|
441
|
-
def _reduce_21(
|
442
|
-
|
443
|
-
|
450
|
+
module_eval(<<'.,.,', 'parser.y', 77)
|
451
|
+
def _reduce_21(val, _values, result)
|
452
|
+
result = LiteralNode.new( val[0][1] )
|
453
|
+
|
454
|
+
result
|
444
455
|
end
|
445
456
|
.,.,
|
446
457
|
|
447
|
-
module_eval
|
448
|
-
def _reduce_22(
|
449
|
-
|
450
|
-
|
458
|
+
module_eval(<<'.,.,', 'parser.y', 81)
|
459
|
+
def _reduce_22(val, _values, result)
|
460
|
+
result = LiteralNode.new( val[0][1] )
|
461
|
+
|
462
|
+
result
|
451
463
|
end
|
452
464
|
.,.,
|
453
465
|
|
454
|
-
module_eval
|
455
|
-
def _reduce_23(
|
456
|
-
|
457
|
-
|
466
|
+
module_eval(<<'.,.,', 'parser.y', 85)
|
467
|
+
def _reduce_23(val, _values, result)
|
468
|
+
result = LiteralNode.new( val[0][1] )
|
469
|
+
|
470
|
+
result
|
458
471
|
end
|
459
472
|
.,.,
|
460
473
|
|
461
|
-
module_eval
|
462
|
-
def _reduce_24(
|
463
|
-
|
474
|
+
module_eval(<<'.,.,', 'parser.y', 89)
|
475
|
+
def _reduce_24(val, _values, result)
|
476
|
+
@num_questions += 1
|
464
477
|
result = QuestionNode.new( @num_questions )
|
465
|
-
|
478
|
+
|
479
|
+
result
|
466
480
|
end
|
467
481
|
.,.,
|
468
482
|
|
469
|
-
module_eval
|
470
|
-
def _reduce_25(
|
471
|
-
|
472
|
-
|
483
|
+
module_eval(<<'.,.,', 'parser.y', 94)
|
484
|
+
def _reduce_25(val, _values, result)
|
485
|
+
result = ActualCommentNode.new( val[0][1] , val[0][2] )
|
486
|
+
|
487
|
+
result
|
473
488
|
end
|
474
489
|
.,.,
|
475
490
|
|
476
|
-
|
491
|
+
# reduce 26 omitted
|
477
492
|
|
478
|
-
|
493
|
+
# reduce 27 omitted
|
479
494
|
|
480
|
-
module_eval
|
481
|
-
def _reduce_28(
|
482
|
-
|
483
|
-
|
495
|
+
module_eval(<<'.,.,', 'parser.y', 101)
|
496
|
+
def _reduce_28(val, _values, result)
|
497
|
+
result = BindVariableNode.new( val[0][1] )
|
498
|
+
|
499
|
+
result
|
484
500
|
end
|
485
501
|
.,.,
|
486
502
|
|
487
|
-
module_eval
|
488
|
-
def _reduce_29(
|
489
|
-
|
490
|
-
|
503
|
+
module_eval(<<'.,.,', 'parser.y', 105)
|
504
|
+
def _reduce_29(val, _values, result)
|
505
|
+
result = BindVariableNode.new( val[0][1] )
|
506
|
+
|
507
|
+
result
|
491
508
|
end
|
492
509
|
.,.,
|
493
510
|
|
494
|
-
module_eval
|
495
|
-
def _reduce_30(
|
496
|
-
|
497
|
-
|
511
|
+
module_eval(<<'.,.,', 'parser.y', 109)
|
512
|
+
def _reduce_30(val, _values, result)
|
513
|
+
result = BindVariableNode.new( val[0][1] )
|
514
|
+
|
515
|
+
result
|
498
516
|
end
|
499
517
|
.,.,
|
500
518
|
|
501
|
-
module_eval
|
502
|
-
def _reduce_31(
|
503
|
-
|
504
|
-
|
519
|
+
module_eval(<<'.,.,', 'parser.y', 113)
|
520
|
+
def _reduce_31(val, _values, result)
|
521
|
+
result = BindVariableNode.new( val[0][1] )
|
522
|
+
|
523
|
+
result
|
505
524
|
end
|
506
525
|
.,.,
|
507
526
|
|
508
|
-
module_eval
|
509
|
-
def _reduce_32(
|
510
|
-
|
511
|
-
|
527
|
+
module_eval(<<'.,.,', 'parser.y', 117)
|
528
|
+
def _reduce_32(val, _values, result)
|
529
|
+
result = ParenBindVariableNode.new( val[0][1] )
|
530
|
+
|
531
|
+
result
|
512
532
|
end
|
513
533
|
.,.,
|
514
534
|
|
515
|
-
module_eval
|
516
|
-
def _reduce_33(
|
517
|
-
|
518
|
-
|
535
|
+
module_eval(<<'.,.,', 'parser.y', 122)
|
536
|
+
def _reduce_33(val, _values, result)
|
537
|
+
result = EmbedVariableNode.new( val[0][1] )
|
538
|
+
|
539
|
+
result
|
519
540
|
end
|
520
541
|
.,.,
|
521
542
|
|
522
|
-
module_eval
|
523
|
-
def _reduce_34(
|
524
|
-
|
525
|
-
|
543
|
+
module_eval(<<'.,.,', 'parser.y', 126)
|
544
|
+
def _reduce_34(val, _values, result)
|
545
|
+
result = EmbedVariableNode.new( val[0][1] )
|
546
|
+
|
547
|
+
result
|
526
548
|
end
|
527
549
|
.,.,
|
528
550
|
|
529
|
-
|
530
|
-
|
531
|
-
|
551
|
+
def _reduce_none(val, _values, result)
|
552
|
+
val[0]
|
553
|
+
end
|
532
554
|
|
533
555
|
end # class Parser
|
534
|
-
|
535
|
-
end # module TwoWaySQL
|
556
|
+
end # module TwoWaySQL
|
data/spec/spec_helper.rb
CHANGED
data/twowaysql.gemspec
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
3
|
+
require "twowaysql/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
s.name = "twowaysql"
|
7
|
+
s.version = TwoWaySQL::VERSION
|
8
|
+
s.authors = ["Takuto Wada"]
|
9
|
+
s.email = ["takuto.wada@gmail.com"]
|
10
|
+
s.homepage = "https://github.com/twada/twowaysql"
|
11
|
+
s.summary = %q{Template Engine for SQL}
|
12
|
+
s.description = %q{Template Engine for SQL}
|
13
|
+
|
14
|
+
s.rubyforge_project = "twowaysql"
|
15
|
+
|
16
|
+
s.files = `git ls-files`.split("\n")
|
17
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
18
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
19
|
+
s.require_paths = ["lib"]
|
20
|
+
|
21
|
+
# specify any dependencies here; for example:
|
22
|
+
s.add_development_dependency "racc"
|
23
|
+
s.add_development_dependency "rspec"
|
24
|
+
s.add_development_dependency "cucumber"
|
25
|
+
# s.add_runtime_dependency "rest-client"
|
26
|
+
end
|
metadata
CHANGED
@@ -1,55 +1,68 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: twowaysql
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.5.0
|
5
|
+
prerelease:
|
5
6
|
platform: ruby
|
6
|
-
authors:
|
7
|
+
authors:
|
7
8
|
- Takuto Wada
|
8
9
|
autorequire:
|
9
10
|
bindir: bin
|
10
11
|
cert_chain: []
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
12
|
+
date: 2012-01-20 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: racc
|
16
|
+
requirement: &70290123701160 !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
17
22
|
type: :development
|
18
|
-
|
19
|
-
version_requirements:
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
- !
|
26
|
-
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: *70290123701160
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: rspec
|
27
|
+
requirement: &70290123700720 !ruby/object:Gem::Requirement
|
28
|
+
none: false
|
29
|
+
requirements:
|
30
|
+
- - ! '>='
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '0'
|
27
33
|
type: :development
|
28
|
-
|
29
|
-
version_requirements:
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
34
|
+
prerelease: false
|
35
|
+
version_requirements: *70290123700720
|
36
|
+
- !ruby/object:Gem::Dependency
|
37
|
+
name: cucumber
|
38
|
+
requirement: &70290123700260 !ruby/object:Gem::Requirement
|
39
|
+
none: false
|
40
|
+
requirements:
|
41
|
+
- - ! '>='
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: '0'
|
44
|
+
type: :development
|
45
|
+
prerelease: false
|
46
|
+
version_requirements: *70290123700260
|
35
47
|
description: Template Engine for SQL
|
36
|
-
email:
|
48
|
+
email:
|
37
49
|
- takuto.wada@gmail.com
|
38
50
|
executables: []
|
39
|
-
|
40
51
|
extensions: []
|
41
|
-
|
42
|
-
|
52
|
+
extra_rdoc_files: []
|
53
|
+
files:
|
54
|
+
- .gitignore
|
55
|
+
- Gemfile
|
43
56
|
- History.txt
|
44
57
|
- License.txt
|
45
|
-
- Manifest.txt
|
46
|
-
- README.rdoc
|
47
|
-
files:
|
48
|
-
- History.txt
|
49
|
-
- License.txt
|
50
|
-
- Manifest.txt
|
51
58
|
- README.rdoc
|
59
|
+
- Rakefile
|
60
|
+
- cucumber.yml
|
61
|
+
- features/feature_helper.rb
|
62
|
+
- features/simple/simple.feature
|
63
|
+
- features/simple/steps/stories_steps.rb
|
52
64
|
- issues/issue-001c53236380a42cd8c5a9099bbcc6ec613919c2.yaml
|
65
|
+
- issues/issue-0c8cb2854109cb31df8a09b4bb7272fa5af52848.yaml
|
53
66
|
- issues/issue-1cee7e821865a216674832b0186bd92792680571.yaml
|
54
67
|
- issues/issue-25efcfc383f3b0f6c0e2730ae7c2975bb2b3de26.yaml
|
55
68
|
- issues/issue-279105dd0d9f03514d318f5eab5e99c4c2d47fda.yaml
|
@@ -76,37 +89,49 @@ files:
|
|
76
89
|
- lib/twowaysql/parser.rb
|
77
90
|
- lib/twowaysql/parser.y
|
78
91
|
- lib/twowaysql/template.rb
|
92
|
+
- lib/twowaysql/version.rb
|
79
93
|
- spec/large_sql_spec.rb
|
80
94
|
- spec/learning_regex_spec.rb
|
81
95
|
- spec/spec.opts
|
82
96
|
- spec/spec_helper.rb
|
83
97
|
- spec/twowaysql_spec.rb
|
84
|
-
|
85
|
-
homepage:
|
98
|
+
- twowaysql.gemspec
|
99
|
+
homepage: https://github.com/twada/twowaysql
|
100
|
+
licenses: []
|
86
101
|
post_install_message:
|
87
|
-
rdoc_options:
|
88
|
-
|
89
|
-
- README.rdoc
|
90
|
-
require_paths:
|
102
|
+
rdoc_options: []
|
103
|
+
require_paths:
|
91
104
|
- lib
|
92
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
105
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
106
|
+
none: false
|
107
|
+
requirements:
|
108
|
+
- - ! '>='
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
111
|
+
segments:
|
112
|
+
- 0
|
113
|
+
hash: 164586672608732535
|
114
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
115
|
+
none: false
|
116
|
+
requirements:
|
117
|
+
- - ! '>='
|
118
|
+
- !ruby/object:Gem::Version
|
119
|
+
version: '0'
|
120
|
+
segments:
|
121
|
+
- 0
|
122
|
+
hash: 164586672608732535
|
104
123
|
requirements: []
|
105
|
-
|
106
124
|
rubyforge_project: twowaysql
|
107
|
-
rubygems_version: 1.
|
125
|
+
rubygems_version: 1.8.10
|
108
126
|
signing_key:
|
109
|
-
specification_version:
|
127
|
+
specification_version: 3
|
110
128
|
summary: Template Engine for SQL
|
111
|
-
test_files:
|
112
|
-
|
129
|
+
test_files:
|
130
|
+
- features/feature_helper.rb
|
131
|
+
- features/simple/simple.feature
|
132
|
+
- features/simple/steps/stories_steps.rb
|
133
|
+
- spec/large_sql_spec.rb
|
134
|
+
- spec/learning_regex_spec.rb
|
135
|
+
- spec/spec.opts
|
136
|
+
- spec/spec_helper.rb
|
137
|
+
- spec/twowaysql_spec.rb
|
data/Manifest.txt
DELETED
@@ -1,36 +0,0 @@
|
|
1
|
-
History.txt
|
2
|
-
License.txt
|
3
|
-
Manifest.txt
|
4
|
-
README.rdoc
|
5
|
-
issues/issue-001c53236380a42cd8c5a9099bbcc6ec613919c2.yaml
|
6
|
-
issues/issue-1cee7e821865a216674832b0186bd92792680571.yaml
|
7
|
-
issues/issue-25efcfc383f3b0f6c0e2730ae7c2975bb2b3de26.yaml
|
8
|
-
issues/issue-279105dd0d9f03514d318f5eab5e99c4c2d47fda.yaml
|
9
|
-
issues/issue-28cde89ed3eb306957edc90595b1d16bf43daf42.yaml
|
10
|
-
issues/issue-2a172da16d3a59adc8448f2e36ec48b36951e02d.yaml
|
11
|
-
issues/issue-39023ea09e17e2d64bcef03aa59cdfe38b78ad5b.yaml
|
12
|
-
issues/issue-4bc308d55ae91f266e656162a4147d356de1166c.yaml
|
13
|
-
issues/issue-5c973ef5bb074eacca0c6c84f7d27c4267773ea8.yaml
|
14
|
-
issues/issue-664986b219202ff1948cab717b56e7540f493561.yaml
|
15
|
-
issues/issue-6daccddf089d11d42bf016897da98f70cf5ab46c.yaml
|
16
|
-
issues/issue-897995fa10377eabdf597e8e7692f17087c76923.yaml
|
17
|
-
issues/issue-901f65630639507c8b05b466790e9f22256c6450.yaml
|
18
|
-
issues/issue-a185b4247f64c1104bc49ebf823b57b5de3d06f8.yaml
|
19
|
-
issues/issue-bd38c1cdc965d73dd629a81db2de1bcdcf4b10b8.yaml
|
20
|
-
issues/issue-dca4b19aa13de59838b33e03252bf824670a2d12.yaml
|
21
|
-
issues/issue-ec698dd75fb717a23045852de2fb367cff119b2e.yaml
|
22
|
-
issues/issue-f1bd40de5458397d9b142ea3e197e5264e0dcdbf.yaml
|
23
|
-
issues/issue-f2b773020b54f839c03d899b38b5113c8fd991df.yaml
|
24
|
-
issues/issue-f39b907d01d7fa93df8c7a9de2e1b5e27727ee0a.yaml
|
25
|
-
issues/issue-f64d73ed4f9854f1ded77e6496dbf59cfb3770a7.yaml
|
26
|
-
issues/project.yaml
|
27
|
-
lib/twowaysql.rb
|
28
|
-
lib/twowaysql/node.rb
|
29
|
-
lib/twowaysql/parser.rb
|
30
|
-
lib/twowaysql/parser.y
|
31
|
-
lib/twowaysql/template.rb
|
32
|
-
spec/large_sql_spec.rb
|
33
|
-
spec/learning_regex_spec.rb
|
34
|
-
spec/spec.opts
|
35
|
-
spec/spec_helper.rb
|
36
|
-
spec/twowaysql_spec.rb
|