guard-migrate 1.0.0 → 1.0.1

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: d51cb8315dfb14923f1bc1429a7e47a56ceb630d
4
- data.tar.gz: e3b9a8da4701605a2ca85b1f5101bbd59d870533
3
+ metadata.gz: 6071bbfbe6292826de322859de484c8dd5dc0125
4
+ data.tar.gz: e9a9b0dfab9190ff9e8ca5b11f680e0b372e84ce
5
5
  SHA512:
6
- metadata.gz: c6cbfe64a7bb7cffc6a1a8dff35aa5ef2f92e1f88199b0ad179d4804404adc16b143c941a202e55aad174b7158781be47510a2cf71936bda535b00def3ba5ec0
7
- data.tar.gz: 70d80717b6085fc39a004c169c76b39609b841c9090ec908bb422e1259d0ceaeb7300303fff93afa80b488edcdf8560d8945e0f16203a39018b9909eab4a3ec1
6
+ metadata.gz: 9cfdbca1c0ffe16b272a8acd877aeb64f3f2f795610008d96ec960c2663ab8b0bede856f1548a3416a095055389d6accfbc7bb5d0098086ed9c9f598c46273cf
7
+ data.tar.gz: 083669965c9746167e05117b178a60b50d249b6df0b21faad44e3680a28b70fe7f7fe7754be6d715a37e25da88679d9df2334b8942e074814388ceb8fb2c5cdf
@@ -28,6 +28,7 @@ Add guard definition to your Guardfile by running this command:
28
28
 
29
29
  Available options:
30
30
 
31
+ * :cmd - this will specify a custom command to run, you can use it to speed up migrations if you use `zeus`, `spring` or simillar in your project. Defaults to `rake`
31
32
  * :run_on_start - this will run the migration task when you start, reload or run all. Defaults to false. If reset is set to true with this, then it will run a reset on the start, reload, run all instead of just a regular migrate
32
33
  * :test_clone - this will run the with the additional `db:test:clone` to update the test database. Defaults to true.
33
34
  * :reset - this will run `rake db:migrate:reset` every time migrate is run. Defaults to false.
@@ -10,6 +10,7 @@ module Guard
10
10
  def initialize(watchers=[], options={})
11
11
  super
12
12
 
13
+ @cmd = options[:cmd].to_s unless options[:cmd].to_s.empty?
13
14
  @reset = true if options[:reset] == true
14
15
  @test_clone = true unless options[:test_clone] == false
15
16
  @run_on_start = true if options[:run_on_start] == true
@@ -25,6 +26,10 @@ module Guard
25
26
  !!@run_on_start
26
27
  end
27
28
 
29
+ def cmd?
30
+ !!@cmd
31
+ end
32
+
28
33
  def test_clone?
29
34
  !!@test_clone
30
35
  end
@@ -99,6 +104,8 @@ module Guard
99
104
 
100
105
  def rake_string(version = nil)
