rdf-normalize 0.4.0 → 0.5.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4228bee01dba3de0d611ae8431824ebf1f6f09ae6039a5570ea3e86f4cb8c467
4
- data.tar.gz: c932b23a352bf3771a5e426c0976050b128f41473a8ea6cea675c1a7bc26ef5a
3
+ metadata.gz: 75218bd6e68ada2e64c27fb691f0ff8b92cfd8b9fe9747f02d862bcbcdd8a5dd
4
+ data.tar.gz: fbe6c3579b66435b0b2620178a3ebf46e1bd56f17180a7a64f081aab65a3c447
5
5
  SHA512:
6
- metadata.gz: 0d5995bdc3c593385a74ba69bf367c01a2d5b44fd7d0b5aab9f8495ebc14d16c3b709ceff21c2294c951613726190c49eab41098feaac0c2ba350afd25552fc4
7
- data.tar.gz: e0e70f5aa3bdfb49bc0679cae8e362fa3191d9452a2ca3aaa004b995622837865dca6d61aaa264407c8fc0d4197fadfbfee6dd91a19cf9e46f399b57e587634c
6
+ metadata.gz: 1363fb834466a6a643245a12776ab6c49cff62436af19ecd5d6dfe58feb83b49971868838dc1d9f687a997ee93af2b12b98a51eedc2f6846e1e0e74810eb4285
7
+ data.tar.gz: 62fb2457433083c9b4181353bfa0ec8740a871f3f58b6ac83233a0dd6385b3556a7540c62b1041bab5ba2aee17a55234c70a323fedfc41db09912bf7d3675215
data/LICENSE CHANGED
@@ -21,5 +21,5 @@ OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
21
21
  ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
22
22
  OTHER DEALINGS IN THE SOFTWARE.
23
23
 
24
- For more information, please refer to <http://unlicense.org>
24
+ For more information, please refer to <https://unlicense.org>
25
25
 
data/README.md CHANGED
@@ -1,11 +1,13 @@
1
1
  # RDF::Normalize
2
2
  RDF Graph normalizer for [RDF.rb][RDF.rb].
3
3
 
