rdf-mongo 1.1.0 → 1.99.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/VERSION +1 -1
  3. data/lib/rdf/mongo.rb +23 -19
  4. metadata +44 -30
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 38ce1eb844f8edbdd27d261737d9bb3121555434
4
- data.tar.gz: 66a03b0e3b3c79d196aea661215eeeecb8702619
3
+ metadata.gz: 7e3195ca4d5d5ad17d35bd15054f50cd7c9bff23
4
+ data.tar.gz: c1974fdf7ed3ed53c454b34dbdb64332037eaaf0
5
5
  SHA512:
6
- metadata.gz: 0921ee24e6436477ca723a39e20255c9882f80a2fbc8b25f6859f769b19f79b1366ffea09038687794d2ebe8e374eb963a30bccfd7304e74625f33d7b6158851
7
- data.tar.gz: aab519c102bb8780ac63d00013533dd1a868a8ddab985fcc655a451784525df6fe7873b9ba24afa3794be152d69a9b3446232e64e18e3c03f5024b2f01fa9fb9
6
+ metadata.gz: 55b5d27957f3005d8baaf891ba5782da2be7f1a3d7ff313c8e9d76bdf57618ee8bce5d14bfd411317965deb2c0cf0aebbdff0d000135a8df405c3f494d30e82e
7
+ data.tar.gz: 74fa5f4c341246983df4b01c1dee4698d0b6298ba52fa19f6370d20e688bf9a6fc133399529a24725c1b9db88f45af79f579ce4230cda3a4cc65128b2aa4c4b4
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.1.0
1
+ 1.99.0
data/lib/rdf/mongo.rb CHANGED
@@ -14,17 +14,17 @@ module RDF
14
14
  end
15
15
 
16
16
  ##
17
- # Create BSON for a statement representation. Note that if the statement has no context,
17
+ # Create BSON for a statement representation. Note that if the statement has no graph name,
18
18
  # a value of `false` will be used to indicate the default context
19
19
  #
20
20
  # @param [RDF::Statement] statement
21
21
  # @return [Hash] Generated BSON representation of statement.
22
22
  def self.from_mongo(statement)
23
23
  RDF::Statement.new(
24
- :subject => RDF::Mongo::Conversion.from_mongo(statement['s'], statement['st'], statement['sl']),
25
- :predicate => RDF::Mongo::Conversion.from_mongo(statement['p'], statement['pt'], statement['pl']),
26
- :object => RDF::Mongo::Conversion.from_mongo(statement['o'], statement['ot'], statement['ol']),
27
- :context => RDF::Mongo::Conversion.from_mongo(statement['c'], statement['ct'], statement['cl']))
24
+ subject: RDF::Mongo::Conversion.from_mongo(statement['s'], statement['st'], statement['sl']),
25
+ predicate: RDF::Mongo::Conversion.from_mongo(statement['p'], statement['pt'], statement['pl']),
26
+ object: RDF::Mongo::Conversion.from_mongo(statement['o'], statement['ot'], statement['ol']),
27
+ graph_name: RDF::Mongo::Conversion.from_mongo(statement['c'], statement['ct'], statement['cl']))
28
28
  end
29
29
  end
30
30
 
@@ -37,9 +37,9 @@ module RDF
37
37
  #
38
38
  # @param [RDF::Value, Symbol, false, nil] value
39
39
  # URI, BNode or Literal. May also be a Variable or Symbol to indicate
40
- # a pattern for a named context, or `false` to indicate the default context.
40
+ # a pattern for a named graph, or `false` to indicate the default graph.
41
41
  # A value of `nil` indicates a pattern that matches any value.
42
- # @param [:subject, :predicate, :object, :context] place_in_statement
42
+ # @param [:subject, :predicate, :object, :graph_name] place_in_statement
43
43
  # Position within statement.
44
44
  # @return [Hash] BSON representation of the statement
45
45
  def self.to_mongo(value, place_in_statement)
