uri_service 0.4.0 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/lib/uri_service/client.rb +6 -16
- data/lib/uri_service/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f5dfd4b23cd1ac5fd404ce7a52833497fcec6f17
|
4
|
+
data.tar.gz: cd29ef22f63ee376810d514be0a27c0e7210e866
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6fc35d8cd790eeebc46e670fad05890bc570522473bc9beaa25dd3b6f77d143f7d0765972a94f572f4029bd1aa7244896e96a9ca299d801d904df2f9ec39ea22
|
7
|
+
data.tar.gz: 5538858d331a40fa7ef8985068a4ff0c9c48586be93667830cfa1670b65b87205613d9471e66c7eae584373dd32b208786a8b8b6e6e77547a2c0dcd37e2f4f5c
|
data/README.md
CHANGED
@@ -14,7 +14,7 @@ Used when defining locally-managed terms in the UriService datastore. Automatica
|
|
14
14
|
|
15
15
|
**Temporary Term (UriService::TermType::TEMPORARY)**
|
16
16
|
|
17
|
-
Used when you want to add a value to your UriService datastore, but have no authority information about the term
|
17
|
+
Used when you want to add a value to your UriService datastore, but have no authority information about the term or do not wish to create a local URI. No two temporary terms within the same vocabulary can have the same value. Basically, a termporary term is intended to identify an *exact string value* rather than identifiying an intellectual entity. Temporary terms should eventually be replaced by external or local terms later on when more information is known about the entity to which you are referring . Example: We want to record information about the author of an old and mysterious letter by "John Smith." We don't know which "John Smith," this refers to, so we'll create (or re-use) a temporary URI that's associated with the value "John Smith." One day, when we figure out more about the letter and the author, we'll be able to update the record information and refer to an external term that has a globally-recognized URI, or we'll create a local URI if an external URI is unavailable.
|
18
18
|
|
19
19
|
### Usage:
|
20
20
|
|
data/lib/uri_service/client.rb
CHANGED
@@ -448,15 +448,15 @@ class UriService::Client
|
|
448
448
|
term_db_row = @db[UriService::TERMS].first(uri: uri)
|
449
449
|
raise UriService::NonExistentUriError, "No term found with uri: " + uri if term_db_row.nil?
|
450
450
|
|
451
|
-
if term_db_row[:type] == UriService::TermType::TEMPORARY
|
452
|
-
# TEMPORARY terms cannot have their values, additional_fields or anything else changed
|
453
|
-
raise UriService::CannotChangeTemporaryTerm, "Temporary terms cannot be changed. Delete unusued temporary terms or create new ones."
|
454
|
-
end
|
455
|
-
|
456
451
|
new_value = opts[:value] || term_db_row[:value]
|
457
452
|
new_authority = opts[:authority] || term_db_row[:authority]
|
458
453
|
new_additional_fields = term_db_row[:additional_fields].nil? ? {} : JSON.parse(term_db_row[:additional_fields])
|
459
454
|
|
455
|
+
if term_db_row[:type] == UriService::TermType::TEMPORARY && new_value != term_db_row[:value]
|
456
|
+
# TEMPORARY terms cannot have their values changed, but it is possible to update other fields
|
457
|
+
raise UriService::CannotChangeTemporaryTermValue, "The value of a temporary term cannot be changed. Delete unusued temporary terms or create a new one with a different value."
|
458
|
+
end
|
459
|
+
|
460
460
|
unless opts[:additional_fields].nil?
|
461
461
|
if merge_additional_fields
|
462
462
|
new_additional_fields.merge!(opts[:additional_fields])
|
@@ -525,16 +525,6 @@ class UriService::Client
|
|
525
525
|
unless uri == self.generate_uri_for_temporary_term(vocabulary_string_key, value)
|
526
526
|
raise UriService::InvalidTemporaryTermUriError, "The supplied URI was not derived from the supplied (vocabulary_string_key+value) pair."
|
527
527
|
end
|
528
|
-
|
529
|
-
# TEMPORARY terms are not meant to hold data in additional_fields.
|
530
|
-
if additional_fields.size > 0
|
531
|
-
raise UriService::InvalidOptsError, "Terms of type #{type} cannot have additional_fields."
|
532
|
-
end
|
533
|
-
|
534
|
-
# TEMPORARY terms are not meant to store authority information
|
535
|
-
unless authority == ''
|
536
|
-
raise UriService::InvalidOptsError, "Terms of type #{type} cannot have an authority."
|
537
|
-
end
|
538
528
|
end
|
539
529
|
|
540
530
|
unless uri =~ UriService::VALID_URI_REGEX
|
@@ -586,7 +576,7 @@ class UriService::Client
|
|
586
576
|
|
587
577
|
end
|
588
578
|
|
589
|
-
class UriService::
|
579
|
+
class UriService::CannotChangeTemporaryTermValue < StandardError;end
|
590
580
|
class UriService::CouldNotGenerateUriError < StandardError;end
|
591
581
|
class UriService::InvalidAdditionalFieldKeyError < StandardError;end
|
592
582
|
class UriService::InvalidOptsError < StandardError;end
|
data/lib/uri_service/version.rb
CHANGED