nose 0.1.0pre4 → 0.1.0pre5

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
2
  SHA1:
3
- metadata.gz: 41ef239c0f70c5620bf23b22375b827c66cf1455
4
- data.tar.gz: 38f9681415bea77fdf86d2046391e264c9498edf
3
+ metadata.gz: 8ed212e03d78e2d1915732350ff36867d08bb269
4
+ data.tar.gz: be5652bafa272b3f4ad5ded93a0ef1c3cbd261bf
5
5
  SHA512:
6
- metadata.gz: 6dfe61788efd183fd066ee28b0e40d63815786c0a6d405f9726705dbd49a288e887ce499a7008abcdd15c5abfc2bcb664a087c0ec9933f857d786742abd5c352
7
- data.tar.gz: 3fe77c7d39f9c24eb95a2ba0ad8b9cfb0f0975d4d48c88ef8050ac109cfbb1df3c26f698ab502aa6e805e18625c8ebad13a48162722702690afd1bf256b68916
6
+ metadata.gz: 448210b5c1423d10138c0fc2693d7d0a2728ac84a13d20b07d2365fe48d34a7e7c36af81535d53d0cf3ee577f350791f02e5a7eda8e473817b5a57699ac42875
7
+ data.tar.gz: d2ae70342d7782474c201d8adddac1eb444f14e216994ed8ea2e5be0684a3dc0e9fdaed8d61ef945eca5cf210b2e36767423d35a9a15fc96540d441ef9fafbbe
@@ -6,7 +6,9 @@ require 'zlib'
6
6
  module NoSE
7
7
  module Backend
8
8
  # A backend which communicates with Cassandra via CQL
9
- class CassandraBackend < BackendBase
9
+ class CassandraBackend < Backend
10
+ include Subtype
11
+
10
12
  def initialize(model, indexes, plans, update_plans, config)
11
13
  super
12
14
 
@@ -172,7 +174,7 @@ module NoSE
172
174
  end
173
175
 
174
176
  # Insert data into an index on the backend
175
- class InsertStatementStep < BackendBase::InsertStatementStep
177
+ class InsertStatementStep < Backend::InsertStatementStep
176
178
  def initialize(client, index, fields)
177
179
  super
178
180
 
@@ -228,7 +230,7 @@ module NoSE
228
230
  end
229
231
 
230
232
  # Delete data from an index on the backend
231
- class DeleteStatementStep < BackendBase::DeleteStatementStep
233
+ class DeleteStatementStep < Backend::DeleteStatementStep
232
234
  def initialize(client, index)
233
235
  super
234
236
 
@@ -266,7 +268,7 @@ module NoSE
266
268
  end
267
269
 
268
270
  # A query step to look up data from a particular column family
269
- class IndexLookupStatementStep < BackendBase::IndexLookupStatementStep
271
+ class IndexLookupStatementStep < Backend::IndexLookupStatementStep
270
272
  # rubocop:disable Metrics/ParameterLists
271
273
  def initialize(client, select, conditions, step, next_step, prev_step)
272
274
  super
@@ -3,7 +3,9 @@
3
3
  module NoSE
4
4
  module Backend
5
5
  # Simple backend which persists data to a file
6
- class FileBackend < BackendBase
6
+ class FileBackend < Backend
7
+ include Subtype
8
+
7
9
  def initialize(model, indexes, plans, update_plans, config)
8
10
  super
9
11
 
@@ -104,7 +106,7 @@ module NoSE
104
106
  end
105
107
 
106
108
  # Look up data on an index in the backend
107
- class IndexLookupStatementStep < BackendBase::IndexLookupStatementStep
109
+ class IndexLookupStatementStep < Backend::IndexLookupStatementStep
108
110
  include RowMatcher
109
111
 
110
112
  # Filter all the rows in the specified index to those requested
@@ -128,7 +130,7 @@ module NoSE
128
130
  end
129
131
 
130
132
  # Insert data into an index on the backend
131
- class InsertStatementStep < BackendBase::InsertStatementStep
133
+ class InsertStatementStep < Backend::InsertStatementStep
132
134
  # Add new rows to the index
133
135
  def process(results)
134
136
  key_ids = (@index.hash_fields + @index.order_fields).map(&:id).to_set
@@ -163,7 +165,7 @@ module NoSE
163
165
  end
164
166
 
165
167
  # Delete data from an index on the backend
166
- class DeleteStatementStep < BackendBase::DeleteStatementStep
168
+ class DeleteStatementStep < Backend::DeleteStatementStep
167
169
  include RowMatcher
168
170
 
169
171
  # Remove rows matching the results from the dataset
@@ -5,7 +5,9 @@ require 'mongo'
5
5
  module NoSE
6
6
  module Backend
7
7
  # A backend which communicates with MongoDB
8
- class MongoBackend < BackendBase
8
+ class MongoBackend < Backend
9
+ include Subtype
10
+
9
11
  def initialize(model, indexes, plans, update_plans, config)
10
12
  super
11
13
 
@@ -134,7 +136,7 @@ module NoSE
134
136
  end
135
137
 
136
138
  # Insert data into an index on the backend
137
- class InsertStatementStep < BackendBase::InsertStatementStep
139
+ class InsertStatementStep < Backend::InsertStatementStep
138
140
  def initialize(client, index, fields)
139
141
  super
140
142
 
@@ -169,7 +171,7 @@ module NoSE
169
171
  end
170
172
 
171
173
  # A query step to look up data from a particular collection
