mssql 0.0.2
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/.autotest +10 -0
- data/.gitignore +2 -0
- data/.rbenv-version +1 -0
- data/Gemfile +16 -0
- data/LICENSE +22 -0
- data/README.md +190 -0
- data/Rakefile +9 -0
- data/bin/mssql +7 -0
- data/emacs/sql-ms.el +120 -0
- data/lib/command.rb +133 -0
- data/lib/command_parser.rb +28 -0
- data/lib/connection.rb +58 -0
- data/lib/controller.rb +126 -0
- data/lib/mssql.rb +22 -0
- data/lib/params_parser.rb +49 -0
- data/lib/query_output.rb +55 -0
- data/lib/simple_update.in +50 -0
- data/lib/simple_update.sql +50 -0
- data/lib/table_output.rb +71 -0
- data/lib/version.rb +3 -0
- data/mssql.gemspec +21 -0
- data/test/in_out/authors.actual +29 -0
- data/test/in_out/authors.expected +29 -0
- data/test/in_out/authors.sql +1 -0
- data/test/in_out/authors_update.actual +1 -0
- data/test/in_out/authors_update.expected +1 -0
- data/test/in_out/authors_update.sql +1 -0
- data/test/in_out/sp_help.actual +74 -0
- data/test/in_out/sp_help.expected +74 -0
- data/test/in_out/sp_help.sql +1 -0
- data/test/test_command_parser.rb +25 -0
- data/test/test_connection.rb +103 -0
- data/test/test_helper.rb +48 -0
- data/test/test_input_output.rb +68 -0
- data/test/test_table.rb +26 -0
- data/todo +20 -0
- metadata +129 -0
data/test/test_helper.rb
ADDED
@@ -0,0 +1,48 @@
|
|
1
|
+
require 'test/unit'
|
2
|
+
require 'minitest/unit'
|
3
|
+
require 'pp'
|
4
|
+
|
5
|
+
$: << File.join(File.dirname(__FILE__), "../lib")
|
6
|
+
require 'mssql'
|
7
|
+
|
8
|
+
class MiniTest::Unit::TestCase
|
9
|
+
|
10
|
+
def load_fixture(file_name)
|
11
|
+
YAML.load(File.open("test/fixtures/#{file_name}.yml"))
|
12
|
+
end
|
13
|
+
|
14
|
+
def assert_string(value)
|
15
|
+
assert_not_nil value
|
16
|
+
assert value.kind_of?(String)
|
17
|
+
end
|
18
|
+
|
19
|
+
def assert_int(value)
|
20
|
+
assert_not_nil value
|
21
|
+
assert value.kind_of?(Fixnum)
|
22
|
+
end
|
23
|
+
|
24
|
+
def assert_time(value)
|
25
|
+
assert_not_nil value
|
26
|
+
assert value.kind_of?(Time)
|
27
|
+
end
|
28
|
+
|
29
|
+
def assert_in_range(range, value)
|
30
|
+
assert range.include?(value.to_i)
|
31
|
+
end
|
32
|
+
|
33
|
+
def assert_time(expected, actual, message = nil)
|
34
|
+
assert_equal expected, actual.strftime("%Y-%m-%d %H:%M"), message
|
35
|
+
end
|
36
|
+
|
37
|
+
def assert_same_hash(expected, actual)
|
38
|
+
compare_hashes expected, actual
|
39
|
+
compare_hashes actual, expected
|
40
|
+
end
|
41
|
+
|
42
|
+
def compare_hashes(h1, h2)
|
43
|
+
h1.each_pair do |key, value|
|
44
|
+
assert_equal value, (h2[key.to_sym] || h2[key.to_s])
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
end
|
@@ -0,0 +1,68 @@
|
|
1
|
+
require 'minitest/unit'
|
2
|
+
require 'pp'
|
3
|
+
|
4
|
+
class TestInputOuput < MiniTest::Unit::TestCase
|
5
|
+
|
6
|
+
def test_all
|
7
|
+
input_files.each do |input_file_name|
|
8
|
+
@input_file_name = input_file_name
|
9
|
+
@actual = execute
|
10
|
+
write_expected unless File.exists?(expected_file)
|
11
|
+
write_actual
|
12
|
+
@expected = expected_content
|
13
|
+
unless @actual == @expected
|
14
|
+
`opendiff #{expected_file} #{actual_file}`
|
15
|
+
end
|
16
|
+
assert @actual == @expected, "#{actual_file} differs from #{expected_file}"
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
private
|
21
|
+
|
22
|
+
def write_expected
|
23
|
+
print "!! writing expected file #{expected_file}\n"
|
24
|
+
print @actual
|
25
|
+
print "\n"
|
26
|
+
File.open(expected_file, "w+") do |f|
|
27
|
+
f.puts @actual
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
def write_actual
|
32
|
+
File.open(actual_file, "w+") do |f|
|
33
|
+
f.puts @actual
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
def expected_content
|
38
|
+
File.read expected_file
|
39
|
+
end
|
40
|
+
|
41
|
+
def base_name
|
42
|
+
File.join app_root, "test/in_out", @input_file_name.gsub(".sql", "")
|
43
|
+
end
|
44
|
+
|
45
|
+
def expected_file
|
46
|
+
base_name + ".expected"
|
47
|
+
end
|
48
|
+
|
49
|
+
def actual_file
|
50
|
+
base_name + ".actual"
|
51
|
+
end
|
52
|
+
|
53
|
+
def input_files
|
54
|
+
Dir.chdir app_root
|
55
|
+
Dir.chdir "./test/in_out"
|
56
|
+
Dir.glob("*.sql")
|
57
|
+
end
|
58
|
+
|
59
|
+
def execute
|
60
|
+
Dir.chdir app_root
|
61
|
+
`bin/mssql.rb -c test -i test/in_out/#{@input_file_name}`
|
62
|
+
end
|
63
|
+
|
64
|
+
def app_root
|
65
|
+
@app_root ||= File.join(File.absolute_path(File.dirname(__FILE__)), "..")
|
66
|
+
end
|
67
|
+
|
68
|
+
end
|
data/test/test_table.rb
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
# -*- coding: utf-8 -*
|
2
|
+
$: << File.join(File.dirname(__FILE__))
|
3
|
+
require 'test_helper'
|
4
|
+
|
5
|
+
class TestTable < MiniTest::Unit::TestCase
|
6
|
+
|
7
|
+
def test_one_table
|
8
|
+
to = TableOutput.new([:id, :pero, :zdero], [[1, 'abc', 123], [10, 'defg', 'nesto']])
|
9
|
+
output = "
|
10
|
+
+----+------+-------+
|
11
|
+
| id | pero | zdero |
|
12
|
+
+----+------+-------+
|
13
|
+
| 1 | abc | 123 |
|
14
|
+
| 10 | defg | nesto |
|
15
|
+
+----+------+-------+
|
16
|
+
2 rows affected
|
17
|
+
"
|
18
|
+
assert_equal output, to.to_s
|
19
|
+
end
|
20
|
+
|
21
|
+
def test_mb_chars
|
22
|
+
assert_equal 20, "Sv.Martin pod Okicom".length
|
23
|
+
assert_equal 20, "SV.martin pod Okićžš".scan(/./mu).size
|
24
|
+
end
|
25
|
+
|
26
|
+
end
|
data/todo
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
## todos
|
2
|
+
|
3
|
+
* .find ponuda.modemi is not working properly (because of .)
|
4
|
+
* move/or link emacs configuration to the project
|
5
|
+
* sample .mssql file
|
6
|
+
* create table script, instead of explain (or keep both options somehow)
|
7
|
+
* json, html output
|
8
|
+
* pipe to to other Ruby application
|
9
|
+
* command can be in any line
|
10
|
+
* tiny tds extensioins
|
11
|
+
* line number for error
|
12
|
+
|
13
|
+
* detect dead db process and reconnect
|
14
|
+
* format dates
|
15
|
+
* commands
|
16
|
+
explain
|
17
|
+
find
|
18
|
+
show tables
|
19
|
+
show columns
|
20
|
+
|
metadata
ADDED
@@ -0,0 +1,129 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: mssql
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.2
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Igor Anic
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2012-01-04 00:00:00.000000000Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: tiny_tds
|
16
|
+
requirement: &70113705960100 !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ~>
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: 0.5.0
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: *70113705960100
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: hashie
|
27
|
+
requirement: &70113705959580 !ruby/object:Gem::Requirement
|
28
|
+
none: false
|
29
|
+
requirements:
|
30
|
+
- - ~>
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: 1.0.0
|
33
|
+
type: :runtime
|
34
|
+
prerelease: false
|
35
|
+
version_requirements: *70113705959580
|
36
|
+
- !ruby/object:Gem::Dependency
|
37
|
+
name: activesupport
|
38
|
+
requirement: &70113705959120 !ruby/object:Gem::Requirement
|
39
|
+
none: false
|
40
|
+
requirements:
|
41
|
+
- - ~>
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: 3.1.1
|
44
|
+
type: :runtime
|
45
|
+
prerelease: false
|
46
|
+
version_requirements: *70113705959120
|
47
|
+
description: mssql server command line tool
|
48
|
+
email:
|
49
|
+
- ianic@minus5.hr
|
50
|
+
executables:
|
51
|
+
- mssql
|
52
|
+
extensions: []
|
53
|
+
extra_rdoc_files: []
|
54
|
+
files:
|
55
|
+
- .autotest
|
56
|
+
- .gitignore
|
57
|
+
- .rbenv-version
|
58
|
+
- Gemfile
|
59
|
+
- LICENSE
|
60
|
+
- README.md
|
61
|
+
- Rakefile
|
62
|
+
- bin/mssql
|
63
|
+
- emacs/sql-ms.el
|
64
|
+
- lib/command.rb
|
65
|
+
- lib/command_parser.rb
|
66
|
+
- lib/connection.rb
|
67
|
+
- lib/controller.rb
|
68
|
+
- lib/mssql.rb
|
69
|
+
- lib/params_parser.rb
|
70
|
+
- lib/query_output.rb
|
71
|
+
- lib/simple_update.in
|
72
|
+
- lib/simple_update.sql
|
73
|
+
- lib/table_output.rb
|
74
|
+
- lib/version.rb
|
75
|
+
- mssql.gemspec
|
76
|
+
- test/in_out/authors.actual
|
77
|
+
- test/in_out/authors.expected
|
78
|
+
- test/in_out/authors.sql
|
79
|
+
- test/in_out/authors_update.actual
|
80
|
+
- test/in_out/authors_update.expected
|
81
|
+
- test/in_out/authors_update.sql
|
82
|
+
- test/in_out/sp_help.actual
|
83
|
+
- test/in_out/sp_help.expected
|
84
|
+
- test/in_out/sp_help.sql
|
85
|
+
- test/test_command_parser.rb
|
86
|
+
- test/test_connection.rb
|
87
|
+
- test/test_helper.rb
|
88
|
+
- test/test_input_output.rb
|
89
|
+
- test/test_table.rb
|
90
|
+
- todo
|
91
|
+
homepage: http://www.minus5.hr
|
92
|
+
licenses: []
|
93
|
+
post_install_message:
|
94
|
+
rdoc_options: []
|
95
|
+
require_paths:
|
96
|
+
- lib
|
97
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
98
|
+
none: false
|
99
|
+
requirements:
|
100
|
+
- - ! '>='
|
101
|
+
- !ruby/object:Gem::Version
|
102
|
+
version: '0'
|
103
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
104
|
+
none: false
|
105
|
+
requirements:
|
106
|
+
- - ! '>='
|
107
|
+
- !ruby/object:Gem::Version
|
108
|
+
version: '0'
|
109
|
+
requirements: []
|
110
|
+
rubyforge_project:
|
111
|
+
rubygems_version: 1.8.10
|
112
|
+
signing_key:
|
113
|
+
specification_version: 3
|
114
|
+
summary: Command line tool for connecting to Microsoft Sql Server from Mac or Linux.
|
115
|
+
test_files:
|
116
|
+
- test/in_out/authors.actual
|
117
|
+
- test/in_out/authors.expected
|
118
|
+
- test/in_out/authors.sql
|
119
|
+
- test/in_out/authors_update.actual
|
120
|
+
- test/in_out/authors_update.expected
|
121
|
+
- test/in_out/authors_update.sql
|
122
|
+
- test/in_out/sp_help.actual
|
123
|
+
- test/in_out/sp_help.expected
|
124
|
+
- test/in_out/sp_help.sql
|
125
|
+
- test/test_command_parser.rb
|
126
|
+
- test/test_connection.rb
|
127
|
+
- test/test_helper.rb
|
128
|
+
- test/test_input_output.rb
|
129
|
+
- test/test_table.rb
|