libis-tools 0.9.65 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (41) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +5 -23
  3. data/lib/libis/tools.rb +0 -1
  4. data/lib/libis/tools/version.rb +1 -1
  5. data/libis-tools.gemspec +1 -1
  6. metadata +4 -51
  7. data/lib/libis/tools/metadata.rb +0 -25
  8. data/lib/libis/tools/metadata/dublin_core_record.rb +0 -116
  9. data/lib/libis/tools/metadata/field_format.rb +0 -121
  10. data/lib/libis/tools/metadata/fix_field.rb +0 -35
  11. data/lib/libis/tools/metadata/mapper.rb +0 -81
  12. data/lib/libis/tools/metadata/mappers/flandrica.rb +0 -76
  13. data/lib/libis/tools/metadata/mappers/kuleuven.rb +0 -1929
  14. data/lib/libis/tools/metadata/mappers/scope.rb +0 -46
  15. data/lib/libis/tools/metadata/marc21_record.rb +0 -51
  16. data/lib/libis/tools/metadata/marc_record.rb +0 -287
  17. data/lib/libis/tools/metadata/parser/basic_parser.rb +0 -120
  18. data/lib/libis/tools/metadata/parser/dublin_core_parser.rb +0 -37
  19. data/lib/libis/tools/metadata/parser/marc21_parser.rb +0 -207
  20. data/lib/libis/tools/metadata/parser/marc_format_parser.rb +0 -53
  21. data/lib/libis/tools/metadata/parser/marc_rules.rb +0 -36
  22. data/lib/libis/tools/metadata/parser/marc_select_parser.rb +0 -26
  23. data/lib/libis/tools/metadata/parser/patch.rb +0 -22
  24. data/lib/libis/tools/metadata/parser/subfield_criteria_parser.rb +0 -72
  25. data/lib/libis/tools/metadata/parsers.rb +0 -12
  26. data/lib/libis/tools/metadata/sharepoint_mapping.rb +0 -119
  27. data/lib/libis/tools/metadata/sharepoint_record.rb +0 -262
  28. data/lib/libis/tools/metadata/var_field.rb +0 -242
  29. data/spec/data/MetadataMapping.xlsx +0 -0
  30. data/spec/metadata/123456789.marc +0 -18
  31. data/spec/metadata/8389207.marc +0 -117
  32. data/spec/metadata/BE_942855_1927_4898_corrected.XML +0 -11
  33. data/spec/metadata/BE_942855_1927_4898_md.XML +0 -11
  34. data/spec/metadata/dublin_core_parser_spec.rb +0 -48
  35. data/spec/metadata/dublin_core_spec.rb +0 -81
  36. data/spec/metadata/marc21_parser_data.rb +0 -382
  37. data/spec/metadata/marc21_parser_spec.rb +0 -67
  38. data/spec/metadata/marc21_spec.rb +0 -178
  39. data/spec/metadata/metadata_mapper_spec.rb +0 -23
  40. data/spec/metadata/scope_mapper_spec.rb +0 -29
  41. data/test.rb +0 -61
