@@ -2,3 +2,84 @@ debian-control-parser-gem
2
2
=========================
3
3
4
4
Parses Debian control files
5
+
6
+ Installation
7
+ ------------
8
+ gem install debian-control-parser
9
+
10
+ Sample application
11
+ ------------------
12
+ ``` ruby
13
+ require ' debian_control_parser'
14
+
15
+ data=<<EOF
16
+ Foo: bar
17
+ Answer-to-Everything: 42
18
+
19
+ Ding: dong
20
+ Zingo: zongo
21
+ Multi:
22
+ several lines
23
+ in a paragraph
24
+ are of course allowd
25
+ Final: field
26
+ EOF
27
+
28
+ parser = DebianControlParser .new (data)
29
+ parser.paragraphs do |paragraph |
30
+ paragraph.fields do |name ,value |
31
+ puts " Name=#{ name } / Value=#{ value } "
32
+ end
33
+ end
34
+
35
+ ```
36
+
37
+ What do I need this Gem for?
38
+ ----------------------------
39
+ If you need to parse control files used by Debian and its derivatives like
40
+ Ubuntu or Linux mint you can use this gem. Control files are used in various
41
+ places like the Packages (list of binary packages), Sources (list of source
42
+ packages) or Release (information about a release, the supported architectures
43
+ and their software packages).
44
+
45
+ Why did you write it?
46
+ ---------------------
47
+ I needed a parser for the rewrite of the
48
+ [ debshots] ( https://www.debian.org/doc/debian-policy/ch-controlfields.html )
49
+ which is a rewrite of the web application tha runs
50
+ [ screenshots.debian.net] ( https://screenshots.debian.net/ ) and similar
51
+ web sites.
52
+
53
+ Where is the layout of Debian control files defined?
54
+ ----------------------------------------------------
55
+ You can find the formal specification of the layout of control files
56
+ in the [ Debian Policy Manual] ( https://www.debian.org/doc/debian-policy/ch-controlfields.html ) .
57
+
58
+ What is so special about this Gem?
59
+ ----------------------------------
60
+ I'm aware that there is at least one other parser for control files. But it reads
61
+ the entire file into memory. This is not always feasible because some control files
62
+ grow very large and require a lot of RAM to parse.
63
+
64
+ This class works as an iterator and lets you parse paragraphs and fields one by one.
65
+ Only paragraphs are read into memory because they are usually smaller.
66
+
67
+ What are paragraphs and fields?
68
+ -------------------------------
69
+ Certain control files like "Packages" are split into several blocks that
70
+ are seperated by newlines.
71
+
72
+ Example with three paragraphs:
73
+
74
+ ```
75
+ Name10: Value10
76
+ Name11: Value11
77
+
78
+ Name20: Value20
79
+ Name21: Value21
80
+
81
+ Name30: Value30
82
+ Name31: Value31
83
+ ```
84
+
85
+ Each of these paragaphs consists of fields that have a name and value each.
0 commit comments