loc_mods 0.2.3 → 0.2.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +2 -0
- data/.rubocop_todo.yml +83 -0
- data/README.adoc +48 -6
- data/lib/loc_mods/abstract.rb +9 -9
- data/lib/loc_mods/access_condition.rb +11 -11
- data/lib/loc_mods/alternative_name.rb +10 -10
- data/lib/loc_mods/area.rb +3 -3
- data/lib/loc_mods/cartographic_extension.rb +4 -4
- data/lib/loc_mods/cartographics.rb +8 -8
- data/lib/loc_mods/city_section.rb +3 -3
- data/lib/loc_mods/classification.rb +8 -8
- data/lib/loc_mods/cli.rb +48 -80
- data/lib/loc_mods/collection.rb +3 -3
- data/lib/loc_mods/copy_information.rb +5 -5
- data/lib/loc_mods/date.rb +8 -8
- data/lib/loc_mods/date_other.rb +4 -4
- data/lib/loc_mods/detail.rb +7 -7
- data/lib/loc_mods/edition.rb +4 -4
- data/lib/loc_mods/enumeration_and_chronology.rb +4 -4
- data/lib/loc_mods/extent.rb +4 -4
- data/lib/loc_mods/extent_definition.rb +7 -7
- data/lib/loc_mods/form.rb +5 -5
- data/lib/loc_mods/genre.rb +8 -8
- data/lib/loc_mods/geographic_code.rb +6 -6
- data/lib/loc_mods/hierarchical_geographic.rb +6 -6
- data/lib/loc_mods/hierarchical_part.rb +8 -8
- data/lib/loc_mods/holding_simple.rb +2 -2
- data/lib/loc_mods/identifier.rb +8 -8
- data/lib/loc_mods/item_identifier.rb +4 -4
- data/lib/loc_mods/language.rb +9 -9
- data/lib/loc_mods/language_term.rb +7 -7
- data/lib/loc_mods/location.rb +8 -8
- data/lib/loc_mods/name.rb +19 -19
- data/lib/loc_mods/name_part.rb +4 -4
- data/lib/loc_mods/non_sort.rb +4 -4
- data/lib/loc_mods/note.rb +7 -7
- data/lib/loc_mods/occupation.rb +6 -6
- data/lib/loc_mods/origin_info.rb +10 -10
- data/lib/loc_mods/part.rb +10 -10
- data/lib/loc_mods/physical_description.rb +10 -10
- data/lib/loc_mods/physical_description_note.rb +7 -7
- data/lib/loc_mods/physical_location.rb +5 -5
- data/lib/loc_mods/place.rb +3 -3
- data/lib/loc_mods/place_term.rb +7 -7
- data/lib/loc_mods/publisher.rb +6 -6
- data/lib/loc_mods/record.rb +4 -4
- data/lib/loc_mods/record_content_source.rb +4 -4
- data/lib/loc_mods/record_identifier.rb +4 -4
- data/lib/loc_mods/record_info.rb +9 -9
- data/lib/loc_mods/record_info_note.rb +8 -8
- data/lib/loc_mods/region.rb +3 -3
- data/lib/loc_mods/related_item.rb +10 -10
- data/lib/loc_mods/role.rb +2 -2
- data/lib/loc_mods/role_term.rb +4 -4
- data/lib/loc_mods/script_term.rb +4 -4
- data/lib/loc_mods/string_plus_language.rb +6 -6
- data/lib/loc_mods/string_plus_language_plus_authority.rb +6 -6
- data/lib/loc_mods/string_plus_language_plus_supplied.rb +4 -4
- data/lib/loc_mods/subject.rb +15 -15
- data/lib/loc_mods/subject_name.rb +14 -14
- data/lib/loc_mods/subject_title_info.rb +16 -16
- data/lib/loc_mods/table_of_contents.rb +9 -9
- data/lib/loc_mods/target_audience.rb +5 -5
- data/lib/loc_mods/temporal.rb +5 -5
- data/lib/loc_mods/text.rb +5 -5
- data/lib/loc_mods/title_info.rb +22 -22
- data/lib/loc_mods/type_of_resource.rb +8 -8
- data/lib/loc_mods/url.rb +8 -8
- data/lib/loc_mods/version.rb +1 -1
- data/lib/loc_mods.rb +7 -6
- data/references/allrecords-MODS.xml +1 -1
- metadata +5 -6
- data/lib/loc_mods/base_mapper.rb +0 -26
- data/lib/loc_mods/comparable_mapper.rb +0 -110
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a2a4762188e137e5ea3515cbff8dcbfa6e2749c7eb1ca4921d230e20c2c066db
|
4
|
+
data.tar.gz: a510dd995107ef4b33dabcc0c8e9658948e3c4d7474d50fd2cbd8d2eaf1b7e31
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 410d05bac6bde6ad26693359a2331c7b93ba4abcdabed33ad51f3f25dd9c08491be258ff0c9c2f4752f9b323cfd9b60102193af4535d30e92b7297679892439a
|
7
|
+
data.tar.gz: a70f2deb4dff1d8fd8f119e2d78b40330444caffa5f3d47fc6939ba51241a47fcbaf47eda8a64f35b002d7c7660c7f9c97debceda0c9019e2d8c7a13870785e2
|
data/.rubocop.yml
CHANGED
data/.rubocop_todo.yml
ADDED
@@ -0,0 +1,83 @@
|
|
1
|
+
# This configuration was generated by
|
2
|
+
# `rubocop --auto-gen-config`
|
3
|
+
# on 2024-08-15 09:25:52 UTC using RuboCop version 1.65.1.
|
4
|
+
# The point is for the user to remove these configuration records
|
5
|
+
# one by one as the offenses are removed from the code base.
|
6
|
+
# Note that changes in the inspected code, or installation of new
|
7
|
+
# versions of RuboCop, may require this file to be generated again.
|
8
|
+
|
9
|
+
# Offense count: 1
|
10
|
+
# Configuration parameters: Severity, Include.
|
11
|
+
# Include: **/*.gemspec
|
12
|
+
Gemspec/RequiredRubyVersion:
|
13
|
+
Exclude:
|
14
|
+
- 'loc_mods.gemspec'
|
15
|
+
|
16
|
+
# Offense count: 4
|
17
|
+
# Configuration parameters: AllowedMethods.
|
18
|
+
# AllowedMethods: enums
|
19
|
+
Lint/ConstantDefinitionInBlock:
|
20
|
+
Exclude:
|
21
|
+
- 'spec/loc_mods/collection_spec.rb'
|
22
|
+
|
23
|
+
# Offense count: 8
|
24
|
+
# Configuration parameters: AllowedMethods, AllowedPatterns, CountRepeatedAttributes.
|
25
|
+
Metrics/AbcSize:
|
26
|
+
Max: 50
|
27
|
+
|
28
|
+
# Offense count: 2
|
29
|
+
# Configuration parameters: CountComments, CountAsOne, AllowedMethods, AllowedPatterns.
|
30
|
+
# AllowedMethods: refine
|
31
|
+
Metrics/BlockLength:
|
32
|
+
Max: 66
|
33
|
+
|
34
|
+
# Offense count: 1
|
35
|
+
# Configuration parameters: CountComments, CountAsOne.
|
36
|
+
Metrics/ClassLength:
|
37
|
+
Max: 253
|
38
|
+
|
39
|
+
# Offense count: 6
|
40
|
+
# Configuration parameters: AllowedMethods, AllowedPatterns.
|
41
|
+
Metrics/CyclomaticComplexity:
|
42
|
+
Max: 15
|
43
|
+
|
44
|
+
# Offense count: 10
|
45
|
+
# Configuration parameters: CountComments, CountAsOne, AllowedMethods, AllowedPatterns.
|
46
|
+
Metrics/MethodLength:
|
47
|
+
Max: 43
|
48
|
+
|
49
|
+
# Offense count: 5
|
50
|
+
# Configuration parameters: AllowedMethods, AllowedPatterns.
|
51
|
+
Metrics/PerceivedComplexity:
|
52
|
+
Max: 17
|
53
|
+
|
54
|
+
# Offense count: 1
|
55
|
+
# Configuration parameters: ForbiddenDelimiters.
|
56
|
+
# ForbiddenDelimiters: (?i-mx:(^|\s)(EO[A-Z]{1}|END)(\s|$))
|
57
|
+
Naming/HeredocDelimiterNaming:
|
58
|
+
Exclude:
|
59
|
+
- 'bin/update-nist-mods'
|
60
|
+
|
61
|
+
# Offense count: 1
|
62
|
+
Security/Open:
|
63
|
+
Exclude:
|
64
|
+
- 'bin/update-nist-mods'
|
65
|
+
|
66
|
+
# Offense count: 65
|
67
|
+
# Configuration parameters: AllowedConstants.
|
68
|
+
Style/Documentation:
|
69
|
+
Enabled: false
|
70
|
+
|
71
|
+
# Offense count: 1
|
72
|
+
# Configuration parameters: AllowedMethods.
|
73
|
+
# AllowedMethods: respond_to_missing?
|
74
|
+
Style/OptionalBooleanParameter:
|
75
|
+
Exclude:
|
76
|
+
- 'lib/loc_mods/comparable_mapper.rb'
|
77
|
+
|
78
|
+
# Offense count: 1
|
79
|
+
# This cop supports safe autocorrection (--autocorrect).
|
80
|
+
# Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, AllowedPatterns.
|
81
|
+
# URISchemes: http, https
|
82
|
+
Layout/LineLength:
|
83
|
+
Max: 126
|
data/README.adoc
CHANGED
@@ -28,15 +28,44 @@ LocMods::Collection.from_xml(File.read("reference/allrecords-MODS.xml"))
|
|
28
28
|
|
29
29
|
=== Command line interface
|
30
30
|
|
31
|
-
LocMods provides a command-line interface (CLI) for various operations.
|
32
|
-
|
31
|
+
LocMods provides a command-line interface (CLI) for various operations.
|
32
|
+
|
33
|
+
The main executable is `loc-mods`.
|
34
|
+
|
35
|
+
[source,shell]
|
36
|
+
----
|
37
|
+
Commands:
|
38
|
+
loc-mods detect-duplicates PATH... # Detect duplicate records in MODS XML files or directories
|
39
|
+
loc-mods help [COMMAND] # Describe available commands or one specific command
|
40
|
+
----
|
41
|
+
|
42
|
+
|
43
|
+
|
33
44
|
|
34
45
|
==== Detect duplicates
|
35
46
|
|
36
47
|
The `detect-duplicates` command allows you to find duplicate MODS records based
|
37
48
|
on using a "primary ID" that is their DOI (Digital Object Identifier).
|
38
49
|
|
50
|
+
NOTE: The library assumes that every record has a DOI. If that is not the case,
|
51
|
+
another way to setting the primary key needs to be defined.
|
52
|
+
|
53
|
+
Usage:
|
54
|
+
|
55
|
+
[source,shell]
|
56
|
+
----
|
39
57
|
Usage:
|
58
|
+
loc-mods detect-duplicates PATH...
|
59
|
+
|
60
|
+
Options:
|
61
|
+
[--show-unchanged], [--no-show-unchanged] # Show unchanged attributes in the diff output
|
62
|
+
# Default: false
|
63
|
+
[--highlight-diff], [--no-highlight-diff] # Highlight only the differences
|
64
|
+
# Default: false
|
65
|
+
[--color=COLOR] # Use colors in the diff output (auto, on, off)
|
66
|
+
# Default: auto
|
67
|
+
# Possible values: auto, on, off
|
68
|
+
----
|
40
69
|
|
41
70
|
[source,shell]
|
42
71
|
----
|
@@ -45,15 +74,28 @@ $ loc-mods detect-duplicates [OPTIONS] <file_or_directory_path>
|
|
45
74
|
|
46
75
|
Options:
|
47
76
|
|
48
|
-
|
49
|
-
|
50
|
-
|
77
|
+
`--show-unchanged`::
|
78
|
+
(default: `false`)
|
79
|
+
Show attributes of both objects even when they were not changed.
|
80
|
+
|
81
|
+
`--highlight-diff`::
|
82
|
+
(default: `false`)
|
83
|
+
Highlight values only when they differ between two records.
|
84
|
+
|
85
|
+
`--color=COLOR`::
|
86
|
+
(default: `auto`) Use colors in the diff output. Values:
|
87
|
+
|
88
|
+
`auto`::: the CLI will detect whether the terminal supports colors and display
|
89
|
+
with colors if it does.
|
90
|
+
`on`::: the CLI will always display with colors.
|
91
|
+
`off`::: the CLI will never display with colors.
|
92
|
+
|
51
93
|
|
52
94
|
Example:
|
53
95
|
|
54
96
|
[source,shell]
|
55
97
|
----
|
56
|
-
$ loc-mods detect-duplicates
|
98
|
+
$ loc-mods detect-duplicates /path/to/mods/files
|
57
99
|
----
|
58
100
|
|
59
101
|
This command will:
|
data/lib/loc_mods/abstract.rb
CHANGED
@@ -1,16 +1,16 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
|
3
|
+
require "lutaml/model"
|
4
4
|
|
5
5
|
module LocMods
|
6
|
-
class Abstract <
|
7
|
-
attribute :content,
|
8
|
-
attribute :display_label,
|
9
|
-
attribute :type,
|
10
|
-
attribute :shareable,
|
11
|
-
attribute :alt_rep_group,
|
12
|
-
attribute :alt_format,
|
13
|
-
attribute :content_type,
|
6
|
+
class Abstract < Lutaml::Model::Serializable
|
7
|
+
attribute :content, :string
|
8
|
+
attribute :display_label, :string
|
9
|
+
attribute :type, :string
|
10
|
+
attribute :shareable, :string
|
11
|
+
attribute :alt_rep_group, :string
|
12
|
+
attribute :alt_format, :string
|
13
|
+
attribute :content_type, :string
|
14
14
|
|
15
15
|
xml do
|
16
16
|
root "abstract"
|
@@ -1,18 +1,18 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
|
3
|
+
require "lutaml/model"
|
4
4
|
|
5
5
|
module LocMods
|
6
|
-
class AccessCondition <
|
7
|
-
attribute :content,
|
8
|
-
attribute :display_label,
|
9
|
-
attribute :lang,
|
10
|
-
attribute :script,
|
11
|
-
attribute :transliteration,
|
12
|
-
attribute :type,
|
13
|
-
attribute :alt_rep_group,
|
14
|
-
attribute :alt_format,
|
15
|
-
attribute :content_type,
|
6
|
+
class AccessCondition < Lutaml::Model::Serializable
|
7
|
+
attribute :content, :string
|
8
|
+
attribute :display_label, :string
|
9
|
+
attribute :lang, :string
|
10
|
+
attribute :script, :string
|
11
|
+
attribute :transliteration, :string
|
12
|
+
attribute :type, :string
|
13
|
+
attribute :alt_rep_group, :string
|
14
|
+
attribute :alt_format, :string
|
15
|
+
attribute :content_type, :string
|
16
16
|
|
17
17
|
xml do
|
18
18
|
root "accessCondition"
|
@@ -1,23 +1,23 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
|
3
|
+
require "lutaml/model"
|
4
4
|
|
5
5
|
require_relative "identifier"
|
6
6
|
require_relative "name_part"
|
7
7
|
require_relative "role"
|
8
8
|
|
9
9
|
module LocMods
|
10
|
-
class AlternativeName <
|
11
|
-
attribute :lang,
|
12
|
-
attribute :script,
|
13
|
-
attribute :transliteration,
|
14
|
-
attribute :display_label,
|
15
|
-
attribute :alt_type,
|
10
|
+
class AlternativeName < Lutaml::Model::Serializable
|
11
|
+
attribute :lang, :string
|
12
|
+
attribute :script, :string
|
13
|
+
attribute :transliteration, :string
|
14
|
+
attribute :display_label, :string
|
15
|
+
attribute :alt_type, :string
|
16
16
|
attribute :name_part, NamePart, collection: true
|
17
|
-
attribute :display_form,
|
18
|
-
attribute :affiliation,
|
17
|
+
attribute :display_form, :string, collection: true
|
18
|
+
attribute :affiliation, :string, collection: true
|
19
19
|
attribute :role, Role, collection: true
|
20
|
-
attribute :description,
|
20
|
+
attribute :description, :string, collection: true
|
21
21
|
attribute :name_identifier, Identifier, collection: true
|
22
22
|
|
23
23
|
xml do
|
data/lib/loc_mods/area.rb
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
|
3
|
+
require "lutaml/model"
|
4
4
|
|
5
5
|
require_relative "hierarchical_part"
|
6
6
|
|
7
7
|
module LocMods
|
8
|
-
class Area <
|
8
|
+
class Area < Lutaml::Model::Serializable
|
9
9
|
attribute :content, HierarchicalPart
|
10
|
-
attribute :area_type,
|
10
|
+
attribute :area_type, :string
|
11
11
|
|
12
12
|
xml do
|
13
13
|
root "area"
|
@@ -1,11 +1,11 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
|
3
|
+
require "lutaml/model"
|
4
4
|
|
5
5
|
module LocMods
|
6
|
-
class CartographicExtension <
|
7
|
-
attribute :content,
|
8
|
-
attribute :display_label,
|
6
|
+
class CartographicExtension < Lutaml::Model::Serializable
|
7
|
+
attribute :content, :string
|
8
|
+
attribute :display_label, :string
|
9
9
|
|
10
10
|
xml do
|
11
11
|
root "cartographicExtension"
|
@@ -1,17 +1,17 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
|
3
|
+
require "lutaml/model"
|
4
4
|
|
5
5
|
require_relative "cartographic_extension"
|
6
6
|
|
7
7
|
module LocMods
|
8
|
-
class Cartographics <
|
9
|
-
attribute :authority,
|
10
|
-
attribute :authority_uri,
|
11
|
-
attribute :value_uri,
|
12
|
-
attribute :scale,
|
13
|
-
attribute :projection,
|
14
|
-
attribute :coordinates,
|
8
|
+
class Cartographics < Lutaml::Model::Serializable
|
9
|
+
attribute :authority, :string
|
10
|
+
attribute :authority_uri, :string
|
11
|
+
attribute :value_uri, :string
|
12
|
+
attribute :scale, :string
|
13
|
+
attribute :projection, :string
|
14
|
+
attribute :coordinates, :string, collection: true
|
15
15
|
attribute :cartographic_extension, CartographicExtension, collection: true
|
16
16
|
|
17
17
|
xml do
|
@@ -1,13 +1,13 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
|
3
|
+
require "lutaml/model"
|
4
4
|
|
5
5
|
require_relative "hierarchical_part"
|
6
6
|
|
7
7
|
module LocMods
|
8
|
-
class CitySection <
|
8
|
+
class CitySection < Lutaml::Model::Serializable
|
9
9
|
attribute :content, HierarchicalPart
|
10
|
-
attribute :city_section_type,
|
10
|
+
attribute :city_section_type, :string
|
11
11
|
|
12
12
|
xml do
|
13
13
|
root "citySection"
|
@@ -1,15 +1,15 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
|
3
|
+
require "lutaml/model"
|
4
4
|
|
5
5
|
module LocMods
|
6
|
-
class Classification <
|
7
|
-
attribute :content,
|
8
|
-
attribute :edition,
|
9
|
-
attribute :display_label,
|
10
|
-
attribute :alt_rep_group,
|
11
|
-
attribute :usage,
|
12
|
-
attribute :generator,
|
6
|
+
class Classification < Lutaml::Model::Serializable
|
7
|
+
attribute :content, :string
|
8
|
+
attribute :edition, :string
|
9
|
+
attribute :display_label, :string
|
10
|
+
attribute :alt_rep_group, :string
|
11
|
+
attribute :usage, :string
|
12
|
+
attribute :generator, :string
|
13
13
|
|
14
14
|
xml do
|
15
15
|
root "classification"
|
data/lib/loc_mods/cli.rb
CHANGED
@@ -1,12 +1,15 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
# lib/loc_mods/cli.rb
|
4
3
|
require "thor"
|
5
4
|
require "loc_mods"
|
6
5
|
|
7
6
|
module LocMods
|
8
7
|
class Cli < Thor
|
9
8
|
desc "detect-duplicates PATH...", "Detect duplicate records in MODS XML files or directories"
|
9
|
+
method_option :show_unchanged, type: :boolean, default: false, desc: "Show unchanged attributes in the diff output"
|
10
|
+
method_option :highlight_diff, type: :boolean, default: false, desc: "Highlight only the differences"
|
11
|
+
method_option :color, type: :string, enum: %w[auto on off], default: "auto",
|
12
|
+
desc: "Use colors in the diff output (auto, on, off)"
|
10
13
|
|
11
14
|
def detect_duplicates(*paths)
|
12
15
|
all_records = []
|
@@ -46,12 +49,13 @@ module LocMods
|
|
46
49
|
puts " Comparison #{index + 1}:"
|
47
50
|
puts " File 1: #{record1[:file]}"
|
48
51
|
puts " File 2: #{record2[:file]}"
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
52
|
+
print_differences(
|
53
|
+
record1[:record],
|
54
|
+
record2[:record],
|
55
|
+
options[:show_unchanged],
|
56
|
+
options[:highlight_diff],
|
57
|
+
color_enabled?
|
58
|
+
)
|
55
59
|
puts "\n"
|
56
60
|
end
|
57
61
|
end
|
@@ -67,87 +71,51 @@ module LocMods
|
|
67
71
|
end
|
68
72
|
end
|
69
73
|
|
70
|
-
def print_differences(
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
74
|
+
def print_differences(record1, record2, show_unchanged, highlight_diff, use_colors)
|
75
|
+
diff_score, diff_tree = Lutaml::Model::Serialize.diff_with_score(
|
76
|
+
record1,
|
77
|
+
record2,
|
78
|
+
show_unchanged: show_unchanged,
|
79
|
+
highlight_diff: highlight_diff,
|
80
|
+
use_colors: use_colors,
|
81
|
+
indent: " ",
|
82
|
+
)
|
83
|
+
similarity_percentage = (1 - diff_score) * 100
|
84
|
+
|
85
|
+
puts " Differences:"
|
86
|
+
puts diff_tree
|
87
|
+
puts " Similarity score: #{similarity_percentage.round(2)}%"
|
88
|
+
end
|
85
89
|
|
86
|
-
|
90
|
+
def color_enabled?
|
91
|
+
case options[:color]
|
92
|
+
when "on"
|
93
|
+
true
|
94
|
+
when "off"
|
95
|
+
false
|
96
|
+
else
|
97
|
+
supports_color?
|
98
|
+
end
|
99
|
+
end
|
87
100
|
|
88
|
-
|
89
|
-
|
90
|
-
k.is_a?(Integer) || k == :_array_size_difference
|
91
|
-
end
|
101
|
+
def supports_color?
|
102
|
+
return false unless $stdout.tty?
|
92
103
|
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
# puts
|
98
|
-
# end
|
99
|
-
|
100
|
-
value.each do |subkey, subvalue|
|
101
|
-
# if [:self, :other].include?(subkey)
|
102
|
-
# raise "Subkey is self or other"
|
103
|
-
# end
|
104
|
-
# puts "subkey (#{subkey})"
|
105
|
-
# puts "subvalue #{subvalue}, prefix #{prefix}, current_path + [subkey] #{current_path + [subkey]}"
|
106
|
-
|
107
|
-
if subkey.is_a?(Integer)
|
108
|
-
print_differences(subvalue, prefix, current_path + [subkey])
|
109
|
-
else
|
110
|
-
if subvalue.is_a?(Comparison)
|
111
|
-
print_difference(subvalue, current_path + [subkey])
|
112
|
-
next
|
113
|
-
end
|
114
|
-
|
115
|
-
raise "In an array diff but not an Integer!"
|
116
|
-
end
|
117
|
-
end
|
104
|
+
if RbConfig::CONFIG["host_os"] =~ /mswin|mingw|cygwin/
|
105
|
+
return true if ENV["ANSICON"]
|
106
|
+
return true if ENV["ConEmuANSI"] == "ON"
|
107
|
+
return true if ENV["TERM"] == "xterm"
|
118
108
|
end
|
119
|
-
end
|
120
109
|
|
121
|
-
|
122
|
-
return unless value.original || value.updated
|
110
|
+
return true if ENV["COLORTERM"]
|
123
111
|
|
124
|
-
|
125
|
-
|
126
|
-
puts " Record 2: #{format_value(value.updated)}"
|
127
|
-
puts
|
128
|
-
end
|
112
|
+
term = ENV["TERM"]
|
113
|
+
return false if term.nil? || term.empty?
|
129
114
|
|
130
|
-
|
131
|
-
|
132
|
-
if index.zero?
|
133
|
-
part.to_s
|
134
|
-
elsif part.is_a?(Integer)
|
135
|
-
"[#{part}]"
|
136
|
-
else
|
137
|
-
".#{part}"
|
138
|
-
end
|
139
|
-
end.join
|
140
|
-
end
|
115
|
+
color_terms = %w[ansi color console cygwin gnome konsole kterm
|
116
|
+
linux msys putty rxvt screen tmux vt100 xterm]
|
141
117
|
|
142
|
-
|
143
|
-
case value
|
144
|
-
when nil, ComparableNil
|
145
|
-
"(nil)"
|
146
|
-
when String
|
147
|
-
"\"#{value}\""
|
148
|
-
else
|
149
|
-
value.to_s
|
150
|
-
end
|
118
|
+
color_terms.any? { |ct| term.include?(ct) }
|
151
119
|
end
|
152
120
|
end
|
153
121
|
end
|
data/lib/loc_mods/collection.rb
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
|
3
|
+
require "lutaml/model"
|
4
4
|
|
5
5
|
require_relative "record"
|
6
6
|
|
7
7
|
module LocMods
|
8
|
-
class Collection <
|
8
|
+
class Collection < Lutaml::Model::Serializable
|
9
9
|
attribute :mods, Record, collection: true
|
10
|
-
attribute :schema_location,
|
10
|
+
attribute :schema_location, :string
|
11
11
|
|
12
12
|
xml do
|
13
13
|
root "modsCollection"
|
@@ -1,6 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
|
3
|
+
require "lutaml/model"
|
4
4
|
|
5
5
|
require_relative "enumeration_and_chronology"
|
6
6
|
require_relative "form"
|
@@ -8,11 +8,11 @@ require_relative "item_identifier"
|
|
8
8
|
require_relative "note"
|
9
9
|
|
10
10
|
module LocMods
|
11
|
-
class CopyInformation <
|
11
|
+
class CopyInformation < Lutaml::Model::Serializable
|
12
12
|
attribute :form, Form
|
13
|
-
attribute :sub_location,
|
14
|
-
attribute :shelf_locator,
|
15
|
-
attribute :electronic_locator,
|
13
|
+
attribute :sub_location, :string, collection: true
|
14
|
+
attribute :shelf_locator, :string, collection: true
|
15
|
+
attribute :electronic_locator, :string, collection: true
|
16
16
|
attribute :note, Note, collection: true
|
17
17
|
attribute :enumeration_and_chronology, EnumerationAndChronology,
|
18
18
|
collection: true
|
data/lib/loc_mods/date.rb
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
|
3
|
+
require "lutaml/model"
|
4
4
|
|
5
5
|
module LocMods
|
6
|
-
class Date <
|
7
|
-
attribute :content,
|
8
|
-
attribute :encoding,
|
9
|
-
attribute :qualifier,
|
10
|
-
attribute :point,
|
11
|
-
attribute :key_date,
|
12
|
-
attribute :calendar,
|
6
|
+
class Date < Lutaml::Model::Serializable
|
7
|
+
attribute :content, :string
|
8
|
+
attribute :encoding, :string
|
9
|
+
attribute :qualifier, :string
|
10
|
+
attribute :point, :string
|
11
|
+
attribute :key_date, :string
|
12
|
+
attribute :calendar, :string
|
13
13
|
|
14
14
|
xml do
|
15
15
|
root "recordChangeDate"
|
data/lib/loc_mods/date_other.rb
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
|
3
|
+
require "lutaml/model"
|
4
4
|
|
5
5
|
require_relative "date"
|
6
6
|
|
7
7
|
module LocMods
|
8
|
-
class DateOther <
|
9
|
-
attribute :content,
|
10
|
-
attribute :type,
|
8
|
+
class DateOther < Lutaml::Model::Serializable
|
9
|
+
attribute :content, :string
|
10
|
+
attribute :type, :string
|
11
11
|
|
12
12
|
xml do
|
13
13
|
root "dateOther"
|
data/lib/loc_mods/detail.rb
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
|
3
|
+
require "lutaml/model"
|
4
4
|
|
5
5
|
module LocMods
|
6
|
-
class Detail <
|
7
|
-
attribute :type,
|
8
|
-
attribute :level,
|
9
|
-
attribute :number,
|
10
|
-
attribute :caption,
|
11
|
-
attribute :title,
|
6
|
+
class Detail < Lutaml::Model::Serializable
|
7
|
+
attribute :type, :string
|
8
|
+
attribute :level, :integer
|
9
|
+
attribute :number, :string, collection: true
|
10
|
+
attribute :caption, :string, collection: true
|
11
|
+
attribute :title, :string, collection: true
|
12
12
|
|
13
13
|
xml do
|
14
14
|
root "detail"
|
data/lib/loc_mods/edition.rb
CHANGED
@@ -1,12 +1,12 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
|
3
|
+
require "lutaml/model"
|
4
4
|
|
5
5
|
module LocMods
|
6
6
|
# LocMods::StringPlusLanguagePlusSupplied
|
7
|
-
class Edition <
|
8
|
-
attribute :content,
|
9
|
-
attribute :supplied,
|
7
|
+
class Edition < Lutaml::Model::Serializable
|
8
|
+
attribute :content, :string
|
9
|
+
attribute :supplied, :string
|
10
10
|
|
11
11
|
xml do
|
12
12
|
root "edition"
|