couch-migrate 1.1.3 → 2.0.2

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile CHANGED
@@ -8,4 +8,7 @@ group :development do
8
8
  gem "jeweler", "~> 1.6.4"
9
9
  gem "rcov", ">= 0"
10
10
  gem 'fakefs'
11
+ gem "couchrest_model"
11
12
  end
13
+
14
+
@@ -1,13 +1,26 @@
1
1
  GEM
2
2
  remote: http://rubygems.org/
3
3
  specs:
4
+ activemodel (3.1.1)
5
+ activesupport (= 3.1.1)
6
+ builder (~> 3.0.0)
7
+ i18n (~> 0.6)
8
+ activesupport (3.1.1)
9
+ multi_json (~> 1.0)
10
+ builder (3.0.0)
4
11
  couchrest (1.1.2)
5
12
  mime-types (~> 1.15)
6
13
  multi_json (~> 1.0.0)
7
14
  rest-client (~> 1.6.1)
15
+ couchrest_model (1.1.2)
16
+ activemodel (~> 3.0)
17
+ couchrest (~> 1.1.2)
18
+ mime-types (~> 1.15)
19
+ tzinfo (~> 0.3.22)
8
20
  diff-lcs (1.1.3)
9
21
  fakefs (0.4.0)
10
22
  git (1.2.5)
23
+ i18n (0.6.0)
11
24
  jeweler (1.6.4)
12
25
  bundler (~> 1.0)
13
26
  git (>= 1.2.5)
@@ -26,6 +39,7 @@ GEM
26
39
  rspec-expectations (2.6.0)
27
40
  diff-lcs (~> 1.1.2)
28
41
  rspec-mocks (2.6.0)
42
+ tzinfo (0.3.31)
29
43
  yard (0.6.8)
30
44
 
31
45
  PLATFORMS
@@ -34,6 +48,7 @@ PLATFORMS
34
48
  DEPENDENCIES
35
49
  bundler (~> 1.0.0)
36
50
  couchrest
51
+ couchrest_model
37
52
  fakefs
38
53
  jeweler (~> 1.6.4)
39
54
  rcov
@@ -0,0 +1,8 @@
1
+ 2.0.0
2
+ ----
3
+
4
+ Prevent models defined in migration from auto updating their design
5
+ documents (and there by overwriting the real ones). This is a major
6
+ change and may require modification existing migrations to allow boot
7
+ strapping using migration.
8
+
@@ -44,7 +44,7 @@ db:seed" could provide.
44
44
  property :characteristics, [String]
45
45
  timestamps!
46
46
  design do
47
- view :by_name # views work as expected
47
+ view :by_name
48
48
  end
49
49
  end
50
50
 
@@ -62,6 +62,11 @@ db:seed" could provide.
62
62
  rescue
63
63
  end
64
64
 
65
+ Thing.save_design_doc # you have to manually save the design
66
+ # document for the view to work. NOTE:
67
+ # this will destroy any views not
68
+ # declared in this file.
69
+
65
70
  Account.create! do |a|
66
71
  a.name = "A new account"
67
72
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.1.3
1
+ 2.0.2
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{couch-migrate}
8
- s.version = "1.1.3"
8
+ s.version = "2.0.2"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Greg Edwards"]
12
- s.date = %q{2011-10-04}
12
+ s.date = %q{2011-11-16}
13
13
  s.description = %q{A simple migration system for CouchDB.}
14
14
  s.email = %q{greg@greglearns.com}
