sbfaulkner-rsql 0.9.4 → 0.9.5

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.
Files changed (5) hide show
  1. data/Rakefile +0 -1
  2. data/bin/rsql +0 -79
  3. data/lib/rsql/rsql.rb +76 -0
  4. data/rsql.gemspec +1 -1
  5. metadata +1 -1
data/Rakefile CHANGED
@@ -5,7 +5,6 @@ require 'rake/gempackagetask'
5
5
  load File.join(File.dirname(__FILE__),'rsql.gemspec')
6
6
 
7
7
  Rake::GemPackageTask.new(SPEC) do |pkg|
8
- pkg.need_tar = true
9
8
  end
10
9
 
11
10
  task :default => :package
data/bin/rsql CHANGED
@@ -4,86 +4,7 @@
4
4
  # Created by: S. Brent Faulkner (brentf@unwwwired.net) 2007-08-29
5
5
  #
6
6
 
7
- require 'getoptlong'
8
- require 'readline'
9
- include Readline
10
- require 'shellwords'
11
- include Shellwords
12
- require 'singleton'
13
-
14
7
  require 'odbc'
15
8
 
16
9
  require 'rsql/odbc'
17
10
  require 'rsql/rsql'
18
-
19
-
20
- module RSQL
21
- COMMAND = File.basename($0)
22
-
23
- opts = GetoptLong.new(
24
- [ "--execute", "-e", GetoptLong::REQUIRED_ARGUMENT ],
25
- [ "--mode", "-m", GetoptLong::REQUIRED_ARGUMENT ],
26
- [ "--password", "-p", GetoptLong::REQUIRED_ARGUMENT ],
27
- [ "--quiet", "-q", GetoptLong::NO_ARGUMENT ],
28
- [ "--user", "-u", GetoptLong::REQUIRED_ARGUMENT ],
29
- [ "--verbose", "-v", GetoptLong::NO_ARGUMENT ]
30
- )
31
-
32
- opts.each do |opt, arg|
33
- OPTIONS[opt[/--(.*)/,1].to_sym] = arg
34
- end
35
-
36
- # to hide the noise from the ODBC driver
37
- STDERR.reopen("/dev/null") unless OPTIONS[:verbose]
38
-
39
- if ARGV.length > 1
40
- puts "#{COMMAND}: too many arguments"
41
- exit
42
- end
43
-
44
- if OPTIONS[:execute]
45
- # a command requires a database
46
- if ARGV.length < 1
47
- puts "#{COMMAND}: no database specified"
48
- exit
49
- end
50
- # force quiet-mode if command provided
51
- OPTIONS[:quiet] = true
52
- end
53
-
54
- # set format for output
55
- begin
56
- ODBC::Statement.mode = OPTIONS[:mode]
57
- rescue => e
58
- puts "#{COMMAND}: #{e}"
59
- exit
60
- end
61
-
62
- # quiet-mode wins over verbose-mode
63
- OPTIONS.delete :verbose if OPTIONS[:quiet]
64
-
65
- puts "#{COMMAND} v0.9.4 - Copyright (c) 2007-2008 unwwwired.net" unless OPTIONS[:quiet]
66
-
67
- begin
68
- # use dsn if provided
69
- begin
70
- RSQL.instance.use(ARGV[0]) if ARGV.length > 0
71
- rescue ODBC::Error => error
72
- puts "ERROR: #{error}"
73
- end
74
-
75
- if OPTIONS[:execute]
76
- RSQL.execute OPTIONS[:execute]
77
- else
78
- # get (and process) each command line in turn
79
- while command = readline("#{COMMAND}> ", true)
80
- RSQL.execute command
81
- end
82
- end
83
- rescue SystemExit
84
- puts "Bye" unless OPTIONS[:quiet]
85
- rescue => exception
86
- puts %Q(INTERNAL ERROR: #{exception}\n#{exception.backtrace.join("\n")})
87
- end
88
-
89
- end
data/lib/rsql/rsql.rb CHANGED
@@ -1,3 +1,11 @@
1
+ require 'getoptlong'
2
+ require 'readline'
3
+ include Readline
4
+
5
+ require 'shellwords'
6
+ include Shellwords
7
+ require 'singleton'
8
+
1
9
  module RSQL
2
10
  OPTIONS = { :mode => 'column', :password => '', :user => ENV['USER'] }
3
11
 
@@ -200,4 +208,72 @@ module RSQL
200
208
  end
201
209
 
202
210
  end
211
+
212
+ COMMAND = File.basename($0)
213
+
214
+ opts = GetoptLong.new(
215
+ [ "--execute", "-e", GetoptLong::REQUIRED_ARGUMENT ],
216
+ [ "--mode", "-m", GetoptLong::REQUIRED_ARGUMENT ],
217
+ [ "--password", "-p", GetoptLong::REQUIRED_ARGUMENT ],
218
+ [ "--quiet", "-q", GetoptLong::NO_ARGUMENT ],
219
+ [ "--user", "-u", GetoptLong::REQUIRED_ARGUMENT ],
220
+ [ "--verbose", "-v", GetoptLong::NO_ARGUMENT ]
221
+ )
222
+
223
+ opts.each do |opt, arg|
224
+ OPTIONS[opt[/--(.*)/,1].to_sym] = arg
225
+ end
226
+
227
+ # to hide the noise from the ODBC driver
228
+ STDERR.reopen("/dev/null") unless OPTIONS[:verbose]
229
+
230
+ if ARGV.length > 1
231
+ puts "#{COMMAND}: too many arguments"
232
+ exit
233
+ end
234
+
235
+ if OPTIONS[:execute]
236
+ # a command requires a database
237
+ if ARGV.length < 1
238
+ puts "#{COMMAND}: no database specified"
239
+ exit
240
+ end
241
+ # force quiet-mode if command provided
242
+ OPTIONS[:quiet] = true
243
+ end
244
+
245
+ # set format for output
246
+ begin
247
+ ODBC::Statement.mode = OPTIONS[:mode]
248
+ rescue => e
249
+ puts "#{COMMAND}: #{e}"
250
+ exit
251
+ end
252
+
253
+ # quiet-mode wins over verbose-mode
254
+ OPTIONS.delete :verbose if OPTIONS[:quiet]
255
+
256
+ puts "#{COMMAND} v0.9.5 - Copyright (c) 2007-2008 unwwwired.net" unless OPTIONS[:quiet]
257
+
258
+ begin
259
+ # use dsn if provided
260
+ begin
261
+ RSQL.instance.use(ARGV[0]) if ARGV.length > 0
262
+ rescue ODBC::Error => error
263
+ puts "ERROR: #{error}"
264
+ end
265
+
266
+ if OPTIONS[:execute]
267
+ RSQL.execute OPTIONS[:execute]
268
+ else
269
+ # get (and process) each command line in turn
270
+ while command = readline("#{COMMAND}> ", true)
271
+ RSQL.execute command
272
+ end
273
+ end
274
+ rescue SystemExit
275
+ puts "Bye" unless OPTIONS[:quiet]
276
+ rescue => exception
277
+ puts %Q(INTERNAL ERROR: #{exception}\n#{exception.backtrace.join("\n")})
278
+ end
203
279
  end
data/rsql.gemspec CHANGED
@@ -1,7 +1,7 @@
1
1
  SPEC = Gem::Specification.new do |s|
2
2
  # identify the gem
3
3
  s.name = "rsql"
4
- s.version = "0.9.4"
4
+ s.version = "0.9.5"
5
5
  s.author = "S. Brent Faulkner"
6
6
  s.email = "brentf@unwwwired.net"
7
7
  s.homepage = "http://www.unwwwired.net"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sbfaulkner-rsql
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.4
4
+ version: 0.9.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - S. Brent Faulkner