lib/build-tool/configuration.rb in build-tool-0.6.3 vs lib/build-tool/configuration.rb in build-tool-0.6.4
- old
+ new
@@ -19,29 +19,53 @@
require 'build-tool/build-system/custom'
require 'build-tool/build-system/none'
require 'build-tool/build-system/kdel10n'
require 'build-tool/build-system/qmake'
+require 'stringio'
+require 'inifile'
+
module BuildTool
class Configuration
def self.edit( only = [] )
settings = BuildTool::Setting::export(
BuildTool::Application.instance.configuration.settings,
only )
- editor = MJ::Tools::TmpFileEditor.new( YAML::dump( settings ) )
+ text = StringIO.new
+ settings.each do |s|
+ text << '# ' << s[:description].gsub( /\n(?!\z)/, "\n# " )
+ text << s[:name] << ' = ' << s[:value]
+ text << "\n"
+ text << "\n"
+ end
+ editor = MJ::Tools::TmpFileEditor.new( text.string )
+
+ # Give the user the possibility to edit the file
editor.edit()
if not Pathname.new( editor.path() ).exist?
- info( "File deleted!" )
+ logger.info( "File deleted!" )
return 0
end
- values = YAML::load( File.open( editor.path(), 'r:UTF-8' ) )
+ # Reparse it
+ values = Array.new
+ file = IniFile.new( editor.path() )
+ file.each do | section, param, value |
+ if section != 'global'
+ logger.error( 'section is not global?' )
+ end
+ values << {
+ name: param,
+ value: value }
+ end
+
+ # Write it back
BuildTool::Setting::import(
BuildTool::Application.instance.configuration.settings,
values )
return 0
end