15
15
  s.extra_rdoc_files = [
@@ -21,6 +21,7 @@ Gem::Specification.new do |s|
21
21
  ".rspec",
22
22
  "Gemfile",
23
23
  "Gemfile.lock",
24
+ "HISTORY.txt",
24
25
  "LICENSE.txt",
25
26
  "README.rdoc",
26
27
  "Rakefile",
@@ -67,6 +68,7 @@ Gem::Specification.new do |s|
67
68
  s.add_development_dependency(%q<jeweler>, ["~> 1.6.4"])
68
69
  s.add_development_dependency(%q<rcov>, [">= 0"])
69
70
  s.add_development_dependency(%q<fakefs>, [">= 0"])
71
+ s.add_development_dependency(%q<couchrest_model>, [">= 0"])
70
72
  else
71
73
  s.add_dependency(%q<couchrest>, [">= 0"])
72
74
  s.add_dependency(%q<rspec>, ["~> 2.6.0"])
@@ -75,6 +77,7 @@ Gem::Specification.new do |s|
75
77
  s.add_dependency(%q<jeweler>, ["~> 1.6.4"])
76
78
  s.add_dependency(%q<rcov>, [">= 0"])
77
79
  s.add_dependency(%q<fakefs>, [">= 0"])
80
+ s.add_dependency(%q<couchrest_model>, [">= 0"])
78
81
  end
79
82
  else
80
83
  s.add_dependency(%q<couchrest>, [">= 0"])
@@ -84,6 +87,7 @@ Gem::Specification.new do |s|
84
87
  s.add_dependency(%q<jeweler>, ["~> 1.6.4"])
85
88
  s.add_dependency(%q<rcov>, [">= 0"])
86
89
  s.add_dependency(%q<fakefs>, [">= 0"])
90
+ s.add_dependency(%q<couchrest_model>, [">= 0"])
87
91
  end
88
92
  end
89
93
 
@@ -11,6 +11,20 @@ module CouchMigrate
11
11
  self
12
12
  end
13
13
 
14
+ def migrate(*args)
15
+ if defined?( CouchRest::Model::Base)
16
+ orig_auto_update_design_doc = CouchRest::Model::Base.auto_update_design_doc
17
+ CouchRest::Model::Base.auto_update_design_doc = false
18
+ end
19
+ begin
20
+ super
21
+ ensure
22
+ if defined?(CouchRest::Model::Base)
23
+ CouchRest::Model::Base.auto_update_design_doc = orig_auto_update_design_doc
24
+ end
25
+ end
26
+
27
+ end
14
28
  end
15
29
  end
16
30
 
@@ -1,18 +1,15 @@
1
+ require_relative '../base_executer'
2
+ require 'couchrest_model'
3
+
1
4
  # use "use_couchrest_model" in the DSL or
2
5
  # include this module in a migration to use CouchRest::Model
3
- if defined?(::CouchRest::Model)
4
- module ::CouchRest
5
- module Model
6
- class Base
7
- class << self
8
- alias to_s_original to_s
9
-
10
- def to_s
11
- to_s_original.sub(/CouchMigrate::BaseExecuter::Namespaced::/, '')
12
- end
13
- end
14
6
 
15
- end
16
- end
7
+ class << ::CouchRest::Model::Base
8
+ alias to_s_original to_s
9
+
10
+ def to_s
11
+ to_s_original.sub(/CouchMigrate::BaseExecuter::Namespaced::/, '')
17
12
  end
18
13
  end
14
+
15
+
@@ -3,18 +3,44 @@ require 'couch-migrate'
3
3
  require_relative 'shared_sequential_migrations'
4
4
 
5
5
  describe CouchMigrate::CouchMigrater, "#migrate" do
6
+ let(:path) { Pathname.new("./tmp/spec").expand_path.tap{|it| it.mkpath} }
7
+ let(:db_uri) { 'http://127.0.0.1:5984/couch-migrate_test' }
6
8
 
7
9
  it_should_behave_like "sequential_migrations" do
8
- subject { CouchMigrate::CouchMigrater }
10
+ let(:path) { Pathname.new("spec/tmp") }
9
11
 
10
- let(:path){ Pathname.new("spec/tmp") }
11
- let(:db_path) { 'http://127.0.0.1:5984/couch-migrate_test' }
12
+ subject { CouchMigrate::CouchMigrater }
12
13
 
13
14
  def migrater
14
15
  # allows new migrations to be picked up
15
- subject.new(db_path, path)
16
+ subject.new(db_uri, path)
16
17
  end
17
18
  end
18
19
 
20
+ it "doesn't automatically destroy design documents created in previous runs" do
21
+ class ::TestModel < CouchRest::Model::Base
22
+ property :name, String
23
+ design do
24
+ view :by_name
25
+ end
26
+ end
27
+ ::TestModel.save_design_doc!
28
+ Object.module_eval { remove_const :TestModel }
29
+
30
+ File.open(path + "1_model_wo_by_name-view.rb", 'w'){|f| f << <<-MIGR}
31
+ use_couchrest_model
32
+ class TestModel < CouchRest::Model::Base
33
+ property :name, String
34
+ end
35
+ up do
36
+ TestModel.all
37
+ end
38
+ MIGR
39
+
40
+ lambda {
41
+ CouchMigrate::CouchMigrater.new(db_uri, path).migrate(:up, :quiet)
42
+ }.should_not change { CouchRest::Model::Base.database.get('_design/TestModel') || raise("missing design doc") }
43
+ end
44
+
19
45
  end
20
46
 
@@ -1,8 +1,4 @@
1
- require 'fakefs/spec_helpers'
2
-
3
1
  shared_examples_for "a_persisted_list" do
4
- include FakeFS::SpecHelpers
5
-
6
2
  subject { raise "subject must return a new instance" }
7
3
 
8
4
  it "starts off with an empty value/list" do
@@ -4,8 +4,6 @@ require 'fakefs/spec_helpers'
4
4
  shared_examples_for "sequential_migrations" do
5
5
  let(:path){ raise "a path must be defined by the grouping using these shared examples" }
6
6
 
7
- include FakeFS::SpecHelpers
8
-
9
7
  def migrater
10
8
  # allows new migrations to be picked up
11
9
  raise "Groups that include shared examples for sequential migrations must implement a migrater function that returns a new migration object"
@@ -1,3 +1,5 @@
1
+ require 'fakefs/safe'
2
+
1
3
  $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
2
4
  $LOAD_PATH.unshift(File.dirname(__FILE__))
3
5
  require 'rspec'
@@ -8,5 +10,13 @@ require 'fakefs/safe'
8
10
  Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}
9
11
 
10
12
  RSpec.configure do |config|
13
+ config.before(:each) do
14
+ FakeFS::FileSystem.clear
15
+ FakeFS.activate!
16
+ end
11
17
 
