grom 0.6.1 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.ruby-version +1 -1
- data/grom.gemspec +3 -2
- data/lib/grom/builder.rb +4 -2
- data/lib/grom/node.rb +5 -3
- data/lib/grom/reader.rb +3 -2
- data/lib/grom/version.rb +1 -1
- metadata +22 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: dbf2858155b7cc3f38c1b76cc2f4b07cb5ec3bed
|
4
|
+
data.tar.gz: 5a37dacf7ef16733c5ee2080a82bc2f0bb6f2e58
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 868b419c8e808d8ab0fab118e7275af1e0c3033212ef52401eece385044e7b375a4d50e0d514a062bc84a6498b22d64505a68c21018ef85f62f4e9d9ac9c9e0b
|
7
|
+
data.tar.gz: '0457895235f090e5433e19494fe3b80b1621016f45995bbe2353de2339b04030541d8f51e16b720fa3479f531f6d4472e4011572f4b8a0a2aff5694674d49752'
|
data/.ruby-version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
2.
|
1
|
+
2.5.1
|
data/grom.gemspec
CHANGED
@@ -21,9 +21,9 @@ Gem::Specification.new do |spec|
|
|
21
21
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
22
22
|
spec.require_paths = ['lib']
|
23
23
|
|
24
|
-
spec.add_dependency 'rdf', '
|
24
|
+
spec.add_dependency 'rdf', '~> 3'
|
25
25
|
# Defines RDF vocabularies
|
26
|
-
spec.add_dependency 'rdf-vocab', '~>
|
26
|
+
spec.add_dependency 'rdf-vocab', '~> 3'
|
27
27
|
spec.add_dependency 'activesupport', '>= 5.0.0.1'
|
28
28
|
|
29
29
|
# the below are test dependencies
|
@@ -32,4 +32,5 @@ Gem::Specification.new do |spec|
|
|
32
32
|
spec.add_development_dependency 'rspec', '~> 3.0'
|
33
33
|
spec.add_development_dependency 'rubocop', '~> 0.51'
|
34
34
|
spec.add_development_dependency 'simplecov', '~> 0.13'
|
35
|
+
spec.add_development_dependency 'parliament-grom-decorators', '~> 0.31'
|
35
36
|
end
|
data/lib/grom/builder.rb
CHANGED
@@ -7,8 +7,10 @@ module Grom
|
|
7
7
|
attr_reader :objects
|
8
8
|
|
9
9
|
# @param [Grom::Reader] reader a Grom::Reader instance populated with data.
|
10
|
-
|
10
|
+
# @param [Module] decorators a Module that answers to #decorate_with_type(node, type)
|
11
|
+
def initialize(reader, decorators = nil)
|
11
12
|
@reader = reader
|
13
|
+
@decorators = decorators
|
12
14
|
|
13
15
|
build_objects
|
14
16
|
end
|
@@ -31,7 +33,7 @@ module Grom
|
|
31
33
|
@objects_by_subject = {}
|
32
34
|
|
33
35
|
@reader.statements_by_subject.each do |subject, statements|
|
34
|
-
object = Grom::Node.new(statements)
|
36
|
+
object = Grom::Node.new(statements, @decorators)
|
35
37
|
@objects_by_subject[subject] = object
|
36
38
|
@objects << object
|
37
39
|
end
|
data/lib/grom/node.rb
CHANGED
@@ -9,10 +9,10 @@ module Grom
|
|
9
9
|
attr_reader :statements
|
10
10
|
|
11
11
|
# @param [Array] statements an array of n-triple statements.
|
12
|
-
def initialize(statements)
|
12
|
+
def initialize(statements, decorators = nil)
|
13
13
|
@statements = statements
|
14
14
|
|
15
|
-
populate
|
15
|
+
populate(decorators)
|
16
16
|
end
|
17
17
|
|
18
18
|
# Allows the user to access instance variables as methods or raise an error if the variable is not defined.
|
@@ -78,7 +78,7 @@ module Grom
|
|
78
78
|
instance_variable_set('@graph_id'.to_sym, graph_id)
|
79
79
|
end
|
80
80
|
|
81
|
-
def populate
|
81
|
+
def populate(decorators)
|
82
82
|
set_graph_id
|
83
83
|
@statements.each do |statement|
|
84
84
|
predicate = Grom::Helper.get_id(statement.predicate).to_sym
|
@@ -93,6 +93,8 @@ module Grom
|
|
93
93
|
else
|
94
94
|
instance_variable_set("@#{predicate}", object)
|
95
95
|
end
|
96
|
+
|
97
|
+
decorators&.decorate_with_type(self, object) if statement.predicate == RDF.type && decorators
|
96
98
|
end
|
97
99
|
end
|
98
100
|
end
|
data/lib/grom/reader.rb
CHANGED
@@ -10,12 +10,13 @@ module Grom
|
|
10
10
|
attr_reader :data, :statements_by_subject, :edges_by_subject, :objects
|
11
11
|
|
12
12
|
# @param [String] data n-triple data.
|
13
|
-
|
13
|
+
# @param [Module] decorators decorators to use when building Grom::Node objects.
|
14
|
+
def initialize(data, decorators = nil)
|
14
15
|
@data = data
|
15
16
|
|
16
17
|
read_data
|
17
18
|
|
18
|
-
@objects = Grom::Builder.new(self).objects
|
19
|
+
@objects = Grom::Builder.new(self, decorators).objects
|
19
20
|
end
|
20
21
|
|
21
22
|
# Reads the n-triple data and separates the statements by subject.
|
data/lib/grom/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: grom
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Rebecca Appleyard
|
@@ -10,36 +10,36 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: exe
|
12
12
|
cert_chain: []
|
13
|
-
date: 2018-
|
13
|
+
date: 2018-09-06 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: rdf
|
17
17
|
requirement: !ruby/object:Gem::Requirement
|
18
18
|
requirements:
|
19
|
-
- -
|
19
|
+
- - "~>"
|
20
20
|
- !ruby/object:Gem::Version
|
21
|
-
version:
|
21
|
+
version: '3'
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
24
|
version_requirements: !ruby/object:Gem::Requirement
|
25
25
|
requirements:
|
26
|
-
- -
|
26
|
+
- - "~>"
|
27
27
|
- !ruby/object:Gem::Version
|
28
|
-
version:
|
28
|
+
version: '3'
|
29
29
|
- !ruby/object:Gem::Dependency
|
30
30
|
name: rdf-vocab
|
31
31
|
requirement: !ruby/object:Gem::Requirement
|
32
32
|
requirements:
|
33
33
|
- - "~>"
|
34
34
|
- !ruby/object:Gem::Version
|
35
|
-
version: '
|
35
|
+
version: '3'
|
36
36
|
type: :runtime
|
37
37
|
prerelease: false
|
38
38
|
version_requirements: !ruby/object:Gem::Requirement
|
39
39
|
requirements:
|
40
40
|
- - "~>"
|
41
41
|
- !ruby/object:Gem::Version
|
42
|
-
version: '
|
42
|
+
version: '3'
|
43
43
|
- !ruby/object:Gem::Dependency
|
44
44
|
name: activesupport
|
45
45
|
requirement: !ruby/object:Gem::Requirement
|
@@ -124,6 +124,20 @@ dependencies:
|
|
124
124
|
- - "~>"
|
125
125
|
- !ruby/object:Gem::Version
|
126
126
|
version: '0.13'
|
127
|
+
- !ruby/object:Gem::Dependency
|
128
|
+
name: parliament-grom-decorators
|
129
|
+
requirement: !ruby/object:Gem::Requirement
|
130
|
+
requirements:
|
131
|
+
- - "~>"
|
132
|
+
- !ruby/object:Gem::Version
|
133
|
+
version: '0.31'
|
134
|
+
type: :development
|
135
|
+
prerelease: false
|
136
|
+
version_requirements: !ruby/object:Gem::Requirement
|
137
|
+
requirements:
|
138
|
+
- - "~>"
|
139
|
+
- !ruby/object:Gem::Version
|
140
|
+
version: '0.31'
|
127
141
|
description: Grom is a Graph Object Mapper
|
128
142
|
email:
|
129
143
|
- rklappleyard@gmail.com
|