Class: ConfigEditor

Inherits:
Object
  • Object
show all
Defined in:
lib/dvdprofiler2xbmc/views/config_editor.rb

Overview

Synopsis

This is a command line config editor

Usage

editor = ConfigEditor.new editor.execute

Instance Method Summary collapse

Constructor Details

#initializeConfigEditor

Synopsis



42
43
# File 'lib/dvdprofiler2xbmc/views/config_editor.rb', line 42

def initialize
end

Instance Method Details

#executeObject

Synopsis

main execution loop for the config editor



47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
# File 'lib/dvdprofiler2xbmc/views/config_editor.rb', line 47

def execute
  report_invalid_config_items
  begin
    AppConfig[:logger].info('Configuration Editor')

    # get the list of config fields
    fields = AppConfig.navigation.collect do |page|
      page.values.flatten.select do|field|
        AppConfig.data_type[field]
      end
    end.flatten.uniq.compact

    # edit the fields
    while(field = menu_select('field', fields))
      begin
        edit_field(field)
      rescue
      end
    end

    # save changes?
    if agree("Save? yes/no") {|q| q.default = 'yes'}
      AppConfig.save
    end
  rescue
  end
end