@@ -76,7 +76,7 @@ module RDF
76
76
  t, k1, lt = :pt, :p, :pl
77
77
  when :object
78
78
  t, k1, lt = :ot, :o, :ol
79
- when :context
79
+ when :graph_name
80
80
  t, k1, lt = :ct, :c, :cl
81
81
  end
82
82
  h = {k1 => v, t => k, lt => ll}
@@ -92,9 +92,9 @@ module RDF
92
92
  when :u
93
93
  RDF::URI.intern(value)
94
94
  when :ll
95
- RDF::Literal.new(value, :language => literal_extra.to_sym)
95
+ RDF::Literal.new(value, language: literal_extra.to_sym)
96
96
  when :lt
97
- RDF::Literal.new(value, :datatype => RDF::URI.intern(literal_extra))
97
+ RDF::Literal.new(value, datatype: RDF::URI.intern(literal_extra))
98
98
  when :l
99
99
  RDF::Literal.new(value)
100
100
  when :n
@@ -126,12 +126,15 @@ module RDF
126
126
  # @option options [String] :host
127
127
  # @option options [Integer] :port
128
128
  # @option options [String] :db
129
+ # @option options [String] :user for authentication
130
+ # @option options [String] :password for authentication
129
131
  # @option options [String] :collection ('quads')
130
132
  # @yield [repository]
131
133
  # @yieldparam [Repository] repository
132
134
  def initialize(options = {}, &block)
133
- options = {:host => 'localhost', :port => 27017, :db => 'quadb', :collection => 'quads'}.merge(options)
135
+ options = {host: 'localhost', port: 27017, db: 'quadb', collection: 'quads'}.merge(options)
134
136
  @db = ::Mongo::Connection.new(options[:host], options[:port]).db(options[:db])
137
+ @db.authenticate(options[:user], options[:password]) if options[:user] && options[:password]
135
138
  @coll = @db[options[:collection]]
136
139
  @coll.create_index("s")
137
140
  @coll.create_index("p")
@@ -146,21 +149,22 @@ module RDF
146
149
  # @see RDF::Mutable#insert_statement
147
150
  def supports?(feature)
148
151
  case feature.to_sym
149
- when :context then true
152
+ when :graph_name then true
150
153
  else false
151
154
  end
152
155
  end
153
156
 
154
157
  def insert_statement(statement)
158
+ raise ArgumentError, "Statement #{statement.inspect} is incomplete" if statement.incomplete?
155
159
  st_mongo = statement.to_mongo
156
- st_mongo[:ct] ||= :default # Indicate statement is in the default context
160
+ st_mongo[:ct] ||= :default # Indicate statement is in the default graph
157
161
  #puts "insert statement: #{st_mongo.inspect}"
158
- @coll.update(st_mongo, st_mongo, :upsert => true)
162
+ @coll.update(st_mongo, st_mongo, upsert: true)
159
163
  end
160
164
 
161
165
  # @see RDF::Mutable#delete_statement
162
166
  def delete_statement(statement)
163
- case statement.context
167
+ case statement.graph_name
164
168
  when nil
165
169
  @coll.remove(statement.to_mongo.merge('ct'=>:default))
166
170
  else
@@ -213,8 +217,8 @@ module RDF
213
217
 
214
218
  ##
215
219
  # @private
216
- # @see RDF::Enumerable#has_context?
217
- def has_context?(value)
220
+ # @see RDF::Enumerable#has_graph?
221
+ def has_graph?(value)
218
222
  !!@coll.find_one(RDF::Mongo::Conversion.to_mongo(value, :context))
219
223
  end
220
224
 
@@ -227,9 +231,9 @@ module RDF
227
231
  def query_pattern(pattern, &block)
228
232
  @nodes = {} # reset cache. FIXME this should probably be in Node.intern
229
233
 
230
- # A pattern context of `false` is used to indicate the default context
234
+ # A pattern graph_name of `false` is used to indicate the default graph
231
235
  pm = pattern.to_mongo
