Changeset 1241

Show
Ignore:
Timestamp:
01/09/08 18:31:26 (9 months ago)
Author:
wayneesegu..@gmail.com
Message:

Preparing merb_activerecord for 0.5.0

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • plugins/merb_activerecord/lib/merb/orms/active_record/connection.rb

    r1230 r1241  
    2020              full_config = Erubis.load_yaml_file(config_file) 
    2121              config = (Merb::Plugins.config[:merb_active_record] = {}) 
    22               (full_config[MERB_ENV.to_sym] || full_config[MERB_ENV]).each { |k, v| config[k.to_sym] = v } 
     22              (full_config[Merb.environment_ENV.to_sym] || full_config[Merb.environment_ENV]).each { |k, v| config[k.to_sym] = v } 
    2323               ::ActiveRecord::Base.configurations= full_config 
    2424              config 
     
    3434 
    3535            ::ActiveRecord::Base.verification_timeout = 14400 
    36             ::ActiveRecord::Base.logger = MERB_LOGGER 
     36            ::ActiveRecord::Base.logger = Merb.environment_LOGGER 
    3737            ::ActiveRecord::Base.establish_connection config 
    3838          else 
  • plugins/merb_activerecord/lib/merb/orms/active_record/tasks/databases.rb

    r1230 r1241  
    11task :environment do 
    2  MERB_ENV = ( ENV['MERB_ENV'] || MERB_ENV ).to_sym 
     2 Merb.environment_ENV = ( ENV['Merb.environment_ENV'] || Merb.environment_ENV ).to_sym 
    33end 
    44 
     
    1313  end 
    1414 
    15   desc 'Create the local database defined in config/database.yml for the current MERB_ENV' 
     15  desc 'Create the local database defined in config/database.yml for the current Merb.environment_ENV' 
    1616  task :create => :environment do 
    17     create_local_database(ActiveRecord::Base.configurations[MERB_ENV]) 
     17    create_local_database(ActiveRecord::Base.configurations[Merb.environment_ENV]) 
    1818  end 
    1919 
     
    5454  desc 'Drops the database for the current environment' 
    5555  task :drop => :environment do 
    56     config = ActiveRecord::Base.configurations[MERB_ENV || :development] 
     56    config = ActiveRecord::Base.configurations[Merb.environment_ENV || :development] 
    5757    p config 
    5858    case config[:adapter] 
     
    7777  # desc "Retrieves the charset for the current environment's database" 
    7878  # task :charset => :environment do 
    79   #   config = ActiveRecord::Base.configurations[MERB_ENV || :development] 
     79  #   config = ActiveRecord::Base.configurations[Merb.environment_ENV || :development] 
    8080  #   case config[:adapter] 
    8181  #   when 'mysql' 
     
    8989  # desc "Retrieves the collation for the current environment's database" 
    9090  # task :collation => :environment do 
    91   #   config = ActiveRecord::Base.configurations[MERB_ENV || :development] 
     91  #   config = ActiveRecord::Base.configurations[Merb.environment_ENV || :development] 
    9292  #   case config[:adapter] 
    9393  #   when 'mysql' 
     
    108108    task :load => :environment do 
    109109      require 'active_record/fixtures' 
    110       ActiveRecord::Base.establish_connection(MERB_ENV.to_sym) 
     110      ActiveRecord::Base.establish_connection(Merb.environment_ENV.to_sym) 
    111111      (ENV['FIXTURES'] ? ENV['FIXTURES'].split(/,/) : Dir.glob(File.join(Merb.root, 'test', 'fixtures', '*.{yml,csv}'))).each do |fixture_file| 
    112112        Fixtures.create_fixtures('test/fixtures', File.basename(fixture_file, '.*')) 
     
    134134    desc "Dump the database structure to a SQL file" 
    135135    task :dump do 
    136       config = ActiveRecord::Base.configurations[MERB_ENV.to_sym] 
     136      config = ActiveRecord::Base.configurations[Merb.environment_ENV.to_sym] 
    137137      case config[:adapter] 
    138138        when "mysql", "oci", "oracle" 
    139           ActiveRecord::Base.establish_connection(config[MERB_ENV]) 
    140           File.open("schema/#{MERB_ENV}_structure.sql", "w+") { |f| f << ActiveRecord::Base.connection.structure_dump } 
     139          ActiveRecord::Base.establish_connection(config[Merb.environment_ENV]) 
     140          File.open("schema/#{Merb.environment_ENV}_structure.sql", "w+") { |f| f << ActiveRecord::Base.connection.structure_dump } 
    141141        when "postgresql" 
    142142          ENV['PGHOST']     = config[:host] if config[:host] 
     
    145145          search_path = config[:schema_search_path] 
    146146          search_path = "--schema=#{search_path}" if search_path 
    147           `pg_dump -i -U "#{config[:username]}" -s -x -O -f schema/#{MERB_ENV}_structure.sql #{search_path} #{config[:database]}` 
     147          `pg_dump -i -U "#{config[:username]}" -s -x -O -f schema/#{Merb.environment_ENV}_structure.sql #{search_path} #{config[:database]}` 
    148148          raise "Error dumping database" if $?.exitstatus == 1 
    149149        when "sqlite", "sqlite3" 
    150150          dbfile = config[:database] || config[:dbfile] 
    151           `#{config[:adapter]} #{dbfile} .schema > schema/#{MERB_ENV}_structure.sql` 
     151          `#{config[:adapter]} #{dbfile} .schema > schema/#{Merb.environment_ENV}_structure.sql` 
    152152        when "sqlserver" 
    153           `scptxfr /s #{config[:host]} /d #{config[:database]} /I /f schema\\#{MERB_ENV}_structure.sql /q /A /r` 
     153          `scptxfr /s #{config[:host]} /d #{config[:database]} /I /f schema\\#{Merb.environment_ENV}_structure.sql /q /A /r` 
    154154          `scptxfr /s #{config[:host]} /d #{config[:database]} /I /F schema\ /q /A /r` 
    155155        when "firebird" 
    156           set_firebird_env(config[MERB_ENV]) 
    157           db_string = firebird_db_string(config[MERB_ENV]) 
    158           sh "isql -a #{db_string} > schema/#{MERB_ENV}_structure.sql" 
     156          set_firebird_env(config[Merb.environment_ENV]) 
     157          db_string = firebird_db_string(config[Merb.environment_ENV]) 
     158          sh "isql -a #{db_string} > schema/#{Merb.environment_ENV}_structure.sql" 
    159159        else 
    160160          raise "Task not supported by '#{config[:adapter]}'" 
     
    162162 
    163163      if ActiveRecord::Base.connection.supports_migrations? 
    164         File.open("schema/#{MERB_ENV}_structure.sql", "a") { |f| f << ActiveRecord::Base.connection.dump_schema_information } 
     164        File.open("schema/#{Merb.environment_ENV}_structure.sql", "a") { |f| f << ActiveRecord::Base.connection.dump_schema_information } 
    165165      end 
    166166    end 
     
    182182          ActiveRecord::Base.establish_connection(:test) 
    183183          ActiveRecord::Base.connection.execute('SET foreign_key_checks = 0') 
    184           IO.readlines("schema/#{MERB_ENV}_structure.sql").join.split("\n\n").each do |table| 
     184          IO.readlines("schema/#{Merb.environment_ENV}_structure.sql").join.split("\n\n").each do |table| 
    185185            ActiveRecord::Base.connection.execute(table) 
    186186          end 
     
    189189          ENV['PGPORT']     = config[:port].to_s if config[:port] 
    190190          ENV['PGPASSWORD'] = config[:password].to_s if config[:password] 
    191           `psql -U "#{config[:username]}" -f schema/#{MERB_ENV}_structure.sql #{config[:database]}` 
     191          `psql -U "#{config[:username]}" -f schema/#{Merb.environment_ENV}_structure.sql #{config[:database]}` 
    192192        when "sqlite", "sqlite3" 
    193193          dbfile = config[:database] ||config[:dbfile] 
    194           `#{config[:adapter]} #{dbfile} < schema/#{MERB_ENV}_structure.sql` 
     194          `#{config[:adapter]} #{dbfile} < schema/#{Merb.environment_ENV}_structure.sql` 
    195195        when "sqlserver" 
    196           `osql -E -S #{config[:host]} -d #{config[:database]} -i schema\\#{MERB_ENV}_structure.sql` 
     196          `osql -E -S #{config[:host]} -d #{config[:database]} -i schema\\#{Merb.environment_ENV}_structure.sql` 
    197197        when "oci", "oracle" 
    198198          ActiveRecord::Base.establish_connection(:test) 
    199           IO.readlines("schema/#{MERB_ENV}_structure.sql").join.split(";\n\n").each do |ddl| 
     199          IO.readlines("schema/#{Merb.environment_ENV}_structure.sql").join.split(";\n\n").each do |ddl| 
    200200            ActiveRecord::Base.connection.execute(ddl) 
    201201          end 
     
    203203          set_firebird_env(config) 
    204204          db_string = firebird_db_string(config) 
    205           sh "isql -i schema/#{MERB_ENV}_structure.sql #{db_string}" 
     205          sh "isql -i schema/#{Merb.environment_ENV}_structure.sql #{db_string}" 
    206206        else 
    207207          raise "Task not supported by '#{config[:adapter]}'" 
  • plugins/merb_activerecord/lib/merb/session/active_record_session.rb

    r1152 r1241  
    44  module SessionMixin 
    55    def setup_session 
    6       MERB_LOGGER.info("Setting up session") 
     6      Merb.environment_LOGGER.info("Setting up session") 
    77      before = cookies[_session_id_key] 
    88      request.session, cookies[_session_id_key] = Merb::ActiveRecordSession.persist(cookies[_session_id_key]) 
     
    1212 
    1313    def finalize_session 
    14       MERB_LOGGER.info("Finalize session") 
     14      Merb.environment_LOGGER.info("Finalize session") 
    1515      request.session.save if @_fingerprint != Marshal.dump(request.session.data).hash 
    1616      set_cookie(_session_id_key, request.session.session_id, _session_expiry) if (@_new_cookie || request.session.needs_new_cookie)