cff 0.9.0 → 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/lib/cff/reference.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # Copyright (c) 2018-2021 The Ruby Citation File Format Developers.
3
+ # Copyright (c) 2018-2022 The Ruby Citation File Format Developers.
4
4
  #
5
5
  # Licensed under the Apache License, Version 2.0 (the "License");
6
6
  # you may not use this file except in compliance with the License.
@@ -14,9 +14,13 @@
14
14
  # See the License for the specific language governing permissions and
15
15
  # limitations under the License.
16
16
 
17
+ require_relative 'licensable'
18
+ require_relative 'model_part'
19
+ require_relative 'schema'
20
+ require_relative 'util'
21
+
17
22
  ##
18
23
  module CFF
19
-
20
24
  # Reference provides a reference pertaining to the software version or the
21
25
  # software itself, e.g., a software paper describing the abstract concepts of
22
26
  # the software, a paper describing an algorithm that has been implemented in
@@ -74,12 +78,13 @@ module CFF
74
78
  # * `pmcid`
75
79
  # * `publisher`
76
80
  # * `repository`
77
- # * `repository_code`
78
81
  # * `repository_artifact`
82
+ # * `repository_code`
79
83
  # * `scope`
80
84
  # * `section`
81
85
  # * `start`
82
86
  # * `status` - *Note:* see documentation for `status =` below
87
+ # * `term`
83
88
  # * `thesis_type`
84
89
  # * `title`
85
90
  # * `type` - *Note:* see documentation for `type =` below
@@ -90,44 +95,24 @@ module CFF
90
95
  # * `year`
91
96
  # * `year_original`
92
97
  class Reference < ModelPart
93
-
94
98
  include Licensable
95
99
 
96
- ALLOWED_FIELDS = [
97
- 'abbreviation', 'abstract', 'authors', 'collection-doi',
98
- 'collection-title', 'collection-type', 'commit', 'conference', 'contact',
99
- 'copyright', 'data-type', 'database', 'database-provider',
100
- 'date-accessed', 'date-downloaded', 'date-published', 'date-released',
101
- 'department', 'doi', 'edition', 'editors', 'editors-series', 'end',
102
- 'entry', 'filename', 'identifiers', 'institution', 'isbn', 'issn',
103
- 'issue', 'issue-date', 'issue-title', 'journal', 'keywords', 'license',
104
- 'license-url', 'loc-end', 'loc-start', 'location', 'medium', 'month',
105
- 'nihmsid', 'notes', 'number', 'number-volumes', 'pages', 'patent-states',
106
- 'pmcid', 'publisher', 'recipients', 'repository', 'repository-code',
107
- 'repository-artifact', 'scope', 'section', 'senders', 'start', 'status',
108
- 'thesis-type', 'title', 'translators', 'type', 'url', 'version',
109
- 'volume', 'volume-title', 'year', 'year-original'
110
- ].freeze # :nodoc:
111
-
112
- # The [defined set of reference types](https://github.com/citation-file-format/citation-file-format#reference-types).
113
- REFERENCE_TYPES = [
114
- 'art', 'article', 'audiovisual', 'bill', 'blog', 'book', 'catalogue',
115
- 'conference', 'conference-paper', 'data', 'database', 'dictionary',
116
- 'edited-work', 'encyclopedia', 'film-broadcast', 'generic',
117
- 'government-document', 'grant', 'hearing', 'historical-work',
118
- 'legal-case', 'legal-rule', 'magazine-article', 'manual', 'map',
119
- 'multimedia', 'music', 'newspaper-article', 'pamphlet', 'patent',
120
- 'personal-communication', 'proceedings', 'report', 'serial', 'slides',
121
- 'software', 'software-code', 'software-container', 'software-executable',
122
- 'software-virtual-machine', 'sound-recording', 'standard', 'statute',
123
- 'thesis', 'unpublished', 'video', 'website'
124
- ].freeze
125
-
126
- # The [defined set of reference status types](https://github.com/citation-file-format/citation-file-format#status-strings).
127
- REFERENCE_STATUS_TYPES = [
128
- 'abstract', 'advance-online', 'in-preparation', 'in-press',
129
- 'pre-print', 'submitted'
130
- ].freeze
100
+ # This list does not include `format` for reasons explained below, where
101
+ # the `format` method is defined!
102
+ ALLOWED_FIELDS = (
103
+ SCHEMA_FILE['definitions']['reference']['properties'].keys - %w[format languages]
104
+ ).freeze # :nodoc:
105
+
106
+ # The [defined set of reference types](https://github.com/citation-file-format/citation-file-format/blob/main/schema-guide.md#definitionsreferencetype).
107
+ REFERENCE_TYPES =
108
+ SCHEMA_FILE['definitions']['reference']['properties']['type']['enum'].dup.freeze
109
+
110
+ # The [defined set of reference status types](https://github.com/citation-file-format/citation-file-format/blob/main/schema-guide.md#definitionsreferencestatus).
111
+ REFERENCE_STATUS_TYPES =
112
+ SCHEMA_FILE['definitions']['reference']['properties']['status']['enum'].dup.freeze
113
+
114
+ attr_date :date_accessed, :date_downloaded, :date_published,
115
+ :date_released, :issue_date
131
116
 
