Skip to content

Commit

Permalink
Release 1.0.4
Browse files Browse the repository at this point in the history
  • Loading branch information
lecoqlibre committed Apr 7, 2023
1 parent 5ae46b2 commit c62bb73
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 3 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

None.

## [1.0.4] - 2023-04-06

### Fixed

- Properties can be prefixed when serialized.

## [1.0.3] - 2023-02-20

### Fixed
Expand Down Expand Up @@ -49,6 +55,7 @@ None.
- Gemspec file.

[unreleased]: https://github.com/assemblee-virtuelle/semantizer-ruby/compare/v1.0.0...HEAD
[1.0.4]: https://github.com/assemblee-virtuelle/semantizer-ruby/compare/v1.0.3...v1.0.4
[1.0.3]: https://github.com/assemblee-virtuelle/semantizer-ruby/compare/v1.0.2...v1.0.3
[1.0.2]: https://github.com/assemblee-virtuelle/semantizer-ruby/compare/v1.0.1...v1.0.2
[1.0.1]: https://github.com/assemblee-virtuelle/semantizer-ruby/compare/v1.0.0...v1.0.1
Expand Down
19 changes: 17 additions & 2 deletions lib/virtual_assembly/semantizer/hash_serializer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@
# {"http://xmlns.com/foaf/0.1/name" => "John"}.
class VirtualAssembly::Semantizer::HashSerializer

# The inputContext must be a hash like { prefix => uri }
def initialize(inputContext = nil)
@inputContext = inputContext
end

# This is the main method to begin the serialization.
#
# The subject should be a SemanticObject.
Expand All @@ -33,7 +38,7 @@ def process(subject)

# We iterate over all the semantic properties of the subject.
subject.semanticProperties.each do |property|
name = property.name
name = @inputContext? self.prefixName(property.name): property.name
value = property.value

if (value == nil)
Expand Down Expand Up @@ -67,7 +72,17 @@ def process(subject)
return result;
end

private
private

# Replace each URI with its prefix
def prefixName(name)
@inputContext.each do |prefix, uri|
if (!name.start_with?("@") && name.start_with?(uri))
return name.sub(uri, prefix + ':')
end
end
return name
end

# Serialize a collection of values.
def exportCollection(values)
Expand Down
2 changes: 1 addition & 1 deletion semantizer.gemspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Gem::Specification.new do |s|
s.name = "virtual_assembly-semantizer"
s.version = "1.0.3"
s.version = "1.0.4"
s.summary = "Semantizer"
s.description = "A library to add linked data to your models"
s.authors = ["Maxime Lecoq"]
Expand Down

0 comments on commit c62bb73

Please sign in to comment.