guard-migrate 0.1.5 → 0.1.6

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/lib/guard/migrate.rb CHANGED
@@ -3,11 +3,12 @@ require 'guard/guard'
3
3
 
4
4
  module Guard
5
5
  class Migrate < Guard
6
+ autoload :Notify, 'guard/migrate/notify'
6
7
  attr_reader :seed, :rails_env
7
8
 
8
9
  def initialize(watchers=[], options={})
9
10
  super
10
-
11
+
11
12
  @reset = true if options[:reset] == true
12
13
  @test_clone = true unless options[:test_clone] == false
13
14
  @run_on_start = true if options[:run_on_start] == true
@@ -74,15 +75,21 @@ module Guard
74
75
  return if !reset? && paths.empty?
75
76
  if reset?
76
77
  UI.info "Running #{rake_string}"
77
- system rake_string
78
+ result = system(rake_string)
79
+ result &&= "reset"
78
80
  else
79
- run_all_migrations(paths)
81
+ result = run_all_migrations(paths)
80
82
  end
83
+
84
+ UI.info "Sending notification"
85
+ Notify.new(result).notify
81
86
  end
82
87
 
83
88
  def seed_only
84
89
  UI.info "Running #{seed_only_string}"
85
- system seed_only_string
90
+ result = system(seed_only_string)
91
+ result &&= "seed"
92
+ Notify.new(result).notify
86
93
  end
87
94
 
88
95
  def run_redo?(path)
@@ -111,10 +118,14 @@ module Guard
111
118
  private
112
119
 
113
120
  def run_all_migrations(paths)
121
+ result = nil
114
122
  paths.each do |path|
115
123
  UI.info "Running #{rake_string(path)}"
116
- system rake_string(path)
124
+ result = system rake_string(path)
125
+ break unless result
117
126
  end
127
+
128
+ result
118
129
  end
119
130
 
120
131
  def rake_command
@@ -0,0 +1,26 @@
1
+ module Guard
2
+ class Migrate
3
+ class Notify
4
+ def initialize(result)
5
+ @result = result
6
+ end
7
+
8
+ def message
9
+ 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"
14
+ end
15
+ end
16
+
17
+ def image
18
+ @result ? :success : :failure
19
+ end
20
+
21
+ def notify
22
+ ::Guard::Notifier.notify(message, :title => "Database Migrations", :image => image)
23
+ end
24
+ end
25
+ end
26
+ end
@@ -1,5 +1,5 @@
1
1
  module Guard
2
2
  module MigrateVersion
3
- VERSION = "0.1.5"
3
+ VERSION = "0.1.6"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: guard-migrate
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.5
4
+ version: 0.1.6
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-08-16 00:00:00.000000000 Z
12
+ date: 2012-09-01 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: guard
@@ -66,6 +66,7 @@ executables: []
66
66
  extensions: []
67
67
  extra_rdoc_files: []
68
68
  files:
69
+ - lib/guard/migrate/notify.rb
69
70
  - lib/guard/migrate/templates/Guardfile
70
71
  - lib/guard/migrate/version.rb
71
72
  - lib/guard/migrate.rb
@@ -92,7 +93,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
92
93
  version: '0'
93
94
  segments:
94
95
  - 0
95
- hash: -1088046273963210886
96
+ hash: 1464143421398569990
96
97
  required_rubygems_version: !ruby/object:Gem::Requirement
97
98
  none: false
98
99
  requirements: