[Ultrapossum-cvs 849] ultrapossum/ruby 1.2,1.3,ultrapossum.rb

Back to archive index

Masato Taruishi taru****@users*****
2004年 10月 13日 (水) 17:56:17 JST


===================================================================
RCS file: ultrapossum/ruby/ultrapossum.rb,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- ultrapossum/ruby/ultrapossum.rb	2004/04/02 02:34:28	1.2
+++ ultrapossum/ruby/ultrapossum.rb	2004/10/13 08:56:17	1.3
@@ -20,34 +20,22 @@
 
   class Config < Hash
 
-    MODULES = [] 
-    open("|ultrapossum-config module") do |io|
-      io.each_line do |line|
-        MODULES << line.chop!
-      end
-    end
-
-    def Config.variables (mod)
-      variables = []
-      open("|ultrapossum-config variable #{mod}") do |io|
-        io.each_line do |line|
-	  variables << line.chop!
+    def initialize( sysconfdir = nil )
+      env = ""
+      if ! sysconfdir.nil?
+        if FileTest.directory?( sysconfdir )
+          env = "SYSCONFDIR=#{sysconfdir}"
+	else
+	  raise "No such directory: #{sysconfdir}"
 	end
       end
-      variables
-    end
-    VARIABLES = {}
-    MODULES.each do |m|
-      VARIABLES[m] = variables(m)
-    end
-
-    def initialize
-      open("|ultrapossum-config get") do |io|
+      open("|sh -c '#{env} ultrapossum-config get'") do |io|
         io.each_line do |line|
           /([^=]+)=\"(.*)\"/ =~ line
-	  self[$1] = $2
-	end
+          self[$1] = $2
+        end
       end
+    
     end
 
   end
@@ -55,13 +43,7 @@
 end
 
 if __FILE__ == $0
-  UltraPossum::Config::MODULES.each do |m|
-    puts m
-    UltraPossum::Config::VARIABLES[m].each do |v|
-      puts "\t#{v}"
-    end
-  end
-  conf = UltraPossum::Config.new
+  conf = UltraPossum::Config.new(ARGV[0])
   conf.each_key do |key|
     puts "#{key} -> #{conf[key]}"
   end



Ultrapossum-cvs メーリングリストの案内
Back to archive index