172
- class IndexLookupStatementStep < BackendBase::IndexLookupStatementStep
174
+ class IndexLookupStatementStep < Backend::IndexLookupStatementStep
173
175
  # rubocop:disable Metrics/ParameterLists
174
176
  def initialize(client, select, conditions, step, next_step, prev_step)
175
177
  super
data/lib/nose/backend.rb CHANGED
@@ -4,7 +4,10 @@ module NoSE
4
4
  # Communication with backends for index creation and statement execution
5
5
  module Backend
6
6
  # Superclass of all database backends
7
- class BackendBase
7
+ class Backend
8
+ include Listing
9
+ include Supertype
10
+
8
11
  def initialize(model, indexes, plans, update_plans, _config)
9
12
  @model = model
10
13
  @indexes = indexes
@@ -308,7 +311,7 @@ module NoSE
308
311
 
309
312
  # Check if the subclass has overridden this step
310
313
  subclass_step_name = step_class.name.sub \
311
- 'NoSE::Backend::BackendBase', self.class.name
314
+ 'NoSE::Backend::Backend', self.class.name
312
315
  step_class = Object.const_get subclass_step_name
313
316
  step_class.new client, fields, conditions,
314
317
  step, next_step, prev_step
@@ -328,7 +331,7 @@ module NoSE
328
331
  def add_delete_step(plan, steps)
329
332
  step_class = DeleteStatementStep
330
333
  subclass_step_name = step_class.name.sub \
331
- 'NoSE::Backend::BackendBase', self.class.name
334
+ 'NoSE::Backend::Backend', self.class.name
332
335
  step_class = Object.const_get subclass_step_name
333
336
  steps << step_class.new(client, plan.index)
334
337
  end
@@ -338,7 +341,7 @@ module NoSE
338
341
  def add_insert_step(plan, steps, fields)
339
342
  step_class = InsertStatementStep
340
343
  subclass_step_name = step_class.name.sub \
341
- 'NoSE::Backend::BackendBase', self.class.name
344
+ 'NoSE::Backend::Backend', self.class.name
342
345
  step_class = Object.const_get subclass_step_name
343
346
  steps << step_class.new(client, plan.index, fields)
344
347
  end
@@ -369,7 +372,7 @@ module NoSE
369
372
  results = nil
370
373
 
371
374
  @steps.each do |step|
372
- if step.is_a?(BackendBase::IndexLookupStatementStep)
375
+ if step.is_a?(Backend::IndexLookupStatementStep)
373
376
  field_ids = step.index.all_fields.map(&:id)
374
377
  field_conds = conditions.select { |key| field_ids.include? key }
375
378
  else
@@ -400,10 +403,10 @@ module NoSE
400
403
  @statement = statement
401
404
  @support_plans = support_plans
402
405
  @delete_step = steps.find do |step|
403
- step.is_a? BackendBase::DeleteStatementStep
406
+ step.is_a? Backend::DeleteStatementStep
404
407
  end
405
408
  @insert_step = steps.find do |step|
406
- step.is_a? BackendBase::InsertStatementStep
409
+ step.is_a? Backend::InsertStatementStep
407
410
  end
408
411
  end
409
412
 
@@ -555,3 +558,7 @@ module NoSE
555
558
  end
556
559
  end
557
560
  end
561
+
562
+ require_relative 'backend/cassandra'
563
+ require_relative 'backend/file'
564
+ require_relative 'backend/mongo'
data/lib/nose/cost.rb CHANGED
@@ -5,6 +5,7 @@ module NoSE
5
5
  module Cost
6
6
  # Cost model for a backend database
7
7
  class Cost
8
+ include Listing
8
9
  include Supertype
9
10
 
10
11
  def initialize(**options)
data/lib/nose/util.rb CHANGED
@@ -276,10 +276,14 @@ module NoSE
276
276
  # by the LOAD_PATH class constant
277
277
  # @return [Object] an instance of the class which included this module
278
278
  def load(name)
279
- path = const_get(:LOAD_PATH)
280
- filename = File.expand_path "../../../#{path}/#{name}.rb", __FILE__
281
- source_code = File.read(filename)
279
+ if File.exist? name
280
+ filename = name
281
+ else
282
+ path = const_get(:LOAD_PATH)
283
+ filename = File.expand_path "../../../#{path}/#{name}.rb", __FILE__
284
+ end
282
285
 
286
+ source_code = File.read(filename)
283
287
  instance = binding.eval source_code, filename
284
288
  instance.instance_variable_set :@source_code, source_code
285
289
  instance
@@ -288,6 +292,29 @@ module NoSE
288
292
  end
289
293
  end
290
294
 
295
+ # Allow tracking of subclasses for plugin purposes
296
+ module Listing
297
+ def self.included(base)
298
+ base.extend ClassMethods
299
+ base.class_variable_set :@@registry, {}
300
+ end
301
+
302
+ # Add a class method to track new subclasses
303
+ module ClassMethods
304
+ # Track this new subclass for later
305
+ # @return [void]
306
+ def inherited(subclass)
307
+ class_variable_get(:@@registry)[subclass.name] = subclass
308
+ end
309
+
310
+ # List all of the encountered subclasses
311
+ # @return [Hash<String, Class>]
312
+ def subclasses
313
+ class_variable_get(:@@registry)
314
+ end
315
+ end
316
+ end
317
+
291
318
  # Extend Time to allow conversion to DateTime instances
292
319
  class Time
293
320
  # Convert to a DateTime instance
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nose
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0pre4
4
+ version: 0.1.0pre5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michael Mior
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-12-31 00:00:00.000000000 Z
11
+ date: 2017-01-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faker