vorax 0.1.2 → 0.1.3

Sign up to get free protection for your applications and to get access to all the features.
data/Rakefile CHANGED
@@ -18,7 +18,7 @@ end
18
18
 
19
19
  desc 'Builds and installs the gem'
20
20
  task :install => :build do
21
- sh "gem install vorax-#{Vorax::VERSION}"
21
+ sh "gem install vorax-#{Vorax::VERSION} --no-rdoc --no-ri"
22
22
  end
23
23
 
24
24
  desc 'Tags version, pushes to remote, and pushes gem'
@@ -303,14 +303,38 @@ module Vorax
303
303
  if opts[:sqlplus_commands]
304
304
  walker.register_spot(Parser::SQLPLUS_TERMINATOR) do |scanner|
305
305
  type = Parser.statement_type(scanner.string[(start_pos..scanner.pos)])
306
- if type && type == 'SQLPLUS' && (start_pos..scanner.pos).include?(position)
307
- end_pos = scanner.pos - scanner.matched.length
308
- scanner.terminate
306
+ if type
307
+ if type == 'SQLPLUS'
308
+ if (start_pos..scanner.pos-1).include?(position)
309
+ end_pos = scanner.pos - scanner.matched.length
310
+ scanner.terminate
311
+ else
312
+ start_pos = scanner.pos
313
+ end
314
+ else
315
+ if opts[:plsql_blocks]
316
+ #this is a plsql block, eat till the slash terminator
317
+ if scanner.scan_until(Parser::SLASH_TERMINATOR)
318
+ if (start_pos..scanner.pos-1).include?(position)
319
+ end_pos = scanner.pos
320
+ scanner.terminate
321
+ else
322
+ start_pos = scanner.pos
323
+ end
324
+ else
325
+ #it's an invalid statement
326
+ scanner.terminate
327
+ end
328
+ end
329
+ end
330
+ #else
331
+ #start_pos = scanner.pos
309
332
  end
310
333
  end
311
334
  end
312
335
 
313
336
  walker.walk
337
+ end_pos = script_content.length if end_pos == 0 #partial statement
314
338
  {:statement => script_content[(start_pos...end_pos)], :range => (start_pos...end_pos)}
315
339
 
316
340
  end
data/lib/vorax/version.rb CHANGED
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Vorax
4
4
 
5
- VERSION = '0.1.2' unless defined?(VERSION)
5
+ VERSION = '0.1.3' unless defined?(VERSION)
6
6
 
7
7
  end
data/spec/parser_spec.rb CHANGED
@@ -294,6 +294,30 @@ STRING
294
294
  Parser.current_statement(text, 71, :sqlplus_commands => true, :plsql_blocks => false)[:statement].should eq("\nbegin\n null;")
295
295
  Parser.current_statement(text, 71, :sqlplus_commands => true, :plsql_blocks => true)[:statement].should eq("\nbegin\n null;\nend;\n/\n")
296
296
  Parser.current_statement(text, 88, :sqlplus_commands => true, :plsql_blocks => true)[:statement].should eq("select c2 from t1\n/\n")
297
+
298
+ text = <<STRING
299
+ select * from all_objects where rownum <= 1000;
300
+
301
+ set serveroutput on
302
+ begin
303
+ dbms_output.put_line('Hello Vorax!');
304
+ end;
305
+ /
306
+
307
+ with
308
+ x as (select *
309
+ from (select file_id, file_name from dba_data_files) t,
310
+ (select * from (select 'abc' col1, 'xyz' col2 from dual) x)
311
+ )
312
+ select *
313
+ from x;
314
+ STRING
315
+ Parser.current_statement(text, 90, :sqlplus_commands => true, :plsql_blocks => true).
316
+ should eq({:statement=>"begin\n\tdbms_output.put_line('Hello Vorax!');\nend;\n/\n", :range=>69...121})
317
+
318
+ text = "exec dbms_crypto.encrypt("
319
+ Parser.current_statement(text, 10, :plslq_blocks => true, :sqlplus_commands => true).
320
+ should eq({:statement=>"exec dbms_crypto.encrypt(", :range=>0...25})
297
321
  end# }}}
298
322
 
299
323
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vorax
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: