@@ -122,16 +122,29 @@ class Repository < ::RDF::Repository
122122 #
123123 # @param [Hash{Symbol => Object}] options
124124 # @option options [URI, #to_s] :uri (nil)
125+ # URI in the form mongodb://host:port/db/collection
125126 # @option options [String, #to_s] :title (nil)
126127 # @option options [String] :host
127128 # @option options [Integer] :port
128- # @option options [String] :db
129+ # @option options [String] :db ('quadb')
129130 # @option options [String] :user for authentication
130131 # @option options [String] :password for authentication
131132 # @option options [String] :collection ('quads')
132133 # @yield [repository]
133134 # @yieldparam [Repository] repository
134135 def initialize ( options = { } , &block )
136+ if options [ :uri ]
137+ options = options . dup
138+ uri = RDF ::URI ( options [ :uri ] )
139+ options [ :host ] ||= uri . host
140+ options [ :port ] ||= uri . port
141+ _ , db , collection = uri . path . split ( '/' )
142+ options [ :db ] ||= db
143+ options [ :collection ] ||= collection
144+ else
145+ warn "[DEPRECATION] RDF::Mongo::Repository#initialize expects a uri argument. Called from #{ Gem . location_of_caller . join ( ':' ) } " unless options . empty?
146+ end
147+
135148 options = { host : 'localhost' , port : 27017 , db : 'quadb' , collection : 'quads' } . merge ( options )
136149 @db = ::Mongo ::Connection . new ( options [ :host ] , options [ :port ] ) . db ( options [ :db ] )
137150 @db . authenticate ( options [ :user ] , options [ :password ] ) if options [ :user ] && options [ :password ]
@@ -150,6 +163,7 @@ def initialize(options = {}, &block)
150163 def supports? ( feature )
151164 case feature . to_sym
152165 when :graph_name then true
166+ when :validity then @options . fetch ( :with_validity , true )
153167 else false
154168 end
155169 end
0 commit comments