[Swift-commit] r3302 - SwiftApps/adem-osg
noreply at svn.ci.uchicago.edu
noreply at svn.ci.uchicago.edu
Mon May 3 14:56:10 CDT 2010
Author: aespinosa
Date: 2010-05-03 14:56:10 -0500 (Mon, 03 May 2010)
New Revision: 3302
Modified:
SwiftApps/adem-osg/adem-test.rb
SwiftApps/adem-osg/adem.rb
Log:
Refactored configurations as method parameters
Modified: SwiftApps/adem-osg/adem-test.rb
===================================================================
--- SwiftApps/adem-osg/adem-test.rb 2010-05-03 19:56:07 UTC (rev 3301)
+++ SwiftApps/adem-osg/adem-test.rb 2010-05-03 19:56:10 UTC (rev 3302)
@@ -87,4 +87,14 @@
class RunTest < Test::Unit::TestCase
include Adem::TestSetup
+
+ def test_config
+ assert_equal(@conf, run_command(["config"], "config", nil))
+ end
+
+ def test_sites_from_file
+ conf = @conf
+ site_list = YAML.load @site_list
+ assert_equal(site_list, run_command(["sites"], "config", "sites"))
+ end
end
Modified: SwiftApps/adem-osg/adem.rb
===================================================================
--- SwiftApps/adem-osg/adem.rb 2010-05-03 19:56:07 UTC (rev 3301)
+++ SwiftApps/adem-osg/adem.rb 2010-05-03 19:56:10 UTC (rev 3302)
@@ -111,16 +111,27 @@
load_config File.open(config_file)
end
-def run_command(args)
+def run_command(args, config_file, sites_file)
command = args.shift
- if command != "config"
- conf = load_config File.open(CONFIGURATION_FILE)
- puts sites(args, conf, SITES_FILE).to_yaml if command == "sites"
+ output = nil
+ if command == "sites"
+ conf = load_config File.open(config_file)
+ begin
+ output = sites(args, conf, sites_file) if command == "sites"
+ rescue SiteError => exception
+ output = exception.output
+ File.open(sites_file, "w") do |sites_file|
+ sites_file << output.to_yaml
+ end
+ end
+ elsif command == "app"
+ conf[:sites] = sites(nil, conf, sites_file)
+ app(args, conf)
else
- config args, CONFIGURATION_FILE
+ output = config args, config_file
end
end
if $0 == __FILE__
- run_command ARGV
+ run_command ARGV, CONFIGURATION_FILE, SITES_FILE
end
More information about the Swift-commit
mailing list