guard-migrate 1.1.0 → 1.2.0

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: 01e51995bff8759625b0385ba4bfe5d41bece453
4
- data.tar.gz: 53de8f5bef5d0f3aeb8791031bd102b70a98be45
3
+ metadata.gz: 2fd638587e2b96584a057e8873cebf55c0da88f0
4
+ data.tar.gz: 4e5e7d7c1b183c2a740a3b600be1776eb67a6735
5
5
  SHA512:
6
- metadata.gz: 8f05fbd7f42707a767b3eb018287d95305191fd9eacd0d913570027c9d05f940c736557f71e89957aab5068d5f680e77b75401792af284e580f0163f3f7f14ee
7
- data.tar.gz: d1239ae0e988afbd345002876836315b6a4baecd6e7d38c71d29313fa728bc457d1e073140a82c4d4b70261e35693975ce37eb08a63fbb20e3710942ca06c279
6
+ metadata.gz: dc9b23bfa2aae9a3ee9f0fdb927812983bdca5ab52d63e146c66593e791308f12588876bd3d75829327b82ed7e00e22dd2c6927a272b38c496e0d194b7b89987
7
+ data.tar.gz: b5ba9b3ba42cc9f73f1882eee89c5aca35dcce9427e26ccec1a8379b7fdd0ed99a26ec952cab3ecd40bf13fc56c284bb47a05c89bf96b8090f683198d7426dd1
data/README.rdoc CHANGED
@@ -10,6 +10,8 @@ Migrate guard allows you to keep you migrations up to date while developing with
10
10
 
11
11
  = Install
12
12
 
