Debian Codegraph @

lib/MARC/MIR.pod

raw ◀ ▶
Source reconstructed at patch state 0 of 2 — not the installed (fully patched) source.
2 Debian patches touch this file
1 =head1 MIR: MARC Intermediate Representation
2
3 MARC::MIR is not a library, it's a specification for in-memory representation
4 of a MARC record with simplcity in mind. The current module comes with a set of
5 helpers to manipulate it (i call it MARC::MIR DSL).
6
7 The DSL itself is designed to be used the more natural way possible. Here are
8 some basic exemples (combined with Perlude).
9
10 use Modern::Perl;
11 use MARC::MIR;
12 use Perlude;
13
14 # marcdump
15
16 now {say for_humans from_iso2709} iso2709_records_of 'source.mrc'
17
18 # report the IDs of the 10 first records of the file
19
20 now {
21 any_fields {
22 tag eq '001' and say value
23 } from_iso2709
24 } take 10, iso2709_records_of 'echantillon_ecparis.raw';
25
26 # or
27
28 now {
29 $_ = from_iso2709;
30 any_fields {
31 tag eq '001' and say value
32 }
33 } take 10, iso2709_records_of 'echantillon_ecparis.raw';
34
35 Some other modules and documentations are worth to read.
36
37 =head2 MARC::MIR::Template
38
39 (shipped appart) is a description format to import/export a MIR from/to a
40 datastructures that fit modern formats like JSON or XML.
41
42 =head2 MARC::MIR::Tutorial
43
44 gives basic exemples of use of the MARC::MIR DSL described below.
45
46 =head1 WARNINGS
47
48 t/* is empty and the API may change (i even i think it's quiet stable on the
49 basics). i think the doc is up to date and the stability of MARC::MIR.
50
51 Anyway: waiting for the tests, MARC::MIR runs daily on linux stations (perl
52 5.12 to 5.17) on large amount of data. It is as faster and easier to use than
53 older libraries and is designed to get the data back from iso files, no matter
54 the quality of the serialization dictionnary so for one shot scripts, i'm now
55 more confident in MARC::MIR than i ever was in MARC::Record, for example.
56
57 =head1 MOTIVATION
58
59 I dealt with lot of MARC records in the past (mainly from/to iso2709 files) and
60 was really annoyed by the state of art:
61
62 ISO2709 was a clever format when it was invented (more than 40 years ago! older
63 than FTP or even UNIX) but the world has changed a so drastic way most of the
64 IT crowd, bred to modern serialization formats (YAML, JSON, XML) are clueless
65 when it comes to magnetic tapes friendly serializations. Librarians haven't got
66 it since recently.
67
68 As a result, IT people just flee libraries and reinvent information sciences
69 from scratch with modern tools fitting the modern interconnected world when
70 librarians are left with the rest of us, dead bored programmers using old
71 school tools and bad designed modules with painfull OO approach. I don't blame
72 anyone: it's just the way the things gone.
73
74 But if you come back to the roots: A MARC record is a very simple structure so
75 they must be simple to manulate. MARC::MIR is an attempt to get the simplicity back.
76
77 =head1 SPECIFICATION
78
79 so MIR is just an array of array (see
80 man perllol) with very simple rules:
81
82 record = [ header, [fields] ]
83 fields = controlfield | datafield
84 controlfield = [tag,string]
85 datafield = [tag,[subfields],indicators]
86 indicators = [ ind1, ind2 ] # can be represented as a 2 chars fields
87 subfields = [tag,string]
88
89 note that tags are always at the index 0, data always at 1.
90
91 All the indexes that are not used by the spec can be used to store instructions
92 for middleware and serializer purposes. there is no convention there.
93
94 =head2 Examples
95
96 A MIR control field is a tag and a value.
97
98 [ '001', '1231313145' ]
99
100 A MIR data field
101
102 [ $tag, [@subfield] ]
103 [ $tag, [@subfield], " " ]
104 [ $tag, [@subfield], [' ',' '] ]
105
106 A MIR record
107
108 [ '01972cam0a2200541 450' =>
109 [ [ '001' => '2344564564' ] # this is the ID
110 , [ '856'
111 , [ [ q => "jpeg" ]
112 , [ z => "cover from original version" ]
113 , [ u => "http://localhost/img/" ]
114 ]
115 ]
116 ]
117 ]
118
119 =head1 DSL
120
121 the use of C<$_> and thd C<(_)> prototype is idiomatic: almost every subs are
122 written to be used a very natural way (my hope is librians to write some code).
123 So we prefer to write
124
125 say for_humans from_iso2709
126
127 than a more pythonic way
128
129 say( for_humans( from_iso2709( $_ )))
130
131 =head2 map_*, with_*, any_*, grep_*
132
133 # TODO: maybe an array there ?
134
135 =head2 tag, value, indicators
136
137 =head2 ISO2709 handling
138
139 # TODO: from|to_iso2709
140
141 =head2 CIB handling
142
143 # TODO: from|to_iso2709
144
145 =head1 Authors
146
147 * Marc Chantreux (eiro) marcc(at)cpan.org
148 * You? https://github.com/eiro/p5-marc-mir
149
150 =head1 KNOWN BUGS
151
152 feedbacks are very welcome. the only known bugs are
153
154 * with_fields needs $_
155 * map_datafields can't work
156 * *_values? must crash on references
157