wherever-positions 0.4.1 → 0.4.2

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.4.1
1
+ 0.4.2
@@ -1,3 +1,4 @@
1
+ require 'mongo'
1
2
  require 'mongoid'
2
3
  require 'wherever/wherever/accessors'
3
4
  require 'wherever/wherever/adder'
@@ -30,14 +30,10 @@ module DbStore
30
30
  end
31
31
 
32
32
  def get_lookup(name, keys)
33
- if keys
34
- DbStore::Lookup.find_or_create_by(:name => name, :keys => keys)
35
- end
36
- name = "Lookup_#{name.upcase}"
37
- return "DbStore::#{name}".constantize if DbStore.constants.include?(name)
33
+ DbStore::Lookup.find_or_create_by(:name => name, :keys => keys) if keys
34
+ return "DbStore::Lookup#{name}".constantize if DbStore.constants.include?("Lookup#{name}")
38
35
  raise "Missing lookup key from definition" unless keys
39
-
40
- build_class(name, DbStore::VersionConfig, :"lookup_#{name}")
36
+ build_class("Lookup#{name}", DbStore::VersionConfig, :"lookup_#{name}")
41
37
  end
42
38
 
43
39
  def build_class(name, module_object, store_in)
@@ -1,15 +1,16 @@
1
1
  class Wherever
2
2
  module Mark
3
3
  def mark(name)
4
- (['identifier'] + config.key_groups).each do |key|
5
- keys = Array(key)
6
- current_db = get_key_store(*keys)
7
- new_db = get_key_store(*(keys + [{'marker' => name}]))
8
- current_db.datasets.all.each do |record|
9
- new_db.datasets.create!(record.attributes)
10
- end
11
- current_db.identifiers.all.each do |record|
12
- new_db.identifiers.create!(record.attributes)
4
+ configuration = if Mongoid::Config.respond_to?(:master)
5
+ Mongoid::Config
6
+ else
7
+ Mongoid::Config.instance
8
+ end
9
+ configuration.master.eval("db.current_identifier.find().forEach( function(x){db.#{name}_identifier.insert(x)} )")
10
+ config.key_groups.each do |keys|
11
+ [:identifier, :dataset].each do |db_type|
12
+ db_id = "#{keys.join('_')}_#{db_type}"
13
+ configuration.master.eval("db.current_#{db_id}.find().forEach( function(x){db.#{name}_#{db_id}.insert(x)} )")
13
14
  end
14
15
  end
15
16
  set_price_lookup('price', nil, [{'marker' => name}])
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{wherever-positions}
8
- s.version = "0.4.1"
8
+ s.version = "0.4.2"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["David Henry"]
12
- s.date = %q{2011-11-03}
12
+ s.date = %q{2011-11-04}
13
13
  s.description = %q{Allow Store of positions by multiple keys with teh option to mark specific points in time for use later}
14
14
  s.email = %q{dw_henry@yahoo.com.au}
15
15
  s.extra_rdoc_files = [
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: wherever-positions
3
3
  version: !ruby/object:Gem::Version
4
- hash: 13
4
+ hash: 11
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 4
9
- - 1
10
- version: 0.4.1
9
+ - 2
10
+ version: 0.4.2
11
11
  platform: ruby
12
12
  authors:
13
13
  - David Henry
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-11-03 00:00:00 +00:00
18
+ date: 2011-11-04 00:00:00 +00:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency