marjoree 0.0.1 → 0.0.9
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/Marjoree.iml +14 -0
- data/README +9 -36
- data/bin/create_marj_structure.rb +75 -0
- data/bin/create_odbc_connections.rb +39 -0
- data/bin/odbc_connection_finder.rb +46 -0
- data/examples/contains_example.rb +1 -1
- data/examples/count_and_insert_example.rb +1 -1
- data/examples/select_example.rb +1 -1
- data/html/classes/ExpectedResultSet.html +60 -33
- data/html/classes/ExpectedResultSet.src/M000002.html +6 -5
- data/html/classes/ExpectedResultSet.src/M000003.html +5 -5
- data/html/classes/ExpectedResultSet.src/M000004.html +5 -5
- data/html/classes/ExpectedResultSet.src/M000005.html +18 -0
- data/html/classes/ExpectedResultSet.src/M000006.html +24 -0
- data/html/classes/ExpectedResultSet.src/M000007.html +23 -0
- data/html/classes/ExpectedResultSet.src/M000008.html +29 -0
- data/html/classes/Fixnum.html +287 -0
- data/html/classes/Fixnum.src/M000031.html +18 -0
- data/html/classes/Fixnum.src/M000034.html +18 -0
- data/html/classes/Fixnum.src/M000037.html +18 -0
- data/html/classes/Fixnum.src/M000039.html +18 -0
- data/html/classes/Fixnum.src/M000041.html +18 -0
- data/html/classes/Hash.html +156 -0
- data/html/classes/Hash.src/M000009.html +21 -0
- data/html/classes/Hash.src/M000010.html +20 -0
- data/html/classes/Marjoree.html +268 -151
- data/html/classes/Marjoree.src/M000057.html +19 -0
- data/html/classes/Marjoree.src/M000058.html +18 -0
- data/html/classes/{ExpectedResultSet.src/M000001.html → Marjoree.src/M000059.html} +4 -4
- data/html/classes/Marjoree.src/{M000024.html → M000060.html} +4 -4
- data/html/classes/Marjoree.src/{M000031.html → M000061.html} +4 -4
- data/html/classes/Marjoree.src/{M000026.html → M000062.html} +3 -3
- data/html/classes/Marjoree.src/{M000027.html → M000063.html} +3 -3
- data/html/classes/Marjoree.src/{M000028.html → M000064.html} +3 -3
- data/html/classes/Marjoree.src/{M000029.html → M000065.html} +5 -6
- data/html/classes/Marjoree.src/{M000030.html → M000066.html} +5 -5
- data/html/classes/Marjoree.src/M000067.html +19 -0
- data/html/classes/Marjoree.src/{M000032.html → M000068.html} +3 -3
- data/html/classes/{ResultSetWrapper.src/M000009.html → Marjoree.src/M000069.html} +4 -4
- data/html/classes/{ResultSetWrapper.src/M000010.html → Marjoree.src/M000070.html} +4 -4
- data/html/classes/{ResultSetWrapper.src/M000011.html → Marjoree.src/M000071.html} +4 -4
- data/html/classes/Marjoree.src/M000072.html +20 -0
- data/html/classes/Marjoree.src/M000073.html +20 -0
- data/html/classes/Marjoree.src/M000074.html +20 -0
- data/html/classes/Marjoree.src/{M000033.html → M000075.html} +3 -3
- data/html/classes/Marjoree.src/{M000034.html → M000076.html} +4 -4
- data/html/classes/Marjoree.src/{M000035.html → M000077.html} +2 -2
- data/html/classes/Marjoree.src/{M000036.html → M000078.html} +4 -3
- data/html/classes/Marjoree.src/{M000037.html → M000079.html} +1 -1
- data/html/classes/Marjoree.src/{M000038.html → M000080.html} +3 -3
- data/html/classes/Marjoree.src/{M000039.html → M000081.html} +3 -4
- data/html/classes/Marjoree.src/{M000040.html → M000082.html} +3 -3
- data/html/classes/Marjoree.src/{M000041.html → M000083.html} +3 -3
- data/html/classes/{ResultSetWrapper.src/M000008.html → Marjoree.src/M000084.html} +4 -4
- data/html/classes/ODBC.html +4 -0
- data/html/classes/ODBC/Error.html +12 -12
- data/html/classes/ODBC/Error.src/M000047.html +21 -0
- data/html/classes/ODBC/Error.src/{M000021.html → M000048.html} +2 -2
- data/html/classes/ODBC/TimeStamp.html +48 -18
- data/html/classes/ODBC/TimeStamp.src/{M000017.html → M000042.html} +2 -2
- data/html/classes/ODBC/TimeStamp.src/M000043.html +22 -0
- data/html/classes/ODBC/TimeStamp.src/{M000019.html → M000044.html} +2 -3
- data/html/classes/ODBC/TimeStamp.src/M000045.html +18 -0
- data/html/classes/ODBC/TimeStamp.src/M000046.html +18 -0
- data/html/classes/OdbcConnectionWrapper.html +244 -0
- data/html/classes/OdbcConnectionWrapper.src/M000023.html +18 -0
- data/html/classes/OdbcConnectionWrapper.src/M000024.html +18 -0
- data/html/classes/OdbcConnectionWrapper.src/M000025.html +22 -0
- data/html/classes/OdbcConnectionWrapper.src/M000026.html +25 -0
- data/html/classes/OdbcConnectionWrapper.src/M000027.html +20 -0
- data/html/classes/OdbcConnectionWrapper.src/M000028.html +28 -0
- data/html/classes/OdbcConnectionWrapper.src/M000029.html +24 -0
- data/html/classes/OdbcConnectionWrapper.src/M000030.html +30 -0
- data/html/classes/{ResultSetWrapper.html → ResultSet.html} +71 -94
- data/html/classes/ResultSet.src/M000011.html +27 -0
- data/html/classes/ResultSet.src/M000012.html +21 -0
- data/html/classes/ResultSet.src/M000013.html +23 -0
- data/html/classes/ResultSet.src/M000014.html +18 -0
- data/html/classes/ResultSet.src/M000015.html +18 -0
- data/html/classes/ResultSet.src/M000016.html +18 -0
- data/html/classes/ResultSet.src/M000017.html +18 -0
- data/html/classes/ResultSet.src/M000018.html +20 -0
- data/html/classes/ResultSet.src/M000019.html +18 -0
- data/html/classes/ResultSet.src/M000020.html +22 -0
- data/html/classes/ResultSet.src/M000021.html +23 -0
- data/html/classes/ResultSet.src/M000022.html +22 -0
- data/html/classes/Test.html +107 -0
- data/html/classes/Test/Unit.html +107 -0
- data/html/classes/Test/Unit/TestCase.html +257 -0
- data/html/classes/Test/Unit/TestCase.src/M000049.html +18 -0
- data/html/classes/Test/Unit/TestCase.src/M000050.html +18 -0
- data/html/classes/Test/Unit/TestCase.src/M000051.html +17 -0
- data/html/classes/Test/Unit/TestCase.src/M000052.html +17 -0
- data/html/classes/Test/Unit/TestCase.src/M000053.html +25 -0
- data/html/classes/Test/Unit/TestCase.src/M000054.html +18 -0
- data/html/classes/Test/Unit/TestCase.src/M000055.html +18 -0
- data/html/classes/Test/Unit/TestCase.src/M000056.html +35 -0
- data/html/created.rid +1 -1
- data/html/files/README.html +2 -51
- data/html/files/lib/expected_result_set_rb.html +1 -16
- data/html/files/lib/marjoree/core_rb.html +111 -0
- data/html/files/lib/marjoree/fixtures_rb.html +111 -0
- data/html/files/lib/marjoree/odbc_connection_wrapper_rb.html +109 -0
- data/html/files/lib/marjoree/odbc_rb.html +108 -0
- data/html/files/lib/{odbc_overrides_rb.html → marjoree/result_set_rb.html} +5 -5
- data/html/files/lib/{result_set_wrapper_rb.html → marjoree/time_rb.html} +5 -5
- data/html/files/lib/marjoree_rb.html +3 -4
- data/html/files/lib/run_marjoree_rb.html +145 -0
- data/html/files/lib/run_marjoree_rb.src/M000001.html +34 -0
- data/html/fr_class_index.html +7 -1
- data/html/fr_file_index.html +7 -2
- data/html/fr_method_index.html +84 -42
- data/lib/Marjoree.iml +12 -0
- data/lib/expected_result_set.rb +51 -24
- data/lib/marjoree.rb +2 -344
- data/lib/marjoree/core.rb +388 -0
- data/lib/marjoree/fixtures.rb +156 -0
- data/lib/marjoree/odbc.rb +45 -0
- data/lib/marjoree/odbc_connection_wrapper.rb +79 -0
- data/lib/marjoree/result_set.rb +165 -0
- data/lib/marjoree/sybase_definitions.rb +223 -0
- data/lib/marjoree/time.rb +31 -0
- data/lib/proc_param_info.txt +20 -0
- data/lib/run_marjoree.rb +31 -0
- data/pkg/marjoree-0.0.9.gem +0 -0
- data/rakefile.rb +3 -3
- data/tests/all_cruby_tests.rb +24 -0
- data/tests/all_jruby_tests.rb +22 -0
- data/tests/all_tests.rb +9 -6
- data/tests/fixtures/A.yml +3 -0
- data/tests/fixtures/B.yml +5 -0
- data/tests/fixtures/first_db/FIRST.yml +8 -0
- data/tests/fixtures/second_db/SECOND.yml +9 -0
- data/tests/marjoree/test_assert_results.rb +82 -0
- data/tests/marjoree/test_connection_details.rb +44 -0
- data/tests/{test_contains.rb → marjoree/test_contains.rb} +0 -0
- data/tests/{test_delete.rb → marjoree/test_delete.rb} +0 -0
- data/tests/marjoree/test_drop_user_objects.rb +52 -0
- data/tests/marjoree/test_expected_result_set.rb +111 -0
- data/tests/marjoree/test_fixtures.rb +112 -0
- data/tests/{test_insert.rb → marjoree/test_insert.rb} +0 -0
- data/tests/{test_marjoree.rb → marjoree/test_marjoree.rb} +14 -2
- data/tests/marjoree/test_multiple_db_fixtures.rb +35 -0
- data/tests/{test_num_rows.rb → marjoree/test_num_rows.rb} +0 -0
- data/tests/marjoree/test_odbc_connection_wrapper.rb +47 -0
- data/tests/{test_result_set_wrapper.rb → marjoree/test_result_set_wrapper.rb} +8 -8
- data/tests/marjoree/test_select.rb +55 -0
- data/tests/marjoree/test_single_odbc_connection_wrapper.rb +39 -0
- data/tests/{test_sproc.rb → marjoree/test_sproc.rb} +3 -4
- data/tests/marjoree/test_time.rb +25 -0
- data/tests/{test_time_stamp.rb → marjoree/test_time_stamp.rb} +10 -1
- data/tests/{test_truncate.rb → marjoree/test_truncate.rb} +0 -0
- data/tests/{test_update.rb → marjoree/test_update.rb} +14 -14
- data/tests/multiple_odbc_config/connections.yml +13 -0
- data/tests/single_odbc_config/connections.yml +3 -0
- metadata +214 -112
- data/html/classes/Marjoree.src/M000022.html +0 -19
- data/html/classes/Marjoree.src/M000023.html +0 -20
- data/html/classes/Marjoree.src/M000025.html +0 -18
- data/html/classes/Marjoree.src/M000042.html +0 -25
- data/html/classes/ODBC/Error.src/M000020.html +0 -21
- data/html/classes/ODBC/TimeStamp.src/M000018.html +0 -22
- data/html/classes/ResultSetWrapper.src/M000005.html +0 -27
- data/html/classes/ResultSetWrapper.src/M000006.html +0 -24
- data/html/classes/ResultSetWrapper.src/M000007.html +0 -23
- data/html/classes/ResultSetWrapper.src/M000012.html +0 -20
- data/html/classes/ResultSetWrapper.src/M000013.html +0 -18
- data/html/classes/ResultSetWrapper.src/M000014.html +0 -22
- data/html/classes/ResultSetWrapper.src/M000015.html +0 -23
- data/html/classes/ResultSetWrapper.src/M000016.html +0 -27
- data/lib/odbc_overrides.rb +0 -33
- data/lib/result_set_wrapper.rb +0 -193
- data/tests/test_expected_result_set.rb +0 -40
- data/tests/test_select.rb +0 -30
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
<?xml version="1.0" encoding="iso-8859-1"?>
|
|
2
|
-
<!DOCTYPE html
|
|
3
|
-
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
|
4
|
-
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
|
5
|
-
|
|
6
|
-
<html>
|
|
7
|
-
<head>
|
|
8
|
-
<title>connect (Marjoree)</title>
|
|
9
|
-
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
|
|
10
|
-
<link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
|
|
11
|
-
</head>
|
|
12
|
-
<body class="standalone-code">
|
|
13
|
-
<pre><span class="ruby-comment cmt"># File lib/marjoree.rb, line 11</span>
|
|
14
|
-
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">connect</span>( <span class="ruby-identifier">odbc_name</span>, <span class="ruby-identifier">username</span>, <span class="ruby-identifier">password</span> )
|
|
15
|
-
<span class="ruby-identifier">$db</span> = <span class="ruby-constant">ODBC</span>.<span class="ruby-identifier">connect</span>(<span class="ruby-identifier">odbc_name</span>, <span class="ruby-identifier">username</span>, <span class="ruby-identifier">password</span> )
|
|
16
|
-
<span class="ruby-identifier">puts</span> <span class="ruby-value str">"Connected"</span>
|
|
17
|
-
<span class="ruby-keyword kw">end</span></pre>
|
|
18
|
-
</body>
|
|
19
|
-
</html>
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
<?xml version="1.0" encoding="iso-8859-1"?>
|
|
2
|
-
<!DOCTYPE html
|
|
3
|
-
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
|
4
|
-
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
|
5
|
-
|
|
6
|
-
<html>
|
|
7
|
-
<head>
|
|
8
|
-
<title>disconnect (Marjoree)</title>
|
|
9
|
-
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
|
|
10
|
-
<link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
|
|
11
|
-
</head>
|
|
12
|
-
<body class="standalone-code">
|
|
13
|
-
<pre><span class="ruby-comment cmt"># File lib/marjoree.rb, line 17</span>
|
|
14
|
-
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">disconnect</span>
|
|
15
|
-
<span class="ruby-identifier">$db</span>.<span class="ruby-identifier">drop_all</span>
|
|
16
|
-
<span class="ruby-identifier">$db</span>.<span class="ruby-identifier">disconnect</span>
|
|
17
|
-
<span class="ruby-identifier">puts</span> <span class="ruby-value str">"Disconnected"</span>
|
|
18
|
-
<span class="ruby-keyword kw">end</span></pre>
|
|
19
|
-
</body>
|
|
20
|
-
</html>
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
<?xml version="1.0" encoding="iso-8859-1"?>
|
|
2
|
-
<!DOCTYPE html
|
|
3
|
-
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
|
4
|
-
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
|
5
|
-
|
|
6
|
-
<html>
|
|
7
|
-
<head>
|
|
8
|
-
<title>select (Marjoree)</title>
|
|
9
|
-
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
|
|
10
|
-
<link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
|
|
11
|
-
</head>
|
|
12
|
-
<body class="standalone-code">
|
|
13
|
-
<pre><span class="ruby-comment cmt"># File lib/marjoree.rb, line 42</span>
|
|
14
|
-
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">select</span>( <span class="ruby-identifier">table_name</span> )
|
|
15
|
-
<span class="ruby-keyword kw">return</span> <span class="ruby-constant">ResultSetWrapper</span>.<span class="ruby-identifier">new</span>( <span class="ruby-identifier">execute</span>( <span class="ruby-node">"SELECT * FROM #{table_name}"</span> ) )
|
|
16
|
-
<span class="ruby-keyword kw">end</span></pre>
|
|
17
|
-
</body>
|
|
18
|
-
</html>
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
<?xml version="1.0" encoding="iso-8859-1"?>
|
|
2
|
-
<!DOCTYPE html
|
|
3
|
-
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
|
4
|
-
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
|
5
|
-
|
|
6
|
-
<html>
|
|
7
|
-
<head>
|
|
8
|
-
<title>execute (Marjoree)</title>
|
|
9
|
-
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
|
|
10
|
-
<link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
|
|
11
|
-
</head>
|
|
12
|
-
<body class="standalone-code">
|
|
13
|
-
<pre><span class="ruby-comment cmt"># File lib/marjoree.rb, line 189</span>
|
|
14
|
-
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">execute</span>( <span class="ruby-identifier">sql</span> )
|
|
15
|
-
<span class="ruby-identifier">dbCall</span> = <span class="ruby-identifier">$db</span>.<span class="ruby-identifier">prepare</span>( <span class="ruby-identifier">sql</span> )
|
|
16
|
-
<span class="ruby-keyword kw">begin</span>
|
|
17
|
-
<span class="ruby-identifier">dbCall</span>.<span class="ruby-identifier">execute</span>
|
|
18
|
-
<span class="ruby-keyword kw">rescue</span>
|
|
19
|
-
<span class="ruby-identifier">raise</span> <span class="ruby-constant">ODBC</span><span class="ruby-operator">::</span><span class="ruby-constant">Error</span>.<span class="ruby-identifier">new</span>(<span class="ruby-node">"Failed executing: #{sql}\nDue to: #{$!}"</span>)
|
|
20
|
-
<span class="ruby-keyword kw">end</span>
|
|
21
|
-
|
|
22
|
-
<span class="ruby-keyword kw">return</span> <span class="ruby-identifier">dbCall</span>
|
|
23
|
-
<span class="ruby-keyword kw">end</span></pre>
|
|
24
|
-
</body>
|
|
25
|
-
</html>
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
<?xml version="1.0" encoding="iso-8859-1"?>
|
|
2
|
-
<!DOCTYPE html
|
|
3
|
-
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
|
4
|
-
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
|
5
|
-
|
|
6
|
-
<html>
|
|
7
|
-
<head>
|
|
8
|
-
<title>error_code (ODBC::Error)</title>
|
|
9
|
-
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
|
|
10
|
-
<link rel="stylesheet" href="../../.././rdoc-style.css" type="text/css" media="screen" />
|
|
11
|
-
</head>
|
|
12
|
-
<body class="standalone-code">
|
|
13
|
-
<pre><span class="ruby-comment cmt"># File lib/odbc_overrides.rb, line 23</span>
|
|
14
|
-
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">error_code</span>
|
|
15
|
-
<span class="ruby-identifier">start_index</span> = <span class="ruby-identifier">to_s</span> <span class="ruby-operator">=~</span> <span class="ruby-regexp re">/(\()/</span>
|
|
16
|
-
<span class="ruby-identifier">end_index</span> = <span class="ruby-identifier">to_s</span> <span class="ruby-operator">=~</span> <span class="ruby-regexp re">/(\))/</span>
|
|
17
|
-
<span class="ruby-identifier">end_index</span> <span class="ruby-operator">-=</span> <span class="ruby-value">1</span>
|
|
18
|
-
<span class="ruby-keyword kw">return</span> <span class="ruby-identifier">to_s</span>.<span class="ruby-identifier">slice</span>( (<span class="ruby-identifier">start_index</span> <span class="ruby-operator">+</span> <span class="ruby-value">1</span> ), (<span class="ruby-identifier">end_index</span> <span class="ruby-operator">-</span> <span class="ruby-identifier">start_index</span> ) ).<span class="ruby-identifier">to_i</span>
|
|
19
|
-
<span class="ruby-keyword kw">end</span></pre>
|
|
20
|
-
</body>
|
|
21
|
-
</html>
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
<?xml version="1.0" encoding="iso-8859-1"?>
|
|
2
|
-
<!DOCTYPE html
|
|
3
|
-
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
|
4
|
-
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
|
5
|
-
|
|
6
|
-
<html>
|
|
7
|
-
<head>
|
|
8
|
-
<title>to_s (ODBC::TimeStamp)</title>
|
|
9
|
-
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
|
|
10
|
-
<link rel="stylesheet" href="../../.././rdoc-style.css" type="text/css" media="screen" />
|
|
11
|
-
</head>
|
|
12
|
-
<body class="standalone-code">
|
|
13
|
-
<pre><span class="ruby-comment cmt"># File lib/odbc_overrides.rb, line 8</span>
|
|
14
|
-
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">to_s</span>
|
|
15
|
-
<span class="ruby-identifier">datetime</span> = <span class="ruby-identifier">old_to_s</span>
|
|
16
|
-
<span class="ruby-identifier">date</span>, <span class="ruby-identifier">time</span>, <span class="ruby-identifier">fraction</span> = <span class="ruby-identifier">datetime</span>.<span class="ruby-identifier">split</span>(<span class="ruby-value str">" "</span>)
|
|
17
|
-
|
|
18
|
-
<span class="ruby-identifier">fraction_text</span> = (<span class="ruby-identifier">fraction</span> <span class="ruby-operator">==</span> <span class="ruby-value str">'0'</span>) <span class="ruby-operator">?</span> <span class="ruby-value str">''</span> <span class="ruby-operator">:</span> <span class="ruby-node">".#{fraction}"</span>
|
|
19
|
-
<span class="ruby-keyword kw">return</span> <span class="ruby-node">"#{date} #{time}#{fraction_text}"</span>
|
|
20
|
-
<span class="ruby-keyword kw">end</span></pre>
|
|
21
|
-
</body>
|
|
22
|
-
</html>
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
<?xml version="1.0" encoding="iso-8859-1"?>
|
|
2
|
-
<!DOCTYPE html
|
|
3
|
-
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
|
4
|
-
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
|
5
|
-
|
|
6
|
-
<html>
|
|
7
|
-
<head>
|
|
8
|
-
<title>new (ResultSetWrapper)</title>
|
|
9
|
-
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
|
|
10
|
-
<link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
|
|
11
|
-
</head>
|
|
12
|
-
<body class="standalone-code">
|
|
13
|
-
<pre><span class="ruby-comment cmt"># File lib/result_set_wrapper.rb, line 5</span>
|
|
14
|
-
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">initialize</span>( <span class="ruby-identifier">statement</span>, <span class="ruby-identifier">output_param_names</span> = [] )
|
|
15
|
-
<span class="ruby-ivar">@padding</span> = <span class="ruby-value str">" "</span>
|
|
16
|
-
<span class="ruby-ivar">@spacer</span> = <span class="ruby-value str">" "</span>
|
|
17
|
-
<span class="ruby-ivar">@columns</span> = <span class="ruby-identifier">statement</span>.<span class="ruby-identifier">columns</span>
|
|
18
|
-
<span class="ruby-ivar">@hashes</span> = []
|
|
19
|
-
|
|
20
|
-
<span class="ruby-keyword kw">if</span> <span class="ruby-identifier">output_param_names</span>.<span class="ruby-identifier">length</span> <span class="ruby-operator">></span> <span class="ruby-value">0</span>
|
|
21
|
-
<span class="ruby-identifier">apply_output_params</span>( <span class="ruby-identifier">output_param_names</span>, <span class="ruby-identifier">statement</span> )
|
|
22
|
-
<span class="ruby-keyword kw">else</span>
|
|
23
|
-
<span class="ruby-identifier">extract_results</span>( <span class="ruby-identifier">statement</span> )
|
|
24
|
-
<span class="ruby-keyword kw">end</span>
|
|
25
|
-
<span class="ruby-keyword kw">end</span></pre>
|
|
26
|
-
</body>
|
|
27
|
-
</html>
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
<?xml version="1.0" encoding="iso-8859-1"?>
|
|
2
|
-
<!DOCTYPE html
|
|
3
|
-
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
|
4
|
-
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
|
5
|
-
|
|
6
|
-
<html>
|
|
7
|
-
<head>
|
|
8
|
-
<title>apply_output_params (ResultSetWrapper)</title>
|
|
9
|
-
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
|
|
10
|
-
<link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
|
|
11
|
-
</head>
|
|
12
|
-
<body class="standalone-code">
|
|
13
|
-
<pre><span class="ruby-comment cmt"># File lib/result_set_wrapper.rb, line 18</span>
|
|
14
|
-
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">apply_output_params</span>( <span class="ruby-identifier">output_param_names</span>, <span class="ruby-identifier">statement</span> )
|
|
15
|
-
<span class="ruby-keyword kw">for</span> <span class="ruby-identifier">i</span> <span class="ruby-keyword kw">in</span> <span class="ruby-value">0</span><span class="ruby-operator">..</span>( <span class="ruby-identifier">output_param_names</span>.<span class="ruby-identifier">length</span> <span class="ruby-operator">-</span> <span class="ruby-value">1</span> )
|
|
16
|
-
<span class="ruby-identifier">value</span> = <span class="ruby-identifier">statement</span>.<span class="ruby-identifier">fetch!</span>[<span class="ruby-value">0</span>]
|
|
17
|
-
<span class="ruby-identifier">statement</span>.<span class="ruby-identifier">more_results</span>
|
|
18
|
-
|
|
19
|
-
<span class="ruby-identifier">var_name</span> = <span class="ruby-node">"#{output_param_names[i]}"</span>
|
|
20
|
-
<span class="ruby-identifier">instance_variable_set</span>( <span class="ruby-identifier">var_name</span>, <span class="ruby-identifier">value</span> )
|
|
21
|
-
<span class="ruby-keyword kw">end</span>
|
|
22
|
-
<span class="ruby-keyword kw">end</span></pre>
|
|
23
|
-
</body>
|
|
24
|
-
</html>
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
<?xml version="1.0" encoding="iso-8859-1"?>
|
|
2
|
-
<!DOCTYPE html
|
|
3
|
-
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
|
4
|
-
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
|
5
|
-
|
|
6
|
-
<html>
|
|
7
|
-
<head>
|
|
8
|
-
<title>method_missing (ResultSetWrapper)</title>
|
|
9
|
-
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
|
|
10
|
-
<link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
|
|
11
|
-
</head>
|
|
12
|
-
<body class="standalone-code">
|
|
13
|
-
<pre><span class="ruby-comment cmt"># File lib/result_set_wrapper.rb, line 28</span>
|
|
14
|
-
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">method_missing</span>( <span class="ruby-identifier">name</span> )
|
|
15
|
-
<span class="ruby-identifier">member_var</span> = <span class="ruby-identifier">eval</span>( <span class="ruby-node">"@#{name}"</span> )
|
|
16
|
-
<span class="ruby-keyword kw">if</span> <span class="ruby-operator">!</span><span class="ruby-identifier">member_var</span>.<span class="ruby-identifier">nil?</span>
|
|
17
|
-
<span class="ruby-keyword kw">return</span> <span class="ruby-identifier">member_var</span>
|
|
18
|
-
<span class="ruby-keyword kw">else</span>
|
|
19
|
-
<span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">super</span>.<span class="ruby-identifier">method_missing</span>( <span class="ruby-identifier">name</span> )
|
|
20
|
-
<span class="ruby-keyword kw">end</span>
|
|
21
|
-
<span class="ruby-keyword kw">end</span></pre>
|
|
22
|
-
</body>
|
|
23
|
-
</html>
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
<?xml version="1.0" encoding="iso-8859-1"?>
|
|
2
|
-
<!DOCTYPE html
|
|
3
|
-
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
|
4
|
-
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
|
5
|
-
|
|
6
|
-
<html>
|
|
7
|
-
<head>
|
|
8
|
-
<title>collect (ResultSetWrapper)</title>
|
|
9
|
-
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
|
|
10
|
-
<link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
|
|
11
|
-
</head>
|
|
12
|
-
<body class="standalone-code">
|
|
13
|
-
<pre><span class="ruby-comment cmt"># File lib/result_set_wrapper.rb, line 57</span>
|
|
14
|
-
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">collect</span>
|
|
15
|
-
<span class="ruby-ivar">@hashes</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">hash</span><span class="ruby-operator">|</span>
|
|
16
|
-
<span class="ruby-keyword kw">yield</span> <span class="ruby-identifier">hash</span>
|
|
17
|
-
<span class="ruby-keyword kw">end</span>
|
|
18
|
-
<span class="ruby-keyword kw">end</span></pre>
|
|
19
|
-
</body>
|
|
20
|
-
</html>
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
<?xml version="1.0" encoding="iso-8859-1"?>
|
|
2
|
-
<!DOCTYPE html
|
|
3
|
-
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
|
4
|
-
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
|
5
|
-
|
|
6
|
-
<html>
|
|
7
|
-
<head>
|
|
8
|
-
<title>has? (ResultSetWrapper)</title>
|
|
9
|
-
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
|
|
10
|
-
<link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
|
|
11
|
-
</head>
|
|
12
|
-
<body class="standalone-code">
|
|
13
|
-
<pre><span class="ruby-comment cmt"># File lib/result_set_wrapper.rb, line 64</span>
|
|
14
|
-
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">has?</span>( <span class="ruby-identifier">expected_result_set</span> )
|
|
15
|
-
<span class="ruby-keyword kw">return</span> <span class="ruby-identifier">contains?</span>( <span class="ruby-identifier">expected_result_set</span>.<span class="ruby-identifier">row_hashes</span> )
|
|
16
|
-
<span class="ruby-keyword kw">end</span></pre>
|
|
17
|
-
</body>
|
|
18
|
-
</html>
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
<?xml version="1.0" encoding="iso-8859-1"?>
|
|
2
|
-
<!DOCTYPE html
|
|
3
|
-
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
|
4
|
-
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
|
5
|
-
|
|
6
|
-
<html>
|
|
7
|
-
<head>
|
|
8
|
-
<title>contains? (ResultSetWrapper)</title>
|
|
9
|
-
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
|
|
10
|
-
<link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
|
|
11
|
-
</head>
|
|
12
|
-
<body class="standalone-code">
|
|
13
|
-
<pre><span class="ruby-comment cmt"># File lib/result_set_wrapper.rb, line 69</span>
|
|
14
|
-
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">contains?</span>( <span class="ruby-operator">*</span><span class="ruby-identifier">expected_rows</span> )
|
|
15
|
-
<span class="ruby-identifier">expected_rows</span>.<span class="ruby-identifier">flatten</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">expected</span><span class="ruby-operator">|</span>
|
|
16
|
-
<span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">false</span> <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">contains_row?</span>( <span class="ruby-identifier">expected</span> )
|
|
17
|
-
<span class="ruby-keyword kw">end</span>
|
|
18
|
-
|
|
19
|
-
<span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">true</span>
|
|
20
|
-
<span class="ruby-keyword kw">end</span></pre>
|
|
21
|
-
</body>
|
|
22
|
-
</html>
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
<?xml version="1.0" encoding="iso-8859-1"?>
|
|
2
|
-
<!DOCTYPE html
|
|
3
|
-
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
|
4
|
-
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
|
5
|
-
|
|
6
|
-
<html>
|
|
7
|
-
<head>
|
|
8
|
-
<title>contains_row? (ResultSetWrapper)</title>
|
|
9
|
-
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
|
|
10
|
-
<link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
|
|
11
|
-
</head>
|
|
12
|
-
<body class="standalone-code">
|
|
13
|
-
<pre><span class="ruby-comment cmt"># File lib/result_set_wrapper.rb, line 77</span>
|
|
14
|
-
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">contains_row?</span>( <span class="ruby-identifier">expected</span> )
|
|
15
|
-
<span class="ruby-identifier">expected_with_symbols</span> = <span class="ruby-identifier">convert_keys_to_symbols</span>( <span class="ruby-identifier">expected</span> )
|
|
16
|
-
<span class="ruby-ivar">@hashes</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">actual</span><span class="ruby-operator">|</span>
|
|
17
|
-
<span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">true</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">actual</span> <span class="ruby-operator">==</span> <span class="ruby-identifier">actual</span>.<span class="ruby-identifier">merge</span>(<span class="ruby-identifier">expected_with_symbols</span>)
|
|
18
|
-
<span class="ruby-keyword kw">end</span>
|
|
19
|
-
|
|
20
|
-
<span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">false</span>
|
|
21
|
-
<span class="ruby-keyword kw">end</span></pre>
|
|
22
|
-
</body>
|
|
23
|
-
</html>
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
<?xml version="1.0" encoding="iso-8859-1"?>
|
|
2
|
-
<!DOCTYPE html
|
|
3
|
-
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
|
4
|
-
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
|
5
|
-
|
|
6
|
-
<html>
|
|
7
|
-
<head>
|
|
8
|
-
<title>to_s (ResultSetWrapper)</title>
|
|
9
|
-
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
|
|
10
|
-
<link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
|
|
11
|
-
</head>
|
|
12
|
-
<body class="standalone-code">
|
|
13
|
-
<pre><span class="ruby-comment cmt"># File lib/result_set_wrapper.rb, line 87</span>
|
|
14
|
-
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">to_s</span>
|
|
15
|
-
<span class="ruby-identifier">column_widths</span> = <span class="ruby-identifier">widest_value_in_columns</span>
|
|
16
|
-
|
|
17
|
-
<span class="ruby-identifier">result</span> = <span class="ruby-identifier">create_header_row</span>( <span class="ruby-identifier">column_widths</span> )
|
|
18
|
-
<span class="ruby-identifier">result</span> <span class="ruby-operator"><<</span> <span class="ruby-value str">"\n"</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">create_separator_row</span>( <span class="ruby-identifier">column_widths</span> )
|
|
19
|
-
|
|
20
|
-
<span class="ruby-ivar">@hashes</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">row</span><span class="ruby-operator">|</span>
|
|
21
|
-
<span class="ruby-identifier">result</span> <span class="ruby-operator"><<</span> <span class="ruby-value str">"\n"</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">create_data_row</span>( <span class="ruby-identifier">row</span>, <span class="ruby-identifier">column_widths</span> )
|
|
22
|
-
<span class="ruby-keyword kw">end</span>
|
|
23
|
-
|
|
24
|
-
<span class="ruby-keyword kw">return</span> <span class="ruby-identifier">result</span>
|
|
25
|
-
<span class="ruby-keyword kw">end</span></pre>
|
|
26
|
-
</body>
|
|
27
|
-
</html>
|
data/lib/odbc_overrides.rb
DELETED
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
class ODBC::TimeStamp
|
|
2
|
-
alias_method :old_to_s, :to_s
|
|
3
|
-
|
|
4
|
-
def ==( pal )
|
|
5
|
-
return to_s.index( pal.to_s ) == 0
|
|
6
|
-
end
|
|
7
|
-
|
|
8
|
-
def to_s
|
|
9
|
-
datetime = old_to_s
|
|
10
|
-
date, time, fraction = datetime.split(" ")
|
|
11
|
-
|
|
12
|
-
fraction_text = (fraction == '0') ? '' : ".#{fraction}"
|
|
13
|
-
return "#{date} #{time}#{fraction_text}"
|
|
14
|
-
end
|
|
15
|
-
|
|
16
|
-
def self.from_date(date)
|
|
17
|
-
formatted_date = date.strftime '%Y-%m-%d %H:%M:%S.000'
|
|
18
|
-
return ODBC::TimeStamp.new(formatted_date)
|
|
19
|
-
end
|
|
20
|
-
end
|
|
21
|
-
|
|
22
|
-
class ODBC::Error
|
|
23
|
-
def error_code
|
|
24
|
-
start_index = to_s =~ /(\()/
|
|
25
|
-
end_index = to_s =~ /(\))/
|
|
26
|
-
end_index -= 1
|
|
27
|
-
return to_s.slice( (start_index + 1 ), (end_index - start_index ) ).to_i
|
|
28
|
-
end
|
|
29
|
-
|
|
30
|
-
def error_message
|
|
31
|
-
return to_s.split( /\]/ ).last.rstrip!
|
|
32
|
-
end
|
|
33
|
-
end
|
data/lib/result_set_wrapper.rb
DELETED
|
@@ -1,193 +0,0 @@
|
|
|
1
|
-
class ResultSetWrapper
|
|
2
|
-
attr_reader :columns
|
|
3
|
-
attr_reader :hashes
|
|
4
|
-
|
|
5
|
-
def initialize( statement, output_param_names = [] )
|
|
6
|
-
@padding = " "
|
|
7
|
-
@spacer = " "
|
|
8
|
-
@columns = statement.columns
|
|
9
|
-
@hashes = []
|
|
10
|
-
|
|
11
|
-
if output_param_names.length > 0
|
|
12
|
-
apply_output_params( output_param_names, statement )
|
|
13
|
-
else
|
|
14
|
-
extract_results( statement )
|
|
15
|
-
end
|
|
16
|
-
end
|
|
17
|
-
|
|
18
|
-
def apply_output_params( output_param_names, statement )
|
|
19
|
-
for i in 0..( output_param_names.length - 1 )
|
|
20
|
-
value = statement.fetch![0]
|
|
21
|
-
statement.more_results
|
|
22
|
-
|
|
23
|
-
var_name = "#{output_param_names[i]}"
|
|
24
|
-
instance_variable_set( var_name, value )
|
|
25
|
-
end
|
|
26
|
-
end
|
|
27
|
-
|
|
28
|
-
def method_missing( name )
|
|
29
|
-
member_var = eval( "@#{name}" )
|
|
30
|
-
if !member_var.nil?
|
|
31
|
-
return member_var
|
|
32
|
-
else
|
|
33
|
-
return super.method_missing( name )
|
|
34
|
-
end
|
|
35
|
-
end
|
|
36
|
-
|
|
37
|
-
def is_output_param?( name )
|
|
38
|
-
return !eval( "#{name}" ).nil?
|
|
39
|
-
end
|
|
40
|
-
|
|
41
|
-
# Returns the number of rows in self.
|
|
42
|
-
def count
|
|
43
|
-
return @hashes.size
|
|
44
|
-
end
|
|
45
|
-
|
|
46
|
-
# Returns the number of rows in self.
|
|
47
|
-
def size
|
|
48
|
-
return count
|
|
49
|
-
end
|
|
50
|
-
|
|
51
|
-
# Returns true if self contains zero rows.
|
|
52
|
-
def empty?
|
|
53
|
-
return count == 0
|
|
54
|
-
end
|
|
55
|
-
|
|
56
|
-
# Iterates round each row applying a block.
|
|
57
|
-
def collect
|
|
58
|
-
@hashes.each do |hash|
|
|
59
|
-
yield hash
|
|
60
|
-
end
|
|
61
|
-
end
|
|
62
|
-
|
|
63
|
-
# Returns true if the contents of the 'expected_result_set' is held within self.
|
|
64
|
-
def has?( expected_result_set )
|
|
65
|
-
return contains?( expected_result_set.row_hashes )
|
|
66
|
-
end
|
|
67
|
-
|
|
68
|
-
# Returns true if the contents of the 'expected_rows' map is held within self.
|
|
69
|
-
def contains?( *expected_rows )
|
|
70
|
-
expected_rows.flatten.each do |expected|
|
|
71
|
-
return false unless contains_row?( expected )
|
|
72
|
-
end
|
|
73
|
-
|
|
74
|
-
return true
|
|
75
|
-
end
|
|
76
|
-
|
|
77
|
-
def contains_row?( expected )
|
|
78
|
-
expected_with_symbols = convert_keys_to_symbols( expected )
|
|
79
|
-
@hashes.each do |actual|
|
|
80
|
-
return true if actual == actual.merge(expected_with_symbols)
|
|
81
|
-
end
|
|
82
|
-
|
|
83
|
-
return false
|
|
84
|
-
end
|
|
85
|
-
|
|
86
|
-
# Provides the contents of self in the form of a table.
|
|
87
|
-
def to_s
|
|
88
|
-
column_widths = widest_value_in_columns
|
|
89
|
-
|
|
90
|
-
result = create_header_row( column_widths )
|
|
91
|
-
result << "\n" + create_separator_row( column_widths )
|
|
92
|
-
|
|
93
|
-
@hashes.each do |row|
|
|
94
|
-
result << "\n" + create_data_row( row, column_widths )
|
|
95
|
-
end
|
|
96
|
-
|
|
97
|
-
return result
|
|
98
|
-
end
|
|
99
|
-
|
|
100
|
-
private
|
|
101
|
-
|
|
102
|
-
def create_separator_row( column_widths )
|
|
103
|
-
result = ""
|
|
104
|
-
|
|
105
|
-
column_widths.each do |width|
|
|
106
|
-
result << " "
|
|
107
|
-
num_bars = width + ( @padding.length * 2 )
|
|
108
|
-
num_bars.times { result << "-" }
|
|
109
|
-
end
|
|
110
|
-
|
|
111
|
-
result << " "
|
|
112
|
-
|
|
113
|
-
return result
|
|
114
|
-
end
|
|
115
|
-
|
|
116
|
-
def create_header_row( column_widths )
|
|
117
|
-
result = ""
|
|
118
|
-
|
|
119
|
-
counter = 0
|
|
120
|
-
column_names.each do |header|
|
|
121
|
-
result << "|#{@padding}" + create_entry( header, column_widths[counter] ) + "#{@padding}"
|
|
122
|
-
counter += 1
|
|
123
|
-
end
|
|
124
|
-
|
|
125
|
-
return result + "|"
|
|
126
|
-
end
|
|
127
|
-
|
|
128
|
-
def create_data_row( row, column_widths )
|
|
129
|
-
result = ""
|
|
130
|
-
|
|
131
|
-
counter = 0
|
|
132
|
-
column_names.each do |header|
|
|
133
|
-
result << "|#{@padding}" + create_entry( row[header.to_sym].to_s, column_widths[counter] ) + "#{@padding}"
|
|
134
|
-
counter += 1
|
|
135
|
-
end
|
|
136
|
-
|
|
137
|
-
return result + "|"
|
|
138
|
-
end
|
|
139
|
-
|
|
140
|
-
def create_entry( header, expected_width )
|
|
141
|
-
if header.length == expected_width
|
|
142
|
-
return header
|
|
143
|
-
end
|
|
144
|
-
|
|
145
|
-
num_prefix_spaces = (expected_width - header.length)/2
|
|
146
|
-
num_postfix_spaces = expected_width - (num_prefix_spaces + header.length )
|
|
147
|
-
pre = ""
|
|
148
|
-
post = ""
|
|
149
|
-
num_prefix_spaces.times{ pre << " " }
|
|
150
|
-
num_postfix_spaces.times{ post << " " }
|
|
151
|
-
|
|
152
|
-
return pre + header + post
|
|
153
|
-
end
|
|
154
|
-
|
|
155
|
-
def widest_value_in_columns
|
|
156
|
-
result = []
|
|
157
|
-
|
|
158
|
-
column_names.each do |header|
|
|
159
|
-
largest = header.length
|
|
160
|
-
@hashes.each do |row|
|
|
161
|
-
if row[header.to_sym].to_s.length > largest
|
|
162
|
-
largest = row[header.to_sym].length
|
|
163
|
-
end
|
|
164
|
-
end
|
|
165
|
-
|
|
166
|
-
result << largest
|
|
167
|
-
puts
|
|
168
|
-
end
|
|
169
|
-
|
|
170
|
-
return result
|
|
171
|
-
end
|
|
172
|
-
|
|
173
|
-
def column_names
|
|
174
|
-
return columns.keys
|
|
175
|
-
end
|
|
176
|
-
|
|
177
|
-
def convert_keys_to_symbols( row )
|
|
178
|
-
result = {}
|
|
179
|
-
|
|
180
|
-
row.each do |key, value|
|
|
181
|
-
result[key.to_sym] = value
|
|
182
|
-
end
|
|
183
|
-
|
|
184
|
-
return result
|
|
185
|
-
end
|
|
186
|
-
|
|
187
|
-
def extract_results( statement )
|
|
188
|
-
statement.each_hash do |row|
|
|
189
|
-
@hashes << convert_keys_to_symbols( row )
|
|
190
|
-
end
|
|
191
|
-
end
|
|
192
|
-
|
|
193
|
-
end
|