Show
Ignore:
Timestamp:
07/11/2006 17:01:35 (2 years ago)
Author:
why
Message:
  • lib/camping.rb: only HashWithIndifferentAccess? is loaded by default (to assist Og users.) if you use ActiveRecord, though, all of ActiveSupport? will be loaded.
  • lib/camping/db.rb: ditto.
  • bin/camping: moved all database code into the Reloader so you, Mr. Tim Bray, can mount many database-free apps without inconvenience. really this is for zimbatm, author of Equipment, who has been tremendously resourceful and cunning of late!
  • lib/camping/reloader.rb: ditto.
  • Rakefile: allow ActiveSupport? 1.3.1.
Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/lib/camping/reloader.rb

    r119 r131  
    6464            return 
    6565        end 
     66         
     67        Reloader.conditional_connect 
    6668        @klass.create if @klass.respond_to? :create 
    6769        @klass 
     
    104106        File.read(@script) 
    105107    end 
     108 
     109    class << self 
     110        def database=(db) 
     111            @database = db 
     112        end 
     113        def log=(log) 
     114            @log = log 
     115        end 
     116        def conditional_connect 
     117            # If database models are present, `autoload?` will return nil. 
     118            unless Camping::Models.autoload? :Base 
     119                require 'logger' 
     120                require 'camping/session' 
     121                Camping::Models::Base.establish_connection @database 
     122 
     123                case @log 
     124                when Logger 
     125                    Camping::Models::Base.logger = @log 
     126                when String 
     127                    Camping::Models::Base.logger = Logger.new(@log == "-" ? STDOUT : @log) 
     128                end 
     129 
     130                begin 
     131                    Camping::Models::Session.create_schema 
     132                rescue MissingSourceFile 
     133                    puts "** #$0 stopped: SQLite3 not found, please install." 
     134                    puts "** See http://code.whytheluckystiff.net/camping/wiki/BeAlertWhenOnSqlite3 for instructions." 
     135                    exit 
     136                end 
     137 
     138                if @database[:adapter] == 'sqlite3' 
     139                    begin 
     140                        require 'sqlite3_api' 
     141                    rescue LoadError 
     142                        puts "!! Your SQLite3 adapter isn't a compiled extension." 
     143                        abort "!! Please check out http://code.whytheluckystiff.net/camping/wiki/BeAlertWhenOnSqlite3 for tips." 
     144                    end 
     145                end 
     146            end 
     147        end 
     148    end 
    106149end 
    107150end