config.rb in ruby-station-0.1.3 vs config.rb in ruby-station-0.1.4.rc1
- old
+ new
@@ -8,20 +8,17 @@
VERSION = File.read(__DIR__("VERSION")).chomp
RUNTIME_VERSION = File.read(__DIR__("runtime", "VERSION")).chomp
end
class Conf
- %w(ruby_command gem_command gem_dir gem_bin_dir gem_install_option data_dir server_port debug).each do |m|
+ %w(ruby_command gem_command gem_dir gem_bin_dir data_dir
+ db_path gem_install_option server_port debug).each do |m|
class_eval <<-EOD
def self.#{m}; @yaml[:#{m}]; end
EOD
end
- def self.db_path
- File.join(@home, "ruby-station.db")
- end
-
def self.parse_opt
@home = File.expand_path("~/.ruby-station")
@opt = OptionParser.new{|o|
o.on("--home PATH", "path to save ruby-station data (default: #@home)"){|path|
@@ -62,10 +59,11 @@
@home = home if home
@yaml = self.load_yaml
@yaml[:gem_dir] = File.expand_path(@yaml[:gem_dir], @home)
@yaml[:gem_bin_dir] = File.expand_path(@yaml[:gem_bin_dir], @home)
@yaml[:data_dir] = File.expand_path(@yaml[:data_dir], @home)
+ @yaml[:db_path] = File.expand_path(@yaml[:db_path], @home)
FileUtils.makedirs(@yaml[:gem_dir])
FileUtils.makedirs(@yaml[:gem_bin_dir])
FileUtils.makedirs(@yaml[:data_dir])
Runtime.install unless Runtime.installed?
@@ -89,5 +87,12 @@
GemManager.install_file(path)
end
end
end
+
+if defined?(TESTS_DIR)
+ Conf.set_home(TESTS_DIR/"data/conf_dir/")
+else
+ Conf.parse_opt
+end
+Conf.init