guard-go 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -32,6 +32,13 @@ Read Guard usage https://github.com/guard/guard#usage
32
32
 
33
33
  $ bundle exec guard init go
34
34
 
35
- This will create your Guardfile. Edit it and configure your application file name (defaults to app.go)
35
+ This will create your Guardfile.
36
+
37
+ Edit this and configure your application file name and desired options.
38
+
39
+ Options defaults to:
40
+
41
+ :server => 'app.go' - Go source file to run
42
+ :test => false - To run go test insted of the app.
36
43
 
37
44
  $ bundle exec guard
@@ -11,26 +11,23 @@ module Guard
11
11
  super
12
12
 
13
13
  defaults = {
14
- :server => 'app.go'
14
+ :server => 'app.go',
15
+ :test => false
15
16
  }
16
17
 
17
- @runner = ::Guard::GoRunner.new(defaults.merge(options))
18
+ @options = defaults.merge(options)
19
+
20
+ @runner = ::Guard::GoRunner.new(@options)
18
21
  end
19
22
 
20
23
  def start
21
- UI.info "Starting Go..."
22
- if pid = @runner.start
23
- UI.info "Started Go app, pid #{pid}"
24
- end
24
+ start_info
25
+ run_info @runner.start
25
26
  end
26
27
 
27
28
  def run_on_change(paths)
28
- UI.info "Restarting Go..."
29
- if @runner.restart
30
- UI.info "Go restarted, pid #{@runner.pid}"
31
- else
32
- UI.info "Go NOT restarted, check your log files."
33
- end
29
+ start_info
30
+ run_info @runner.restart
34
31
  end
35
32
 
36
33
  def stop
@@ -38,5 +35,23 @@ module Guard
38
35
  UI.info "Stopping Go..."
39
36
  Notifier.notify("Until next time...", :title => "Go shutting down.", :image => :pending)
40
37
  end
38
+
39
+ private
40
+ def start_info
41
+ if @options[:test]
42
+ UI.info "Running go test..."
43
+ else
44
+ UI.info "Running #{options[:server]}..."
45
+ end
46
+ end
47
+
48
+ def run_info(pid)
49
+ return if @options[:test]
50
+ if pid
51
+ UI.info "Started Go app, pid #{pid}"
52
+ else
53
+ UI.info "Go command failed, check your log files."
54
+ end
55
+ end
41
56
  end
42
57
  end
@@ -29,7 +29,11 @@ module Guard
29
29
  end
30
30
 
31
31
  def build_go_command
32
- %{cd #{Dir.pwd} && go run #{@options[:server]} &}
32
+ if @options[:test]
33
+ %{cd #{Dir.pwd} && go test}
34
+ else
35
+ %{cd #{Dir.pwd} && go run #{@options[:server]} &}
36
+ end
33
37
  end
34
38
 
35
39
  def ps_go_pid
@@ -1,5 +1,5 @@
1
1
  module Guard
2
2
  module GoVersion
3
- VERSION = "0.0.3"
3
+ VERSION = "0.0.4"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: guard-go
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -13,7 +13,7 @@ date: 2012-04-06 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: guard
16
- requirement: &70329117963240 !ruby/object:Gem::Requirement
16
+ requirement: &70283079905260 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,7 +21,7 @@ dependencies:
21
21
  version: 1.0.0
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *70329117963240
24
+ version_requirements: *70283079905260
25
25
  description: Guard gem for Go
26
26
  email:
27
27
  - victorcoder@gmail.com