grom 0.2.0 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.hound.yml +4 -0
- data/.travis.yml +2 -0
- data/grom.gemspec +6 -6
- data/lib/grom/builder.rb +16 -26
- data/lib/grom/reader.rb +8 -8
- data/lib/grom/version.rb +1 -1
- metadata +29 -27
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 20f616b442b532519b292aaec26616dcf076bfea
|
4
|
+
data.tar.gz: 0f26bb9b60fcd19b61c52ec37cb863eb3447411c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c101a727c6c84c3c579bc2e13eb6c1455b64949bb9ff9cd49b0e1af6b760831e28cfc9994be07a5ba95e2d41d64c2683eff7e51a80301490b27752a2a85cc5a4
|
7
|
+
data.tar.gz: 17b55727718efbcb37c0fb98eaca5caa2719192b58221183d992340d3e9ec078561ac03a125caa06bee1e31db31647937654e901daa66e5f2d92b893c12f99df
|
data/.hound.yml
ADDED
data/.travis.yml
ADDED
data/grom.gemspec
CHANGED
@@ -21,15 +21,15 @@ 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'
|
25
|
-
spec.add_dependency 'activesupport'
|
24
|
+
spec.add_dependency 'rdf', '2.2.3'
|
25
|
+
spec.add_dependency 'activesupport', '5.0.1'
|
26
26
|
|
27
27
|
# the below are test dependencies
|
28
28
|
spec.add_development_dependency 'bundler', '~> 1.13'
|
29
29
|
spec.add_development_dependency 'rake', '~> 10.0'
|
30
30
|
spec.add_development_dependency 'rspec', '~> 3.0'
|
31
|
-
spec.add_development_dependency 'rubocop'
|
32
|
-
spec.add_development_dependency 'pry'
|
33
|
-
spec.add_development_dependency 'pry-nav'
|
34
|
-
spec.add_development_dependency 'simplecov'
|
31
|
+
spec.add_development_dependency 'rubocop', '~> 0.47'
|
32
|
+
spec.add_development_dependency 'pry', '~> 0.10'
|
33
|
+
spec.add_development_dependency 'pry-nav', '~> 0.2'
|
34
|
+
spec.add_development_dependency 'simplecov', '~> 0.13'
|
35
35
|
end
|
data/lib/grom/builder.rb
CHANGED
@@ -21,45 +21,35 @@ module Grom
|
|
21
21
|
|
22
22
|
def build_objects_by_subject
|
23
23
|
initialize_objects_hashes
|
24
|
-
@reader.
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
@objects_by_subject[subject] = object
|
29
|
-
@objects << object
|
30
|
-
rescue NoMethodError
|
31
|
-
p 'No statements passed to Grom::Node.new'
|
32
|
-
super
|
33
|
-
end
|
34
|
-
end
|
24
|
+
@reader.statements_by_subject.each do |subject, statements|
|
25
|
+
object = Grom::Node.new(statements)
|
26
|
+
@objects_by_subject[subject] = object
|
27
|
+
@objects << object
|
35
28
|
end
|
36
29
|
|
37
30
|
self
|
38
31
|
end
|
39
32
|
|
40
33
|
def link_objects
|
41
|
-
@reader.
|
42
|
-
|
43
|
-
|
44
|
-
begin
|
45
|
-
connection_node = @objects_by_subject[connection_subject]
|
46
|
-
current_node_type = Grom::Helper.get_id(current_node.type)
|
47
|
-
connector_name_symbol = Grom::Helper.pluralize_instance_variable_symbol(current_node_type)
|
34
|
+
@reader.edges_by_subject.each do |subject, predicates|
|
35
|
+
predicates.each do |predicate, object_uris|
|
36
|
+
current_node = @objects_by_subject[subject]
|
48
37
|
|
49
|
-
|
50
|
-
connected_object_array = [] if connected_object_array.nil?
|
51
|
-
connected_object_array << current_node
|
38
|
+
object_uris.each do |object_uri|
|
52
39
|
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
40
|
+
predicate_name_symbol = "@#{predicate}".to_sym
|
41
|
+
object_array = current_node.instance_variable_get(predicate_name_symbol)
|
42
|
+
object_array = [] if object_array.is_a?(String)
|
43
|
+
object_array << @objects_by_subject[object_uri]
|
44
|
+
|
45
|
+
current_node.instance_variable_set(predicate_name_symbol, object_array)
|
46
|
+
|
47
|
+
# TODO: Not sure about the above conditional
|
57
48
|
end
|
58
49
|
end
|
59
50
|
end
|
60
51
|
|
61
52
|
self
|
62
53
|
end
|
63
|
-
|
64
54
|
end
|
65
55
|
end
|
data/lib/grom/reader.rb
CHANGED
@@ -2,7 +2,7 @@ require 'pry'
|
|
2
2
|
|
3
3
|
module Grom
|
4
4
|
class Reader
|
5
|
-
attr_reader :data, :statements_by_subject, :subjects_by_type, :
|
5
|
+
attr_reader :data, :statements_by_subject, :subjects_by_type, :edges_by_subject, :objects
|
6
6
|
|
7
7
|
def initialize(data)
|
8
8
|
@data = data
|
@@ -15,8 +15,9 @@ module Grom
|
|
15
15
|
def read_data
|
16
16
|
# Reset all our hashes just in case
|
17
17
|
@statements_by_subject = {}
|
18
|
-
|
19
|
-
|
18
|
+
|
19
|
+
# TODO: Find a better name for this hash!
|
20
|
+
@edges_by_subject = {}
|
20
21
|
|
21
22
|
RDF::NTriples::Reader.new(@data) do |reader|
|
22
23
|
reader.each_statement do |statement|
|
@@ -27,12 +28,11 @@ module Grom
|
|
27
28
|
|
28
29
|
predicate = statement.predicate.to_s
|
29
30
|
|
30
|
-
if predicate == RDF.type.to_s
|
31
|
-
Grom::Helper.lazy_array_insert(@subjects_by_type, Grom::Helper.get_id(statement.object), subject)
|
32
|
-
end
|
33
|
-
|
34
31
|
if (statement.object =~ URI.regexp) == 0 && predicate != RDF.type.to_s
|
35
|
-
Grom::Helper.
|
32
|
+
predicate = Grom::Helper.get_id(predicate)
|
33
|
+
@edges_by_subject[subject] ||= {}
|
34
|
+
@edges_by_subject[subject][predicate] ||= []
|
35
|
+
@edges_by_subject[subject][predicate] << statement.object.to_s
|
36
36
|
end
|
37
37
|
end
|
38
38
|
end
|
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: 0.3.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: 2017-01-
|
13
|
+
date: 2017-01-27 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: 2.2.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: 2.2.3
|
29
29
|
- !ruby/object:Gem::Dependency
|
30
30
|
name: activesupport
|
31
31
|
requirement: !ruby/object:Gem::Requirement
|
32
32
|
requirements:
|
33
|
-
- -
|
33
|
+
- - '='
|
34
34
|
- !ruby/object:Gem::Version
|
35
|
-
version:
|
35
|
+
version: 5.0.1
|
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: 5.0.1
|
43
43
|
- !ruby/object:Gem::Dependency
|
44
44
|
name: bundler
|
45
45
|
requirement: !ruby/object:Gem::Requirement
|
@@ -86,58 +86,58 @@ dependencies:
|
|
86
86
|
name: rubocop
|
87
87
|
requirement: !ruby/object:Gem::Requirement
|
88
88
|
requirements:
|
89
|
-
- - "
|
89
|
+
- - "~>"
|
90
90
|
- !ruby/object:Gem::Version
|
91
|
-
version: '0'
|
91
|
+
version: '0.47'
|
92
92
|
type: :development
|
93
93
|
prerelease: false
|
94
94
|
version_requirements: !ruby/object:Gem::Requirement
|
95
95
|
requirements:
|
96
|
-
- - "
|
96
|
+
- - "~>"
|
97
97
|
- !ruby/object:Gem::Version
|
98
|
-
version: '0'
|
98
|
+
version: '0.47'
|
99
99
|
- !ruby/object:Gem::Dependency
|
100
100
|
name: pry
|
101
101
|
requirement: !ruby/object:Gem::Requirement
|
102
102
|
requirements:
|
103
|
-
- - "
|
103
|
+
- - "~>"
|
104
104
|
- !ruby/object:Gem::Version
|
105
|
-
version: '0'
|
105
|
+
version: '0.10'
|
106
106
|
type: :development
|
107
107
|
prerelease: false
|
108
108
|
version_requirements: !ruby/object:Gem::Requirement
|
109
109
|
requirements:
|
110
|
-
- - "
|
110
|
+
- - "~>"
|
111
111
|
- !ruby/object:Gem::Version
|
112
|
-
version: '0'
|
112
|
+
version: '0.10'
|
113
113
|
- !ruby/object:Gem::Dependency
|
114
114
|
name: pry-nav
|
115
115
|
requirement: !ruby/object:Gem::Requirement
|
116
116
|
requirements:
|
117
|
-
- - "
|
117
|
+
- - "~>"
|
118
118
|
- !ruby/object:Gem::Version
|
119
|
-
version: '0'
|
119
|
+
version: '0.2'
|
120
120
|
type: :development
|
121
121
|
prerelease: false
|
122
122
|
version_requirements: !ruby/object:Gem::Requirement
|
123
123
|
requirements:
|
124
|
-
- - "
|
124
|
+
- - "~>"
|
125
125
|
- !ruby/object:Gem::Version
|
126
|
-
version: '0'
|
126
|
+
version: '0.2'
|
127
127
|
- !ruby/object:Gem::Dependency
|
128
128
|
name: simplecov
|
129
129
|
requirement: !ruby/object:Gem::Requirement
|
130
130
|
requirements:
|
131
|
-
- - "
|
131
|
+
- - "~>"
|
132
132
|
- !ruby/object:Gem::Version
|
133
|
-
version: '0'
|
133
|
+
version: '0.13'
|
134
134
|
type: :development
|
135
135
|
prerelease: false
|
136
136
|
version_requirements: !ruby/object:Gem::Requirement
|
137
137
|
requirements:
|
138
|
-
- - "
|
138
|
+
- - "~>"
|
139
139
|
- !ruby/object:Gem::Version
|
140
|
-
version: '0'
|
140
|
+
version: '0.13'
|
141
141
|
description: Grom is a Graph Object Mapper
|
142
142
|
email:
|
143
143
|
- rklappleyard@gmail.com
|
@@ -148,9 +148,11 @@ extensions: []
|
|
148
148
|
extra_rdoc_files: []
|
149
149
|
files:
|
150
150
|
- ".gitignore"
|
151
|
+
- ".hound.yml"
|
151
152
|
- ".rspec"
|
152
153
|
- ".rubocop.yml"
|
153
154
|
- ".ruby-version"
|
155
|
+
- ".travis.yml"
|
154
156
|
- CODE_OF_CONDUCT.md
|
155
157
|
- Gemfile
|
156
158
|
- LICENSE
|
@@ -185,7 +187,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
185
187
|
version: '0'
|
186
188
|
requirements: []
|
187
189
|
rubyforge_project:
|
188
|
-
rubygems_version: 2.
|
190
|
+
rubygems_version: 2.6.6
|
189
191
|
signing_key:
|
190
192
|
specification_version: 4
|
191
193
|
summary: Grom is a Graph Object Mapper
|