sam / do fork watch download tarball
public
Rubygem
Description: DataObjects
Homepage: http://rubyforge.org/projects/dorb
Clone URL: git://github.com/sam/do.git
Whitespace cleanup with "sake strip" (from dm-dev sake tasks)
dkubb (author)
Sun May 25 16:17:33 -0700 2008
commit  7d53d8c0dd1c14faef5f8e365f3686b81bd3ab4b
tree    6c6813931769dc8a33d9f606a731b9163fbb9035
parent  5c4480c2aa6cbb27151da4dcbba4f51c9df3236e
...
1
2
3
 
...
1
 
2
3
0
@@ -1,2 +1,2 @@
0
 pkg
0
-*.db
0
\ No newline at end of file
0
+*.db
...
11
12
13
14
 
15
16
17
18
 
19
20
21
...
26
27
28
29
 
30
31
 
32
33
 
34
35
 
36
37
 
38
39
 
40
...
11
12
13
 
14
15
16
17
 
18
19
20
21
...
26
27
28
 
29
30
 
31
32
 
33
34
 
35
36
 
37
38
 
39
40
0
@@ -11,11 +11,11 @@ require File.expand_path(File.join(File.dirname(__FILE__), 'data_objects', 'quot
0
 
0
 module DataObjects
0
   class LengthMismatchError < StandardError; end
0
-
0
+
0
   def self.root
0
     @root ||= Pathname(__FILE__).dirname.parent.expand_path
0
   end
0
-
0
+
0
   def self.find_const(name)
0
     klass = Object
0
     name.to_s.split('::').each do |part|
0
@@ -26,15 +26,15 @@ module DataObjects
0
 end
0
 
0
 # class ConnectionFailed < StandardError; end
0
-#
0
+#
0
 # class ReaderClosed < StandardError; end
0
-#
0
+#
0
 # class ReaderError < StandardError; end
0
-#
0
+#
0
 # class QueryError < StandardError; end
0
-#
0
+#
0
 # class NoInsertError < StandardError; end
0
-#
0
+#
0
 # class LostConnectionError < StandardError; end
0
-#
0
+#
0
 # class UnknownError < StandardError; end
...
1
2
3
 
4
5
 
6
7
8
9
10
11
 
12
13
14
15
 
16
17
18
19
 
20
21
22
23
 
24
25
26
27
 
28
29
30
31
 
 
...
1
2
 
3
4
 
5
6
7
8
9
10
 
11
12
13
14
 
15
16
17
18
 
19
20
21
22
 
23
24
25
26
 
27
28
 
 
29
30
31
0
@@ -1,30 +1,30 @@
0
 module DataObjects
0
   class Command
0
-
0
+
0
     attr_reader :connection
0
-
0
+
0
     # initialize creates a new Command object
0
     def initialize(connection, text)
0
       raise ArgumentError.new("+connection+ must be a DataObjects::Connection") unless DataObjects::Connection === connection
0
       @connection, @text = connection, text
0
     end
0
-
0
+
0
     def execute_non_query(*args)
0
       raise NotImplementedError.new
0
     end
0
-
0
+
0
     def execute_reader(*args)
0
       raise NotImplementedError.new
0
     end
0
-
0
+
0
     def set_types(column_types)
0
       raise NotImplementedError.new
0
     end
0
-
0
+
0
     def to_s
0
       @text
0
     end
0
-
0
+
0
   end
0
-
0
-end
0
\ No newline at end of file
0
+
0
+end
...
13
14
15
16
 
17
18
19
...
25
26
27
28
 
29
30
31
32
 
33
34
35
36
37
 
38
39
40
41
42
 
 
43
44
45
...
47
48
49
50
 
51
52
53
 
54
55
56
 
57
58
59
...
62
63
64
65
 
66
67
68
69
 
70
71
72
73
74
75
76
 
77
78
79
...
81
82
83
84
 
85
86
87
88
 
89
90
91
92
 
93
94
95
...
100
101
102
103
 
104
105
...
13
14
15
 
16
17
18
19
...
25
26
27
 
28
29
30
31
 
32
33
34
35
36
 
37
38
39
40
 
 
41
42
43
44
45
...
47
48
49
 
50
51
52
 
53
54
55
 
56
57
58
59
...
62
63
64
 
65
66
67
68
 
69
70
71
72
73
74
75
 
76
77
78
79
...
81
82
83
 
84
85
86
87
 
88
89
90
91
 
92
93
94
95
...
100
101
102
 
103
104
105
0
@@ -13,7 +13,7 @@ module DataObjects
0
       base.instance_variable_set('@connection_lock', Mutex.new)
0
       base.instance_variable_set('@available_connections', Hash.new { |h,k| h[k] = [] })
0
       base.instance_variable_set('@reserved_connections', Set.new)
0
-
0
+
0
       if driver_module_name = base.name.split('::')[-2]
0
         driver_module = DataObjects::const_get(driver_module_name)
0
         driver_module.class_eval <<-EOS
0
@@ -25,21 +25,21 @@ module DataObjects
0
             @logger = logger
0
           end
0
         EOS
0
-
0
+
0
         driver_module.logger = DataObjects::DeadLogger
0
       end
0
     end
0
-
0
+
0
     def self.new(uri)
0
       uri = uri.is_a?(String) ? Addressable::URI::parse(uri) : uri
0
       DataObjects.const_get(uri.scheme.capitalize)::Connection.acquire(uri)
0
     end
0
-
0
+
0
     def self.acquire(connection_uri)
0
       conn = nil
0
       connection_string = connection_uri.to_s
0
-
0
- @connection_lock.synchronize do
0
+
0
+ @connection_lock.synchronize do
0
         unless @available_connections[connection_string].empty?
0
           conn = @available_connections[connection_string].pop
0
         else
0
@@ -47,13 +47,13 @@ module DataObjects
0
           conn.send(:initialize, connection_uri)
0
           at_exit { conn.real_close }
0
         end
0
-
0
+
0
         @reserved_connections << conn
0
       end
0
-
0
+
0
       return conn
0
     end
0
-
0
+
0
     def self.release(connection)
0
       @connection_lock.synchronize do
0
         if @reserved_connections.delete?(connection)
0
@@ -62,18 +62,18 @@ module DataObjects
0
       end
0
       return nil
0
     end
0
-
0
+
0
     def close
0
       self.class.release(self)
0
     end
0
-
0
+
0
     #####################################################
0
     # Standard API Definition
0
     #####################################################
0
     def to_s
0
       @uri.to_s
0
     end
0
-
0
+
0
     def initialize(uri)
0
       raise NotImplementedError.new
0
     end
0
@@ -81,15 +81,15 @@ module DataObjects
0
     def real_close
0
       raise NotImplementedError.new
0
     end
0
-
0
+
0
     def create_command(text)
0
       concrete_command.new(self, text)
0
     end
0
-
0
+
0
     private
0
     def concrete_command
0
       @concrete_command || begin
0
-
0
+
0
         class << self
0
           private
0
           def concrete_command
0
@@ -100,6 +100,6 @@ module DataObjects
0
         @concrete_command = DataObjects::const_get(self.class.name.split('::')[-2]).const_get('Command')
0
       end
0
     end
0
-
0
+
0
   end
0
 end
...
1
2
 
3
4
 
5
6
7
8
 
9
10
11
12
 
13
14
15
16
 
17
18
19
20
 
 
...
1
 
2
3
 
4
5
6
7
 
8
9
10
11
 
12
13
14
15
 
16
17
 
 
18
19
20
0
@@ -1,19 +1,19 @@
0
 module DataObjects
0
-
0
+
0
   class Field
0
-
0
+
0
     def initialize(name, type)
0
       @name, @type = name, type
0
     end
0
-
0
+
0
     def name
0
       @name
0
     end
0
-
0
+
0
     def type
0
       @type
0
     end
0
-
0
+
0
   end
0
-
0
-end
0
\ No newline at end of file
0
+
0
+end
...
16
17
18
19
 
20
21
22
23
24
 
25
26
 
27
28
29
...
49
50
51
52
 
53
54
55
 
 
56
57
58
...
115
116
117
118
 
119
120
121
...
156
157
158
159
160
 
 
161
162
163
...
176
177
178
179
 
180
181
182
...
192
193
194
195
 
196
197
198
 
199
...
16
17
18
 
19
20
21
22
23
 
24
25
 
26
27
28
29
...
49
50
51
 
52
53
 
 
54
55
56
57
58
...
115
116
117
 
118
119
120
121
...
156
157
158
 
 
159
160
161
162
163
...
176
177
178
 
179
180
181
182
...
192
193
194
 
195
196
197
 
198
199
0
@@ -16,14 +16,14 @@ require "time" # httpdate
0
 # DataObjects.logger.info(message<String>)
0
 # DataObjects.logger.debug(message<String>)
0
 #
0
-# Flush the buffer to
0
+# Flush the buffer to
0
 # DataObjects.logger.flush
0
 #
0
 # Remove the current log object
0
 # DataObjects.logger.close
0
-#
0
+#
0
 # ==== Private DataObjects Logger API
0
-#
0
+#
0
 # To initialize the logger you create a new object, proxies to set_log.
0
 # DataObjects::Logger.new(log{String, IO},level{Symbol, String})
0
 module DataObjects
0
@@ -49,10 +49,10 @@ module DataObjects
0
     # debug: low-level information for developers
0
     #
0
     # DataObjects::Logger::LEVELS[:fatal, :error, :warn, :info, :debug]
0
- LEVELS =
0
+ LEVELS =
0
     {
0
- :fatal => 7,
0
- :error => 6,
0
+ :fatal => 7,
0
+ :error => 6,
0
       :warn => 4,
0
       :info => 3,
0
       :debug => 0
0
@@ -115,7 +115,7 @@ module DataObjects
0
 
0
     # To replace an existing logger with a new one:
0
     # DataObjects::Logger.set_log(log{String, IO},level{Symbol, String})
0
- #
0
+ #
0
     # ==== Parameters
0
     # log<IO,String>
0
     # Either an IO object or a name of a logfile.
0
@@ -156,8 +156,8 @@ module DataObjects
0
       @log = nil
0
     end
0
 
0
- # Appends a string and log level to logger's buffer.
0
- # Note that the string is discarded if the string's log level less than the logger's log level.
0
+ # Appends a string and log level to logger's buffer.
0
+ # Note that the string is discarded if the string's log level less than the logger's log level.
0
     # Note that if the logger is aio capable then the logger will use non-blocking asynchronous writes.
0
     #
0
     # ==== Parameters
0
@@ -176,7 +176,7 @@ module DataObjects
0
     alias << push
0
 
0
     # Generate the following logging methods for DataObjects.logger as described in the api:
0
- # :fatal, :error, :warn, :info, :debug
0
+ # :fatal, :error, :warn, :info, :debug
0
     LEVELS.each_pair do |name, number|
0
       class_eval <<-LEVELMETHODS, __FILE__, __LINE__
0
       # DOC
0
@@ -192,8 +192,8 @@ module DataObjects
0
     end
0
 
0
   end # class Logger
0
-
0
+
0
   # HACK: Not cross-platform
0
   DeadLogger = Logger.new(File.open('/dev/null', 'w'), :fatal)
0
-
0
+
0
 end # module DataObjects
...
1
2
 
3
4
5
...
9
10
11
12
 
13
14
15
16
17
18
 
19
20
21
22
23
24
 
25
26
27
28
29
30
 
31
32
33
 
34
35
36
...
45
46
47
48
 
49
50
51
...
53
54
55
56
 
57
58
59
60
 
61
62
63
64
 
65
66
67
68
 
69
70
71
72
 
73
74
75
76
 
77
78
79
80
 
81
82
83
84
 
85
86
87
88
 
89
90
91
92
 
93
94
 
95
96
97
98
99
 
 
...
1
 
2
3
4
5
...
9
10
11
 
12
13
14
15
16
17
 
18
19
20
21
22
23
 
24
25
26
27
28
29
 
30
31
32
 
33
34
35
36
...
45
46
47
 
48
49
50
51
...
53
54
55
 
56
57
58
59
 
60
61
62
63
 
64
65
66
67
 
68
69
70
71
 
72
73
74
75
 
76
77
78
79
 
80
81
82
83
 
84
85
86
87
 
88
89
90
91
 
92
93
 
94
95
96
 
 
97
98
99
0
@@ -1,5 +1,5 @@
0
 module DataObjects
0
-
0
+
0
   module Quoting
0
     # Escape a string of SQL with a set of arguments.
0
     # The first argument is assumed to be the SQL to escape,
0
@@ -9,28 +9,28 @@ module DataObjects
0
     # ==== Examples
0
     # escape_sql("SELECT * FROM zoos")
0
     # # => "SELECT * FROM zoos"
0
- #
0
+ #
0
     # escape_sql("SELECT * FROM zoos WHERE name = ?", "Dallas")
0
     # # => "SELECT * FROM zoos WHERE name = `Dallas`"
0
     #
0
     # escape_sql("SELECT * FROM zoos WHERE name = ? AND acreage > ?", "Dallas", 40)
0
     # # => "SELECT * FROM zoos WHERE name = `Dallas` AND acreage > 40"
0
- #
0
+ #
0
     # ==== Warning
0
     # This method is meant mostly for adapters that don't support
0
     # bind-parameters.
0
     def escape_sql(args)
0
       sql = @text.dup
0
-
0
+
0
       unless args.empty?
0
         sql.gsub!(/\?/) do |x|
0
           quote_value(args.shift)
0
         end
0
       end
0
-
0
+
0
       sql
0
     end
0
-
0
+
0
     def quote_value(value)
0
       return 'NULL' if value.nil?
0
 
0
@@ -45,7 +45,7 @@ module DataObjects
0
         when Array then quote_array(value)
0
         when Range then quote_range(value)
0
         when Symbol then quote_symbol(value)
0
- else
0
+ else
0
           if value.respond_to?(:to_sql)
0
             value.to_sql
0
           else
0
@@ -53,46 +53,46 @@ module DataObjects
0
           end
0
       end
0
     end
0
-
0
+
0
     def quote_symbol(value)
0
       quote_string(value.to_s)
0
     end
0
-
0
+
0
     def quote_numeric(value)
0
       value.to_s
0
     end
0
-
0
+
0
     def quote_string(value)
0
       "'#{value.gsub("'", "''")}'"
0
     end
0
-
0
+
0
     def quote_class(value)
0
       quote_string(value.name)
0
     end
0
-
0
+
0
     def quote_time(value)
0
       "'#{value.strftime('%Y-%m-%d %H:%M:%S')}" + (value.usec > 0 ? ".#{value.usec.to_s.rjust(6, '0')}'" : "'")
0
     end
0
-
0
+
0
     def quote_datetime(value)
0
       "'#{value.dup}'"
0
     end
0
-
0
+
0
     def quote_date(value)
0
       "'#{value.strftime("%Y-%m-%d")}'"
0
     end
0
-
0
+
0
     def quote_boolean(value)
0
       value.to_s.upcase
0
     end
0
-
0
+
0
     def quote_array(value)
0
       "(#{value.map { |entry| quote_value(entry) }.join(', ')})"
0
     end
0
-
0
+
0
     def quote_range(value)
0
- "#{quote_value(value.first)} AND #{quote_value(value.last)}"
0
+ "#{quote_value(value.first)} AND #{quote_value(value.last)}"
0
     end
0
   end
0
-
0
-end
0
\ No newline at end of file
0
+
0
+end
...
1
2
3
 
4
5
6
7
 
8
9
10
11
12
 
 
13
14
15
 
16
17
18
19
20
 
21
22
23
 
...
1
2
 
3
4
5
6
 
7
8
9
10
 
 
11
12
13
14
 
15
16
17
18
19
 
20
21
 
22
23
0
@@ -1,22 +1,22 @@
0
 module DataObjects
0
   class Reader
0
-
0
+
0
     def fields
0
       raise NotImplementedError.new
0
     end
0
-
0
+
0
     def values
0
       raise NotImplementedError.new
0
     end
0
-
0
- def close
0
+
0
+ def close
0
       raise NotImplementedError.new
0
     end
0
-
0
+
0
     # Moves the cursor forward.
0
     def next!
0
       raise NotImplementedError.new
0
     end
0
-
0
+
0
   end
0
-end
0
\ No newline at end of file
0
+end
...
1
2
3
4
 
5
6
7
...
1
2
3
 
4
5
6
7
0
@@ -1,7 +1,7 @@
0
 module DataObjects
0
   class Result
0
     attr_accessor :insert_id, :affected_rows
0
-
0
+
0
     def initialize(command, affected_rows, insert_id = nil)
0
       @command, @affected_rows, @insert_id = command, affected_rows, insert_id
0
     end
...
1
2
3
4
 
5
6
7
...
35
36
37
38
 
39
40
41
...
1
2
3
 
4
5
6
7
...
35
36
37
 
38
39
40
41
0
@@ -1,7 +1,7 @@
0
 module DataObjects
0
 
0
   class Transaction
0
-
0
+
0
     HOST = "#{Socket::gethostbyname(Socket::gethostname)[0]}" rescue "localhost"
0
     @@counter = 0
0
 
0
@@ -35,7 +35,7 @@ def #{method_name}
0
   raise NotImplementedError
0
 end
0
 EOF
0
-
0
+
0
     end
0
 
0
   end
...
13
14
15
16
 
17
18
19
...
33
34
35
36
 
37
...
13
14
15
 
16
17
18
19
...
33
34
35
 
36
37
0
@@ -13,7 +13,7 @@ describe DataObjects::Command do
0
   it "should assign the sql text to @text" do
0
     @command.instance_variable_get("@text").should == 'SQL STRING'
0
   end
0
-
0
+
0
   %w{connection execute_non_query execute_reader set_types to_s}.each do |meth|
0
     it "should respond to ##{meth}" do
0
       @command.should respond_to(meth.intern)
0
@@ -33,5 +33,5 @@ describe DataObjects::Command do
0
   it "should make the SQL text available in #to_s" do
0
     @command.to_s.should == @command.instance_variable_get("@text")
0
   end
0
-
0
+
0
 end
...
3
4
5
6
 
7
8
9
 
10
11
12
13
 
14
15
 
16
17
18
...
3
4
5
 
6
7
8
 
9
10
11
12
 
13
14
 
15
16
17
18
0
@@ -3,16 +3,16 @@ require File.expand_path(File.join(File.dirname(__FILE__), 'spec_helper'))
0
 describe DataObjects::Connection do
0
   before do
0
     @connection = DataObjects::Connection.new('mock://localhost')
0
- end
0
+ end
0
 
0
   %w{acquire release}.each do |meth|
0
- it "should respond to class method ##{meth}" do
0
+ it "should respond to class method ##{meth}" do
0
       DataObjects::Connection.should respond_to(meth.intern)
0
     end
0
   end
0
-
0
+
0
   %w{real_close create_command}.each do |meth|
0
- it "should respond to ##{meth}" do
0
+ it "should respond to ##{meth}" do
0
       @connection.should respond_to(meth.intern)
0
     end
0
   end
...
1
2
 
...
 
1
2
0
@@ -1 +1 @@
0
-require File.expand_path(File.join(File.dirname(__FILE__), 'spec_helper'))
0
\ No newline at end of file
0
+require File.expand_path(File.join(File.dirname(__FILE__), 'spec_helper'))
...
1
2
 
3
4
5
6
7
8
 
9
10
11
12
13
 
14
15
16
17
18
 
19
20
21
22
23
 
24
25
26
 
27
28
29
30
31
32
 
 
...
1
 
2
3
4
5
6
7
 
8
9
10
11
12
 
13
14
15
16
17
 
18
19
20
21
22
 
23
24
25
 
26
27
28
29
 
 
30
31
32
0
@@ -1,31 +1,31 @@
0
 module DataObjects
0
-
0
+
0
   module Mock
0
     class Connection < DataObjects::Connection
0
       def initialize(uri)
0
         @uri = uri
0
       end
0
-
0
+
0
       def real_close
0
         nil
0
       end
0
     end
0
-
0
+
0
     class Command < DataObjects::Command
0
       def execute_non_query(*args)
0
         Result.new(self, 0, nil)
0
       end
0
-
0
+
0
       def execute_reader(*args)
0
         Reader.new
0
       end
0
     end
0
-
0
+
0
     class Result < DataObjects::Result
0
     end
0
-
0
+
0
     class Reader < DataObjects::Reader
0
     end
0
   end
0
-
0
-end
0
\ No newline at end of file
0
+
0
+end
...
1
2
3
4
 
5
6
7
 
8
9
 
10
11
 
12
13
14
15
16
17
 
18
...
1
2
3
 
4
5
6
 
7
8
 
9
10
 
11
12
13
14
15
16
 
17
18
0
@@ -1,18 +1,18 @@
0
 require File.expand_path(File.join(File.dirname(__FILE__), 'spec_helper'))
0
 
0
 describe DataObjects::Reader do
0
-
0
+
0
   it "should define a standard API" do
0
     connection = DataObjects::Connection.new('mock://localhost')
0
-
0
+
0
     command = connection.create_command("SELECT * FROM example")
0
-
0
+
0
     reader = command.execute_reader
0
-
0
+
0
     reader.should respond_to(:close)
0
     reader.should respond_to(:next!)
0
     reader.should respond_to(:values)
0
     reader.should respond_to(:fields)
0
   end
0
-
0
+
0
 end