config-model-edit is able to load a model described in YAML. To do this the above file needs to be translated in YAML. Thats not as complicated as it may sound.
--- class: PopCon:
Note that, like with Python language, the indentation is important to define the structure of the file. Here, the PopCon class is followed by a : as it defines a new hierarchical level to describes the configuration elements of this class:
Now we can deal with the configuration parameters. Lets detail the PARTICIPATE element. Heres the spec in from default.conf:
# PARTICIPATE can be one of "yes" or "no". # If you dont want to participate in the contest, say "no" # and we wont send messages. # # If this option is missing, the default is "no". # PARTICIPATE="no"
In the YAML file, the comments are moved in the description field and the value in the file is used as upstream default:
PARTICIPATE: upstream_default: no description: > If you dont want to participate in the contest, say "no" and we wont send messages.
Likewise for the remaining parameters:
MAILTO: description: > specifies the address to e-mail statistics to each week. default: email@example.com MAILFROM: description: >- MAILFROM is the forged sender email address you want to use in email submitted to the popularity-contest. If this is commented out, no From: or Sender: lines will be added to the outgoing mail, and it will be your MTAs job to add them. This is usually what you want. If your MTA is misconfigured or impossible to configure correctly, and it always generates invalid From: and/or Sender: lines, you can force different results by setting MAILFROM here. This can cause problems with spam bouncers, so most people should leave it commented out.
In the description above, the chimping marker - after > is used to keep paragraph formatting in the help.
SUBMITURLS: description: > Space separated list of where to submit popularity-contest reports using http. default: > http://popcon.debian.org/cgi-bin/popcon.cgi USEHTTP: description: > enables http reporting. Set this to yes to enable it. default: "yes" HTTP_PROXY: description: > allows one to specify an HTTP proxy server, the syntax is "http://proxy:port". This overrides the environment variable http_proxy. MY_HOSTID: description: > secret number that the popularity-contest receiver uses to keep track of your submissions. Whenever you send in a new entry, it overwrites the last one that had the same HOSTID. This key was generated automatically so you should normally just leave it alone.
Now that the YAML file was created, you can turn it into a model and load it in the model editor GUI with the following command:
config-model-edit -model PopCon -load_yaml popcon.yml -force
To complete the model, the easiest way is to run the wizard to complete the missing values. In the GUI, you can use the menu File -> wizard to launch the wizard. Then click on the OK button in the new window.
The wizard will first stop on the parameter list (not because theres an error, but because the parameter list is flagged as important)
The widget will now stop on the first missing information. Just select the correct type (leaf here), click store and Next.
You can repeat these steps until the wizard exits.
Once the model is complete, its time to specify how to read and write the file. In Popcon class specification:
You will get a window showing you the parameters to fill to specify the read backend.
o right-click on read_config o click on push new node to create a new read specification o right-click on the created item (shown at index "0")
Now fill the blank on the right side. The backend to use is ShellVar since popularity-contest.conf is made of shell variables.
Since the write specification is identical, theres no need to specify it. Config::Model will do the right thing.
You can test the model by clicking on menu Test -> Model. You will be shown the Popcon configuration editor GUI. The same that your users will get.
If everything is fine, you can quit the model editor (menu File->quit)
The model you have just created is stored in lib/Config/Model/models/Popcon.pl.
You can test directly this model with :
cme edit -dev -try Popcon
Feel free to send comments and suggestion about this page at
config-model-users at lists dot sourceforge dot net.
Dominique Dumont <ddumont at cpan.org>
This software is Copyright (c) 2005-2016 by Dominique Dumont.
This is free software, licensed under:
The GNU Lesser General Public License, Version 2.1, February 1999
|perl v5.20.3||CONFIG::MODEL::COOKBOOK::CREATEMODELFROMDOC (3)||2016-04-03|