[Swift-commit] r3311 - SwiftApps/adem-osg

noreply at svn.ci.uchicago.edu noreply at svn.ci.uchicago.edu
Mon May 3 14:56:30 CDT 2010


Author: aespinosa
Date: 2010-05-03 14:56:30 -0500 (Mon, 03 May 2010)
New Revision: 3311

Modified:
   SwiftApps/adem-osg/adem-test.rb
   SwiftApps/adem-osg/adem.rb
Log:
Refactored application runner

Modified: SwiftApps/adem-osg/adem-test.rb
===================================================================
--- SwiftApps/adem-osg/adem-test.rb	2010-05-03 19:56:28 UTC (rev 3310)
+++ SwiftApps/adem-osg/adem-test.rb	2010-05-03 19:56:30 UTC (rev 3311)
@@ -124,6 +124,7 @@
   def test_sites_from_file
     conf = @conf
     site_list = YAML.load @site_list
-    assert_equal(site_list, run_command(["sites"], "config", "sites"))
+    conf[:sites] = site_list
+    assert_equal(conf, run_command(["sites"], "config", "sites"))
   end
 end

Modified: SwiftApps/adem-osg/adem.rb
===================================================================
--- SwiftApps/adem-osg/adem.rb	2010-05-03 19:56:28 UTC (rev 3310)
+++ SwiftApps/adem-osg/adem.rb	2010-05-03 19:56:30 UTC (rev 3311)
@@ -143,22 +143,20 @@
 def run_command(args, config_file, sites_file)
   command = args.shift
   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
+  conf = load_config File.open(config_file)
+  return conf if command == "config"
+  begin
+    site_args = nil
+    site_args = args if command == "sites"
+    conf[:sites] = sites(site_args, conf, sites_file)
+  rescue SiteError => exception
+    conf[:sites] = exception.output
+    File.open(sites_file, "w") do |sites_file|
+      sites_file << output.to_yaml
     end
-  elsif command == "app"
-    conf[:sites] = sites(nil, conf, sites_file)
-    app(args, conf)
-  else
-    output = config args, config_file
   end
+  return conf if command == "sites"
+  app(args, conf)
 end
 
 if $0 == __FILE__




More information about the Swift-commit mailing list