db2c 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +4 -0
- data/Gemfile +4 -0
- data/Rakefile +7 -0
- data/bin/db2c +6 -21
- data/db2c.gemspec +24 -0
- data/{bin/ac → lib/autocomplete} +0 -12
- data/lib/db2c.rb +2 -1
- data/lib/db2c/command.rb +29 -8
- data/lib/db2c/run.rb +44 -0
- data/man/db2c.1 +36 -9
- data/man/db2c.1.html +28 -13
- data/man/db2c.1.ronn +16 -2
- data/spec/db2c/command_spec.rb +30 -0
- data/spec/db2c/run_spec.rb +34 -0
- metadata +29 -12
data/.gitignore
ADDED
data/Gemfile
ADDED
data/Rakefile
CHANGED
@@ -9,6 +9,13 @@ def git(command)
|
|
9
9
|
system("git #{command}")
|
10
10
|
end
|
11
11
|
|
12
|
+
desc "Build and install gem"
|
13
|
+
task :build do
|
14
|
+
sh "ronn man/*.ronn"
|
15
|
+
sh "gem build db2c.gemspec"
|
16
|
+
sh "gem install db2c-#{version}.gem"
|
17
|
+
end
|
18
|
+
|
12
19
|
desc "Push new version"
|
13
20
|
task :publish do
|
14
21
|
git "tag v#{version}"
|
data/bin/db2c
CHANGED
@@ -1,37 +1,22 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
|
-
if !system("which db2 > /dev/null 2> /dev/null")
|
4
|
-
puts "The db2 command was not found!"
|
5
|
-
exit
|
6
|
-
end
|
7
|
-
|
8
|
-
if !ARGV.include?('--no-rlwrap') && !system("which rlwrap > /dev/null 2> /dev/null")
|
9
|
-
puts "This program depends on rlwrap, install rlwrap"
|
10
|
-
exit
|
11
|
-
end
|
12
|
-
|
13
|
-
cdir = File.dirname(__FILE__)
|
14
|
-
unless (ARGV & %w{h help -help --help --man}).empty?
|
15
|
-
exec "man #{cdir}/../man/db2c.1"
|
16
|
-
end
|
17
|
-
unless ARGV.include? '--no-rlwrap'
|
18
|
-
exec "rlwrap -z pipeto -i -r -s 999999 -pBLUE -f #{cdir}/ac -H ~/.db2c_history db2c --no-rlwrap #{ARGV.join(' ')}"
|
19
|
-
end
|
20
|
-
|
21
3
|
$LOAD_PATH.unshift 'lib'
|
22
4
|
require "db2c"
|
23
5
|
|
24
|
-
Db2c::
|
6
|
+
run = Db2c::Run.new *ARGV
|
7
|
+
|
8
|
+
exec "man #{run.gdir}/man/db2c.1" if run.help?
|
9
|
+
exec "rlwrap -z pipeto -i -r -s 999999 -pBLUE -f #{run.autocomplete} -H ~/.db2c_history db2c --no-rlwrap #{run.args}" if run.wrap?
|
25
10
|
|
26
11
|
loop do
|
27
12
|
print Db2c::Command.prompt
|
28
|
-
|
29
13
|
begin
|
30
14
|
command = Db2c::Command.new $stdin.gets
|
31
15
|
rescue Interrupt
|
32
16
|
exit
|
33
17
|
end
|
34
|
-
|
35
18
|
exit if command.quit?
|
19
|
+
system 'less ~/.db2c_history' if command.history?
|
20
|
+
system "man #{run.gdir}/man/db2c.1" if command.help?
|
36
21
|
command.execute
|
37
22
|
end
|
data/db2c.gemspec
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
lib = File.expand_path('../lib/', __FILE__)
|
3
|
+
$:.unshift lib unless $:.include?(lib)
|
4
|
+
|
5
|
+
require 'db2c'
|
6
|
+
|
7
|
+
Gem::Specification.new do |s|
|
8
|
+
s.name = "db2c"
|
9
|
+
s.version = Db2c::VERSION
|
10
|
+
s.platform = Gem::Platform::RUBY
|
11
|
+
s.date = Time.now.strftime('%Y-%m-%d')
|
12
|
+
s.summary = "a smarter db2 console"
|
13
|
+
s.description = "a db2 console with with history and autocomplete support, and few other goodies"
|
14
|
+
s.homepage = "http://github.com/on-site/db2c"
|
15
|
+
s.email = "samer@on-siteNOSPAM.com"
|
16
|
+
s.authors = ["Samer Abukhait"]
|
17
|
+
|
18
|
+
s.files = `git ls-files`.split("\n")
|
19
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
20
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map { |f| File.basename(f) }
|
21
|
+
s.require_paths = ["lib"]
|
22
|
+
|
23
|
+
s.add_development_dependency "rspec"
|
24
|
+
end
|
data/{bin/ac → lib/autocomplete}
RENAMED
@@ -145,7 +145,6 @@ deferred
|
|
145
145
|
delete
|
146
146
|
desc
|
147
147
|
describe
|
148
|
-
descriptor
|
149
148
|
deterministic
|
150
149
|
diagnostics
|
151
150
|
dimensions
|
@@ -158,7 +157,6 @@ domain
|
|
158
157
|
do
|
159
158
|
double
|
160
159
|
drop
|
161
|
-
dropin
|
162
160
|
dynamic
|
163
161
|
dynamic_function
|
164
162
|
each
|
@@ -181,7 +179,6 @@ exclusive
|
|
181
179
|
exec
|
182
180
|
execute
|
183
181
|
exists
|
184
|
-
exit
|
185
182
|
explain
|
186
183
|
extension
|
187
184
|
external
|
@@ -239,7 +236,6 @@ insert
|
|
239
236
|
instead
|
240
237
|
insts_per_argbyte
|
241
238
|
insts_per_invoc
|
242
|
-
int
|
243
239
|
integer
|
244
240
|
integrity
|
245
241
|
intersect
|
@@ -247,7 +243,6 @@ interval
|
|
247
243
|
into
|
248
244
|
ios_per_argbyte
|
249
245
|
ios_per_invoc
|
250
|
-
iso
|
251
246
|
iterate
|
252
247
|
isolation
|
253
248
|
java
|
@@ -381,7 +376,6 @@ reads
|
|
381
376
|
real
|
382
377
|
recommend
|
383
378
|
recovery
|
384
|
-
ref
|
385
379
|
reference
|
386
380
|
references
|
387
381
|
referencing
|
@@ -433,14 +427,12 @@ seconds
|
|
433
427
|
secqty
|
434
428
|
section
|
435
429
|
select
|
436
|
-
self
|
437
430
|
sequence
|
438
431
|
serializable
|
439
432
|
server
|
440
433
|
server_name
|
441
434
|
session
|
442
435
|
session_user
|
443
|
-
set
|
444
436
|
sets
|
445
437
|
share
|
446
438
|
signal
|
@@ -452,7 +444,6 @@ some
|
|
452
444
|
source
|
453
445
|
space
|
454
446
|
specific
|
455
|
-
sql
|
456
447
|
sqlcode
|
457
448
|
sqlerror
|
458
449
|
sqlexception
|
@@ -475,7 +466,6 @@ synonym
|
|
475
466
|
system
|
476
467
|
system_user
|
477
468
|
table
|
478
|
-
tables
|
479
469
|
table_name
|
480
470
|
tablespace
|
481
471
|
tablespaces
|
@@ -487,7 +477,6 @@ timestamp
|
|
487
477
|
timezone
|
488
478
|
timezone_hour
|
489
479
|
timezone_minute
|
490
|
-
to
|
491
480
|
trailing
|
492
481
|
transaction
|
493
482
|
transform
|
@@ -536,5 +525,4 @@ wrapper
|
|
536
525
|
write
|
537
526
|
year
|
538
527
|
years
|
539
|
-
yes
|
540
528
|
zone
|
data/lib/db2c.rb
CHANGED
data/lib/db2c/command.rb
CHANGED
@@ -8,12 +8,7 @@ module Db2c
|
|
8
8
|
if input
|
9
9
|
puts "initializing: #{input}" if @@debug
|
10
10
|
@input = input.chomp.strip
|
11
|
-
|
12
|
-
@input.gsub! /;$/, ''
|
13
|
-
@input.gsub! /^use /, 'connect to '
|
14
|
-
@input.insert 0, "? sql" if @input =~ /^\-\d+$/
|
15
|
-
@input.insert 0, "? " if @input =~ /^\d+$/
|
16
|
-
@input.insert 0, "values " if @input =~ /^current.+$/i
|
11
|
+
parse
|
17
12
|
end
|
18
13
|
end
|
19
14
|
|
@@ -21,12 +16,34 @@ module Db2c
|
|
21
16
|
@input
|
22
17
|
end
|
23
18
|
|
19
|
+
def parse
|
20
|
+
@input.gsub! /^db2 /i, ''
|
21
|
+
@input.gsub! /;$/, ''
|
22
|
+
@input.gsub! /^use /, 'connect to '
|
23
|
+
@input.gsub! /^\\d /, 'describe '
|
24
|
+
@input.insert 0, "? sql" if @input =~ /^\-\d+$/
|
25
|
+
@input.insert 0, "? " if @input =~ /^\d+$/
|
26
|
+
@input.insert 0, "values " if @input =~ /^current.+$/i
|
27
|
+
|
28
|
+
if @input =~ /describe [^. ]+\.[^.+ ]+/
|
29
|
+
@input.gsub! /describe /, 'describe table '
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
24
33
|
def quit?
|
25
|
-
@input.nil? || @input =~ /^(exit|quit)$/
|
34
|
+
@input.nil? || @input =~ /^(exit|quit|\\q|\\quit)$/
|
35
|
+
end
|
36
|
+
|
37
|
+
def history?
|
38
|
+
@input =~ /^(history|hist|\\history|\\hist)$/
|
39
|
+
end
|
40
|
+
|
41
|
+
def help?
|
42
|
+
@input =~ /^(help|h|\\help|\\h)$/
|
26
43
|
end
|
27
44
|
|
28
45
|
def valid?
|
29
|
-
|
46
|
+
!quit? && !history? && !help?
|
30
47
|
end
|
31
48
|
|
32
49
|
def execute
|
@@ -44,6 +61,10 @@ module Db2c
|
|
44
61
|
@@debug = value
|
45
62
|
end
|
46
63
|
|
64
|
+
def self.debug?
|
65
|
+
@@debug
|
66
|
+
end
|
67
|
+
|
47
68
|
def self.prompt
|
48
69
|
"db2c".tap do |pr|
|
49
70
|
pr << "(#{@@cdb})" if @@cdb.length > 0
|
data/lib/db2c/run.rb
ADDED
@@ -0,0 +1,44 @@
|
|
1
|
+
module Db2c
|
2
|
+
class Run
|
3
|
+
attr_reader :gdir
|
4
|
+
|
5
|
+
def initialize *args
|
6
|
+
@args = args
|
7
|
+
puts "args: #{@args}" if debug?
|
8
|
+
@gdir = File.expand_path('../../../', __FILE__)
|
9
|
+
puts "cdir: #{@gdir}" if debug?
|
10
|
+
Db2c::Command.debug = debug?
|
11
|
+
|
12
|
+
die "version #{Db2c::VERSION}" if version?
|
13
|
+
die "The db2 command was not found!" unless system("which db2 > /dev/null 2> /dev/null")
|
14
|
+
die "This program depends on rlwrap, please install rlwrap" if wrap? && !system("which rlwrap > /dev/null 2> /dev/null")
|
15
|
+
end
|
16
|
+
|
17
|
+
def help?
|
18
|
+
!(@args & %w{-h help -help --help --man}).empty?
|
19
|
+
end
|
20
|
+
def version?
|
21
|
+
!(@args & %w{-v version -version --version}).empty?
|
22
|
+
end
|
23
|
+
def debug?
|
24
|
+
!(@args & %w{-d debug -debug --debug}).empty?
|
25
|
+
end
|
26
|
+
def wrap?
|
27
|
+
(@args & %w{--no-rlwrap --now}).empty?
|
28
|
+
end
|
29
|
+
|
30
|
+
def autocomplete
|
31
|
+
"#{@gdir}/lib/autocomplete"
|
32
|
+
end
|
33
|
+
|
34
|
+
def args
|
35
|
+
@args.join(' ')
|
36
|
+
end
|
37
|
+
|
38
|
+
def die message
|
39
|
+
puts "DB2C: #{message}"
|
40
|
+
puts "DB2C: #{self.inspect}" if debug?
|
41
|
+
exit
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
data/man/db2c.1
CHANGED
@@ -4,7 +4,7 @@
|
|
4
4
|
.TH "DB2C" "1" "November 2011" "" ""
|
5
5
|
.
|
6
6
|
.SH "NAME"
|
7
|
-
\fBdb2c\fR \-
|
7
|
+
\fBdb2c\fR \- A DB2 console with with history and autocomplete support, and few other goodies
|
8
8
|
.
|
9
9
|
.SH "SYNOPSIS"
|
10
10
|
\fBdb2c\fR \fI\fIoptions\fR\fR
|
@@ -12,8 +12,8 @@
|
|
12
12
|
.SH "DESCRIPTION && EXAMPLES"
|
13
13
|
DB2 console mode does not support readline and autocomplete, this is a wrapper for the db2 command with support for both\.
|
14
14
|
.
|
15
|
-
.
|
16
|
-
\fBHistory\fR
|
15
|
+
.IP "\(bu" 4
|
16
|
+
\fBHistory\fR:
|
17
17
|
.
|
18
18
|
.IP "" 4
|
19
19
|
.
|
@@ -24,14 +24,16 @@ db2 => connect to testdb (or: db2 => use testdb)
|
|
24
24
|
db2(testdb) => current date
|
25
25
|
db2(testdb) => \-107
|
26
26
|
(Use the arrows for history, you can also use \fICTRL\fR\-r to search the history)
|
27
|
+
db2(testdb) => history
|
28
|
+
(To see a list of all saved history lines)
|
27
29
|
.
|
28
30
|
.fi
|
29
31
|
.
|
30
32
|
.IP "" 0
|
31
33
|
|
32
34
|
.
|
33
|
-
.
|
34
|
-
\fBAutocomplete\fR
|
35
|
+
.IP "\(bu" 4
|
36
|
+
\fBAutocomplete\fR:
|
35
37
|
.
|
36
38
|
.IP "" 4
|
37
39
|
.
|
@@ -48,8 +50,8 @@ db2(testdb) => select * from xyz\.tab[double\-tab]
|
|
48
50
|
.IP "" 0
|
49
51
|
|
50
52
|
.
|
51
|
-
.
|
52
|
-
\fBYou can pipe\fR
|
53
|
+
.IP "\(bu" 4
|
54
|
+
\fBYou can pipe\fR:
|
53
55
|
.
|
54
56
|
.IP "" 4
|
55
57
|
.
|
@@ -64,8 +66,8 @@ db2(testdb) => select * from large\.table | less
|
|
64
66
|
.IP "" 0
|
65
67
|
|
66
68
|
.
|
67
|
-
.
|
68
|
-
|
69
|
+
.IP "\(bu" 4
|
70
|
+
For example, if a command outputs long lines, \fBless \-S\fR is your friend:
|
69
71
|
.
|
70
72
|
.IP "" 4
|
71
73
|
.
|
@@ -79,6 +81,27 @@ db2(testdb) => select * from table\.with\.many\.columns | less \-S
|
|
79
81
|
.
|
80
82
|
.IP "" 0
|
81
83
|
|
84
|
+
.
|
85
|
+
.IP "\(bu" 4
|
86
|
+
You can use \fIsome psql\-like\fR commands
|
87
|
+
.
|
88
|
+
.IP "" 4
|
89
|
+
.
|
90
|
+
.nf
|
91
|
+
|
92
|
+
|
93
|
+
db2(testdb) => \fB\ed schema\.table\fR
|
94
|
+
== describe table schema\.table
|
95
|
+
db2(testdb) => \fB\eh\fR
|
96
|
+
== To see this help from within the console
|
97
|
+
db2(testdb) => \fB\eq\fR
|
98
|
+
.
|
99
|
+
.fi
|
100
|
+
.
|
101
|
+
.IP "" 0
|
102
|
+
|
103
|
+
.
|
104
|
+
.IP "" 0
|
82
105
|
.
|
83
106
|
.SH "OPTIONS"
|
84
107
|
.
|
@@ -90,6 +113,10 @@ Displays this help page\.
|
|
90
113
|
\fB\-\-debug\fR
|
91
114
|
Displays annoying messages\.
|
92
115
|
.
|
116
|
+
.TP
|
117
|
+
\fB\-\-no\-rlrwap\fR
|
118
|
+
Don\'t use rlwrap
|
119
|
+
.
|
93
120
|
.SH "BUGS"
|
94
121
|
\fIhttp://github\.com/on\-site/db2c/issues\fR
|
95
122
|
.
|
data/man/db2c.1.html
CHANGED
@@ -3,7 +3,7 @@
|
|
3
3
|
<head>
|
4
4
|
<meta http-equiv='content-type' value='text/html;charset=utf8'>
|
5
5
|
<meta name='generator' value='Ronn/v0.7.3 (http://github.com/rtomayko/ronn/tree/0.7.3)'>
|
6
|
-
<title>db2c(1) -
|
6
|
+
<title>db2c(1) - A DB2 console with with history and autocomplete support, and few other goodies</title>
|
7
7
|
<style type='text/css' media='all'>
|
8
8
|
/* style: man */
|
9
9
|
body#manpage {margin:0}
|
@@ -70,7 +70,7 @@
|
|
70
70
|
|
71
71
|
<h2 id="NAME">NAME</h2>
|
72
72
|
<p class="man-name">
|
73
|
-
<code>db2c</code> - <span class="man-whatis">
|
73
|
+
<code>db2c</code> - <span class="man-whatis">A DB2 console with with history and autocomplete support, and few other goodies</span>
|
74
74
|
</p>
|
75
75
|
|
76
76
|
<h2 id="SYNOPSIS">SYNOPSIS</h2>
|
@@ -81,28 +81,42 @@
|
|
81
81
|
|
82
82
|
<p>DB2 console mode does not support readline and autocomplete, this is a wrapper for the db2 command with support for both.</p>
|
83
83
|
|
84
|
-
<
|
85
|
-
<
|
84
|
+
<ul>
|
85
|
+
<li><p><strong>History</strong>:
|
86
|
+
</p><pre>
|
86
87
|
db2 => connect to testdb (or: db2 => use testdb)
|
87
88
|
db2(testdb) => current date
|
88
89
|
db2(testdb) => -107
|
89
90
|
(Use the arrows for history, you can also use <var>CTRL</var>-r to search the history)
|
90
|
-
|
91
|
-
|
91
|
+
db2(testdb) => history
|
92
|
+
(To see a list of all saved history lines)
|
93
|
+
</pre></li>
|
94
|
+
<li><p><strong>Autocomplete</strong>:
|
95
|
+
</p><pre>
|
92
96
|
db2(testdb) => sel[double-tab]
|
93
97
|
it remembers..
|
94
98
|
db2(testdb) => list tables for schema xyz
|
95
99
|
db2(testdb) => select * from xyz.tab[double-tab]
|
96
|
-
</pre></
|
97
|
-
<
|
100
|
+
</pre></li>
|
101
|
+
<li><p><strong>You can pipe</strong>:
|
102
|
+
</p><pre>
|
98
103
|
db2(testdb) => select * from large.table | grep -v something
|
99
104
|
db2(testdb) => select * from large.table | less
|
100
|
-
</pre></
|
101
|
-
<
|
105
|
+
</pre></li>
|
106
|
+
<li><p>For example, if a command outputs long lines, <strong>less -S</strong> is your friend:
|
107
|
+
</p><pre>
|
102
108
|
db2(testdb) => select * from table.with.many.columns | less -S
|
103
109
|
(you can scorll horizontally with left/right arrows)
|
104
|
-
</pre></
|
105
|
-
</
|
110
|
+
</pre></li>
|
111
|
+
<li><p>You can use <em>some psql-like</em> commands
|
112
|
+
</p><pre>
|
113
|
+
db2(testdb) => <strong>\d schema.table</strong>
|
114
|
+
== describe table schema.table
|
115
|
+
db2(testdb) => <strong>\h</strong>
|
116
|
+
== To see this help from within the console
|
117
|
+
db2(testdb) => <strong>\q</strong>
|
118
|
+
</pre></li>
|
119
|
+
</ul>
|
106
120
|
|
107
121
|
|
108
122
|
<h2 id="OPTIONS">OPTIONS</h2>
|
@@ -110,6 +124,7 @@ db2(testdb) => select * from table.with.many.columns | less -S
|
|
110
124
|
<dl>
|
111
125
|
<dt><code>-h</code>, <code>--help</code>, <code>--man</code></dt><dd><p>Displays this help page.</p></dd>
|
112
126
|
<dt class="flush"><code>--debug</code></dt><dd><p>Displays annoying messages.</p></dd>
|
127
|
+
<dt><code>--no-rlrwap</code></dt><dd><p>Don't use rlwrap</p></dd>
|
113
128
|
</dl>
|
114
129
|
|
115
130
|
|
@@ -119,7 +134,7 @@ db2(testdb) => select * from table.with.many.columns | less -S
|
|
119
134
|
|
120
135
|
<h2 id="AUTHOR">AUTHOR</h2>
|
121
136
|
|
122
|
-
<p>Samer Abukhait <a href="&#
|
137
|
+
<p>Samer Abukhait <a href="mailto:samer@on-siteNOSPAM.com" data-bare-link="true">samer@on-siteNOSPAM.com</a>, @s4mer</p>
|
123
138
|
|
124
139
|
<h2 id="SEE-ALSO">SEE ALSO</h2>
|
125
140
|
|
data/man/db2c.1.ronn
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
db2c(1) -
|
1
|
+
db2c(1) - A DB2 console with with history and autocomplete support, and few other goodies
|
2
2
|
===================================
|
3
3
|
|
4
4
|
## SYNOPSIS
|
@@ -15,6 +15,8 @@ DB2 console mode does not support readline and autocomplete, this is a wrapper f
|
|
15
15
|
db2(testdb) => current date
|
16
16
|
db2(testdb) => -107
|
17
17
|
(Use the arrows for history, you can also use <CTRL>-r to search the history)
|
18
|
+
db2(testdb) => history
|
19
|
+
(To see a list of all saved history lines)
|
18
20
|
</pre>
|
19
21
|
|
20
22
|
* **Autocomplete**:
|
@@ -31,12 +33,21 @@ DB2 console mode does not support readline and autocomplete, this is a wrapper f
|
|
31
33
|
db2(testdb) => select * from large.table | less
|
32
34
|
</pre>
|
33
35
|
|
34
|
-
*
|
36
|
+
* For example, if a command outputs long lines, **less -S** is your friend:
|
35
37
|
<pre>
|
36
38
|
db2(testdb) => select * from table.with.many.columns | less -S
|
37
39
|
(you can scorll horizontally with left/right arrows)
|
38
40
|
</pre>
|
39
41
|
|
42
|
+
* You can use _some psql-like_ commands
|
43
|
+
<pre>
|
44
|
+
db2(testdb) => **\d schema.table**
|
45
|
+
== describe table schema.table
|
46
|
+
db2(testdb) => **\h**
|
47
|
+
== To see this help from within the console
|
48
|
+
db2(testdb) => **\q**
|
49
|
+
</pre>
|
50
|
+
|
40
51
|
## OPTIONS
|
41
52
|
|
42
53
|
* `-h`, `--help`, `--man`:
|
@@ -45,6 +56,9 @@ DB2 console mode does not support readline and autocomplete, this is a wrapper f
|
|
45
56
|
* `--debug`:
|
46
57
|
Displays annoying messages.
|
47
58
|
|
59
|
+
* `--no-rlrwap`:
|
60
|
+
Don't use rlwrap
|
61
|
+
|
48
62
|
## BUGS
|
49
63
|
|
50
64
|
<http://github.com/on-site/db2c/issues>
|
@@ -0,0 +1,30 @@
|
|
1
|
+
require 'db2c'
|
2
|
+
|
3
|
+
describe Db2c::Command do
|
4
|
+
it 'strips db2 if any' do
|
5
|
+
Db2c::Command.new('db2 do something').to_s.should == 'do something'
|
6
|
+
Db2c::Command.new('db2 do something').should be_valid
|
7
|
+
end
|
8
|
+
it 'supports use *' do
|
9
|
+
Db2c::Command.new('use somedb').to_s.should == 'connect to somedb'
|
10
|
+
end
|
11
|
+
it 'supports describe tablei_name' do
|
12
|
+
Db2c::Command.new('describe schema.table').to_s.should == 'describe table schema.table'
|
13
|
+
end
|
14
|
+
it 'supports \d tale_name' do
|
15
|
+
Db2c::Command.new('\d schema.table').to_s.should == 'describe table schema.table'
|
16
|
+
end
|
17
|
+
it 'supports \q' do
|
18
|
+
Db2c::Command.new('\q').should be_quit
|
19
|
+
Db2c::Command.new('\quit').should be_quit
|
20
|
+
end
|
21
|
+
it 'supports history commands' do
|
22
|
+
Db2c::Command.new('history').should be_history
|
23
|
+
Db2c::Command.new('\hist').should be_history
|
24
|
+
end
|
25
|
+
it 'supports help command' do
|
26
|
+
Db2c::Command.new('help').should be_help
|
27
|
+
Db2c::Command.new('\help').should be_help
|
28
|
+
Db2c::Command.new('\h').should be_help
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
require "db2c"
|
2
|
+
|
3
|
+
describe Db2c::Run do
|
4
|
+
it "works with empty arguments" do
|
5
|
+
Db2c::Run.new("").should be
|
6
|
+
end
|
7
|
+
it "defines helper boolean methods" do
|
8
|
+
Db2c::Run.any_instance.stub(:die)
|
9
|
+
Db2c::Run.new("").should_not be_version
|
10
|
+
Db2c::Run.new("").should_not be_debug
|
11
|
+
Db2c::Run.new("").should_not be_help
|
12
|
+
Db2c::Run.new("").should be_wrap
|
13
|
+
|
14
|
+
Db2c::Run.new("-v").should be_version
|
15
|
+
Db2c::Run.new("-d").should be_debug
|
16
|
+
Db2c::Run.new("-h").should be_help
|
17
|
+
Db2c::Run.new("--now").should_not be_wrap
|
18
|
+
|
19
|
+
Db2c::Run.new("version").should be_version
|
20
|
+
Db2c::Run.new("debug").should be_debug
|
21
|
+
Db2c::Run.new("help").should be_help
|
22
|
+
Db2c::Run.new("--no-rlwrap").should_not be_wrap
|
23
|
+
|
24
|
+
end
|
25
|
+
it "sets command debug flag" do
|
26
|
+
Db2c::Command.should_not be_debug
|
27
|
+
Db2c::Run.new("debug")
|
28
|
+
Db2c::Command.should be_debug
|
29
|
+
end
|
30
|
+
it "outputs version" do
|
31
|
+
Db2c::Run.any_instance.should_receive(:die).with("version #{Db2c::VERSION}")
|
32
|
+
Db2c::Run.new("--version")
|
33
|
+
end
|
34
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: db2c
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,26 +9,43 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2011-11-
|
13
|
-
dependencies:
|
14
|
-
|
15
|
-
|
12
|
+
date: 2011-11-22 00:00:00.000000000Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: rspec
|
16
|
+
requirement: &9232020 !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
22
|
+
type: :development
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: *9232020
|
25
|
+
description: a db2 console with with history and autocomplete support, and few other
|
26
|
+
goodies
|
16
27
|
email: samer@on-siteNOSPAM.com
|
17
28
|
executables:
|
18
29
|
- db2c
|
19
30
|
extensions: []
|
20
31
|
extra_rdoc_files: []
|
21
32
|
files:
|
22
|
-
-
|
33
|
+
- .gitignore
|
34
|
+
- Gemfile
|
35
|
+
- LICENSE
|
36
|
+
- README.md
|
37
|
+
- Rakefile
|
23
38
|
- bin/db2c
|
24
|
-
-
|
39
|
+
- db2c.gemspec
|
40
|
+
- lib/autocomplete
|
25
41
|
- lib/db2c.rb
|
26
|
-
-
|
42
|
+
- lib/db2c/command.rb
|
43
|
+
- lib/db2c/run.rb
|
27
44
|
- man/db2c.1
|
45
|
+
- man/db2c.1.html
|
28
46
|
- man/db2c.1.ronn
|
29
|
-
-
|
30
|
-
-
|
31
|
-
- Rakefile
|
47
|
+
- spec/db2c/command_spec.rb
|
48
|
+
- spec/db2c/run_spec.rb
|
32
49
|
homepage: http://github.com/on-site/db2c
|
33
50
|
licenses: []
|
34
51
|
post_install_message:
|
@@ -52,5 +69,5 @@ rubyforge_project:
|
|
52
69
|
rubygems_version: 1.8.10
|
53
70
|
signing_key:
|
54
71
|
specification_version: 3
|
55
|
-
summary: a db2 console
|
72
|
+
summary: a smarter db2 console
|
56
73
|
test_files: []
|