13
+ *** NOTE: this version is for rails > 4.1.0, for rails < 4.1.0, please use version 1.0.x ***
14
+
13
15
  Please be sure to have {Guard}[https://github.com/guard/guard] installed before continue.
14
16
 
15
17
  Install the gem:
data/lib/guard/migrate.rb CHANGED
@@ -1,13 +1,12 @@
1
- require 'guard'
2
- require 'guard/guard'
1
+ require 'guard/plugin'
3
2
 
4
3
  module Guard
5
- class Migrate < Guard
4
+ class Migrate < Plugin
6
5
  autoload :Notify, 'guard/migrate/notify'
7
6
  autoload :Migration, 'guard/migrate/migration'
8
7
  attr_reader :seed, :rails_env
9
8
 
10
- def initialize(watchers=[], options={})
9
+ def initialize(options={})
11
10
  super
12
11
 
13
12
  @bundler = true unless options[:bundler] == false
@@ -70,7 +69,7 @@ module Guard
70
69
  end
71
70
 
72
71
  # Called on file(s) modifications
73
- def run_on_modifications(paths)
72
+ def run_on_changes(paths)
74
73
  if paths.any?{|path| path.match(%r{^db/migrate/(\d+).+\.rb})} || reset?
75
74
  migrations = paths.map {|path| Migration.new(path)}
76
75
  migrate(migrations)
@@ -5,22 +5,28 @@ module Guard
5
5
  @result = result
6
6
  end
7
7
 
8
+ def notify
9
+ ::Guard::Notifier.notify(
10
+ message,
11
+ :title => "Database Migrations",
12
+ :image => image
13
+ )
14
+ end
15
+
16
+ private
17
+
8
18
  def message
9
19
  case @result
10
- when "reset" then "The database has been reset"
11
- when "seed" then "The database has been seeded"
12
- when true then "Migrations have been applied successfully"
13
- else "There was an error running migrations"
20
+ when "reset" then "The database has been reset"
21
+ when "seed" then "The database has been seeded"
22
+ when true then "Migrations have been applied successfully"
23
+ else "There was an error running migrations"
14
24
  end
15
25
  end
16
26
 
17
27
  def image
18
28
  @result ? :success : :failure
19
29
  end
20
-
21
- def notify
22
- ::Guard::Notifier.notify(message, :title => "Database Migrations", :image => image)
23
- end
24
30
  end
25
31
  end
26
32
  end
@@ -1,5 +1,5 @@
1
1
  module Guard
2
2
  module MigrateVersion
3
- VERSION = "1.1.0"
3
+ VERSION = "1.2.0"
4
4
  end
5
5
  end
@@ -2,10 +2,10 @@ require 'spec_helper'
2
2
  require 'tempfile'
3
3
 
4
4
  describe Guard::Migrate do
5
- let(:options){ {}}
5
+ let(:options){ {watchers: paths}}
6
6
  let(:paths){{}}
7
7
 
8
- subject{ Guard::Migrate.new(paths, options) }
8
+ subject{ Guard::Migrate.new(options) }
9
9
 
10
10
  before(:all) do
11
11
  FileUtils.mkdir_p('db/migrate')
@@ -223,7 +223,7 @@ describe Guard::Migrate do
223
223
 
224
224
  it "runs the rake command with seed only" do
225
225
  subject.should_receive(:system).with(subject.seed_only_string)
226
- subject.run_on_modifications paths
226
+ subject.run_on_changes paths
227
227
  end
228
228
 
229
229
  context "When reset is set to true" do
@@ -240,7 +240,7 @@ describe Guard::Migrate do
240
240
  let(:paths){ [create_valid_up_and_down_migration('1234_i_like_cheese').path] }
241
241
  it "should run the rake command" do
242
242
  subject.should_receive(:system).with(subject.rake_string('1234'))
243
- subject.run_on_modifications paths
243
+ subject.run_on_changes paths
244
244
  end
245
245
  end
246
246
 
@@ -249,7 +249,7 @@ describe Guard::Migrate do
249
249
  let(:options){ {:reset => true, :test_clone => true} }
250
250
  it "should run the rake command" do
251
251
  subject.should_receive(:system).with(subject.rake_string('1234'))
252
- subject.run_on_modifications paths
252
+ subject.run_on_changes paths
253
253
  end
254
254
  end
255
255
 
@@ -259,28 +259,28 @@ describe Guard::Migrate do
259
259
  migration = create_valid_up_and_down_migration('1234_i_like_cheese')
260
260
 
261
261
  subject.should_receive(:system).with(subject.rake_string('1234'))
262
- subject.run_on_modifications [migration.path]
262
+ subject.run_on_changes [migration.path]
263
263
  end
264
264
 
265
265
  it "should keep valid change migrations" do
266
266
  migration = create_valid_change_migration('1234_i_like_cheese')
267
267
 
268
268
  subject.should_receive(:system).with(subject.rake_string('1234'))
269
- subject.run_on_modifications [migration.path]
269
+ subject.run_on_changes [migration.path]
270
270
  end
271
271
 
272
272
  it "should remove empty up/down migrations" do
273
273
  migration = create_invalid_up_and_down_migration('1234_i_like_cheese')
274
274
 
275
275
  subject.should_not_receive(:system).with(subject.rake_string('1234'))
276
- subject.run_on_modifications [migration.path]
276
+ subject.run_on_changes [migration.path]
277
277
  end
278
278
 
279
279
  it "should remove empty change migrations" do
280
280
  migration = create_invalid_change_migration('1234_i_like_cheese')
281
281
 
282
282
  subject.should_not_receive(:system).with(subject.rake_string('1234'))
283
- subject.run_on_modifications [migration.path]
283
+ subject.run_on_changes [migration.path]
284
284
  end
285
285
  end
286
286
 
data/spec/spec_helper.rb CHANGED
@@ -1,4 +1,4 @@
1
- if RUBY_VERSION.match(/^1\.9\.\d?$/)
1
+ if RUBY_VERSION.to_f == 1.9
2
2
  begin
3
3
  require 'simplecov'
4
4
  SimpleCov.start 'rails'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: guard-migrate
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.2.0
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-05-01 00:00:00.000000000 Z
11
+ date: 2014-11-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: guard