guard-go 0.0.1 → 0.0.2

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/README.md CHANGED
@@ -4,6 +4,16 @@ Guard Go runs go programs and restart when file changes
4
4
 
5
5
  ## Installation
6
6
 
7
+ # For gophers
8
+
9
+ You must have a working Ruby installation, then:
10
+
11
+ $ gem install bundler
12
+ $ cd /your/project/dir
13
+ $ bundle init
14
+
15
+ # For gophers and Rubysts
16
+
7
17
  Add this line to your application's Gemfile:
8
18
 
9
19
  gem 'guard-go'
@@ -18,6 +28,10 @@ Or install it yourself as:
18
28
 
19
29
  ## Usage
20
30
 
21
- $ guard init go
31
+ Read Guard usage https://github.com/guard/guard#usage
32
+
33
+ $ bundle exec guard init go
34
+
35
+ This will create your Guardfile. Edit it and configure your application file name (defaults to app.go)
22
36
 
23
- This will create your Guardfile. Edit it and configure your application file name.
37
+ $ bundle exec guard
@@ -1,14 +1,13 @@
1
- require 'fileutils'
2
-
3
1
  module Guard
4
2
  class GoRunner
5
3
  MAX_WAIT_COUNT = 10
6
4
 
7
5
  attr_reader :options, :pid
8
6
 
9
- def initialize(file, options)
10
- @file = file
7
+ def initialize(options)
11
8
  @options = options
9
+
10
+ raise "Server file not found. Check your :server option in your Guarfile." unless File.exists? @options[:server]
12
11
  end
13
12
 
14
13
  def start
@@ -30,7 +29,7 @@ module Guard
30
29
  end
31
30
 
32
31
  def build_go_command
33
- %{cd #{Dir.pwd} && go run #{@file}}
32
+ %{cd #{Dir.pwd} && go run #{@options[:server]} &}
34
33
  end
35
34
 
36
35
  def ps_go_pid
@@ -43,10 +42,8 @@ module Guard
43
42
 
44
43
  private
45
44
  def run_go_command!
46
- @pid = fork do
47
- exec build_go_command
48
- end
49
- @pid
45
+ system build_go_command
46
+ @pid = $?.pid
50
47
  end
51
48
  end
52
49
  end
@@ -1,6 +1,6 @@
1
1
  # Add files and commands to this file, like the example:
2
2
  # watch(%r{file/path}) { `command(s)` }
3
3
  #
4
- guard 'go' do
5
- watch('app.go')
6
- end
4
+ guard 'go', :server => 'app.go' do
5
+ watch(%r{\.go$})
6
+ end
@@ -1,5 +1,5 @@
1
1
  module Guard
2
2
  module GoVersion
3
- VERSION = "0.0.1"
3
+ VERSION = "0.0.2"
4
4
  end
5
5
  end
data/lib/guard/go.rb CHANGED
@@ -10,12 +10,11 @@ module Guard
10
10
  def initialize(watchers = [], options = {})
11
11
  super
12
12
 
13
- go_file = watchers.first.pattern || 'app.go'
13
+ defaults = {
14
+ :server => 'app.go'
15
+ }
14
16
 
15
- unless File.exists? go_file
16
- raise "Go file #{go_file} not found"
17
- end
18
- @runner = ::Guard::GoRunner.new(go_file, options)
17
+ @runner = ::Guard::GoRunner.new(defaults.merge(options))
19
18
  end
20
19
 
21
20
  def start
@@ -25,7 +24,7 @@ module Guard
25
24
  end
26
25
  end
27
26
 
28
- def run_on_change
27
+ def run_on_change(paths)
29
28
  UI.info "Restarting Go..."
30
29
  if @runner.restart
31
30
  UI.info "Go restarted, pid #{@runner.pid}"
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.1
4
+ version: 0.0.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-04-05 00:00:00.000000000 Z
12
+ date: 2012-04-06 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: guard
16
- requirement: &70240600442320 !ruby/object:Gem::Requirement
16
+ requirement: &70360100995200 !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: *70240600442320
24
+ version_requirements: *70360100995200
25
25
  description: Guard gem for Go
26
26
  email:
27
27
  - victorcoder@gmail.com