132
117
  # :call-seq:
133
118
  # new(title) -> Reference
@@ -137,24 +122,25 @@ module CFF
137
122
  #
138
123
  # Create a new Reference with the supplied title and, optionally, type.
139
124
  # If type is not given, or is not one of the
140
- # [defined set of reference types](https://github.com/citation-file-format/citation-file-format#reference-types),
125
+ # [defined set of reference types](https://github.com/citation-file-format/citation-file-format/blob/main/schema-guide.md#definitionsreferencetype),
141
126
  # 'generic' will be used by default.
142
- def initialize(param, *more) # rubocop:disable Metrics/AbcSize
127
+ def initialize(param, *more) # rubocop:disable Metrics
128
+ super()
129
+
143
130
  if param.is_a?(Hash)
144
131
  @fields = build_model(param)
145
- @fields.default = ''
146
132
  else
147
- @fields = Hash.new('')
133
+ @fields = {}
148
134
  type = more[0] &&= more[0].downcase
149
135
  @fields['type'] = REFERENCE_TYPES.include?(type) ? type : 'generic'
150
136
  @fields['title'] = param
151
137
  end
152
138
 
153
- [
154
- 'authors', 'contact', 'editors', 'editors-series', 'identifiers',
155
- 'keywords', 'patent-states', 'recipients', 'senders', 'translators'
139
+ %w[
140
+ authors contact editors editors-series identifiers
141
+ keywords patent-states recipients senders translators
156
142
  ].each do |field|
157
- @fields[field] = [] if @fields[field].empty?
143
+ @fields[field] = [] if @fields[field].nil? || @fields[field].empty?
158
144
  end
159
145
 
160
146
  yield self if block_given?
@@ -162,9 +148,9 @@ module CFF
162
148
 
163
149
  # :call-seq:
164
150
  # from_cff(File, type: 'software') -> Reference
165
- # from_cff(Model, type: 'software') -> Reference
151
+ # from_cff(Index, type: 'software') -> Reference
166
152
  #
167
- # Create a Reference from another CFF File or Model. This is useful for
153
+ # Create a Reference from another CFF File or Index. This is useful for
168
154
  # easily adding a reference to something with its own CITATION.cff file
169
155
  # already.
170
156
  #
@@ -190,12 +176,13 @@ module CFF
190
176
  # three letter language code, so `GER` becomes `deu`, `french` becomes
191
177
  # `fra` and `en` becomes `eng`.
192
178
  def add_language(lang)
193
- @fields['languages'] = [] if @fields['languages'].empty?
179
+ require 'language_list'
180
+ @fields['languages'] = [] if @fields['languages'].nil? || @fields['languages'].empty?
194
181
  lang = LanguageList::LanguageInfo.find(lang)
195
182
  return if lang.nil?
196
183
 
197
184
  lang = lang.iso_639_3
198
- @fields['languages'] << lang unless @fields['languages'].include? lang
185
+ @fields['languages'] << lang unless @fields['languages'].include?(lang)
199
186
  end
200
187
 
201
188
  # :call-seq:
@@ -211,51 +198,7 @@ module CFF
211
198
  #
212
199
  # Return the list of languages associated with this Reference.
213
200
  def languages
214
- @fields['languages'].empty? ? [] : @fields['languages'].dup
215
- end
216
-
217
- # :call-seq:
218
- # date_accessed = date
219
- #
220
- # Set the `date-accessed` field. If a non-Date object is passed in it will
221
- # be parsed into a Date.
222
- def date_accessed=(date)
223
- date = Date.parse(date) unless date.is_a?(Date)
224
-
225
- @fields['date-accessed'] = date
226
- end
227
-
228
- # :call-seq:
229
- # date_downloaded = date
230
- #
231
- # Set the `date-downloaded` field. If a non-Date object is passed in it will
232
- # be parsed into a Date.
233
- def date_downloaded=(date)
234
- date = Date.parse(date) unless date.is_a?(Date)
235
-
236
- @fields['date-downloaded'] = date
237
- end
238
-
239
- # :call-seq:
240
- # date_published = date
241
- #
242
- # Set the `date-published` field. If a non-Date object is passed in it will
243
- # be parsed into a Date.
244
- def date_published=(date)
245
- date = Date.parse(date) unless date.is_a?(Date)
246
-
247
- @fields['date-published'] = date
248
- end
249
-
250
- # :call-seq:
251
- # date_released = date
252
- #
253
- # Set the `date-released` field. If a non-Date object is passed in it will
254
- # be parsed into a Date.
255
- def date_released=(date)
256
- date = Date.parse(date) unless date.is_a?(Date)
257
-
258
- @fields['date-released'] = date
201
+ @fields['languages'].nil? || @fields['languages'].empty? ? [] : @fields['languages'].dup
259
202
  end
260
203
 
261
204
  # Returns the format of this Reference.
@@ -263,7 +206,7 @@ module CFF
263
206
  # This method is explicitly defined to override the private format method
264
207
  # that all objects seem to have.
265
208
  def format # :nodoc:
266
- @fields['format']
209
+ @fields['format'].nil? ? '' : @fields['format']
267
210
  end
268
211
 
269
212
  # Sets the format of this Reference.
@@ -278,7 +221,7 @@ module CFF
278
221
  # status = status
279
222
  #
280
223
  # Sets the status of this Reference. The status is restricted to a
281
- # [defined set of status types](https://github.com/citation-file-format/citation-file-format#status-strings).
224
+ # [defined set of status types](https://github.com/citation-file-format/citation-file-format/blob/main/schema-guide.md#definitionsreferencestatus).
282
225
  def status=(status)
283
226
  status = status.downcase
284
227
  @fields['status'] = status if REFERENCE_STATUS_TYPES.include?(status)
@@ -288,7 +231,7 @@ module CFF
288
231
  # type = type
289
232
  #
290
233
  # Sets the type of this Reference. The type is restricted to a
291
- # [defined set of reference types](https://github.com/citation-file-format/citation-file-format#reference-types).
234
+ # [defined set of reference types](https://github.com/citation-file-format/citation-file-format/blob/main/schema-guide.md#definitionsreferencetype).
292
235
  def type=(type)
293
236
  type = type.downcase
294
237
  @fields['type'] = type if REFERENCE_TYPES.include?(type)
@@ -296,29 +239,27 @@ module CFF
296
239
 
297
240
  # Override superclass #fields as References contain model parts too.
298
241
  def fields # :nodoc:
299
- [
300
- 'authors', 'contact', 'editors', 'editors-series', 'identifiers',
301
- 'recipients', 'senders', 'translators'
242
+ %w[
243
+ authors contact editors editors-series identifiers
244
+ recipients senders translators
302
245
  ].each do |field|
303
- normalize_modelpart_array!(@fields[field])
246
+ Util.normalize_modelpart_array!(@fields[field])
304
247
  end
305
248
 
306
- fields_to_hash(@fields)
249
+ Util.fields_to_hash(@fields)
307
250
  end
308
251
 
309
252
  private
310
253
 
311
254
  def build_model(fields) # :nodoc:
312
- [
313
- 'authors', 'contact', 'editors', 'editors-series', 'recipients',
314
- 'senders', 'translators'
255
+ %w[
256
+ authors contact editors editors-series recipients senders translators
315
257
  ].each do |field|
316
- build_actor_collection!(fields[field]) if fields.include?(field)
258
+ Util.build_actor_collection!(fields[field]) if fields.include?(field)
317
259
  end
318
260
 
319
- [
320
- 'conference', 'database-provider', 'institution', 'location',
321
- 'publisher'
261
+ %w[
262
+ conference database-provider institution location publisher
322
263
  ].each do |field|
323
264
  fields[field] &&= Entity.new(fields[field])
324
265
  end
@@ -436,7 +377,7 @@ module CFF
436
377
  # the list, use:
437
378
  #
438
379
  # ```
439
- # model.identifiers << identifier
380
+ # reference.identifiers << identifier
440
381
  # ```
441
382
 
442
383
  ##
@@ -455,7 +396,7 @@ module CFF
455
396
  # list, use:
456
397
  #
457
398
  # ```
458
- # model.keywords << keyword
399
+ # reference.keywords << keyword
459
400
  # ```
460
401
  #
461
402
  # Keywords will be converted to Strings on output.
@@ -478,7 +419,7 @@ module CFF
478
419
  # state to the list, use:
479
420
  #
480
421
  # ```
481
- # model.patent_states << patent_state
422
+ # reference.patent_states << patent_state
482
423
  # ```
483
424
  #
484
425
  # Patent states will be converted to Strings on output.
data/lib/cff/schema.rb ADDED
@@ -0,0 +1,23 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Copyright (c) 2018-2022 The Ruby Citation File Format Developers.
4
+ #
5
+ # Licensed under the Apache License, Version 2.0 (the "License");
6
+ # you may not use this file except in compliance with the License.
7
+ # You may obtain a copy of the License at
8
+ #
9
+ # http://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing, software
12
+ # distributed under the License is distributed on an "AS IS" BASIS,
13
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ # See the License for the specific language governing permissions and
15
+ # limitations under the License.
16
+
17
+ require 'json'
18
+
19
+ ##
20
+ module CFF
21
+ SCHEMA_PATH = ::File.join(__dir__, 'schemas', '1.2.0.json') # :nodoc:
22
+ SCHEMA_FILE = JSON.parse(::File.read(SCHEMA_PATH)) # :nodoc:
23
+ end
File without changes
data/lib/cff/util.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # Copyright (c) 2018-2021 The Ruby Citation File Format Developers.
3
+ # Copyright (c) 2018-2022 The Ruby Citation File Format Developers.
4
4
  #
5
5
  # Licensed under the Apache License, Version 2.0 (the "License");
6
6
  # you may not use this file except in compliance with the License.
@@ -14,17 +14,22 @@
14
14
  # See the License for the specific language governing permissions and
15
15
  # limitations under the License.
16
16
 
17
+ require_relative 'entity'
18
+ require_relative 'person'
19
+ require_relative 'version'
20
+
17
21
  require 'rubygems'
18
22
 
19
23
  ##
20
24
  module CFF
21
-
22
25
  # Util provides utility methods useful throughout the rest of the CFF library.
23
26
  #
24
27
  # Util does not provide any methods or fields for the public API.
25
28
  module Util
26
29
  # :stopdoc:
27
30
 
31
+ module_function
32
+
28
33
  def update_cff_version(version)
29
34
  return '' if version.nil? || version.empty?
30
35
 
@@ -35,13 +40,11 @@ module CFF
35
40
  end
36
41
  end
37
42
 
38
- def method_to_field(name)
39
- name.tr('_', '-')
40
- end
41
-
43
+ # Currently need to make some sort of guess as to whether an actor
44
+ # is a Person or Entity. This isn't perfect, but works 99.99% I think.
42
45
  def build_actor_collection!(source)
43
46
  source.map! do |s|
44
- s.has_key?('given-names') ? Person.new(s) : Entity.new(s)
47
+ s.has_key?('name') ? Entity.new(s) : Person.new(s)
45
48
  end
46
49
  end
47
50
 
@@ -67,6 +70,62 @@ module CFF
67
70
  hash
68
71
  end
69
72
 
73
+ DEFAULT_CHAR_APPROXIMATIONS = {
74
+ 'À' => 'A', 'Á' => 'A', 'Â' => 'A', 'Ã' => 'A', 'Ä' => 'A', 'Å' => 'A',
75
+ 'Æ' => 'AE', 'Ç' => 'C', 'È' => 'E', 'É' => 'E', 'Ê' => 'E', 'Ë' => 'E',
76
+ 'Ì' => 'I', 'Í' => 'I', 'Î' => 'I', 'Ï' => 'I', 'Ð' => 'D', 'Ñ' => 'N',
77
+ 'Ò' => 'O', 'Ó' => 'O', 'Ô' => 'O', 'Õ' => 'O', 'Ö' => 'O', '×' => 'x',
78
+ 'Ø' => 'O', 'Ù' => 'U', 'Ú' => 'U', 'Û' => 'U', 'Ü' => 'U', 'Ý' => 'Y',
79
+ 'Þ' => 'Th', 'ß' => 'ss', 'à' => 'a', 'á' => 'a', 'â' => 'a',
80
+ 'ã' => 'a', 'ä' => 'a', 'å' => 'a', 'æ' => 'ae', 'ç' => 'c', 'è' => 'e',
81
+ 'é' => 'e', 'ê' => 'e', 'ë' => 'e', 'ì' => 'i', 'í' => 'i', 'î' => 'i',
82
+ 'ï' => 'i', 'ð' => 'd', 'ñ' => 'n', 'ò' => 'o', 'ó' => 'o', 'ô' => 'o',
83
+ 'õ' => 'o', 'ö' => 'o', 'ø' => 'o', 'ù' => 'u', 'ú' => 'u', 'û' => 'u',
84
+ 'ü' => 'u', 'ý' => 'y', 'þ' => 'th', 'ÿ' => 'y', 'Ā' => 'A', 'ā' => 'a',
85
+ 'Ă' => 'A', 'ă' => 'a', 'Ą' => 'A', 'ą' => 'a', 'Ć' => 'C', 'ć' => 'c',
86
+ 'Ĉ' => 'C', 'ĉ' => 'c', 'Ċ' => 'C', 'ċ' => 'c', 'Č' => 'C', 'č' => 'c',
87
+ 'Ď' => 'D', 'ď' => 'd', 'Đ' => 'D', 'đ' => 'd', 'Ē' => 'E', 'ē' => 'e',
88
+ 'Ĕ' => 'E', 'ĕ' => 'e', 'Ė' => 'E', 'ė' => 'e', 'Ę' => 'E', 'ę' => 'e',
89
+ 'Ě' => 'E', 'ě' => 'e', 'ệ' => 'e', 'Ĝ' => 'G', 'ĝ' => 'g', 'Ğ' => 'G',
90
+ 'ğ' => 'g', 'Ġ' => 'G', 'ġ' => 'g', 'Ģ' => 'G', 'ģ' => 'g', 'Ĥ' => 'H',
91
+ 'ĥ' => 'h', 'Ħ' => 'H', 'ħ' => 'h', 'Ĩ' => 'I', 'ĩ' => 'i', 'Ī' => 'I',
92
+ 'ī' => 'i', 'Ĭ' => 'I', 'ĭ' => 'i', 'Į' => 'I', 'į' => 'i', 'İ' => 'I',
93
+ 'ı' => 'i', 'IJ' => 'IJ', 'ij' => 'ij', 'Ĵ' => 'J', 'ĵ' => 'j',
94
+ 'Ķ' => 'K', 'ķ' => 'k', 'ĸ' => 'k', 'Ĺ' => 'L', 'ĺ' => 'l', 'Ļ' => 'L',
95
+ 'ļ' => 'l', 'Ľ' => 'L', 'ľ' => 'l', 'Ŀ' => 'L', 'ŀ' => 'l', 'Ł' => 'L',
96
+ 'ł' => 'l', 'Ń' => 'N', 'ń' => 'n', 'Ņ' => 'N', 'ņ' => 'n', 'Ň' => 'N',
97
+ 'ň' => 'n', 'ʼn' => "'n", 'Ŋ' => 'NG', 'ŋ' => 'ng', 'Ō' => 'O',
98
+ 'ō' => 'o', 'Ŏ' => 'O', 'ŏ' => 'o', 'Ő' => 'O', 'ő' => 'o', 'Œ' => 'OE',
99
+ 'œ' => 'oe', 'Ŕ' => 'R', 'ŕ' => 'r', 'Ŗ' => 'R', 'ŗ' => 'r', 'Ř' => 'R',
100
+ 'ř' => 'r', 'Ś' => 'S', 'ś' => 's', 'Ŝ' => 'S', 'ŝ' => 's', 'Ş' => 'S',
101
+ 'ş' => 's', 'Š' => 'S', 'š' => 's', 'Ţ' => 'T', 'ţ' => 't', 'Ť' => 'T',
102
+ 'ť' => 't', 'Ŧ' => 'T', 'ŧ' => 't', 'Ũ' => 'U', 'ũ' => 'u', 'Ū' => 'U',
103
+ 'ū' => 'u', 'Ŭ' => 'U', 'ŭ' => 'u', 'Ů' => 'U', 'ů' => 'u', 'Ű' => 'U',
104
+ 'ű' => 'u', 'Ų' => 'U', 'ų' => 'u', 'Ŵ' => 'W', 'ŵ' => 'w', 'Ŷ' => 'Y',
105
+ 'ŷ' => 'y', 'Ÿ' => 'Y', 'Ź' => 'Z', 'ź' => 'z', 'Ż' => 'Z', 'ż' => 'z',
106
+ 'Ž' => 'Z', 'ž' => 'z'
107
+ }.freeze
108
+
109
+ def transliterate(string, fallback: '')
110
+ string.gsub(/[^\x00-\x7f]/u) do |char|
111
+ DEFAULT_CHAR_APPROXIMATIONS[char] || fallback
112
+ end
113
+ end
114
+
115
+ def parameterize(string, separator: '_')
116
+ # Normalize into ASCII.
117
+ param = transliterate(string)
118
+
119
+ # Remove unwanted chars by turning them into the separator.
120
+ param.gsub!(/[^a-z0-9\-_]+/i, separator)
121
+
122
+ # Only one separator at a time.
123
+ param.gsub!(/#{separator}{2,}/, separator)
124
+
125
+ # No leading/trailing separators.
126
+ param.gsub(/^#{separator}|#{separator}$/i, '')
127
+ end
128
+
70
129
  # :startdoc:
71
130
  end
72
131
  end
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # Copyright (c) 2018-2021 The Ruby Citation File Format Developers.
3
+ # Copyright (c) 2018-2022 The Ruby Citation File Format Developers.
4
4
  #
5
5
  # Licensed under the Apache License, Version 2.0 (the "License");
6
6
  # you may not use this file except in compliance with the License.
@@ -14,24 +14,25 @@
14
14
  # See the License for the specific language governing permissions and
15
15
  # limitations under the License.
16
16
 
17
+ require_relative 'errors'
18
+ require_relative 'schema'
19
+
17
20
  require 'json_schema'
18
21
 
19
22
  ##
20
23
  module CFF
21
-
22
24
  # Methods to validate CFF files/models against a formal schema.
23
25
  module Validatable
24
-
25
26
  SCHEMA = JsonSchema.parse!(SCHEMA_FILE) # :nodoc:
26
27
 
27
28
  # :call-seq:
28
29
  # validate!(fail_fast: false)
29
30
  #
30
- # Validate a CFF file or model and raise a ValidationError upon failure.
31
- # If an error is raised it will contain the detected validation failures
32
- # for further inspection. Setting `fail_fast` to true will fail validation
33
- # at the first detected failure, rather than gathering and returning all
34
- # failures.
31
+ # Validate a CFF file or model (Index) and raise a ValidationError upon
32
+ # failure. If an error is raised it will contain the detected validation
33
+ # failures for further inspection. Setting `fail_fast` to true will fail
34
+ # validation at the first detected failure, rather than gathering and
35
+ # returning all failures.
35
36
  def validate!(fail_fast: false)
36
37
  result = validate(fail_fast: fail_fast)
37
38
  return if result[0]
@@ -42,9 +43,9 @@ module CFF
42
43
  # :call-seq:
43
44
  # validate(fail_fast: false) -> Array
44
45
  #
45
- # Validate a CFF file or model and return an array with the result. The
46
- # result array is a two-element array, with `true`/`false` at index 0 to
47
- # indicate pass/fail, and an array of errors at index 1 (if any).
46
+ # Validate a CFF file or model (Index) and return an array with the result.
47
+ # The result array is a two-element array, with `true`/`false` at index 0
48
+ # to indicate pass/fail, and an array of errors at index 1 (if any).
48
49
  # Setting `fail_fast` to true will fail validation at the first detected
49
50
  # failure, rather than gathering and returning all failures.
50
51
  def validate(fail_fast: false)
data/lib/cff/version.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # Copyright (c) 2018-2021 The Ruby Citation File Format Developers.
3
+ # Copyright (c) 2018-2022 The Ruby Citation File Format Developers.
4
4
  #
5
5
  # Licensed under the Apache License, Version 2.0 (the "License");
6
6
  # you may not use this file except in compliance with the License.
@@ -17,7 +17,7 @@
17
17
  ##
18
18
  module CFF
19
19
  # :nodoc:
20
- VERSION = '0.9.0'
20
+ VERSION = '1.0.1'
21
21
  DEFAULT_SPEC_VERSION = '1.2.0'
22
22
  MIN_VALIDATABLE_VERSION = '1.2.0'
23
23
  end
data/lib/cff.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # Copyright (c) 2018-2021 The Ruby Citation File Format Developers.
3
+ # Copyright (c) 2018-2022 The Ruby Citation File Format Developers.
4
4
  #
5
5
  # Licensed under the Apache License, Version 2.0 (the "License");
6
6
  # you may not use this file except in compliance with the License.
@@ -14,34 +14,11 @@
14
14
  # See the License for the specific language governing permissions and
15
15
  # limitations under the License.
16
16
 
17
- require 'date'
18
- require 'json'
19
- require 'yaml'
20
-
21
- require 'language_list'
22
-
23
17
  # This library provides a Ruby interface to manipulate CITATION.cff files. The
24
- # primary entry points are Model and File.
18
+ # primary entry points are Index and File.
25
19
  #
26
20
  # See the [CITATION.cff documentation](https://citation-file-format.github.io/)
27
21
  # for more details.
28
- module CFF
29
- SCHEMA_PATH = ::File.join(__dir__, 'schema', '1.2.0.json') # :nodoc:
30
- SCHEMA_FILE = JSON.parse(::File.read(SCHEMA_PATH)) # :nodoc:
31
- end
22
+ module CFF; end
32
23
 
33
- require 'cff/version'
34
- require 'cff/errors'
35
- require 'cff/util'
36
- require 'cff/licensable'
37
- require 'cff/validatable'
38
- require 'cff/model_part'
39
- require 'cff/person'
40
- require 'cff/entity'
41
- require 'cff/identifier'
42
- require 'cff/reference'
43
- require 'cff/model'
44
- require 'cff/file'
45
- require 'cff/formatter/formatter'
46
- require 'cff/formatter/apa_formatter'
47
- require 'cff/formatter/bibtex_formatter'
24
+ require_relative 'cff/file'