101
106
  [
107
+ bundler_command,
108
+ custom_command,
102
109
  rake_command,
103
110
  migrate_string(version),
104
111
  seed_string,
@@ -109,6 +116,8 @@ module Guard
109
116
 
110
117
  def seed_only_string
111
118
  [
119
+ bundler_command,
120
+ custom_command,
112
121
  rake_command,
113
122
  seed_string,
114
123
  clone_string,
@@ -134,10 +143,15 @@ module Guard
134
143
  end
135
144
 
136
145
  def rake_command
137
- command = ""
138
- command += "bundle exec " if bundler?
139
- command += "rake"
140
- command
146
+ "rake" unless custom_command.to_s.match(/rake/)
147
+ end
148
+
149
+ def bundler_command
150
+ "bundle exec" if bundler?
151
+ end
152
+
153
+ def custom_command
154
+ "#{@cmd.strip}" if cmd?
141
155
  end
142
156
 
143
157
  def rails_env_string
@@ -145,7 +159,9 @@ module Guard
145
159
  end
146
160
 
147
161
  def clone_string
148
- "db:test:clone" if test_clone?
162
+ if test_clone? and !custom_command.to_s.match(/db:test:clone/)
163
+ "db:test:clone"
164
+ end
149
165
  end
150
166
 
151
167
  def seed_string
@@ -153,10 +169,12 @@ module Guard
153
169
  end
154
170
 
155
171
  def migrate_string(version)
156
- string = "db:migrate"
157
- string += ":reset" if reset?
158
- string += ":redo VERSION=#{version}" if run_redo?(version)
159
- string
172
+ if !custom_command.to_s.match(/db:migrate/)
173
+ string = "db:migrate"
174
+ string += ":reset" if reset?
175
+ string += ":redo VERSION=#{version}" if run_redo?(version)
176
+ string
177
+ end
160
178
  end
161
179
 
162
180
  end
@@ -1,5 +1,5 @@
1
1
  module Guard
2
2
  module MigrateVersion
3
- VERSION = "1.0.0"
3
+ VERSION = "1.0.1"
4
4
  end
5
5
  end
@@ -13,8 +13,8 @@ describe Guard::Migrate do
13
13
 
14
14
  after(:all) do
15
15
  FileUtils.rm_rf('db')
16
- end
17
-
16
+ end
17
+
18
18
  describe "options" do
19
19
  context "bundler" do
20
20
  context "with a gemfile found" do
@@ -28,8 +28,58 @@ describe Guard::Migrate do
28
28
  its(:bundler?){should_not be_true}
29
29
  its(:rake_string){should match(/^rake/)}
30
30
  end
31
+ end
32
+
33
+ context "cmd" do
34
+ context "without command customization" do
35
+ its(:cmd?){should_not be_true}
36
+ end
37
+
38
+ context "with command customization" do
39
+ before{File.stub(:exist?).and_return(false)}
40
+ let(:options){ { :cmd => "custom command rake" } }
41
+
42
+ its(:cmd?){should be_true}
43
+ its(:rake_string){should match(/^custom command rake/)}
44
+
45
+ context "without presence of 'rake' keyword" do
46
+ let(:options){ { :cmd => "custom command" } }
47
+
48
+ it "should raise and error" do
49
+ pending
50
+ end
51
+ end
52
+
53
+ context "with Bundler" do
54
+ before{File.stub(:exist?).and_return(true)}
31
55
 
56
+ its(:rake_string){should match(/^bundle exec custom command rake/)}
57
+ end
58
+
59
+ context "with custom rake task specified" do
60
+ context "with duplication of db:migrate" do
61
+ let(:options){ { :cmd => "custom command rake db:migrate" } }
62
+
63
+ context "rake_string" do
64
+ it "should contains 'db:migrate' once" do
65
+ subject.rake_string.scan("db:migrate").size.should == 1
66
+ end
67
+ end
68
+ end
69
+
70
+ context "with duplication of db:test:clone" do
71
+ let(:options){ { :cmd => "custom command rake db:test:clone" } }
72
+
73
+ context "rake_string" do
74
+ it "should contains 'db:test:clone' once" do
75
+ subject.rake_string.scan("db:test:clone").size.should == 1
76
+ end
77
+ end
78
+ end
79
+ end
80
+ end
32
81
  end
82
+
33
83
  context "test clone" do
34
84
  context "with no options passed" do
35
85
  its(:test_clone?){should be_true}
@@ -209,7 +259,7 @@ describe Guard::Migrate do
209
259
 
210
260
  subject.should_not_receive(:system).with(subject.rake_string('1234'))
211
261
  subject.run_on_changes [migration.path]
212
- end
262
+ end
213
263
  end
214
264
 
215
265
  end
metadata CHANGED
@@ -1,57 +1,43 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: guard-migrate
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Geoff Lanotte
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-01-01 00:00:00.000000000 Z
11
+ date: 2014-02-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: guard
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - '>='
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: 1.3.0
19
+ version: 2.3.0
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - '>='
24
+ - - ">="
25
25
  - !ruby/object:Gem::Version
26
- version: 1.3.0
26
+ version: 2.3.0
27
27
  - !ruby/object:Gem::Dependency
28
- name: rspec
28
+ name: bundler
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - ~>
31
+ - - ">="
32
32
  - !ruby/object:Gem::Version
33
- version: 2.11.0
33
+ version: 1.3.5
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - ~>
38
+ - - ">="
39
39
  - !ruby/object:Gem::Version
40
- version: 2.11.0
41
- - !ruby/object:Gem::Dependency
42
- name: guard-rspec
43
- requirement: !ruby/object:Gem::Requirement
44
- requirements:
45
- - - ~>
46
- - !ruby/object:Gem::Version
47
- version: 1.2.1
48
- type: :development
49
- prerelease: false
50
- version_requirements: !ruby/object:Gem::Requirement
51
- requirements:
52
- - - ~>
53
- - !ruby/object:Gem::Version
54
- version: 1.2.1
40
+ version: 1.3.5
55
41
  description: Guard::Migrate automatically runs your database migrations when needed
56
42
  email:
57
43
  - geofflanotte@gmail.com
@@ -59,13 +45,13 @@ executables: []
59
45
  extensions: []
60
46
  extra_rdoc_files: []
61
47
  files:
48
+ - LICENSE.txt
49
+ - README.rdoc
50
+ - lib/guard/migrate.rb
62
51
  - lib/guard/migrate/migration.rb
63
52
  - lib/guard/migrate/notify.rb
64
53
  - lib/guard/migrate/templates/Guardfile
65
54
  - lib/guard/migrate/version.rb
66
- - lib/guard/migrate.rb
67
- - LICENSE.txt
68
- - README.rdoc
69
55
  - spec/guard/migrate/notifier_spec.rb
70
56
  - spec/guard/migrate/template_spec.rb
71
57
  - spec/guard/migrate_spec.rb
@@ -77,24 +63,24 @@ licenses:
77
63
  metadata: {}
78
64
  post_install_message:
79
65
  rdoc_options:
80
- - --charset=UTF-8
81
- - --main=README.rdoc
82
- - --exclude='(lib|test|spec)|(Gem|Guard|Rake)file'
66
+ - "--charset=UTF-8"
67
+ - "--main=README.rdoc"
68
+ - "--exclude='(lib|test|spec)|(Gem|Guard|Rake)file'"
83
69
  require_paths:
84
70
  - lib
85
71
  required_ruby_version: !ruby/object:Gem::Requirement
86
72
  requirements:
87
- - - '>='
73
+ - - ">="
88
74
  - !ruby/object:Gem::Version
89
75
  version: '0'
90
76
  required_rubygems_version: !ruby/object:Gem::Requirement
91
77
  requirements:
92
- - - '>='
78
+ - - ">="
93
79
  - !ruby/object:Gem::Version
94
80
  version: 1.3.6
95
81
  requirements: []
96
82
  rubyforge_project: guard-migrate
97
- rubygems_version: 2.0.14
83
+ rubygems_version: 2.2.0
98
84
  signing_key:
99
85
  specification_version: 4
100
86
  summary: Guard gem for rails migrations