couchrest_model 2.1.0.beta1 → 2.1.0.beta2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 57c0015876d459e0bee7cfb9e3f59a2aa5231d1d
4
- data.tar.gz: 7c0e6f7444fa9e73fc041946c5736f94eb42b765
3
+ metadata.gz: d9d09e0aa83e793199ecb3d666f57623870fd63c
4
+ data.tar.gz: e4faadfdc65e72a4212a59932c8953fb80ae04ee
5
5
  SHA512:
6
- metadata.gz: 306a335f39a5530bd4273731affe1f1c238b0e487177d3340b8c6e9cefa885ec2e2048182cd008b3a3ab12ca31d487110f8e0bca036d28639b8d1b74c8872238
7
- data.tar.gz: 9d09641f25b138dbb3c56cfbbe2663947d6ed04135a64d5d4157b8f94d068881989ac79f0f19d7e0c1af64cee4d42aedc9534becdc26c97551b04c8193ef0a5e
6
+ metadata.gz: 61d9e906196acbd827666ca4541b682b066b48bafe1adcdf34bd08f163a4c977ec5c22769afde441c5b259694239298d584308f59c67eaa95db2f62e4b1965a7
7
+ data.tar.gz: 13360a9c60b859e5e39723d585efe273f57198d70e8c38662dc248c5449b04fb07b3d36c91689e78e42c13ba851e30872f37c5b060fcfabdd45a4a4aec06cad2
data/VERSION CHANGED
@@ -1 +1 @@
1
- 2.1.0.beta1
1
+ 2.1.0.beta2
data/history.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # CouchRest Model Change History
2
2
 
3
+ ## 2.1.0.beta2 - 2016-02-29
4
+
5
+ * Changing migration namespace and supporting initial "prepare" phase (@samlown)
6
+
3
7
  ## 2.1.0.beta1 - 2016-01-13
4
8
 
5
9
  * Upgrading to CouchRest 2.0.0 series (@samlown)
@@ -22,7 +22,22 @@ module CouchRest
22
22
  #
23
23
  # Typically however you'd want to run these methods from the rake tasks:
24
24
  #
25
- # $ rake couchrest:migrate_with_proxies
25
+ # $ rake couchrest:designs:migrate_with_proxies
26
+ #
27
+ # In production environments, you sometimes want to prepare large view
28
+ # indexes that take a long term to generate before activating them. To
29
+ # support this scenario we provide the `:activate` option:
30
+ #
31
+ # # Prepare all models, but do not activate
32
+ # CouchRest::Model::Utils::Migrate.all_models(activate: false)
33
+ #
34
+ # Or from Rake:
35
+ #
36
+ # $ rake couchrest:designs:prepare
37
+ #
38
+ # Once finished, just before uploading your code you can repeat without
39
+ # the `activate` option so that the view indexes are ready for the new
40
+ # designs.
26
41
  #
27
42
  # NOTE: This is an experimental feature that is not yet properly tested.
28
43
  #
@@ -41,15 +56,16 @@ module CouchRest
41
56
 
42
57
  # Go through each class that inherits from CouchRest::Model::Base and
43
58
  # attempt to migrate the design documents.
44
- def all_models
59
+ def all_models(opts = {})
60
+ opts.reverse_merge!(activate: true, with_proxies: false)
45
61
  callbacks = migrate_each_model(find_models)
46
- cleanup(callbacks)
62
+ callbacks += migrate_each_proxying_model(find_proxying_models) if opts[:with_proxies]
63
+ activate_designs(callbacks) if opts[:activate]
47
64
  end
48
65
 
49
- def all_models_and_proxies
50
- callbacks = migrate_each_model(find_models)
51
- callbacks += migrate_each_proxying_model(find_proxying_models)
52
- cleanup(callbacks)
66
+ def all_models_and_proxies(opts = {})
67
+ opts[:with_proxies] = true
68
+ all_models(opts)
53
69
  end
54
70
 
55
71
  protected
@@ -98,7 +114,7 @@ module CouchRest
98
114
  callback ? {:design => design, :proc => callback, :db => db || model.database} : nil
99
115
  end
100
116
 
101
- def cleanup(methods)
117
+ def activate_designs(methods)
102
118
  methods.compact.each do |cb|
103
119
  name = "/#{cb[:db].name}/#{cb[:design]['_id']}"
104
120
  puts "Activating new design: #{name}"
@@ -5,17 +5,31 @@
5
5
  #
6
6
  namespace :couchrest do
7
7
 
8
- desc "Migrate all the design docs found in each model"
9
- task :migrate => :environment do
10
- CouchRest::Model::Utils::Migrate.load_all_models
11
- CouchRest::Model::Utils::Migrate.all_models
12
- end
8
+ namespace :designs do
13
9
 
14
- desc "Migrate all the design docs "
15
- task :migrate_with_proxies => :environment do
16
- CouchRest::Model::Utils::Migrate.load_all_models
17
- CouchRest::Model::Utils::Migrate.all_models_and_proxies
18
- end
10
+ desc "Migrate all the design docs found in each model"
11
+ task :migrate => :environment do
12
+ CouchRest::Model::Utils::Migrate.load_all_models
13
+ CouchRest::Model::Utils::Migrate.all_models
14
+ end
15
+
16
+ desc "Migrate all the design docs found in each model, but do not active the designs"
17
+ task :prepare => :environment do
18
+ CouchRest::Model::Utils::Migrate.load_all_models
19
+ CouchRest::Model::Utils::Migrate.all_models(activate: false)
20
+ end
19
21
 
22
+ desc "Migrate all the design docs "
23
+ task :migrate_with_proxies => :environment do
24
+ CouchRest::Model::Utils::Migrate.load_all_models
25
+ CouchRest::Model::Utils::Migrate.all_models_and_proxies
26
+ end
20
27
 
28
+ desc "Migrate all the design docs "
29
+ task :prepare_with_proxies => :environment do
30
+ CouchRest::Model::Utils::Migrate.load_all_models
31
+ CouchRest::Model::Utils::Migrate.all_models_and_proxies(activate: false)
32
+ end
33
+
34
+ end
21
35
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: couchrest_model
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.0.beta1
4
+ version: 2.1.0.beta2
5
5
  platform: ruby
6
6
  authors:
7
7
  - J. Chris Anderson
@@ -12,7 +12,7 @@ authors:
12
12
  autorequire:
13
13
  bindir: bin
14
14
  cert_chain: []
15
- date: 2015-07-10 00:00:00.000000000 Z
15
+ date: 2016-02-25 00:00:00.000000000 Z
16
16
  dependencies:
17
17
  - !ruby/object:Gem::Dependency
18
18
  name: couchrest