Changeset 69

Show
Ignore:
Timestamp:
06/05/06 23:59:30 (7 years ago)
Author:
dema
Message:

Allow repository/username/password to be passed as parameters to console, import and export scripts using -r, -u and -p command-line options.

Also, fixed a bug that would prevent automatic model generation when running the console script on Windows.

Location:
trunk
Files:
4 modified

Legend:

Unmodified
Added
Removed
  • trunk/config/hyperde_init.rb

    r67 r69  
    44 
    55Dir["#{RAILS_ROOT}/app/models/**.rb"].each { |model| require File.basename(model, ".rb") } 
    6  
    76SemanticRecord::Base.logger = RAILS_DEFAULT_LOGGER 
    87SemanticRecord::Base.configurations = File.open("#{RAILS_ROOT}/config/database.yml") { |f| YAML::load(f) } 
     8 
     9SemanticRecord::Base.configurations[RAILS_ENV]['repository'] = ENV['REPO'] if ENV['REPO'] 
     10SemanticRecord::Base.configurations[RAILS_ENV]['username'] = ENV['REPO_USERNAME'] if ENV['REPO_USERNAME'] 
     11SemanticRecord::Base.configurations[RAILS_ENV]['password'] = ENV['REPO_PASSWORD'] if ENV['REPO_PASSWORD'] 
     12  
    913SemanticRecord::Base.save_schema 
    1014 
     
    1519 
    1620e "Running from #{$0}..." 
    17 AppModel.sync if $0 == 'irb' 
     21AppModel.sync if $0 =~ /irb/ 
  • trunk/script/export

    r63 r69  
    22 
    33require 'optparse' 
     4require File.dirname(__FILE__) + '/../lib/opts_addon' 
    45 
    56OPTIONS = { :path => ARGV.first } 
     
    89  opts.banner = "Usage: ruby #{script_name} your_export_script.yml [options]" 
    910 
    10 #  opts.on("-r", "--repo", "Select repository") { |o| OPTIONS[:repo] = o } 
    11 #  opts.separator "" 
    12  
     11  OptsAddon.add_options(opts, OPTIONS) 
    1312  opts.on("-h", "--help", 
    1413          "Show this help message.") { puts opts; exit } 
     
    1918end 
    2019 
     20OptsAddon.set_env(OPTIONS) 
    2121 
    2222require 'yaml' 
  • trunk/script/import

    r63 r69  
    11#!/usr/bin/env ruby 
    22require 'optparse' 
     3require File.dirname(__FILE__) + '/../lib/opts_addon' 
    34 
    45OPTIONS = { :model => ARGV.first } 
     
    67  script_name = File.basename($0) 
    78  opts.banner = "Usage: ruby #{script_name} your_import_script.yml [options]" 
    8  
    9   opts.separator "" 
    10  
    119  opts.on("-n", "--noclear", "Don't clear repository before importing.") { OPTIONS[:noclear] = true } 
    12  
    13   opts.separator "" 
    14  
     10  OptsAddon.add_options(opts, OPTIONS) 
    1511  opts.on("-h", "--help", 
    1612          "Show this help message.") { puts opts; exit } 
     
    2117end 
    2218 
     19OptsAddon.set_env(OPTIONS) 
    2320 
    2421require 'yaml' 
  • trunk/vendor/rails/railties/lib/commands/console.rb

    r58 r69  
    22 
    33require 'optparse' 
     4require 'opts_addon' 
    45options = { :sandbox => false, :irb => irb } 
    56OptionParser.new do |opt| 
     
    78  opt.on('-s', '--sandbox', 'Rollback database modifications on exit.') { |options[:sandbox]| } 
    89  opt.on("--irb=[#{irb}]", 'Invoke a different irb.') { |options[:irb]| } 
     10   
     11  OptsAddon.add_options(opt, options) 
    912  opt.parse!(ARGV) 
    1013end 
     
    1720 
    1821ENV['RAILS_ENV'] = ARGV.first || ENV['RAILS_ENV'] || 'development' 
     22OptsAddon.set_env(options) 
     23 
    1924if options[:sandbox] 
    2025  puts "Loading #{ENV['RAILS_ENV']} environment in sandbox."