ruby-marc-spec 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.github/workflows/build.yml +18 -0
- data/.gitignore +388 -0
- data/.gitmodules +3 -0
- data/.idea/codeStyles/codeStyleConfig.xml +5 -0
- data/.idea/go.imports.xml +6 -0
- data/.idea/inspectionProfiles/Project_Default.xml +23 -0
- data/.idea/marc_spec.iml +102 -0
- data/.idea/misc.xml +6 -0
- data/.idea/modules.xml +8 -0
- data/.idea/templateLanguages.xml +6 -0
- data/.idea/vcs.xml +7 -0
- data/.rubocop.yml +269 -0
- data/.ruby-version +1 -0
- data/.simplecov +8 -0
- data/CHANGES.md +3 -0
- data/Gemfile +6 -0
- data/LICENSE.md +21 -0
- data/README.md +172 -0
- data/Rakefile +20 -0
- data/lib/.rubocop.yml +5 -0
- data/lib/marc/spec/module_info.rb +14 -0
- data/lib/marc/spec/parsing/closed_int_range.rb +28 -0
- data/lib/marc/spec/parsing/closed_lc_alpha_range.rb +28 -0
- data/lib/marc/spec/parsing/parser.rb +213 -0
- data/lib/marc/spec/parsing.rb +1 -0
- data/lib/marc/spec/queries/al_num_range.rb +105 -0
- data/lib/marc/spec/queries/applicable.rb +18 -0
- data/lib/marc/spec/queries/character_spec.rb +81 -0
- data/lib/marc/spec/queries/comparison_string.rb +45 -0
- data/lib/marc/spec/queries/condition.rb +133 -0
- data/lib/marc/spec/queries/condition_context.rb +49 -0
- data/lib/marc/spec/queries/dsl.rb +80 -0
- data/lib/marc/spec/queries/indicator_value.rb +77 -0
- data/lib/marc/spec/queries/operator.rb +129 -0
- data/lib/marc/spec/queries/part.rb +63 -0
- data/lib/marc/spec/queries/position.rb +59 -0
- data/lib/marc/spec/queries/position_or_range.rb +27 -0
- data/lib/marc/spec/queries/query.rb +94 -0
- data/lib/marc/spec/queries/query_executor.rb +52 -0
- data/lib/marc/spec/queries/selector.rb +12 -0
- data/lib/marc/spec/queries/subfield.rb +88 -0
- data/lib/marc/spec/queries/subfield_value.rb +63 -0
- data/lib/marc/spec/queries/tag.rb +107 -0
- data/lib/marc/spec/queries/transform.rb +154 -0
- data/lib/marc/spec/queries.rb +1 -0
- data/lib/marc/spec.rb +32 -0
- data/rakelib/.rubocop.yml +19 -0
- data/rakelib/bundle.rake +8 -0
- data/rakelib/coverage.rake +11 -0
- data/rakelib/gem.rake +54 -0
- data/rakelib/parser_specs/formatter.rb +31 -0
- data/rakelib/parser_specs/parser_specs.rb.txt.erb +35 -0
- data/rakelib/parser_specs/rule.rb +95 -0
- data/rakelib/parser_specs/suite.rb +91 -0
- data/rakelib/parser_specs/test.rb +97 -0
- data/rakelib/parser_specs.rb +1 -0
- data/rakelib/rubocop.rake +18 -0
- data/rakelib/spec.rake +27 -0
- data/ruby-marc-spec.gemspec +42 -0
- data/spec/.rubocop.yml +46 -0
- data/spec/README.md +16 -0
- data/spec/data/b23161018-sru.xml +182 -0
- data/spec/data/sandburg.xml +82 -0
- data/spec/generated/char_indicator_spec.rb +174 -0
- data/spec/generated/char_spec.rb +113 -0
- data/spec/generated/comparison_string_spec.rb +74 -0
- data/spec/generated/field_tag_spec.rb +156 -0
- data/spec/generated/index_char_spec.rb +669 -0
- data/spec/generated/index_indicator_spec.rb +174 -0
- data/spec/generated/index_spec.rb +113 -0
- data/spec/generated/index_sub_spec_spec.rb +1087 -0
- data/spec/generated/indicators_spec.rb +75 -0
- data/spec/generated/position_or_range_spec.rb +110 -0
- data/spec/generated/sub_spec_spec.rb +208 -0
- data/spec/generated/sub_spec_sub_spec_spec.rb +1829 -0
- data/spec/generated/subfield_char_spec.rb +405 -0
- data/spec/generated/subfield_range_range_spec.rb +48 -0
- data/spec/generated/subfield_range_spec.rb +87 -0
- data/spec/generated/subfield_range_sub_spec_spec.rb +214 -0
- data/spec/generated/subfield_tag_range_spec.rb +477 -0
- data/spec/generated/subfield_tag_sub_spec_spec.rb +3216 -0
- data/spec/generated/subfield_tag_tag_spec.rb +5592 -0
- data/spec/marc/spec/parsing/closed_int_range_spec.rb +49 -0
- data/spec/marc/spec/parsing/closed_lc_alpha_range_spec.rb +49 -0
- data/spec/marc/spec/parsing/parser_spec.rb +545 -0
- data/spec/marc/spec/queries/al_num_range_spec.rb +114 -0
- data/spec/marc/spec/queries/character_spec_spec.rb +28 -0
- data/spec/marc/spec/queries/comparison_string_spec.rb +28 -0
- data/spec/marc/spec/queries/indicator_value_spec.rb +28 -0
- data/spec/marc/spec/queries/query_spec.rb +200 -0
- data/spec/marc/spec/queries/subfield_spec.rb +92 -0
- data/spec/marc/spec/queries/subfield_value_spec.rb +31 -0
- data/spec/marc/spec/queries/tag_spec.rb +144 -0
- data/spec/marc/spec/queries/transform_spec.rb +459 -0
- data/spec/marc_spec_spec.rb +247 -0
- data/spec/scratch_spec.rb +112 -0
- data/spec/spec_helper.rb +23 -0
- metadata +341 -0
@@ -0,0 +1,174 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'parslet/rig/rspec'
|
3
|
+
|
4
|
+
module MARC
|
5
|
+
module Spec
|
6
|
+
module Parsing
|
7
|
+
context 'suite' do
|
8
|
+
describe :index_indicator do
|
9
|
+
let(:parser) { Parser.new }
|
10
|
+
let(:reporter) { Parslet::ErrorReporter::Deepest.new }
|
11
|
+
|
12
|
+
describe 'marc_spec: valid field tag, index and indicators' do
|
13
|
+
# /valid/wildCombination_validIndexIndicator.json
|
14
|
+
|
15
|
+
describe 'last position' do
|
16
|
+
|
17
|
+
it '&& indicator 1 -> valid' do
|
18
|
+
# /valid/wildCombination_validIndexIndicator.json
|
19
|
+
expect(parser.marc_spec).to parse('...[#]^1', trace: true, reporter: reporter)
|
20
|
+
end
|
21
|
+
|
22
|
+
it '&& indicator 2 -> valid' do
|
23
|
+
# /valid/wildCombination_validIndexIndicator.json
|
24
|
+
expect(parser.marc_spec).to parse('...[#]^2', trace: true, reporter: reporter)
|
25
|
+
end
|
26
|
+
|
27
|
+
end
|
28
|
+
|
29
|
+
describe 'first position' do
|
30
|
+
|
31
|
+
it '&& indicator 1 -> valid' do
|
32
|
+
# /valid/wildCombination_validIndexIndicator.json
|
33
|
+
expect(parser.marc_spec).to parse('...[0]^1', trace: true, reporter: reporter)
|
34
|
+
end
|
35
|
+
|
36
|
+
it '&& indicator 2 -> valid' do
|
37
|
+
# /valid/wildCombination_validIndexIndicator.json
|
38
|
+
expect(parser.marc_spec).to parse('...[0]^2', trace: true, reporter: reporter)
|
39
|
+
end
|
40
|
+
|
41
|
+
end
|
42
|
+
|
43
|
+
describe 'position ten' do
|
44
|
+
|
45
|
+
it '&& indicator 1 -> valid' do
|
46
|
+
# /valid/wildCombination_validIndexIndicator.json
|
47
|
+
expect(parser.marc_spec).to parse('...[9]^1', trace: true, reporter: reporter)
|
48
|
+
end
|
49
|
+
|
50
|
+
it '&& indicator 2 -> valid' do
|
51
|
+
# /valid/wildCombination_validIndexIndicator.json
|
52
|
+
expect(parser.marc_spec).to parse('...[9]^2', trace: true, reporter: reporter)
|
53
|
+
end
|
54
|
+
|
55
|
+
end
|
56
|
+
|
57
|
+
describe 'position eleven' do
|
58
|
+
|
59
|
+
it '&& indicator 1 -> valid' do
|
60
|
+
# /valid/wildCombination_validIndexIndicator.json
|
61
|
+
expect(parser.marc_spec).to parse('...[10]^1', trace: true, reporter: reporter)
|
62
|
+
end
|
63
|
+
|
64
|
+
it '&& indicator 2 -> valid' do
|
65
|
+
# /valid/wildCombination_validIndexIndicator.json
|
66
|
+
expect(parser.marc_spec).to parse('...[10]^2', trace: true, reporter: reporter)
|
67
|
+
end
|
68
|
+
|
69
|
+
end
|
70
|
+
|
71
|
+
describe 'position 101' do
|
72
|
+
|
73
|
+
it '&& indicator 1 -> valid' do
|
74
|
+
# /valid/wildCombination_validIndexIndicator.json
|
75
|
+
expect(parser.marc_spec).to parse('...[100]^1', trace: true, reporter: reporter)
|
76
|
+
end
|
77
|
+
|
78
|
+
it '&& indicator 2 -> valid' do
|
79
|
+
# /valid/wildCombination_validIndexIndicator.json
|
80
|
+
expect(parser.marc_spec).to parse('...[100]^2', trace: true, reporter: reporter)
|
81
|
+
end
|
82
|
+
|
83
|
+
end
|
84
|
+
|
85
|
+
describe 'range from first position to second' do
|
86
|
+
|
87
|
+
it '&& indicator 1 -> valid' do
|
88
|
+
# /valid/wildCombination_validIndexIndicator.json
|
89
|
+
expect(parser.marc_spec).to parse('...[0-1]^1', trace: true, reporter: reporter)
|
90
|
+
end
|
91
|
+
|
92
|
+
it '&& indicator 2 -> valid' do
|
93
|
+
# /valid/wildCombination_validIndexIndicator.json
|
94
|
+
expect(parser.marc_spec).to parse('...[0-1]^2', trace: true, reporter: reporter)
|
95
|
+
end
|
96
|
+
|
97
|
+
end
|
98
|
+
|
99
|
+
describe 'range from first position to last' do
|
100
|
+
|
101
|
+
it '&& indicator 1 -> valid' do
|
102
|
+
# /valid/wildCombination_validIndexIndicator.json
|
103
|
+
expect(parser.marc_spec).to parse('...[0-#]^1', trace: true, reporter: reporter)
|
104
|
+
end
|
105
|
+
|
106
|
+
it '&& indicator 2 -> valid' do
|
107
|
+
# /valid/wildCombination_validIndexIndicator.json
|
108
|
+
expect(parser.marc_spec).to parse('...[0-#]^2', trace: true, reporter: reporter)
|
109
|
+
end
|
110
|
+
|
111
|
+
end
|
112
|
+
|
113
|
+
describe 'range from first position to first position, is like first position' do
|
114
|
+
|
115
|
+
it '&& indicator 1 -> valid' do
|
116
|
+
# /valid/wildCombination_validIndexIndicator.json
|
117
|
+
expect(parser.marc_spec).to parse('...[0-0]^1', trace: true, reporter: reporter)
|
118
|
+
end
|
119
|
+
|
120
|
+
it '&& indicator 2 -> valid' do
|
121
|
+
# /valid/wildCombination_validIndexIndicator.json
|
122
|
+
expect(parser.marc_spec).to parse('...[0-0]^2', trace: true, reporter: reporter)
|
123
|
+
end
|
124
|
+
|
125
|
+
end
|
126
|
+
|
127
|
+
describe 'range from last position to last position, is like last position' do
|
128
|
+
|
129
|
+
it '&& indicator 1 -> valid' do
|
130
|
+
# /valid/wildCombination_validIndexIndicator.json
|
131
|
+
expect(parser.marc_spec).to parse('...[#-#]^1', trace: true, reporter: reporter)
|
132
|
+
end
|
133
|
+
|
134
|
+
it '&& indicator 2 -> valid' do
|
135
|
+
# /valid/wildCombination_validIndexIndicator.json
|
136
|
+
expect(parser.marc_spec).to parse('...[#-#]^2', trace: true, reporter: reporter)
|
137
|
+
end
|
138
|
+
|
139
|
+
end
|
140
|
+
|
141
|
+
describe 'range from last position to position one (index reverted), is like last position' do
|
142
|
+
|
143
|
+
it '&& indicator 1 -> valid' do
|
144
|
+
# /valid/wildCombination_validIndexIndicator.json
|
145
|
+
expect(parser.marc_spec).to parse('...[#-0]^1', trace: true, reporter: reporter)
|
146
|
+
end
|
147
|
+
|
148
|
+
it '&& indicator 2 -> valid' do
|
149
|
+
# /valid/wildCombination_validIndexIndicator.json
|
150
|
+
expect(parser.marc_spec).to parse('...[#-0]^2', trace: true, reporter: reporter)
|
151
|
+
end
|
152
|
+
|
153
|
+
end
|
154
|
+
|
155
|
+
describe 'range from last position to position two (index reverted)' do
|
156
|
+
|
157
|
+
it '&& indicator 1 -> valid' do
|
158
|
+
# /valid/wildCombination_validIndexIndicator.json
|
159
|
+
expect(parser.marc_spec).to parse('...[#-1]^1', trace: true, reporter: reporter)
|
160
|
+
end
|
161
|
+
|
162
|
+
it '&& indicator 2 -> valid' do
|
163
|
+
# /valid/wildCombination_validIndexIndicator.json
|
164
|
+
expect(parser.marc_spec).to parse('...[#-1]^2', trace: true, reporter: reporter)
|
165
|
+
end
|
166
|
+
|
167
|
+
end
|
168
|
+
|
169
|
+
end
|
170
|
+
end
|
171
|
+
end
|
172
|
+
end
|
173
|
+
end
|
174
|
+
end
|
@@ -0,0 +1,113 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'parslet/rig/rspec'
|
3
|
+
|
4
|
+
module MARC
|
5
|
+
module Spec
|
6
|
+
module Parsing
|
7
|
+
context 'suite' do
|
8
|
+
describe :index do
|
9
|
+
let(:parser) { Parser.new }
|
10
|
+
let(:reporter) { Parslet::ErrorReporter::Deepest.new }
|
11
|
+
|
12
|
+
describe 'marc_spec: valid field tag and index' do
|
13
|
+
# /valid/wildCombination_validIndex.json
|
14
|
+
it 'first position -> valid' do
|
15
|
+
# /valid/wildCombination_validIndex.json
|
16
|
+
expect(parser.marc_spec).to parse('...[0]', trace: true, reporter: reporter)
|
17
|
+
end
|
18
|
+
|
19
|
+
it 'last position -> valid' do
|
20
|
+
# /valid/wildCombination_validIndex.json
|
21
|
+
expect(parser.marc_spec).to parse('...[#]', trace: true, reporter: reporter)
|
22
|
+
end
|
23
|
+
|
24
|
+
it 'position 101 -> valid' do
|
25
|
+
# /valid/wildCombination_validIndex.json
|
26
|
+
expect(parser.marc_spec).to parse('...[100]', trace: true, reporter: reporter)
|
27
|
+
end
|
28
|
+
|
29
|
+
it 'position eleven -> valid' do
|
30
|
+
# /valid/wildCombination_validIndex.json
|
31
|
+
expect(parser.marc_spec).to parse('...[10]', trace: true, reporter: reporter)
|
32
|
+
end
|
33
|
+
|
34
|
+
it 'position ten -> valid' do
|
35
|
+
# /valid/wildCombination_validIndex.json
|
36
|
+
expect(parser.marc_spec).to parse('...[9]', trace: true, reporter: reporter)
|
37
|
+
end
|
38
|
+
|
39
|
+
it 'range from first position to first position, is like first position -> valid' do
|
40
|
+
# /valid/wildCombination_validIndex.json
|
41
|
+
expect(parser.marc_spec).to parse('...[0-0]', trace: true, reporter: reporter)
|
42
|
+
end
|
43
|
+
|
44
|
+
it 'range from first position to last -> valid' do
|
45
|
+
# /valid/wildCombination_validIndex.json
|
46
|
+
expect(parser.marc_spec).to parse('...[0-#]', trace: true, reporter: reporter)
|
47
|
+
end
|
48
|
+
|
49
|
+
it 'range from first position to second -> valid' do
|
50
|
+
# /valid/wildCombination_validIndex.json
|
51
|
+
expect(parser.marc_spec).to parse('...[0-1]', trace: true, reporter: reporter)
|
52
|
+
end
|
53
|
+
|
54
|
+
it 'range from last position to last position, is like last position -> valid' do
|
55
|
+
# /valid/wildCombination_validIndex.json
|
56
|
+
expect(parser.marc_spec).to parse('...[#-#]', trace: true, reporter: reporter)
|
57
|
+
end
|
58
|
+
|
59
|
+
it 'range from last position to position one (index reverted), is like last position -> valid' do
|
60
|
+
# /valid/wildCombination_validIndex.json
|
61
|
+
expect(parser.marc_spec).to parse('...[#-0]', trace: true, reporter: reporter)
|
62
|
+
end
|
63
|
+
|
64
|
+
it 'range from last position to position two (index reverted) -> valid' do
|
65
|
+
# /valid/wildCombination_validIndex.json
|
66
|
+
expect(parser.marc_spec).to parse('...[#-1]', trace: true, reporter: reporter)
|
67
|
+
end
|
68
|
+
|
69
|
+
end
|
70
|
+
describe 'marc_spec: valid field tag and invalid index' do
|
71
|
+
# /invalid/wildCombination_invalidIndex.json
|
72
|
+
it 'empty string -> invalid' do
|
73
|
+
# /invalid/wildCombination_invalidIndex.json
|
74
|
+
expect(parser.marc_spec).not_to parse('...[]', trace: true, reporter: reporter)
|
75
|
+
end
|
76
|
+
|
77
|
+
it 'missing ending position -> invalid' do
|
78
|
+
# /invalid/wildCombination_invalidIndex.json
|
79
|
+
expect(parser.marc_spec).not_to parse('...[#-]', trace: true, reporter: reporter)
|
80
|
+
end
|
81
|
+
|
82
|
+
it 'missing starting position -> invalid' do
|
83
|
+
# /invalid/wildCombination_invalidIndex.json
|
84
|
+
expect(parser.marc_spec).not_to parse('...[-2]', trace: true, reporter: reporter)
|
85
|
+
end
|
86
|
+
|
87
|
+
it "only digits, one hyphen and the char '#' are allowed -> invalid" do
|
88
|
+
# /invalid/wildCombination_invalidIndex.json
|
89
|
+
expect(parser.marc_spec).not_to parse('...[1-X]', trace: true, reporter: reporter)
|
90
|
+
expect(parser.marc_spec).not_to parse('...[?]', trace: true, reporter: reporter)
|
91
|
+
end
|
92
|
+
|
93
|
+
it 'only one hyphen allwed -> invalid' do
|
94
|
+
# /invalid/wildCombination_invalidIndex.json
|
95
|
+
expect(parser.marc_spec).not_to parse('...[1-2-]', trace: true, reporter: reporter)
|
96
|
+
end
|
97
|
+
|
98
|
+
it 'this matches pattern, but starting position number must not be higher than ending position number -> invalid' do
|
99
|
+
# /invalid/wildCombination_invalidIndex.json
|
100
|
+
expect(parser.marc_spec).not_to parse('...[2-1]', trace: true, reporter: reporter)
|
101
|
+
end
|
102
|
+
|
103
|
+
it 'whitespace is not allowed -> invalid' do
|
104
|
+
# /invalid/wildCombination_invalidIndex.json
|
105
|
+
expect(parser.marc_spec).not_to parse('...[1- 2]', trace: true, reporter: reporter)
|
106
|
+
end
|
107
|
+
|
108
|
+
end
|
109
|
+
end
|
110
|
+
end
|
111
|
+
end
|
112
|
+
end
|
113
|
+
end
|