18
+ config.after(:each) do
19
+ FakeFS.deactivate!
20
+ FakeFS::FileSystem.clear
21
+ end
12
22
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: couch-migrate
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.3
4
+ version: 2.0.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,12 +9,12 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2011-10-04 00:00:00.000000000 -06:00
12
+ date: 2011-11-16 00:00:00.000000000 -07:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: couchrest
17
- requirement: &2154429960 !ruby/object:Gem::Requirement
17
+ requirement: &2163551160 !ruby/object:Gem::Requirement
18
18
  none: false
19
19
  requirements:
20
20
  - - ! '>='
@@ -22,10 +22,10 @@ dependencies:
22
22
  version: '0'
23
23
  type: :runtime
24
24
  prerelease: false
25
- version_requirements: *2154429960
25
+ version_requirements: *2163551160
26
26
  - !ruby/object:Gem::Dependency
27
27
  name: rspec
28
- requirement: &2154429080 !ruby/object:Gem::Requirement
28
+ requirement: &2163492540 !ruby/object:Gem::Requirement
29
29
  none: false
30
30
  requirements:
31
31
  - - ~>
@@ -33,10 +33,10 @@ dependencies:
33
33
  version: 2.6.0
34
34
  type: :development
35
35
  prerelease: false
36
- version_requirements: *2154429080
36
+ version_requirements: *2163492540
37
37
  - !ruby/object:Gem::Dependency
38
38
  name: yard
39
- requirement: &2154428340 !ruby/object:Gem::Requirement
39
+ requirement: &2163491960 !ruby/object:Gem::Requirement
40
40
  none: false
41
41
  requirements:
42
42
  - - ~>
@@ -44,10 +44,10 @@ dependencies:
44
44
  version: 0.6.0
45
45
  type: :development
46
46
  prerelease: false
47
- version_requirements: *2154428340
47
+ version_requirements: *2163491960
48
48
  - !ruby/object:Gem::Dependency
49
49
  name: bundler
50
- requirement: &2154427760 !ruby/object:Gem::Requirement
50
+ requirement: &2163490880 !ruby/object:Gem::Requirement
51
51
  none: false
52
52
  requirements:
53
53
  - - ~>
@@ -55,10 +55,10 @@ dependencies:
55
55
  version: 1.0.0
56
56
  type: :development
57
57
  prerelease: false
58
- version_requirements: *2154427760
58
+ version_requirements: *2163490880
59
59
  - !ruby/object:Gem::Dependency
60
60
  name: jeweler
61
- requirement: &2154427160 !ruby/object:Gem::Requirement
61
+ requirement: &2163489340 !ruby/object:Gem::Requirement
62
62
  none: false
63
63
  requirements:
64
64
  - - ~>
@@ -66,10 +66,10 @@ dependencies:
66
66
  version: 1.6.4
67
67
  type: :development
68
68
  prerelease: false
69
- version_requirements: *2154427160
69
+ version_requirements: *2163489340
70
70
  - !ruby/object:Gem::Dependency
71
71
  name: rcov
72
- requirement: &2154426620 !ruby/object:Gem::Requirement
72
+ requirement: &2163487940 !ruby/object:Gem::Requirement
73
73
  none: false
74
74
  requirements:
75
75
  - - ! '>='
@@ -77,10 +77,10 @@ dependencies:
77
77
  version: '0'
78
78
  type: :development
79
79
  prerelease: false
80
- version_requirements: *2154426620
80
+ version_requirements: *2163487940
81
81
  - !ruby/object:Gem::Dependency
82
82
  name: fakefs
83
- requirement: &2154425960 !ruby/object:Gem::Requirement
83
+ requirement: &2163486780 !ruby/object:Gem::Requirement
84
84
  none: false
85
85
  requirements:
86
86
  - - ! '>='
@@ -88,7 +88,18 @@ dependencies:
88
88
  version: '0'
89
89
  type: :development
90
90
  prerelease: false
91
- version_requirements: *2154425960
91
+ version_requirements: *2163486780
92
+ - !ruby/object:Gem::Dependency
93
+ name: couchrest_model
94
+ requirement: &2163486040 !ruby/object:Gem::Requirement
95
+ none: false
96
+ requirements:
97
+ - - ! '>='
98
+ - !ruby/object:Gem::Version
99
+ version: '0'
100
+ type: :development
101
+ prerelease: false
102
+ version_requirements: *2163486040
92
103
  description: A simple migration system for CouchDB.
93
104
  email: greg@greglearns.com
94
105
  executables: []
@@ -101,6 +112,7 @@ files:
101
112
  - .rspec
102
113
  - Gemfile
103
114
  - Gemfile.lock
115
+ - HISTORY.txt
104
116
  - LICENSE.txt
105
117
  - README.rdoc
106
118
  - Rakefile
@@ -145,7 +157,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
145
157
  version: '0'
146
158
  segments:
147
159
  - 0
148
- hash: 3382144699293927769
160
+ hash: -4165065190086607812
149
161
  required_rubygems_version: !ruby/object:Gem::Requirement
150
162
  none: false
151
163
  requirements: