rdf-normalize 0.1.0 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: d7076dcfeccdbfc0b35ec046d0b338a6ad41d776
4
- data.tar.gz: cd5f278797b575a3a6cced04890b9014c2350f42
2
+ SHA256:
3
+ metadata.gz: 4228bee01dba3de0d611ae8431824ebf1f6f09ae6039a5570ea3e86f4cb8c467
4
+ data.tar.gz: c932b23a352bf3771a5e426c0976050b128f41473a8ea6cea675c1a7bc26ef5a
5
5
  SHA512:
6
- metadata.gz: 2510cec72f19af6eef55678382f688a5948b59fad4c6be18465c53a66d16b25bb543dadbd5a5148675d291afac133c8cc7d5399650ad9043b858c1a1f6165291
7
- data.tar.gz: f785bd00b4abacf7da181daae96e2101aa449b19791a08742654451cf9a3b25abdf368dd77d99a86c4f74a49084b2d9af6464ea30bbed45589f87713e899ee63
6
+ metadata.gz: 0d5995bdc3c593385a74ba69bf367c01a2d5b44fd7d0b5aab9f8495ebc14d16c3b709ceff21c2294c951613726190c49eab41098feaac0c2ba350afd25552fc4
7
+ data.tar.gz: e0e70f5aa3bdfb49bc0679cae8e362fa3191d9452a2ca3aaa004b995622837865dca6d61aaa264407c8fc0d4197fadfbfee6dd91a19cf9e46f399b57e587634c
data/README.md CHANGED
@@ -15,12 +15,12 @@ to serialize normalized statements.
15
15
  Algorithms implemented:
16
16
 
17
17
  * [URGNA2012](http://json-ld.github.io/normalization/spec/index.html#dfn-urgna2012)
18
- * [URDNA2014](http://json-ld.github.io/normalization/spec/index.html#dfn-urdna2015)
18
+ * [URDNA2015](http://json-ld.github.io/normalization/spec/index.html#dfn-urdna2015)
19
19
 
20
20
  Install with `gem install rdf-normalize`
21
21
 
22
22
  * 100% free and unencumbered [public domain](http://unlicense.org/) software.
23
- * Compatible with Ruby >= 1.9.3.
23
+ * Compatible with Ruby >= 2.4.
24
24
 
25
25
  ## Usage
26
26
 
@@ -38,8 +38,8 @@ Full documentation available on [Rubydoc.info][Normalize doc]
38
38
 
39
39
  ## Dependencies
40
40
 
41
- * [Ruby](http://ruby-lang.org/) (>= 1.9.2)
42
- * [RDF.rb](http://rubygems.org/gems/rdf) (~> 1.1)
41
+ * [Ruby](http://ruby-lang.org/) (>= 2.4)
42
+ * [RDF.rb](http://rubygems.org/gems/rdf) (~> 3.1)
43
43
 
44
44
  ## Installation
45
45
 
@@ -79,4 +79,4 @@ see or the accompanying {file:LICENSE} file.
79
79
  [RDF.rb]: http://rubydoc.info/github/ruby-rdf/rdf-normalize
80
80
  [N-Triples]: http://www.w3.org/TR/rdf-testcases/#ntriples
81
81
  [RDF Normalize]:http://json-ld.github.io/normalization/spec/
82
- [Normalize doc]:http://rubydoc.info/github/ruby-rdf/rdf-normalize/master/file/README.markdown
82
+ [Normalize doc]:http://rubydoc.info/github/ruby-rdf/rdf-normalize/master
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.0
1
+ 0.4.0
@@ -28,7 +28,6 @@ module RDF
28
28
  # @author [Gregg Kellogg](http://greggkellogg.net/)
29
29
  module Normalize
30
30
  require 'rdf/normalize/format'
31
- require 'rdf/normalize/utils'
32
31
  autoload :Base, 'rdf/normalize/base'
33
32
  autoload :Carroll2001,'rdf/normalize/carroll2001'
34
33
  autoload :URGNA2012, 'rdf/normalize/urgna2012'
@@ -54,11 +53,11 @@ module RDF
54
53
  # One of `:carroll2001`, `:urgna2012`, or `:urdna2015`
55
54
  # @return [RDF::Normalize::Base]
56
55
  # @raise [ArgumentError] selected algorithm not defined
57
- def new(enumerable, options = {})
56
+ def new(enumerable, **options)
58
57
  algorithm = options.fetch(:algorithm, :urdna2015)
59
58
  raise ArgumentError, "No algoritm defined for #{algorithm.to_sym}" unless ALGORITHMS.has_key?(algorithm)
60
59
  algorithm_class = const_get(ALGORITHMS[algorithm])
61
- algorithm_class.new(enumerable, options)
60
+ algorithm_class.new(enumerable, **options)
62
61
  end
63
62
  module_function :new
64
63
 
@@ -9,7 +9,7 @@ module RDF::Normalize
9
9
  #
10
10
  # @param [RDF::Enumerable] enumerable
11
11
  # @return [RDF::Enumerable]
12
- def initialize(enumerable, options)
12
+ def initialize(enumerable, **options)
13
13
  @dataset = enumerable
14
14
  end
15
15
 
@@ -2,6 +2,7 @@ require 'rdf/nquads'
2
2
 
3
3
  module RDF::Normalize
4
4
  class Format < RDF::Format
5
+ content_type 'application/normalized+n-quads', alias: 'application/x-normalized+n-quads'
5
6
  content_encoding 'utf-8'
6
7
 
7
8
  # It reads like normal N-Quads
@@ -1,15 +1,15 @@
1
1
  module RDF::Normalize
2
2
  class URDNA2015
3
3
  include RDF::Enumerable
4
+ include RDF::Util::Logger
4
5
  include Base
5
- include Utils
6
6
 
7
7
  ##
8
8
  # Create an enumerable with grounded nodes
9
9
  #
10
10
  # @param [RDF::Enumerable] enumerable
11
11
  # @return [RDF::Enumerable]
12
- def initialize(enumerable, options)
12
+ def initialize(enumerable, **options)
13
13
  @dataset, @options = enumerable, options
14
14
  end
15
15
 
@@ -35,8 +35,8 @@ module RDF::Normalize
35
35
 
36
36
  # Calculate hashes for first degree nodes
37
37
  non_normalized_identifiers.each do |node|
38
- hash = depth {ns.hash_first_degree_quads(node)}
39
- debug("1deg") {"hash: #{hash}"}
38
+ hash = log_depth {ns.hash_first_degree_quads(node)}
39
+ log_debug("1deg") {"hash: #{hash}"}
40
40
  ns.add_bnode_hash(node, hash)
41
41
  end
42
42
 
@@ -46,7 +46,7 @@ module RDF::Normalize
46
46
  next if identifier_list.length > 1
47
47
  node = identifier_list.first
48
48
  id = ns.canonical_issuer.issue_identifier(node)
49
- debug("single node") {"node: #{node.to_ntriples}, hash: #{hash}, id: #{id}"}
49
+ log_debug("single node") {"node: #{node.to_ntriples}, hash: #{hash}, id: #{id}"}
50
50
  non_normalized_identifiers -= identifier_list
51
51
  ns.hash_to_bnodes.delete(hash)
52
52
  simple = true
@@ -57,7 +57,7 @@ module RDF::Normalize
57
57
  ns.hash_to_bnodes.keys.sort.each do |hash|
58
58
  identifier_list = ns.hash_to_bnodes[hash]
59
59
 
60
- debug("multiple nodes") {"node: #{identifier_list.map(&:to_ntriples).join(",")}, hash: #{hash}"}
60
+ log_debug("multiple nodes") {"node: #{identifier_list.map(&:to_ntriples).join(",")}, hash: #{hash}"}
61
61
  hash_path_list = []
62
62
 
63
63
  # Create a hash_path_list for all bnodes using a temporary identifier used to create canonical replacements
@@ -65,15 +65,15 @@ module RDF::Normalize
65
65
  next if ns.canonical_issuer.issued.include?(identifier)
66
66
  temporary_issuer = IdentifierIssuer.new("_:b")
67
67
  temporary_issuer.issue_identifier(identifier)
68
- hash_path_list << depth {ns.hash_n_degree_quads(identifier, temporary_issuer)}
68
+ hash_path_list << log_depth {ns.hash_n_degree_quads(identifier, temporary_issuer)}
69
69
  end
70
- debug("->") {"hash_path_list: #{hash_path_list.map(&:first).inspect}"}
70
+ log_debug("->") {"hash_path_list: #{hash_path_list.map(&:first).inspect}"}
71
71
 
72
72
  # Create canonical replacements for nodes
73
73
  hash_path_list.sort_by(&:first).map(&:last).each do |issuer|
74
74
  issuer.issued.each do |node|
75
75
  id = ns.canonical_issuer.issue_identifier(node)
76
- debug("-->") {"node: #{node.to_ntriples}, id: #{id}"}
76
+ log_debug("-->") {"node: #{node.to_ntriples}, id: #{id}"}
77
77
  end
78
78
  end
79
79
  end
@@ -94,7 +94,7 @@ module RDF::Normalize
94
94
  private
95
95
 
96
96
  class NormalizationState
97
- include Utils
97
+ include RDF::Util::Logger
98
98
 
99
99
  attr_accessor :bnode_to_statements
100
100
  attr_accessor :hash_to_bnodes
@@ -116,7 +116,7 @@ module RDF::Normalize
116
116
  end
117
117
 
118
118
  # @param [RDF::Node] node
119
- # @return [String] the SHA1 hexdigest hash of statements using this node, with replacements
119
+ # @return [String] the SHA256 hexdigest hash of statements using this node, with replacements
120
120
  def hash_first_degree_quads(node)
121
121
  quads = bnode_to_statements[node].
122
122
  map do |statement|
@@ -130,7 +130,7 @@ module RDF::Normalize
130
130
  RDF::NQuads::Writer.serialize(RDF::Statement.from(quad))
131
131
  end
132
132
 
133
- debug("1deg") {"node: #{node}, quads: #{quads}"}
133
+ log_debug("1deg") {"node: #{node}, quads: #{quads}"}
134
134
  hexdigest(quads.sort.join)
135
135
  end
136
136
 
@@ -138,7 +138,7 @@ module RDF::Normalize
138
138
  # @param [RDF::Statement] statement
139
139
  # @param [IdentifierIssuer] issuer
140
140
  # @param [String] position one of :s, :o, or :g
141
- # @return [String] the SHA1 hexdigest hash
141
+ # @return [String] the SHA256 hexdigest hash
142
142
  def hash_related_node(related, statement, issuer, position)
143
143
  identifier = canonical_issuer.identifier(related) ||
144
144
  issuer.identifier(related) ||
@@ -146,7 +146,7 @@ module RDF::Normalize
146
146
  input = position.to_s
147
147
  input << statement.predicate.to_ntriples unless position == :g
148
148
  input << identifier
149
- debug("hrel") {"input: #{input.inspect}, hash: #{hexdigest(input)}"}
149
+ log_debug("hrel") {"input: #{input.inspect}, hash: #{hexdigest(input)}"}
150
150
  hexdigest(input)
151
151
  end
152
152
 
@@ -154,7 +154,7 @@ module RDF::Normalize
154
154
  # @param [IdentifierIssuer] issuer
155
155
  # @return [Array<String,IdentifierIssuer>] the Hash and issuer
156
156
  def hash_n_degree_quads(identifier, issuer)
157
- debug("ndeg") {"identifier: #{identifier.to_ntriples}"}
157
+ log_debug("ndeg") {"identifier: #{identifier.to_ntriples}"}
158
158
 
159
159
  # hash to related blank nodes map
160
160
  map = {}
@@ -165,8 +165,8 @@ module RDF::Normalize
165
165
 
166
166
  data_to_hash = ""
167
167
 
168
- debug("ndeg") {"map: #{map.map {|h,l| "#{h}: #{l.map(&:to_ntriples)}"}.join('; ')}"}
169
- depth do
168
+ log_debug("ndeg") {"map: #{map.map {|h,l| "#{h}: #{l.map(&:to_ntriples)}"}.join('; ')}"}
169
+ log_depth do
170
170
  map.keys.sort.each do |hash|
171
171
  list = map[hash]
172
172
  # Iterate over related nodes
@@ -174,7 +174,7 @@ module RDF::Normalize
174
174
  data_to_hash += hash
175
175
 
176
176
  list.permutation do |permutation|
177
- debug("ndeg") {"perm: #{permutation.map(&:to_ntriples).join(",")}"}
177
+ log_debug("ndeg") {"perm: #{permutation.map(&:to_ntriples).join(",")}"}
178
178
  issuer_copy, path, recursion_list = issuer.dup, "", []
179
179
 
180
180
  permutation.each do |related|
@@ -188,10 +188,10 @@ module RDF::Normalize
188
188
  # Skip to the next permutation if chosen path isn't empty and the path is greater than the chosen path
189
189
  break if !chosen_path.empty? && path.length >= chosen_path.length
190
190
  end
191
- debug("ndeg") {"hash: #{hash}, path: #{path}, recursion: #{recursion_list.map(&:to_ntriples)}"}
191
+ log_debug("ndeg") {"hash: #{hash}, path: #{path}, recursion: #{recursion_list.map(&:to_ntriples)}"}
192
192
 
193
193
  recursion_list.each do |related|
194
- result = depth {hash_n_degree_quads(related, issuer_copy)}
194
+ result = log_depth {hash_n_degree_quads(related, issuer_copy)}
195
195
  path << issuer_copy.issue_identifier(related)
196
196
  path << "<#{result.first}>"
197
197
  issuer_copy = result.last
@@ -208,23 +208,22 @@ module RDF::Normalize
208
208
  end
209
209
  end
210
210
 
211
- debug("ndeg") {"datatohash: #{data_to_hash.inspect}, hash: #{hexdigest(data_to_hash)}"}
211
+ log_debug("ndeg") {"datatohash: #{data_to_hash.inspect}, hash: #{hexdigest(data_to_hash)}"}
212
212
  return [hexdigest(data_to_hash), issuer]
213
213
  end
214
214
 
215
215
  protected
216
216
 
217
- # FIXME: should be SHA-256.
218
217
  def hexdigest(val)
219
- Digest::SHA1.hexdigest(val)
218
+ Digest::SHA256.hexdigest(val)
220
219
  end
221
220
 
222
221
  # Group adjacent bnodes by hash
223
222
  def hash_related_statement(identifier, statement, issuer, map)
224
- statement.to_hash(:s, :p, :o, :g).each do |pos, term|
223
+ statement.to_h(:s, :p, :o, :g).each do |pos, term|
225
224
  next if !term.is_a?(RDF::Node) || term == identifier
226
225
 
227
- hash = depth {hash_related_node(term, statement, issuer, pos)}
226
+ hash = log_depth {hash_related_node(term, statement, issuer, pos)}
228
227
  map[hash] ||= []
229
228
  map[hash] << term unless map[hash].include?(term)
230
229
  end
@@ -261,4 +260,4 @@ module RDF::Normalize
261
260
  end
262
261
  end
263
262
  end
264
- end
263
+ end
@@ -26,18 +26,18 @@ module RDF::Normalize
26
26
  input = position.to_s
27
27
  input << statement.predicate.to_s
28
28
  input << identifier
29
- debug("hrel") {"input: #{input.inspect}, hash: #{hexdigest(input)}"}
29
+ log_debug("hrel") {"input: #{input.inspect}, hash: #{hexdigest(input)}"}
30
30
  hexdigest(input)
31
31
  end
32
32
 
33
33
  # In URGNA2012, the position parameter passed to the Hash Related Blank Node algorithm was instead modeled as a direction parameter, where it could have the value p, for property, when the related blank node was a `subject` and the value r, for reverse or reference, when the related blank node was an `object`. Since URGNA2012 only normalized graphs, not datasets, there was no use of the `graph` position.
34
34
  def hash_related_statement(identifier, statement, issuer, map)
35
35
  if statement.subject.node? && statement.subject != identifier
36
- hash = depth {hash_related_node(statement.subject, statement, issuer, :p)}
36
+ hash = log_depth {hash_related_node(statement.subject, statement, issuer, :p)}
37
37
  map[hash] ||= []
38
38
  map[hash] << statement.subject unless map[hash].include?(statement.subject)
39
39
  elsif statement.object.node? && statement.object != identifier
40
- hash = depth {hash_related_node(statement.object, statement, issuer, :r)}
40
+ hash = log_depth {hash_related_node(statement.object, statement, issuer, :r)}
41
41
  map[hash] ||= []
42
42
  map[hash] << statement.object unless map[hash].include?(statement.object)
43
43
  end
@@ -0,0 +1,18 @@
1
+ module RDF::Normalize::VERSION
2
+ VERSION_FILE = File.join(File.expand_path(File.dirname(__FILE__)), "..", "..", "..", "VERSION")
3
+ MAJOR, MINOR, TINY, EXTRA = File.read(VERSION_FILE).chop.split(".")
4
+
5
+ STRING = [MAJOR, MINOR, TINY, EXTRA].compact.join('.')
6
+
7
+ ##
8
+ # @return [String]
9
+ def self.to_s() STRING end
10
+
11
+ ##
12
+ # @return [String]
13
+ def self.to_str() STRING end
14
+
15
+ ##
16
+ # @return [Array(Integer, Integer, Integer)]
17
+ def self.to_a() STRING.split(".") end
18
+ end
@@ -23,9 +23,8 @@ module RDF::Normalize
23
23
  # @yieldreturn [void]
24
24
  # @yield [writer]
25
25
  # @yieldparam [RDF::Writer] writer
26
- def initialize(output = $stdout, options = {}, &block)
26
+ def initialize(output = $stdout, **options, &block)
27
27
  super do
28
- @options[:depth] ||= 0
29
28
  @repo = RDF::Repository.new
30
29
  if block_given?
31
30
  case block.arity
@@ -36,10 +35,17 @@ module RDF::Normalize
36
35
  end
37
36
  end
38
37
 
38
+
39
39
  ##
40
- # Defer writing to epilogue
41
- def write_statement(statement)
42
- self
40
+ # Adds statements to the repository to be serialized in epilogue.
41
+ #
42
+ # @param [RDF::Resource] subject
43
+ # @param [RDF::URI] predicate
44
+ # @param [RDF::Value] object
45
+ # @param [RDF::Resource] graph_name
46
+ # @return [void]
47
+ def write_quad(subject, predicate, object, graph_name)
48
+ @repo.insert(RDF::Statement(subject, predicate, object, graph_name: graph_name))
43
49
  end
44
50
 
45
51
  ##
@@ -47,7 +53,7 @@ module RDF::Normalize
47
53
  #
48
54
  # @return [void]
49
55
  def write_epilogue
50
- statements = RDF::Normalize.new(@repo, @options).
56
+ statements = RDF::Normalize.new(@repo, **@options).
51
57
  statements.
52
58
  reject(&:variable?).
53
59
  map {|s| format_statement(s)}.
@@ -55,18 +61,11 @@ module RDF::Normalize
55
61
  each do |line|
56
62
  puts line
57
63
  end
64
+ super
58
65
  end
59
66
 
60
67
  protected
61
68
 
62
- ##
63
- # Adds a statement to be serialized
64
- # @param [RDF::Statement] statement
65
- # @return [void]
66
- def insert_statement(statement)
67
- @repo.insert(statement)
68
- end
69
-
70
69
  ##
71
70
  # Insert an Enumerable
72
71
  #
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.1.0
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gregg Kellogg
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-05-20 00:00:00.000000000 Z
11
+ date: 2019-12-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rdf
@@ -16,28 +16,28 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '1.1'
19
+ version: '3.1'
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: '1.1'
26
+ version: '3.1'
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: '1.1'
33
+ version: '3.1'
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: '1.1'
40
+ version: '3.1'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: open-uri-cached
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -64,56 +64,56 @@ dependencies:
64
64
  requirements:
65
65
  - - "~>"
66
66
  - !ruby/object:Gem::Version
67
- version: '3.2'
67
+ version: '3.9'
68
68
  type: :development
69
69
  prerelease: false
70
70
  version_requirements: !ruby/object:Gem::Requirement
71
71
  requirements:
72
72
  - - "~>"
73
73
  - !ruby/object:Gem::Version
74
- version: '3.2'
74
+ version: '3.9'
75
75
  - !ruby/object:Gem::Dependency
76
76
  name: webmock
77
77
  requirement: !ruby/object:Gem::Requirement
78
78
  requirements:
79
79
  - - "~>"
80
80
  - !ruby/object:Gem::Version
81
- version: '1.17'
81
+ version: '3.7'
82
82
  type: :development
83
83
  prerelease: false
84
84
  version_requirements: !ruby/object:Gem::Requirement
85
85
  requirements:
86
86
  - - "~>"
87
87
  - !ruby/object:Gem::Version
88
- version: '1.17'
88
+ version: '3.7'
89
89
  - !ruby/object:Gem::Dependency
90
90
  name: json-ld
91
91
  requirement: !ruby/object:Gem::Requirement
92
92
  requirements:
93
93
  - - "~>"
94
94
  - !ruby/object:Gem::Version
95
- version: '1.1'
95
+ version: '3.1'
96
96
  type: :development
97
97
  prerelease: false
98
98
  version_requirements: !ruby/object:Gem::Requirement
99
99
  requirements:
100
100
  - - "~>"
101
101
  - !ruby/object:Gem::Version
102
- version: '1.1'
102
+ version: '3.1'
103
103
  - !ruby/object:Gem::Dependency
104
104
  name: yard
105
105
  requirement: !ruby/object:Gem::Requirement
106
106
  requirements:
107
107
  - - "~>"
108
108
  - !ruby/object:Gem::Version
109
- version: '0.8'
109
+ version: 0.9.20
110
110
  type: :development
111
111
  prerelease: false
112
112
  version_requirements: !ruby/object:Gem::Requirement
113
113
  requirements:
114
114
  - - "~>"
115
115
  - !ruby/object:Gem::Version
116
- version: '0.8'
116
+ version: 0.9.20
117
117
  description: RDF::Normalize is a Graph normalizer for the RDF.rb library suite.
118
118
  email: public-rdf-ruby@w3.org
119
119
  executables: []
@@ -130,11 +130,11 @@ files:
130
130
  - lib/rdf/normalize/format.rb
131
131
  - lib/rdf/normalize/urdna2015.rb
132
132
  - lib/rdf/normalize/urgna2012.rb
133
- - lib/rdf/normalize/utils.rb
133
+ - lib/rdf/normalize/version.rb
134
134
  - lib/rdf/normalize/writer.rb
135
135
  homepage: http://github.com/gkellogg/rdf-normalize
136
136
  licenses:
137
- - Public Domain
137
+ - Unlicense
138
138
  metadata: {}
139
139
  post_install_message:
140
140
  rdoc_options: []
@@ -144,17 +144,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
144
144
  requirements:
145
145
  - - ">="
146
146
  - !ruby/object:Gem::Version
147
- version: 1.9.2
147
+ version: '2.4'
148
148
  required_rubygems_version: !ruby/object:Gem::Requirement
149
149
  requirements:
150
150
  - - ">="
151
151
  - !ruby/object:Gem::Version
152
152
  version: '0'
153
153
  requirements: []
154
- rubyforge_project: rdf-normalize
155
- rubygems_version: 2.4.7
154
+ rubygems_version: 3.0.6
156
155
  signing_key:
157
156
  specification_version: 4
158
157
  summary: RDF Graph normalizer for Ruby.
159
158
  test_files: []
160
- has_rdoc: false
@@ -1,33 +0,0 @@
1
- module RDF::Normalize
2
- module Utils
3
- # Add debug event to debug array, if specified
4
- #
5
- # param [String] message
6
- # yieldreturn [String] appended to message, to allow for lazy-evaulation of message
7
- def debug(*args)
8
- options = args.last.is_a?(Hash) ? args.pop : {}
9
- return unless options[:debug] || @options[:debug]
10
- depth = options[:depth] || @options[:depth]
11
- d_str = depth > 100 ? ' ' * 100 + '+' : ' ' * depth
12
- list = args
13
- list << yield if block_given?
14
- message = d_str + (list.empty? ? "" : list.join(": "))
15
- options[:debug] << message if options[:debug].is_a?(Array)
16
- @options[:debug] << message if @options[:debug].is_a?(Array)
17
- $stderr.puts(message) if @options[:debug] == TrueClass
18
- end
19
- module_function :debug
20
-
21
- # Increase depth around a method invocation
22
- # @yield
23
- # Yields with no arguments
24
- # @yieldreturn [Object] returns the result of yielding
25
- # @return [Object]
26
- def depth
27
- @options[:depth] += 1
28
- ret = yield
29
- @options[:depth] -= 1
30
- ret
31
- end
32
- end
33
- end