lib/rconftool.rb in rwdruby-1.06 vs lib/rconftool.rb in rwdruby-1.07

- old
+ new

@@ -119,17 +119,21 @@ unless old_setting debug << " #{name}: new\n" next end if old_setting.version == src_setting.version + if $DEBUG + $stderr.puts "old setting: #{old_setting.version}" + $stderr.puts "src setting: #{src_setting.version}" + end debug << " #{name}: unchanged\n" - src_setting.add_comment("\n DEFAULT SETTING from #{distfile}:\n") + src_setting.add_comment("\n DEFAULT SETTING from #{distfile}:\n") src_setting.add_comment(src_setting.content) src_setting.content = old_setting.content next end - # Otherwise, must install updated setting and comment out + # Otherwise, must install updated setting and comment out # the current setting for reference debug << " #{name}: UPDATED\n" src_setting.add_comment("\n Previous setting (inserted by rconftool):\n\n") src_setting.add_comment(old_setting.content) end @@ -213,21 +217,23 @@ File.open(filename) do |f| # VERSION header must occur within first 20 lines 20.times do line = f.gets break unless line - curr_setting << line + linetmp = line.chop + "\r\n" + curr_setting << linetmp if line =~ /\A##VERSION:/ - @version = line + @version = line.chop break end end raise NoVersionLine, "#{filename}: No VERSION line found" unless @version while line = f.gets unless line =~ /\A##NAME:(.*):(.*)/ - curr_setting << line + linetmp = line.chop + "\r\n" + curr_setting << linetmp next end curr_setting = Setting.new($1,$2) @settings << curr_setting @settings_hash[curr_setting.name] = curr_setting @@ -236,10 +242,11 @@ end def write(filename) File.open(filename,"w") do |f| @settings.each do |s| - f << s.to_s + stmp = s.to_s.chop + "\r\n" + f << stmp end end end end # class ConfigFile