4
- [![Gem Version](https://badge.fury.io/rb/rdf-normalize.png)](http://badge.fury.io/rb/rdf-normalize)
5
- [![Build Status](https://secure.travis-ci.org/ruby-rdf/rdf-normalize.png?branch=master)](http://travis-ci.org/ruby-rdf/rdf-normalize)
4
+ [![Gem Version](https://badge.fury.io/rb/rdf-normalize.png)](https://badge.fury.io/rb/rdf-normalize)
5
+ [![Build Status](https://github.com/ruby-rdf/rdf-normalize/workflows/CI/badge.svg?branch=develop)](https://github.com/ruby-rdf/rdf-normalize/actions?query=workflow%3ACI)
6
+ [![Coverage Status](https://coveralls.io/repos/ruby-rdf/rdf-normalize/badge.svg?branch=develop)](https://coveralls.io/github/ruby-rdf/rdf-normalize?branch=develop)
7
+ [![Gitter chat](https://badges.gitter.im/ruby-rdf/rdf.png)](https://gitter.im/ruby-rdf/rdf)
6
8
 
7
9
  ## Description
8
- This is a [Ruby][] implementation of a [RDF Normalize][] for [RDF.rb][].
10
+ This is a [Ruby][] implementation of a [RDF Dataset Canonicalization][] for [RDF.rb][].
9
11
 
10
12
  ## Features
11
13
  RDF::Normalize generates normalized [N-Quads][] output for an RDF Dataset using the algorithm
@@ -14,18 +16,28 @@ to serialize normalized statements.
14
16
 
15
17
  Algorithms implemented:
16
18
 
17
- * [URGNA2012](http://json-ld.github.io/normalization/spec/index.html#dfn-urgna2012)
18
- * [URDNA2015](http://json-ld.github.io/normalization/spec/index.html#dfn-urdna2015)
19
+ * [URGNA2012](https://www.w3.org/TR/rdf-canon/#dfn-urgna2012)
20
+ * [URDNA2015](https://www.w3.org/TR/rdf-canon/#dfn-urdna2015)
19
21
 
20
22
  Install with `gem install rdf-normalize`
21
23
 
22
- * 100% free and unencumbered [public domain](http://unlicense.org/) software.
23
- * Compatible with Ruby >= 2.4.
24
+ * 100% free and unencumbered [public domain](https://unlicense.org/) software.
25
+ * Compatible with Ruby >= 2.6.
24
26
 
25
27
  ## Usage
26
28
 
27
29
  ## Documentation
28
- Full documentation available on [Rubydoc.info][Normalize doc]
30
+
31
+ Full documentation available on [GitHub][Normalize doc]
32
+
33
+ ## Examples
34
+
35
+ ### Returning normalized N-Quads
36
+
37
+ require 'rdf/normalize'
38
+ require 'rdf/turtle'
39
+ g = RDF::Graph.load("etc/doap.ttl")
40
+ puts g.dump(:normalize)
29
41
 
30
42
  ### Principle Classes
31
43
  * {RDF::Normalize}
@@ -35,24 +47,23 @@ Full documentation available on [Rubydoc.info][Normalize doc]
35
47
  * {RDF::Normalize::URGNA2012}
36
48
  * {RDF::Normalize::URDNA2015}
37
49
 
38
-
39
50
  ## Dependencies
40
51
 
41
- * [Ruby](http://ruby-lang.org/) (>= 2.4)
42
- * [RDF.rb](http://rubygems.org/gems/rdf) (~> 3.1)
52
+ * [Ruby](https://ruby-lang.org/) (>= 2.6)
53
+ * [RDF.rb](https://rubygems.org/gems/rdf) (~> 3.2)
43
54
 
44
55
  ## Installation
45
56
 
46
- The recommended installation method is via [RubyGems](http://rubygems.org/).
57
+ The recommended installation method is via [RubyGems](https://rubygems.org/).
47
58
  To install the latest official release of the `RDF::Normalize` gem, do:
48
59
 
49
60
  % [sudo] gem install rdf-normalize
50
61
 
51
62
  ## Mailing List
52
- * <http://lists.w3.org/Archives/Public/public-rdf-ruby/>
63
+ * <https://lists.w3.org/Archives/Public/public-rdf-ruby/>
53
64
 
54
65
  ## Author
55
- * [Gregg Kellogg](http://github.com/gkellogg) - <http://greggkellogg.net/>
66
+ * [Gregg Kellogg](https://github.com/gkellogg) - <https://greggkellogg.net/>
56
67
 
57
68
  ## Contributing
58
69
  * Do your best to adhere to the existing coding conventions and idioms.
@@ -65,18 +76,20 @@ To install the latest official release of the `RDF::Normalize` gem, do:
65
76
  list in the the `README`. Alphabetical order applies.
66
77
  * Do note that in order for us to merge any non-trivial changes (as a rule
67
78
  of thumb, additions larger than about 15 lines of code), we need an
68
- explicit [public domain dedication][PDD] on record from you.
79
+ explicit [public domain dedication][PDD] on record from you,
80
+ which you will be asked to agree to on the first commit to a repo within the organization.
81
+ Note that the agreement applies to all repos in the [Ruby RDF](https://github.com/ruby-rdf/) organization.
69
82
 
70
83
  ## License
71
84
  This is free and unencumbered public domain software. For more information,
72
- see <http://unlicense.org/> or the accompanying {file:LICENSE} file.
73
-
74
- [Ruby]: http://ruby-lang.org/
75
- [RDF]: http://www.w3.org/RDF/
76
- [YARD]: http://yardoc.org/
77
- [YARD-GS]: http://rubydoc.info/docs/yard/file/docs/GettingStarted.md
78
- [PDD]: http://lists.w3.org/Archives/Public/public-rdf-ruby/2010May/0013.html
79
- [RDF.rb]: http://rubydoc.info/github/ruby-rdf/rdf-normalize
80
- [N-Triples]: http://www.w3.org/TR/rdf-testcases/#ntriples
81
- [RDF Normalize]:http://json-ld.github.io/normalization/spec/
82
- [Normalize doc]:http://rubydoc.info/github/ruby-rdf/rdf-normalize/master
85
+ see <https://unlicense.org/> or the accompanying {file:LICENSE} file.
86
+
87
+ [Ruby]: https://ruby-lang.org/
88
+ [RDF]: https://www.w3.org/RDF/
89
+ [YARD]: https://yardoc.org/
90
+ [YARD-GS]: https://rubydoc.info/docs/yard/file/docs/GettingStarted.md
91
+ [PDD]: https://unlicense.org/#unlicensing-contributions
92
+ [RDF.rb]: https://ruby-rdf.github.io/rdf-normalize
93
+ [N-Triples]: https://www.w3.org/TR/rdf-testcases/#ntriples
94
+ [RDF Dataset Canonicalization]: https://www.w3.org/TR/rdf-canon/
95
+ [Normalize doc]: https://ruby-rdf.github.io/rdf-normalize/
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.4.0
1
+ 0.5.1
@@ -27,30 +27,23 @@ module RDF::Normalize
27
27
  end
28
28
  end
29
29
 
30
- non_normalized_identifiers, simple = ns.bnode_to_statements.keys, true
30
+ ns.hash_to_bnodes = {}
31
31
 
32
- while simple
33
- simple = false
34
- ns.hash_to_bnodes = {}
35
-
36
- # Calculate hashes for first degree nodes
37
- non_normalized_identifiers.each do |node|
38
- hash = log_depth {ns.hash_first_degree_quads(node)}
39
- log_debug("1deg") {"hash: #{hash}"}
40
- ns.add_bnode_hash(node, hash)
41
- end
32
+ # Calculate hashes for first degree nodes
33
+ ns.bnode_to_statements.each_key do |node|
34
+ hash = log_depth {ns.hash_first_degree_quads(node)}
35
+ log_debug("1deg") {"hash: #{hash}"}
36
+ ns.add_bnode_hash(node, hash)
37
+ end
42
38
 
43
- # Create canonical replacements for hashes mapping to a single node
44
- ns.hash_to_bnodes.keys.sort.each do |hash|
45
- identifier_list = ns.hash_to_bnodes[hash]
46
- next if identifier_list.length > 1
47
- node = identifier_list.first
48
- id = ns.canonical_issuer.issue_identifier(node)
49
- log_debug("single node") {"node: #{node.to_ntriples}, hash: #{hash}, id: #{id}"}
50
- non_normalized_identifiers -= identifier_list
51
- ns.hash_to_bnodes.delete(hash)
52
- simple = true
53
- end
39
+ # Create canonical replacements for hashes mapping to a single node
40
+ ns.hash_to_bnodes.keys.sort.each do |hash|
41
+ identifier_list = ns.hash_to_bnodes[hash]
42
+ next if identifier_list.length > 1
43
+ node = identifier_list.first
44
+ id = ns.canonical_issuer.issue_identifier(node)
45
+ log_debug("single node") {"node: #{node.to_ntriples}, hash: #{hash}, id: #{id}"}
46
+ ns.hash_to_bnodes.delete(hash)
54
47
  end
55
48
 
56
49
  # Iterate over hashs having more than one node
@@ -107,12 +100,13 @@ module RDF::Normalize
107
100
 
108
101
  def add_statement(node, statement)
109
102
  bnode_to_statements[node] ||= []
110
- bnode_to_statements[node] << statement unless bnode_to_statements[node].include?(statement)
103
+ bnode_to_statements[node] << statement unless bnode_to_statements[node].any? {|st| st.eql?(statement)}
111
104
  end
112
105
 
113
106
  def add_bnode_hash(node, hash)
114
107
  hash_to_bnodes[hash] ||= []
115
- hash_to_bnodes[hash] << node unless hash_to_bnodes[hash].include?(node)
108
+ # Match on object IDs of nodes, rather than simple node equality
109
+ hash_to_bnodes[hash] << node unless hash_to_bnodes[hash].any? {|n| n.eql?(node)}
116
110
  end
117
111
 
118
112
  # @param [RDF::Node] node
@@ -143,7 +137,7 @@ module RDF::Normalize
143
137
  identifier = canonical_issuer.identifier(related) ||
144
138
  issuer.identifier(related) ||
145
139
  hash_first_degree_quads(related)
146
- input = position.to_s
140
+ input = "#{position}"
147
141
  input << statement.predicate.to_ntriples unless position == :g
148
142
  input << identifier
149
143
  log_debug("hrel") {"input: #{input.inspect}, hash: #{hexdigest(input)}"}
@@ -225,7 +219,7 @@ module RDF::Normalize
225
219
 
226
220
  hash = log_depth {hash_related_node(term, statement, issuer, pos)}
227
221
  map[hash] ||= []
228
- map[hash] << term unless map[hash].include?(term)
222
+ map[hash] << term unless map[hash].any? {|n| n.eql?(term)}
229
223
  end
230
224
  end
231
225
  end
@@ -23,9 +23,7 @@ module RDF::Normalize
23
23
  identifier = canonical_issuer.identifier(related) ||
24
24
  issuer.identifier(related) ||
25
25
  hash_first_degree_quads(related)
26
- input = position.to_s
27
- input << statement.predicate.to_s
28
- input << identifier
26
+ input = "#{position}#{statement.predicate}#{identifier}"
29
27
  log_debug("hrel") {"input: #{input.inspect}, hash: #{hexdigest(input)}"}
30
28
  hexdigest(input)
31
29
  end
@@ -35,11 +33,11 @@ module RDF::Normalize
35
33
  if statement.subject.node? && statement.subject != identifier
36
34
  hash = log_depth {hash_related_node(statement.subject, statement, issuer, :p)}
37
35
  map[hash] ||= []
38
- map[hash] << statement.subject unless map[hash].include?(statement.subject)
36
+ map[hash] << statement.subject unless map[hash].any? {|n| n.eql?(statement.subject)}
39
37
  elsif statement.object.node? && statement.object != identifier
40
38
  hash = log_depth {hash_related_node(statement.object, statement, issuer, :r)}
41
39
  map[hash] ||= []
42
- map[hash] << statement.object unless map[hash].include?(statement.object)
40
+ map[hash] << statement.object unless map[hash].any? {|n| n.eql?(statement.object)}
43
41
  end
44
42
  end
45
43
  end
@@ -1,5 +1,5 @@
1
1
  module RDF::Normalize::VERSION
2
- VERSION_FILE = File.join(File.expand_path(File.dirname(__FILE__)), "..", "..", "..", "VERSION")
2
+ VERSION_FILE = File.expand_path("../../../../VERSION", __FILE__)
3
3
  MAJOR, MINOR, TINY, EXTRA = File.read(VERSION_FILE).chop.split(".")
4
4
 
5
5
  STRING = [MAJOR, MINOR, TINY, EXTRA].compact.join('.')
@@ -4,11 +4,11 @@ module RDF::Normalize
4
4
  #
5
5
  # Normalizes the enumerated statements into normal form in the form of N-Quads.
6
6
  #
7
- # @author [Gregg Kellogg](http://kellogg-assoc.com/)
7
+ # @author [Gregg Kellogg](https://greggkellogg.net/)
8
8
  class Writer < RDF::NQuads::Writer
9
9
  format RDF::Normalize::Format
10
10
 
11
- # @attr_accessor [RDF::Repository] Repository of statements to serialized
11
+ # @return [RDF::Repository] Repository of statements to serialized
12
12
  attr_accessor :repo
13
13
 
14
14
  ##
@@ -69,7 +69,7 @@ module RDF::Normalize
69
69
  ##
70
70
  # Insert an Enumerable
71
71
  #
72
- # @param [RDF::Enumerable] graph
72
+ # @param [RDF::Enumerable] enumerable
73
73
  # @return [void]
74
74
  def insert_statements(enumerable)
75
75
  @repo = enumerable
data/lib/rdf/normalize.rb CHANGED
@@ -25,7 +25,7 @@ module RDF
25
25
  # writer << RDF::Repository.load("etc/doap.ttl")
26
26
  # end
27
27
  #
28
- # @author [Gregg Kellogg](http://greggkellogg.net/)
28
+ # @author [Gregg Kellogg](https://greggkellogg.net/)
29
29
  module Normalize
30
30
  require 'rdf/normalize/format'
31
31
  autoload :Base, 'rdf/normalize/base'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rdf-normalize
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.5.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gregg Kellogg
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-12-13 00:00:00.000000000 Z
11
+ date: 2022-11-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rdf
@@ -16,105 +16,71 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '3.1'
19
+ version: '3.2'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '3.1'
26
+ version: '3.2'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rdf-spec
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '3.1'
33
+ version: '3.2'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: '3.1'
41
- - !ruby/object:Gem::Dependency
42
- name: open-uri-cached
43
- requirement: !ruby/object:Gem::Requirement
44
- requirements:
45
- - - "~>"
46
- - !ruby/object:Gem::Version
47
- version: '0.0'
48
- - - ">="
49
- - !ruby/object:Gem::Version
50
- version: 0.0.5
51
- type: :development
52
- prerelease: false
53
- version_requirements: !ruby/object:Gem::Requirement
54
- requirements:
55
- - - "~>"
56
- - !ruby/object:Gem::Version
57
- version: '0.0'
58
- - - ">="
59
- - !ruby/object:Gem::Version
60
- version: 0.0.5
40
+ version: '3.2'
61
41
  - !ruby/object:Gem::Dependency
62
42
  name: rspec
63
43
  requirement: !ruby/object:Gem::Requirement
64
44
  requirements:
65
45
  - - "~>"
66
46
  - !ruby/object:Gem::Version
67
- version: '3.9'
68
- type: :development
69
- prerelease: false
70
- version_requirements: !ruby/object:Gem::Requirement
71
- requirements:
72
- - - "~>"
73
- - !ruby/object:Gem::Version
74
- version: '3.9'
75
- - !ruby/object:Gem::Dependency
76
- name: webmock
77
- requirement: !ruby/object:Gem::Requirement
78
- requirements:
79
- - - "~>"
80
- - !ruby/object:Gem::Version
81
- version: '3.7'
47
+ version: '3.10'
82
48
  type: :development
83
49
  prerelease: false
84
50
  version_requirements: !ruby/object:Gem::Requirement
85
51
  requirements:
86
52
  - - "~>"
87
53
  - !ruby/object:Gem::Version
88
- version: '3.7'
54
+ version: '3.10'
89
55
  - !ruby/object:Gem::Dependency
90
56
  name: json-ld
91
57
  requirement: !ruby/object:Gem::Requirement
92
58
  requirements:
93
59
  - - "~>"
94
60
  - !ruby/object:Gem::Version
95
- version: '3.1'
61
+ version: '3.2'
96
62
  type: :development
97
63
  prerelease: false
98
64
  version_requirements: !ruby/object:Gem::Requirement
99
65
  requirements:
100
66
  - - "~>"
101
67
  - !ruby/object:Gem::Version
102
- version: '3.1'
68
+ version: '3.2'
103
69
  - !ruby/object:Gem::Dependency
104
70
  name: yard
105
71
  requirement: !ruby/object:Gem::Requirement
106
72
  requirements:
107
73
  - - "~>"
108
74
  - !ruby/object:Gem::Version
109
- version: 0.9.20
75
+ version: '0.9'
110
76
  type: :development
111
77
  prerelease: false
112
78
  version_requirements: !ruby/object:Gem::Requirement
113
79
  requirements:
114
80
  - - "~>"
115
81
  - !ruby/object:Gem::Version
116
- version: 0.9.20
117
- description: RDF::Normalize is a Graph normalizer for the RDF.rb library suite.
82
+ version: '0.9'
83
+ description: RDF::Normalize performs Dataset Canonicalization for RDF.rb.
118
84
  email: public-rdf-ruby@w3.org
119
85
  executables: []
120
86
  extensions: []
@@ -132,11 +98,16 @@ files:
132
98
  - lib/rdf/normalize/urgna2012.rb
133
99
  - lib/rdf/normalize/version.rb
134
100
  - lib/rdf/normalize/writer.rb
135
- homepage: http://github.com/gkellogg/rdf-normalize
101
+ homepage: https://github.com/ruby-rdf/rdf-normalize
136
102
  licenses:
137
103
  - Unlicense
138
- metadata: {}
139
- post_install_message:
104
+ metadata:
105
+ documentation_uri: https://ruby-rdf.github.io/rdf-normalize
106
+ bug_tracker_uri: https://github.com/ruby-rdf/rdf-normalize/issues
107
+ homepage_uri: https://github.com/ruby-rdf/rdf-normalize
108
+ mailing_list_uri: https://lists.w3.org/Archives/Public/public-rdf-ruby/
109
+ source_code_uri: https://github.com/ruby-rdf/rdf-normalize
110
+ post_install_message:
140
111
  rdoc_options: []
141
112
  require_paths:
142
113
  - lib
@@ -144,15 +115,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
144
115
  requirements:
145
116
  - - ">="
146
117
  - !ruby/object:Gem::Version
147
- version: '2.4'
118
+ version: '2.6'
148
119
  required_rubygems_version: !ruby/object:Gem::Requirement
149
120
  requirements:
150
121
  - - ">="
151
122
  - !ruby/object:Gem::Version
152
123
  version: '0'
153
124
  requirements: []
154
- rubygems_version: 3.0.6
155
- signing_key:
125
+ rubygems_version: 3.3.7
126
+ signing_key:
156
127
  specification_version: 4
157
128
  summary: RDF Graph normalizer for Ruby.
158
129
  test_files: []