Imported Upstream version 1.5.0
[platform/upstream/augeas.git] / lenses / puppetfile.aug
1 (*
2 Module: Puppetfile
3   Parses libarian-puppet's Puppetfile format
4
5 Author: Raphael Pinson <raphael.pinson@camptocamp.com>
6
7 About: Reference
8   See https://github.com/rodjek/librarian-puppet
9
10 About: License
11    This file is licenced under the LGPL v2+, like the rest of Augeas.
12
13 About: Lens Usage
14    To be documented
15
16 About: Configuration files
17    This lens applies to Puppetfiles.
18
19 About: Examples
20    The <Test_Puppetfile> file contains various examples and tests.
21 *)
22
23 module Puppetfile =
24
25 (* View: comma
26      a comma, optionally preceded or followed by spaces or newlines *)
27 let comma = del /[ \t\n]*,[ \t\n]*/ ", "
28
29 (* View: moduledir
30      The moduledir setting specifies where modules from the Puppetfile will be installed *)
31 let moduledir = [ Util.indent . key "moduledir" . Sep.space . Quote.any . Util.eol ]
32
33 (* View: forge
34      a forge entry *)
35 let forge = [ Util.indent . key "forge" . Sep.space . Quote.any . Util.eol ]
36
37 (* View: metadata
38      a metadata entry *)
39 let metadata = [ Util.indent . key "metadata" . Util.eol ]
40
41 (* View: mod
42      a module entry, with optional version and options *)
43 let mod =
44      let mod_name = Quote.do_quote (store ((Rx.word . /[\/-]/)? . Rx.word))
45   in let version = [ label "@version" . Quote.do_quote (store /[^:\n]+/) ]
46   in let opt = [ Util.del_str ":" . key Rx.word . del /[ \t]*=>[ \t]*/ " => "
47                . Quote.do_quote (store /[^,\n]*/) ]
48   in let opts = Build.opt_list opt comma
49   in [ Util.indent . Util.del_str "mod" . seq "mod" . Sep.space . mod_name
50      . (comma . version)?
51      . (comma . opts)?
52      . Util.eol ] 
53
54 (* View: lns
55      the Puppetfile lens *)
56 let lns = (Util.empty | Util.comment | forge | metadata | mod | moduledir )*