vorax 0.1.3 → 0.1.4

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -9,7 +9,7 @@ SQL/PLSQL code.
9
9
 
10
10
  Add this line to your application's Gemfile:
11
11
 
12
- gem 'ruby-vorax'
12
+ gem 'vorax'
13
13
 
14
14
  And then execute:
15
15
 
@@ -17,7 +17,7 @@ And then execute:
17
17
 
18
18
  Or install it yourself as:
19
19
 
20
- $ gem install ruby-vorax
20
+ $ gem install vorax
21
21
 
22
22
  ## Usage
23
23
 
@@ -36,10 +36,3 @@ To get the structure of a PLSQL code:
36
36
 
37
37
  See the "YARD" generated documentation for additional info.
38
38
 
39
- ## Contributing
40
-
41
- 1. Fork it
42
- 2. Create your feature branch (`git checkout -b my-new-feature`)
43
- 3. Commit your changes (`git commit -am 'Add some feature'`)
44
- 4. Push to the branch (`git push origin my-new-feature`)
45
- 5. Create new Pull Request
data/lib/vorax/sqlplus.rb CHANGED
@@ -5,11 +5,6 @@ module Vorax
5
5
  # Provides integration with Oracle SqlPlus CLI tool.
6
6
  class Sqlplus
7
7
 
8
- # the tail size of the output chunk to be searched
9
- # for the output END_MARKER.
10
- TAIL_LENGTH = 100 unless defined?(TAIL_LENGTH)
11
- private_constant :TAIL_LENGTH
12
-
13
8
  attr_reader :bin_file, :default_funnel_name, :process
14
9
 
15
10
  # Creates a new sqlplus instance.
@@ -38,6 +33,14 @@ module Vorax
38
33
  @registered_convertors = {:vertical => Output::VerticalConvertor,
39
34
  :pagezip => Output::PagezipConvertor,
40
35
  :tablezip => Output::TablezipConvertor}
36
+ # warm up
37
+ sleep 0.2
38
+ # set the blockterm as the end_marker. The blockterm should
39
+ # not be touch by the Vorax user, otherwise nasty things
40
+ # may happen. This is also a workaround to mark the end of
41
+ # output when the "echo" setting of sqlplus is "on". See the
42
+ # implementation of pack().
43
+ send_text("set blockterm \"#@end_marker\"\n")
41
44
  end
42
45
 
43
46
  # Set the default convertor for the output returned by sqlplus.
@@ -83,7 +86,6 @@ module Vorax
83
86
  def exec(command, params = {})
84
87
  Vorax.debug("exec: command=#{command.inspect} params=#{params.inspect}")
85
88
  raise AnotherExecRunning if busy?
86
- @tail = ""
87
89
  opts = {
88
90
  :prep => nil,
89
91
  :post => nil,
@@ -139,27 +141,13 @@ module Vorax
139
141
  # @return the output chunk
140
142
  def read_output(bytes=4086)
141
143
  output = ""
142
- raw_output = @tail
144
+ raw_output = nil
143
145
  begin
144
- raw_output << (@io_read.read_nonblock(bytes) || '').gsub(/\r/, '')
146
+ raw_output = @io_read.read_nonblock(bytes)
145
147
  rescue Errno::EAGAIN
146
148
  end
147
149
  if raw_output
148
- #p raw_output if raw_output
149
- if @tail.empty?
150
- # The logic of tail: when SET ECHO ON is used, the PRO <end_marker>
151
- # statement will be also part of the output. The user will end up
152
- # with something like "SQL> pro" as the last line. The solution would
153
- # be to search for "pro <end_marker>" and to stop just before "pro", but
154
- # the chunk may be split in the middle of the "pro <end_marker>" text and
155
- # this is something which depends on the output of the executed
156
- # statement (e.g. bytes=4086, output=4084 => chunk="...SQL> p"). The
157
- # workaround is to delay sending the last TAIL_LENGTH characters until
158
- # the next fetch.
159
- raw_output, @tail = raw_output.slice!(0...raw_output.length-TAIL_LENGTH), raw_output
160
- else
161
- @tail = ''
162
- end
150
+ raw_output.gsub!(/\r/, '')
163
151
  scanner = StringScanner.new(raw_output)
164
152
  while not scanner.eos?
165
153
  if @look_for == @start_marker
@@ -180,7 +168,6 @@ module Vorax
180
168
  if @look_for == @end_marker
181
169
  output = scanner.scan(/[^#{@look_for}]*/)
182
170
  if scanner.scan(/#{@look_for}/)
183
- output.gsub!(/\n.*?pro \z/, "")
184
171
  # end of output reached
185
172
  scanner.terminate
186
173
  @busy = false
@@ -267,8 +254,13 @@ module Vorax
267
254
  f.puts opts[:prep]
268
255
  f.puts "#pro #@start_marker"
269
256
  f.puts command.strip
257
+ # we assume that the @end_marker is also
258
+ # set as a block terminator. If "set echo on"
259
+ # the output region will end here since the
260
+ # block terminator command will be echoed. Otherwise,
261
+ # the next prompt statement will do the job.
262
+ f.puts "#{@end_marker}"
270
263
  f.puts "#pro #@end_marker"
271
- f.puts "."
272
264
  f.puts opts[:post]
273
265
  end
274
266
  end
data/lib/vorax/version.rb CHANGED
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Vorax
4
4
 
5
- VERSION = '0.1.3' unless defined?(VERSION)
5
+ VERSION = '0.1.4' unless defined?(VERSION)
6
6
 
7
7
  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.3
4
+ version: 0.1.4
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: 2013-02-15 00:00:00.000000000 Z
12
+ date: 2013-02-17 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: nokogiri