wherever-positions 0.4.2 → 0.4.3

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.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.4.2
1
+ 0.4.3
@@ -1,19 +1,23 @@
1
1
  class Wherever
2
2
  module Mark
3
3
  def mark(name)
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)} )")
4
+ copy_collections("current_identifier", "#{name}_identifier")
10
5
  config.key_groups.each do |keys|
11
6
  [:identifier, :dataset].each do |db_type|
12
7
  db_id = "#{keys.join('_')}_#{db_type}"
13
- configuration.master.eval("db.current_#{db_id}.find().forEach( function(x){db.#{name}_#{db_id}.insert(x)} )")
8
+ copy_collections("current_#{db_id}", "#{name}_#{db_id}")
14
9
  end
15
10
  end
16
11
  set_price_lookup('price', nil, [{'marker' => name}])
17
12
  end
13
+
14
+ def copy_collections(from_collection, to_collection)
15
+ copy_function = "db.#{from_collection}.find().forEach( function(x){db.#{to_collection}.insert(x)} )"
16
+ if Mongoid::Config.respond_to?(:instance)
17
+ Mongoid::Config.instance.master.eval(copy_function)
18
+ else
19
+ Mongoid::Config.master.eval(copy_function)
20
+ end
21
+ end
18
22
  end
19
23
  end
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{wherever-positions}
8
- s.version = "0.4.2"
8
+ s.version = "0.4.3"
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"]
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: 11
4
+ hash: 9
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 4
9
- - 2
10
- version: 0.4.2
9
+ - 3
10
+ version: 0.4.3
11
11
  platform: ruby
12
12
  authors:
13
13
  - David Henry