• R/O
  • SSH
  • HTTPS

tenarai: 提交


Commit MetaInfo

修訂92 (tree)
時間2008-05-17 01:14:49
作者junkikuchi

Log Message

updated.

Change Summary

差異

--- trunk/lib/tenarai/db/engine.rb (revision 91)
+++ trunk/lib/tenarai/db/engine.rb (revision 92)
@@ -296,7 +296,7 @@
296296 SQL = 'UPDATE %s SET %s = NULL WHERE %s = ?'
297297
298298 def execute(col, row)
299- @stmt = self.class::SQL % [@table.name, col, col]
299+ @stmt = self.class::SQL % [@table.name, col, col]
300300 @bindvar = row.primary_key
301301 super
302302 @engine.rows.each do |key, val|
--- trunk/lib/tenarai/db/table.rb (revision 91)
+++ trunk/lib/tenarai/db/table.rb (revision 92)
@@ -29,7 +29,7 @@
2929 attr_reader :relation
3030
3131 ENGINE = {
32- :mysql => MySQL
32+ 'mysql' => MySQL
3333 }
3434
3535 def initialize(db, row_class, name)
@@ -37,7 +37,7 @@
3737 @row_class = row_class
3838 @name = name
3939 @relation = {}
40- @engine = ENGINE[@db.param[:engine]].new(self)
40+ @engine = ENGINE[@db.param[:engine].downcase].new(self)
4141 @engine.build
4242 end
4343
--- trunk/lib/tenarai/db.rb (revision 91)
+++ trunk/lib/tenarai/db.rb (revision 92)
@@ -11,12 +11,17 @@
1111 def initialize(param, &block)
1212 @handle = nil
1313
14- @param = param
15- @param[:echo] ||= false
16- @param[:host] ||= '127.0.0.1'
14+ @param = {
15+ :host => '127.0.0.1',
16+ :engine => 'MySQL',
17+ :db => nil,
18+ :user => nil,
19+ :password => nil,
20+ :echo => false,
21+ }.merge!(param)
1722
1823 if block_given?
19- connect
24+ open
2025 block.call(self)
2126 close
2227 end
@@ -30,9 +35,9 @@
3035 @param[:echo] = val
3136 end
3237
33- def connect
38+ def open
3439 @handle = DBI.connect(
35- "dbi:%s:%s:%s" % [@param[:engine], @param[:db], @param[:host]],
40+ ['dbi', @param[:engine].downcase, @param[:db], @param[:host]].join(':'),
3641 @param[:user],
3742 @param[:password]
3843 ) unless @handle
@@ -39,7 +44,7 @@
3944 @handle
4045 end
4146
42- alias :handle :connect
47+ alias :handle :open
4348
4449 def close
4550 @handle.disconnect if @handle
--- trunk/lib/tenarai/cgi/response.rb (revision 91)
+++ trunk/lib/tenarai/cgi/response.rb (revision 92)
@@ -8,6 +8,26 @@
88 module Tenarai
99 class CGI
1010 class Response
11+ class Header
12+ include Enumerable
13+
14+ def initialize
15+ @hash = {}
16+ end
17+
18+ def [](key)
19+ @hash[key.downcase]
20+ end
21+
22+ def []=(key, val)
23+ @hash[key.downcase] = val
24+ end
25+
26+ def each(&block)
27+ @hash.each(&block)
28+ end
29+ end
30+
1131 class Cookie
1232 attr_reader :name
1333 attr_accessor :value
@@ -103,7 +123,7 @@
103123
104124 def initialize(out)
105125 @code = 200
106- @header = {}
126+ @header = Header.new
107127 @cookie = Container.new
108128 @content = ''
109129 @out = out
Show on old repository browser