232
- pm.merge!(:c => nil, :ct => :default) if pattern.context == false
236
+ pm.merge!(c: nil, ct: :default) if pattern.graph_name == false
233
237
  #puts "query using #{pm.inspect}"
234
238
  @coll.find(pm) do |cursor|
235
239
  cursor.each do |data|
metadata CHANGED
@@ -1,97 +1,111 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rdf-mongo
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.99.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Pius Uzamere
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-11-13 00:00:00.000000000 Z
11
+ date: 2015-10-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rdf
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - '>='
17
+ - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '1.1'
19
+ version: '1.99'
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: '1.99'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: mongo
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - '>='
31
+ - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: 1.8.6
33
+ version: '1.10'
34
34
  type: :runtime
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.8.6
40
+ version: '1.10'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: rdf-spec
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - '>='
45
+ - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: '1.1'
47
+ version: '1.99'
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - '>='
52
+ - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: '1.1'
54
+ version: '1.99'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: rspec
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - '>='
59
+ - - "~>"
60
60
  - !ruby/object:Gem::Version
61
- version: 2.14.0
61
+ version: '3.0'
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - '>='
66
+ - - "~>"
67
67
  - !ruby/object:Gem::Version
68
- version: 2.14.0
68
+ version: '3.0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rspec-its
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '1.0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '1.0'
69
83
  - !ruby/object:Gem::Dependency
70
84
  name: yard
71
85
  requirement: !ruby/object:Gem::Requirement
72
86
  requirements:
73
- - - '>='
87
+ - - "~>"
74
88
  - !ruby/object:Gem::Version
75
- version: 0.8.7
89
+ version: '0.8'
76
90
  type: :development
77
91
  prerelease: false
78
92
  version_requirements: !ruby/object:Gem::Requirement
79
93
  requirements:
80
- - - '>='
94
+ - - "~>"
81
95
  - !ruby/object:Gem::Version
82
- version: 0.8.7
96
+ version: '0.8'
83
97
  - !ruby/object:Gem::Dependency
84
98
  name: bson_ext
85
99
  requirement: !ruby/object:Gem::Requirement
86
100
  requirements:
87
- - - '>='
101
+ - - ">="
88
102
  - !ruby/object:Gem::Version
89
103
  version: '0'
90
104
  type: :development
91
105
  prerelease: false
92
106
  version_requirements: !ruby/object:Gem::Requirement
93
107
  requirements:
94
- - - '>='
108
+ - - ">="
95
109
  - !ruby/object:Gem::Version
96
110
  version: '0'
97
111
  description: rdf-mongo is a storage adapter for integrating MongoDB and rdf.rb, a
@@ -102,10 +116,10 @@ extensions: []
102
116
  extra_rdoc_files: []
103
117
  files:
104
118
  - LICENSE
105
- - VERSION
106
119
  - README.md
107
- - lib/rdf/mongo/version.rb
120
+ - VERSION
108
121
  - lib/rdf/mongo.rb
122
+ - lib/rdf/mongo/version.rb
109
123
  homepage: http://ruby-rdf.github.com/rdf-mongo
110
124
  licenses:
111
125
  - MIT License
@@ -116,17 +130,17 @@ require_paths:
116
130
  - lib
117
131
  required_ruby_version: !ruby/object:Gem::Requirement
118
132
  requirements:
119
- - - '>='
133
+ - - ">="
120
134
  - !ruby/object:Gem::Version
121
- version: 1.9.2
135
+ version: 1.9.3
122
136
  required_rubygems_version: !ruby/object:Gem::Requirement
123
137
  requirements:
124
- - - '>='
138
+ - - ">="
125
139
  - !ruby/object:Gem::Version
126
140
  version: '0'
127
141
  requirements: []
128
142
  rubyforge_project:
129
- rubygems_version: 2.1.11
143
+ rubygems_version: 2.4.5.1
130
144
  signing_key:
131
145
  specification_version: 4
132
146
  summary: A storage adapter for integrating MongoDB and rdf.rb, a Ruby library for