Binary file
@@ -1,18 +0,0 @@
1
- <?xml version="1.0" encoding="UTF-8"?>
2
- <record xsi:schemaLocation="http://www.loc.gov/MARC21/slim http://www.loc.gov/standards/marcxml/schema/MARC21slim.xsd"
3
- xmlns="http://www.loc.gov/MARC21/slim" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
4
- <leader>01068nam 2200241u 4500</leader>
5
- <controlfield tag="005">20150701153710.0</controlfield>
6
- <controlfield tag="008">000608m17221724xx |||| | 000|0 lat c</controlfield>
7
- <controlfield tag="001">9901234567890471</controlfield>
8
- <datafield tag="035" ind1=" " ind2=" ">
9
- <subfield code="a">(BeLVLBS)123456789LBS01-Aleph</subfield>
10
- </datafield>
11
- <datafield tag="035" ind1=" " ind2=" ">
12
- <subfield code="a">123456789</subfield>
13
- </datafield>
14
- <datafield tag="245" ind1="0" ind2="0">
15
- <subfield code="a">Title with special chars: 'éÄçñåúðäíö&apos; / "ߥ²¤€®©œøæ’×½¼þ«»¶ǽµ¢ŒÆØŒ§Ð&quot; &lt; &amp; % $ # &gt;</subfield>
16
- <subfield code="c">subtitle with special chars: "ߥ²¤€®©œøæ’×½¼þ«»¶ǽµ¢ŒÆØŒ§Ð&quot; &lt; &amp; % $ # &gt;</subfield>
17
- </datafield>
18
- </record>
@@ -1,117 +0,0 @@
1
- <?xml version="1.0" encoding="UTF-8"?>
2
- <record xsi:schemaLocation="http://www.loc.gov/MARC21/slim http://www.loc.gov/standards/marcxml/schema/MARC21slim.xsd"
3
- xmlns="http://www.loc.gov/MARC21/slim" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
4
- <leader>01068nam 2200241u 4500</leader>
5
- <controlfield tag="005">20150701153710.0</controlfield>
6
- <controlfield tag="008">000608m17221724xx |||| | 000|0 lat c</controlfield>
7
- <controlfield tag="001">9921543960101471</controlfield>
8
- <datafield tag="035" ind1=" " ind2=" ">
9
- <subfield code="a">(BeLVLBS)002154396LBS01-Aleph</subfield>
10
- </datafield>
11
- <datafield tag="035" ind1=" " ind2=" ">
12
- <subfield code="a">8389207</subfield>
13
- </datafield>
14
- <datafield tag="245" ind1="0" ind2="0">
15
- <subfield code="a">Anecdota Graeca, sacra et profana /</subfield>
16
- <subfield code="c">ex codicibus manu exaratis nunc primum in lucem edita, versione Latina donata, et notis
17
- illustrata a Io. Christophoro Wolfio ... Tom. I [-IIII]
18
- </subfield>
19
- </datafield>
20
- <datafield tag="264" ind1=" " ind2="1">
21
- <subfield code="a">Hamburgi</subfield>
22
- <subfield code="b">apud Theodorum Christophorum Felginer,</subfield>
23
- <subfield code="c">1722-1724</subfield>
24
- </datafield>
25
- <datafield tag="300" ind1=" " ind2=" ">
26
- <subfield code="a">8o: 4 v.; [22], 298, [8]; [16], 354, [1]; [16], 299, [7]; [16], 271, [5] p.</subfield>
27
- </datafield>
28
- <datafield tag="336" ind1=" " ind2=" ">
29
- <subfield code="a">text</subfield>
30
- <subfield code="2">rdacontent</subfield>
31
- </datafield>
32
- <datafield tag="337" ind1=" " ind2=" ">
33
- <subfield code="a">unmediated</subfield>
34
- <subfield code="2">rdamedia</subfield>
35
- </datafield>
36
- <datafield tag="338" ind1=" " ind2=" ">
37
- <subfield code="a">volume</subfield>
38
- <subfield code="2">rdacarrier</subfield>
39
- </datafield>
40
- <datafield tag="500" ind1=" " ind2=" ">
41
- <subfield code="a">Ded. Petrus Theodorus Seelmann; Erdmannus Neumeister; Thomas Claussen; Joannes Grammius
42
- </subfield>
43
- </datafield>
44
- <datafield tag="500" ind1=" " ind2=" ">
45
- <subfield code="a">Elk deel heeft eigen titelp. in roodzwartdruk, met drukkersmerk</subfield>
46
- </datafield>
47
- <datafield tag="650" ind1=" " ind2="7">
48
- <subfield code="2">UDC</subfield>
49
- <subfield code="a">276 =75</subfield>
50
- <subfield code="x">Griekse patrologie</subfield>
51
- </datafield>
52
- <datafield tag="650" ind1=" " ind2="7">
53
- <subfield code="2">KADOC</subfield>
54
- <subfield code="a">Bisdom Antwerpen (1961-heden)</subfield>
55
- <subfield code="6">(ODIS-ORG)9284</subfield>
56
- </datafield>
57
- <datafield tag="650" ind1=" " ind2="7">
58
- <subfield code="2">KADOC</subfield>
59
- <subfield code="a">Studiecentrum voor Zielzorg en Predicatie</subfield>
60
- <subfield code="6">(ODIS-ORG)24894</subfield>
61
- </datafield>
62
- <datafield tag="650" ind1=" " ind2="7">
63
- <subfield code="2">KADOC</subfield>
64
- <subfield code="a">Antwerpen [deelgemeente in gemeente Antwerpen - BE]</subfield>
65
- <subfield code="6">(ODIS-GEO)10560000006504</subfield>
66
- </datafield>
67
- <datafield tag="650" ind1=" " ind2="7">
68
- <subfield code="2">KADOC</subfield>
69
- <subfield code="a">C1</subfield>
70
- <subfield code="x">Kerken en religie</subfield>
71
- <subfield code="6">(ODIS-HT)</subfield>
72
- </datafield>
73
- <datafield tag="653" ind1=" " ind2="6">
74
- <subfield code="a">Books before 1840</subfield>
75
- </datafield>
76
- <datafield tag="700" ind1="1" ind2=" ">
77
- <subfield code="a">Wolf, Johann Christoph</subfield>
78
- <subfield code="d">1683-1739</subfield>
79
- <subfield code="4">aut</subfield>
80
- </datafield>
81
- <datafield tag="953" ind1=" " ind2=" ">
82
- <subfield code="a">1701-1750</subfield>
83
- </datafield>
84
- <datafield tag="998" ind1=" " ind2=" ">
85
- <subfield code="a">LBS01</subfield>
86
- <subfield code="b">bib_200501.mrc.2.av</subfield>
87
- </datafield>
88
- <datafield tag="INST" ind1=" " ind2=" ">
89
- <subfield code="a">32KUL_LIBIS_NETWORK</subfield>
90
- <subfield code="b">P</subfield>
91
- <subfield code="c">71134440820001471</subfield>
92
- </datafield>
93
- <datafield tag="INST" ind1=" " ind2=" ">
94
- <subfield code="a">32KUL_KUL</subfield>
95
- <subfield code="b">P</subfield>
96
- <subfield code="c">21304345390001488</subfield>
97
- </datafield>
98
- <datafield tag="AVA" ind1=" " ind2=" ">
99
- <subfield code="a">32KUL_KUL</subfield>
100
- <subfield code="b">GBIB</subfield>
101
- <subfield code="c">GBIB: Godgeleerdheid</subfield>
102
- <subfield code="d">276.030.4 WOLF Anec</subfield>
103
- <subfield code="e">available</subfield>
104
- <subfield code="f">1</subfield>
105
- <subfield code="g">0</subfield>
106
- <subfield code="j">GBIB</subfield>
107
- <subfield code="p">1</subfield>
108
- </datafield>
109
- <datafield tag="MMS" ind1=" " ind2=" ">
110
- <subfield code="b">9921543960101471</subfield>
111
- <subfield code="a">32KUL_LIBIS_NETWORK</subfield>
112
- </datafield>
113
- <datafield tag="MMS" ind1=" " ind2=" ">
114
- <subfield code="b">9921543960101488</subfield>
115
- <subfield code="a">32KUL_KUL</subfield>
116
- </datafield>
117
- </record>
@@ -1,11 +0,0 @@
1
- <?xml version="1.0" encoding="UTF-8"?>
2
- <dc:record xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:dcterms="http://purl.org/dc/terms/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
3
- <dc:title>Cleo De 5 A 7 (Cleo Tussen 5 En 7)</dc:title>
4
- <dc:identifier>BE/942855/1927/4898 (ref.code)</dc:identifier>
5
- <dc:format>digitale kopie (archival material type)</dc:format>
6
- <dcterms:spatial>Frankrijk</dcterms:spatial>
7
- <dc:identifier xsi:type="dcterms:URI">http://abs.lias.be/Query/detail.aspx?ID=902581</dc:identifier>
8
- <dc:source>Collectie filmdossiers Katholieke Filmliga/Filmmagie</dc:source>
9
- <dcterms:isReferencedBy xsi:type="dcterms:URI">http://abs.lias.be/Query/detail.aspx?ID=886364</dcterms:isReferencedBy>
10
- <dc:source>BE/942855/1927</dc:source>
11
- </dc:record>
@@ -1,11 +0,0 @@
1
- <?xml version="1.0" encoding="UTF-8"?>
2
- <dc:record xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:dcterms="http://purl.org/dc/terms/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
3
- <dc:title>Cleo De 5 A 7 (Cleo Tussen 5 En 7)</dc:title>
4
- <dc:identifier>BE/942855/1927/4898 (ref.code)</dc:identifier>
5
- <dc:format>digitale kopie (archival material type)</dc:format>
6
- <dcterms:spatial>Frankrijk</dcterms:spatial>
7
- <dc:identifier xsi:type="dcterms:URI">http://abs.lias.be/Query/detail.aspx?ID=902581</dc:identifier>
8
- <dc:source>Collectie filmdossiers Katholieke Filmliga/Filmmagie</dc:source>
9
- <dcterms:isPartOf>http://abs.lias.be/Query/detail.aspx?ID=886364</dcterms:isPartOf>
10
- <dc:source>BE/942855/1927</dc:source>
11
- </dc:record>
@@ -1,48 +0,0 @@
1
- # encoding: utf-8
2
- require_relative '../spec_helper'
3
- require 'libis/tools/metadata/parsers'
4
- require 'parslet'
5
- require 'parslet/convenience'
6
- require 'pp'
7
-
8
- $DEBUG = false
9
-
10
- describe 'DublinCore Parser' do
11
-
12
- subject(:parser) { Libis::Tools::Metadata::DublinCoreParser.new }
13
-
14
- it 'parses simple DC' do
15
- expect {
16
- tree = parser.parse_with_debug('dc:title')
17
- # pp tree
18
- expect(tree).to be_a Hash
19
- expect(tree[:namespace]).to eq 'dc'
20
- expect(tree[:element]).to eq 'title'
21
- # noinspection RubyResolve
22
- expect(tree).not_to have_key :attributes
23
- }.not_to raise_error
24
- end
25
-
26
- it 'must see namespace' do
27
- expect {
28
- parser.parse('title')
29
- }.to raise_error(Parslet::ParseFailed)
30
- end
31
-
32
- it 'parses DC with attributes' do
33
- expect {
34
- tree = parser.parse_with_debug('dcterms:date xsi:type="http://example.com" foo:bar="baz"')
35
- # pp tree
36
- expect(tree).to be_a Hash
37
- expect(tree[:namespace]).to eq 'dcterms'
38
- expect(tree[:element]).to eq 'date'
39
- # noinspection RubyResolve
40
- expect(tree[:attributes].size).to be 2
41
- expect(tree[:attributes]).to eq [
42
- {namespace: 'xsi', name: 'type', value: 'http://example.com'},
43
- {namespace: 'foo', name: 'bar', value: 'baz'},
44
- ]
45
- }.not_to raise_error
46
- end
47
-
48
- end
@@ -1,81 +0,0 @@
1
- # encoding: utf-8
2
- require_relative '../spec_helper'
3
- require 'libis/tools/metadata/dublin_core_record'
4
-
5
- require 'rspec/matchers'
6
- require 'equivalent-xml'
7
-
8
- describe 'DublinCoreRecord' do
9
-
10
- let(:header) { '<?xml version="1.0" encoding="utf-8"?>' }
11
-
12
- subject(:dc) { Libis::Tools::Metadata::DublinCoreRecord.new(data) {} }
13
-
14
- def dc_xml(tag, value = '', attributes = {})
15
- "<dc:#{tag}#{attributes.sort.each{|k,v| " #{k}=\"#{v}\""}.join}>#{value}</dc:#{tag}>"
16
- end
17
-
18
- def dcterms_xml(tag, value = '', attributes = {})
19
- "<dcterms:#{tag}#{attributes.sort.each{|k,v| " #{k}=\"#{v}\""}.join}>#{value}</dcterms:#{tag}>"
20
- end
21
-
22
- def match_xml(doc1, doc2)
23
- xml1 = doc1.is_a?(::Libis::Tools::XmlDocument) ? doc1.document : ::Nokogiri::XML(doc1.to_s)
24
- xml2 = doc2.is_a?(::Libis::Tools::XmlDocument) ? doc2.document : ::Nokogiri::XML(doc2.to_s)
25
- # noinspection RubyResolve
26
- expect(xml1).to be_equivalent_to(xml2).respecting_element_order
27
- end
28
-
29
- context 'Empty record' do
30
- let(:data) { nil }
31
- let(:root) { <<STR.chomp
32
- <dc:record \
33
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" \
34
- xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:dcterms="http://purl.org/dc/terms/"
35
- STR
36
- }
37
- let(:record_start) { root + '>' }
38
- let(:record_end) { '</dc:record>' }
39
- let(:empty_record) { header + root + '/>' }
40
-
41
-
42
- it 'contains emtpy record' do
43
- match_xml dc.document, empty_record
44
- end
45
-
46
- it 'add dc:title' do
47
- dc.title = 'abc'
48
- match_xml dc.document, header + record_start + dc_xml('title', 'abc') + record_end
49
- end
50
-
51
- it 'add dc:date' do
52
- dc.date = '2001'
53
- dc.dcdate! '2002'
54
- dc.dc_date! '2003'
55
- match_xml dc.document,
56
- header +
57
- record_start +
58
- dc_xml('date', '2001') +
59
- dc_xml('date', '2002') +
60
- dc_xml('date', '2003') +
61
- record_end
62
- end
63
-
64
- it 'add dcterms:date' do
65
- dc.termsdate! '2001'
66
- dc.dctermsdate! '2002'
67
- dc.terms_date! '2003'
68
- dc.dcterms_date! '2004'
69
- match_xml dc.document,
70
- header +
71
- record_start +
72
- dcterms_xml('date', '2001') +
73
- dcterms_xml('date', '2002') +
74
- dcterms_xml('date', '2003') +
75
- dcterms_xml('date', '2004') +
76
- record_end
77
- end
78
-
79
- end
80
-
81
- end
@@ -1,382 +0,0 @@
1
- def marc21_parser_testdata
2
- [
3
- {
4
- title: 'select statement with numeric tag',
5
- input: 'MARC 123',
6
- tree: {tag: '123', ind1: nil, ind2: nil, subfield: nil, condition: nil},
7
- transform: "record.select_fields('123##')"
8
- }, {
9
- title: 'select statement with LRK tag',
10
- input: 'MARC LKR',
11
- tree: {tag: 'LKR', ind1: nil, ind2: nil, subfield: nil, condition: nil},
12
- transform: "record.select_fields('LKR##')"
13
- }, {
14
- title: 'select statement with FMT tag',
15
- input: 'MARC FMT',
16
- tree: {tag: 'FMT', ind1: nil, ind2: nil, subfield: nil, condition: nil},
17
- transform: "record.select_fields('FMT##')"
18
- }, {
19
- title: 'select statement with bad magic text',
20
- input: 'foo',
21
- tree: :failure
22
- }, {
23
- title: 'select statement with bad tag',
24
- input: 'MARC 1',
25
- tree: :failure
26
- }, {
27
- title: 'select statement with bad indicator',
28
- input: 'MARC 123 *',
29
- tree: :failure
30
- }, {
31
- title: 'select statement with bad subfield',
32
- input: 'MARC 123 $_',
33
- tree: :failure
34
- }, {
35
- title: 'select statement with tag and one indicator',
36
- input: 'MARC 123 #',
37
- tree: {tag: '123', ind1: '#', ind2: nil, subfield: nil, condition: nil},
38
- transform: "record.select_fields('123##')"
39
- }, {
40
- title: 'select statement with tag and indicators',
41
- input: 'MARC 123 #_',
42
- tree: {tag: '123', ind1: '#', ind2: '_', subfield: nil, condition: nil},
43
- transform: "record.select_fields('123#_')"
44
- }, {
45
- title: 'select statement with tag and subfield',
46
- input: 'MARC 123 $a',
47
- tree: {tag: '123', ind1: nil, ind2: nil, subfield: {name: 'a'}, condition: nil},
48
- transform: "record.select_fields('123##a')"
49
- }, {
50
- title: 'select statement with tag, indicators and subfield',
51
- input: 'MARC 123 45 $6',
52
- tree: {tag: '123', ind1: '4', ind2: '5', subfield: {name: '6'}, condition: nil},
53
- transform: "record.select_fields('123456')"
54
- }, {
55
- title: 'select statement with subfield condition',
56
- input: 'MARC 123 [f.match(\'a\')]',
57
- tree: {
58
- tag: '123', ind1: nil, ind2: nil, subfield: nil,
59
- condition: {
60
- cond_format: {
61
- entry: [
62
- {cond_group: {
63
- prefix: 'f.match',
64
- lparen: '(',
65
- entry: [
66
- {cond_group: {
67
- prefix: nil,
68
- lparen: "'",
69
- entry: nil,
70
- postfix: 'a',
71
- rparen: "'"
72
- }}
73
- ],
74
- postfix: nil,
75
- rparen: ')'
76
- }}
77
- ],
78
- postfix: nil
79
- }
80
- }
81
- },
82
- transform: "record.select_fields('123##', Proc.new { |f| f.match('a') })"
83
- }, {
84
- title: 'select statement with regex condition',
85
- input: 'MARC 123 [$0 =~ /^.+"ABC"/]',
86
- tree: {
87
- tag: '123', ind1: nil, ind2: nil, subfield: nil,
88
- condition: {
89
- cond_format: {
90
- entry: [
91
- {subfield: {:prefix => nil, :repeat => nil, :name => '0'}},
92
- {cond_group: {
93
- prefix: ' =~ /^.+',
94
- lparen: "\"",
95
- entry: nil,
96
- postfix: 'ABC',
97
- rparen: "\""
98
- }}
99
- ],
100
- postfix: '/'
101
- }
102
- }
103
- },
104
- transform: "record.select_fields('123##', Proc.new { |f| f.subfield('0') =~ /^.+\"ABC\"/ })"
105
- }, {
106
- title: 'select statement with complex regex condition',
107
- input: 'MARC 690 02 {$0 =~ /^\(ODIS-(PS|ORG)\) (\d)+$$/}',
108
- tree: {
109
- tag: '690', ind1: '0', ind2: '2', subfield: nil,
110
- condition: {
111
- cond_format: {
112
- entry: [
113
- {subfield: {prefix: nil, repeat: nil, name: '0'}},
114
- {cond_group: {prefix: " =~ /^\\",
115
- lparen: '(',
116
- entry: [
117
- {cond_group: {
118
- prefix: 'ODIS-',
119
- lparen: '(',
120
- entry: nil,
121
- postfix: 'PS|ORG',
122
- rparen: ')'}}
123
- ],
124
- postfix: "\\",
125
- rparen: ')'}},
126
- {cond_group: {
127
- prefix: ' ',
128
- lparen: '(',
129
- entry: nil,
130
- postfix: "\\d",
131
- rparen: ')'}}
132
- ],
133
- postfix: '+$$/'}}
134
- },
135
- transform: "record.select_fields('69002', Proc.new { |f| f.subfield('0') =~ /^\\(ODIS-(PS|ORG)\\) (\\d)+$$/ })"
136
- }, {
137
- }, {
138
- title: 'format statement with simple subfield reference',
139
- input: '$a',
140
- tree: {entry: [{subfield: {prefix: nil, repeat: nil, name: 'a'}}], postfix: nil},
141
- transform: "f.subfield('a')"
142
- }, {
143
- title: 'format statement with subfield reference with repeat indicator',
144
- input: '$*a',
145
- tree: {entry: [{subfield: {prefix: nil, repeat: '*', name: 'a'}}], postfix: nil},
146
- transform: "field_format(f.subfield_array('a'), join: ';').to_s"
147
- }, {
148
- title: 'format statement with subfield reference with repeat + separator indicator',
149
- input: '$*"; "a',
150
- tree: {entry: [{subfield: {prefix: nil, repeat: {separator: '; '}, name: 'a'}}], postfix: nil},
151
- transform: "field_format(f.subfield_array('a'), join: '; ').to_s"
152
- }, {
153
- title: 'format statement with position reference',
154
- input: '$[13]',
155
- tree: {entry: [{fixfield: {prefix: nil, position: '13'}}], postfix: nil},
156
- transform: 'f[13]'
157
- }, {
158
- title: 'format statement with range reference',
159
- input: 'abc: $[5-8]',
160
- tree: {entry: [{fixfield: {prefix: 'abc: ', first: '5', last: '8'}}], postfix: nil},
161
- transform: "field_format(f[5,8], prefix: 'abc: ').to_s"
162
- }, {
163
- title: 'format statement with all range reference',
164
- input: 'abc: $[*].',
165
- tree: {entry: [{fixfield: {prefix: 'abc: ', all: '*'}}], postfix: '.'},
166
- transform: "field_format(field_format(f[], prefix: 'abc: ').to_s, postfix: '.').to_s"
167
- }, {
168
- title: 'format statement with multiple subfields with prefixes',
169
- input: '$a, $b - $c',
170
- tree: {
171
- entry: [
172
- {subfield: {prefix: nil, repeat: nil, name: 'a'}},
173
- {subfield: {prefix: ', ', repeat: nil, name: 'b'}},
174
- {subfield: {prefix: ' - ', repeat: nil, name: 'c'}},
175
- ],
176
- postfix: nil},
177
- transform: "field_format(f.subfield('a'),field_format(f.subfield('b'), prefix: ', ').to_s,field_format(f.subfield('c'), prefix: ' - ').to_s).to_s"
178
- }, {
179
- title: 'format statement with multiple subfields with prefixes and postfix',
180
- input: '$a, $b - $c.',
181
- tree: {
182
- entry: [
183
- {subfield: {prefix: nil, repeat: nil, name: 'a'}},
184
- {subfield: {prefix: ', ', repeat: nil, name: 'b'}},
185
- {subfield: {prefix: ' - ', repeat: nil, name: 'c'}},
186
- ],
187
- postfix: '.'},
188
- transform: "field_format(f.subfield('a'),field_format(f.subfield('b'), prefix: ', ').to_s,field_format(f.subfield('c'), prefix: ' - ').to_s, postfix: '.').to_s"
189
- }, {
190
- title: 'format statement with multiple subfields with prefixes and group',
191
- input: '$a, $b - ($c)',
192
- tree: {
193
- entry: [
194
- {subfield: {prefix: nil, repeat: nil, name: 'a'}},
195
- {subfield: {prefix: ', ', repeat: nil, name: 'b'}},
196
- {group: {
197
- prefix: ' - ', postfix: nil,
198
- lparen: '(', rparen: ')',
199
- entry: [{subfield: {prefix: nil, repeat: nil, name: 'c'}}]
200
- }},
201
- ],
202
- postfix: nil},
203
- transform: "field_format(f.subfield('a'),field_format(f.subfield('b'), prefix: ', ').to_s,field_format(f.subfield('c'), prefix: ' - (', postfix: ')').to_s).to_s"
204
- }, {
205
- title: 'format statement with multiple subfields with prefixes and group with multiple entries',
206
- input: '$a, $b - ($c, $d, ...)',
207
- tree: {
208
- entry: [
209
- {subfield: {prefix: nil, repeat: nil, name: 'a'}},
210
- {subfield: {prefix: ', ', repeat: nil, name: 'b'}},
211
- {group: {
212
- prefix: ' - ', postfix: ', ...',
213
- lparen: '(', rparen: ')',
214
- entry: [
215
- {subfield: {prefix: nil, repeat: nil, name: 'c'}},
216
- {subfield: {prefix: ', ', repeat: nil, name: 'd'}},
217
- ],
218
- }},
219
- ],
220
- postfix: nil},
221
- transform: "field_format(f.subfield('a'),field_format(f.subfield('b'), prefix: ', ').to_s,field_format(f.subfield('c'),field_format(f.subfield('d'), prefix: ', ').to_s, prefix: ' - (', postfix: ', ...)').to_s).to_s"
222
- }, {
223
- title: 'format statement with nested groups',
224
- input: '([{{($a)}}])',
225
- tree: {
226
- entry: [
227
- {group: {
228
- prefix: nil, postfix: nil,
229
- lparen: '(', rparen: ')',
230
- entry: [
231
- {group: {
232
- prefix: nil, postfix: nil,
233
- lparen: '[', rparen: ']',
234
- entry: [
235
- {group: {
236
- prefix: nil, postfix: nil,
237
- lparen: '{', rparen: '}',
238
- entry: [
239
- {group: {
240
- prefix: nil, postfix: nil,
241
- lparen: '{', rparen: '}',
242
- entry: [
243
- {group: {
244
- prefix: nil, postfix: nil,
245
- lparen: '(', rparen: ')',
246
- entry: [{subfield: {prefix: nil, repeat: nil, name: 'a'}}]
247
- }}
248
- ]
249
- }}
250
- ]
251
- }}
252
- ]
253
- }}
254
- ]
255
- }}
256
- ],
257
- postfix: nil},
258
- transform: "field_format(field_format(field_format(field_format(field_format(f.subfield('a'), prefix: '(', postfix: ')').to_s, prefix: '{', postfix: '}').to_s, prefix: '{', postfix: '}').to_s, prefix: '[', postfix: ']').to_s, prefix: '(', postfix: ')').to_s"
259
- }, {
260
- title: 'format statement with missing closing bracket',
261
- input: '($a',
262
- tree: :failure
263
- }, {
264
- title: 'format statement with missing opening bracket',
265
- input: '$a)',
266
- tree: :failure
267
- }, {
268
- title: 'format statement with nested quotes',
269
- input: ':"-$a, $*"+"b-".',
270
- tree: {
271
- entry: [
272
- {group: {
273
- prefix: ':', postfix: '-',
274
- lparen: '"', rparen: '"',
275
- entry: [
276
- {subfield: {prefix: '-', repeat: nil, name: 'a'}},
277
- {subfield: {prefix: ', ', repeat: {separator: '+'}, name: 'b'}}
278
- ],
279
- }}
280
- ],
281
- postfix: '.'},
282
- transform: "field_format(field_format(field_format(f.subfield('a'), prefix: '-').to_s,field_format(f.subfield_array('b'), prefix: ', ', join: '+').to_s, prefix: ':\"', postfix: '-\"').to_s, postfix: '.').to_s"
283
- }, {
284
- title: 'format statement with double dollar prefix and postfix',
285
- input: 'ab: $$$*a$$.',
286
- tree: {
287
- entry: [{subfield: {prefix: 'ab: $$', repeat: '*', name: 'a'}}],
288
- postfix: '$$.'},
289
- transform: "field_format(field_format(f.subfield_array('a'), prefix: 'ab: $$', join: ';').to_s, postfix: '$$.').to_s"
290
- }, {
291
- title: 'format statement with condition text',
292
- input: '$0 =~ /^\(ODIS-(PS|ORG)\) (\d)+$$/',
293
- tree: {
294
- entry: [
295
- {subfield: {prefix: nil, repeat: nil, name: '0'}},
296
- {group: {
297
- prefix: ' =~ /^\\', postfix: '\\',
298
- lparen: '(', rparen: ')',
299
- entry: [
300
- {group: {
301
- prefix: 'ODIS-', postfix: 'PS|ORG',
302
- lparen: '(', rparen: ')',
303
- entry: nil
304
- }}
305
- ]
306
- }},
307
- {group: {
308
- prefix: ' ', postfix: '\\d',
309
- lparen: '(', rparen: ')',
310
- entry: nil
311
- }}
312
- ],
313
- postfix: '+$$/'},
314
- transform: "field_format(f.subfield('0'),field_format(field_format(, prefix: 'ODIS-(', postfix: 'PS|ORG)').to_s, prefix: ' =~ /^\\(', postfix: '\\)').to_s,field_format(, prefix: ' (', postfix: '\\d)').to_s, postfix: '+$$/').to_s"
315
- }, {
316
- title: 'format statement with method call',
317
- input: '$(my_method($a,$b))',
318
- tree: {entry: [
319
- {method_call: {
320
- prefix: nil, postfix: nil,
321
- entry: [
322
- {group: {
323
- prefix: 'my_method', postfix: nil,
324
- lparen: '(', rparen: ')',
325
- entry: [
326
- {subfield: {prefix: nil, repeat: nil, name: 'a'}},
327
- {subfield: {prefix: ',', repeat: nil, name: 'b'}}
328
- ]
329
- }}
330
- ]
331
- }}
332
- ],
333
- postfix: nil},
334
- transform: {:format => {:entry => [{:method_call => {:prefix => nil, :entry => ["field_format(f.subfield('a'),field_format(f.subfield('b'), prefix: ',').to_s, prefix: 'my_method(', postfix: ')').to_s"], :postfix => nil}}], :postfix => nil}}
335
- }, {
336
- title: 'format statement with complex with method call',
337
- input: "$a $b ($c) ($d) ($g), $(lookup('DOLLAR4','Name','Tag'=>'100','Code'=>$4.to_s)) ($9)",
338
- tree: {entry: [
339
- {subfield: {prefix: nil, repeat: nil, name: 'a'}},
340
- {subfield: {prefix: ' ', repeat: nil, name: 'b'}},
341
- {group: {
342
- prefix: ' ', postfix: nil,
343
- lparen: '(', rparen: ')',
344
- entry: [{subfield: {prefix: nil, repeat: nil, name: 'c'}}]}},
345
- {group: {
346
- prefix: ' ', postfix: nil,
347
- lparen: '(', rparen: ')',
348
- entry: [{subfield: {prefix: nil, repeat: nil, name: 'd'}}]
349
- }},
350
- {group: {
351
- prefix: ' ', postfix: nil,
352
- lparen: '(', rparen: ')',
353
- entry: [{subfield: {prefix: nil, repeat: nil, name: 'g'}}]
354
- }},
355
- {method_call: {
356
- prefix: ', ', postfix: nil,
357
- entry: [
358
- {group: {
359
- prefix: 'lookup', postfix: '.to_s',
360
- lparen: '(', rparen: ')',
361
- entry: [
362
- {group: {prefix: nil, lparen: "'", entry: nil, postfix: 'DOLLAR4', rparen: "'"}},
363
- {group: {prefix: ',', lparen: "'", entry: nil, postfix: 'Name', rparen: "'"}},
364
- {group: {prefix: ',', lparen: "'", entry: nil, postfix: 'Tag', rparen: "'"}},
365
- {group: {prefix: '=>', lparen: "'", entry: nil, postfix: '100', rparen: "'"}},
366
- {group: {prefix: ',', lparen: "'", entry: nil, postfix: 'Code', rparen: "'"}},
367
- {subfield: {prefix: '=>', repeat: nil, name: '4'}}
368
- ]
369
- }}
370
- ]
371
- }},
372
- {group: {
373
- prefix: ' ', postfix: nil,
374
- lparen: '(', rparen: ')',
375
- entry: [{subfield: {prefix: nil, repeat: nil, name: '9'}}]
376
- }}
377
- ],
378
- postfix: nil},
379
- transform: {:format => {:entry => ["f.subfield('a')", "field_format(f.subfield('b'), prefix: ' ').to_s", "field_format(f.subfield('c'), prefix: ' (', postfix: ')').to_s", "field_format(f.subfield('d'), prefix: ' (', postfix: ')').to_s", "field_format(f.subfield('g'), prefix: ' (', postfix: ')').to_s", {:method_call => {:prefix => ', ', :entry => ["field_format(field_format(, prefix: ''', postfix: 'DOLLAR4'').to_s,field_format(, prefix: ','', postfix: 'Name'').to_s,field_format(, prefix: ','', postfix: 'Tag'').to_s,field_format(, prefix: '=>'', postfix: '100'').to_s,field_format(, prefix: ','', postfix: 'Code'').to_s,field_format(f.subfield('4'), prefix: '=>').to_s, prefix: 'lookup(', postfix: '.to_s)').to_s"], :postfix => nil}}, "field_format(f.subfield('9'), prefix: ' (', postfix: ')').to_s"], :postfix => nil}}
380
- }
381
- ]
382
- end