3 Parses libarian-puppet's Puppetfile format
5 Author: Raphael Pinson <raphael.pinson@camptocamp.com>
8 See https://github.com/rodjek/librarian-puppet
11 This file is licenced under the LGPL v2+, like the rest of Augeas.
16 About: Configuration files
17 This lens applies to Puppetfiles.
20 The <Test_Puppetfile> file contains various examples and tests.
26 a comma, optionally preceded or followed by spaces or newlines *)
27 let comma = del /[ \t\n]*,[ \t\n]*/ ", "
28 let comma_nospace = del /[ \t\n]*,/ ","
30 let comment_or_eol = Util.eol | Util.comment_eol
31 let quote_to_comment_or_eol = Quote.do_quote (store /[^#\n]*/) . comment_or_eol
34 The moduledir setting specifies where modules from the Puppetfile will be installed *)
35 let moduledir = [ Util.indent . key "moduledir" . Sep.space
36 . quote_to_comment_or_eol ]
40 let forge = [ Util.indent . key "forge" . Sep.space
41 . quote_to_comment_or_eol ]
45 let metadata = [ Util.indent . key "metadata" . comment_or_eol ]
48 a module entry, with optional version and options *)
50 let mod_name = Quote.do_quote (store ((Rx.word . /[\/-]/)? . Rx.word))
51 in let version = [ label "@version" . Quote.do_quote (store /[^#:\n]+/) . Util.comment_eol? ]
52 in let sto_opt_val = store /[^#"', \t\n][^#"',\n]*[^#"', \t\n]|[^#"', \t\n]/
54 Util.del_str ":" . key Rx.word
55 . (del /[ \t]*=>[ \t]*/ " => " . Quote.do_quote_opt sto_opt_val)?
57 in let opt_eol = del /([ \t\n]*\n)?/ ""
58 in let opt_space_or_eol = del /[ \t\n]*/ " "
59 in let comma_opt_eol_comment = comma_nospace . (opt_eol . Util.comment_eol)*
61 in let opts = Build.opt_list opt comma_opt_eol_comment
62 in [ Util.indent . Util.del_str "mod" . seq "mod" . Sep.space . mod_name
63 . (comma_opt_eol_comment . version)?
64 . (comma_opt_eol_comment . opts . Util.comment_eol?)?
68 the Puppetfile lens *)
69 let lns = (Util.empty | Util.comment | forge | metadata | mod | moduledir )*