guard-gotest 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +17 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +29 -0
- data/Rakefile +1 -0
- data/guard-gotest.gemspec +24 -0
- data/lib/guard/gotest/runner.rb +70 -0
- data/lib/guard/gotest/templates/Guardfile +4 -0
- data/lib/guard/gotest/version.rb +5 -0
- data/lib/guard/gotest.rb +38 -0
- metadata +110 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2013 Jon Doveston
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
# Guard::Gotest
|
2
|
+
|
3
|
+
TODO: Write a gem description
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
gem 'guard-gotest'
|
10
|
+
|
11
|
+
And then execute:
|
12
|
+
|
13
|
+
$ bundle
|
14
|
+
|
15
|
+
Or install it yourself as:
|
16
|
+
|
17
|
+
$ gem install guard-gotest
|
18
|
+
|
19
|
+
## Usage
|
20
|
+
|
21
|
+
TODO: Write usage instructions here
|
22
|
+
|
23
|
+
## Contributing
|
24
|
+
|
25
|
+
1. Fork it
|
26
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
27
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
28
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
29
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'guard/gotest/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = 'guard-gotest'
|
8
|
+
spec.version = Guard::GotestVersion::VERSION
|
9
|
+
spec.authors = ["Jon Doveston"]
|
10
|
+
spec.email = ["jon@doveston.me.uk"]
|
11
|
+
spec.description = %q{Guard gem for Go test}
|
12
|
+
spec.summary = %q{Automatically runs go test in the directories of changed files.}
|
13
|
+
spec.homepage = 'https://github.com/hatoishi/guard-gotest'
|
14
|
+
spec.license = 'MIT'
|
15
|
+
|
16
|
+
spec.files = `git ls-files`.split($/)
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ['lib']
|
20
|
+
|
21
|
+
spec.add_dependency 'guard', '>= 1.8'
|
22
|
+
spec.add_development_dependency 'bundler', '~> 1.3'
|
23
|
+
spec.add_development_dependency 'rake'
|
24
|
+
end
|
@@ -0,0 +1,70 @@
|
|
1
|
+
module Guard
|
2
|
+
class Gotest
|
3
|
+
class Runner
|
4
|
+
attr_accessor :options
|
5
|
+
|
6
|
+
def initialize(options = {})
|
7
|
+
@options = {
|
8
|
+
:env => nil,
|
9
|
+
:notification => true,
|
10
|
+
:sleep_time => 1
|
11
|
+
}.merge(options)
|
12
|
+
end
|
13
|
+
|
14
|
+
def run(paths, options = {})
|
15
|
+
return false if paths.empty?
|
16
|
+
|
17
|
+
message = options[:message] || "Running: #{paths.join(' ')}"
|
18
|
+
UI.info(message, :reset => true)
|
19
|
+
|
20
|
+
options = @options.merge(options)
|
21
|
+
|
22
|
+
puts gotest_command(paths, options)
|
23
|
+
success = system(gotest_command(paths, options))
|
24
|
+
|
25
|
+
if @options[:notification] && !success
|
26
|
+
Notifier.notify('Failed', :title => 'Gotest results', :image => :failed, :priority => 2)
|
27
|
+
end
|
28
|
+
|
29
|
+
success
|
30
|
+
end
|
31
|
+
|
32
|
+
def stop
|
33
|
+
ps_go_pid.each do |pid|
|
34
|
+
system %{kill -KILL #{pid}}
|
35
|
+
end
|
36
|
+
while ps_go_pid.count > 0
|
37
|
+
sleep @options[:sleep_time].to_f || 1
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
private
|
42
|
+
|
43
|
+
def ps_go_pid
|
44
|
+
`ps aux | awk '/a.out/&&!/awk/{print $2;}'`.split("\n").map { |pid| pid.to_i }
|
45
|
+
end
|
46
|
+
|
47
|
+
def gotest_command(paths, options)
|
48
|
+
cmd_parts = []
|
49
|
+
dirs = paths.map{ |path| File.dirname(path) }.uniq
|
50
|
+
dirs.each do |dir|
|
51
|
+
cmd_parts << "cd #{dir}"
|
52
|
+
cmd_parts << '&&'
|
53
|
+
cmd_parts << environment_variables
|
54
|
+
cmd_parts << gotest_executable
|
55
|
+
cmd_parts << ';'
|
56
|
+
end
|
57
|
+
cmd_parts.compact.join(' ')
|
58
|
+
end
|
59
|
+
|
60
|
+
def gotest_executable
|
61
|
+
'go test'
|
62
|
+
end
|
63
|
+
|
64
|
+
def environment_variables
|
65
|
+
return if @options[:env].nil?
|
66
|
+
'export ' + @options[:env].map {|key, value| "#{key}=#{value}"}.join(' ') + ';'
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
data/lib/guard/gotest.rb
ADDED
@@ -0,0 +1,38 @@
|
|
1
|
+
require 'guard'
|
2
|
+
require 'guard/guard'
|
3
|
+
require 'guard/gotest/version'
|
4
|
+
|
5
|
+
module Guard
|
6
|
+
class Gotest < Guard
|
7
|
+
autoload :Runner, 'guard/gotest/runner'
|
8
|
+
|
9
|
+
attr_accessor :runner
|
10
|
+
|
11
|
+
def initialize(watchers = [], options = {})
|
12
|
+
super
|
13
|
+
@options = {
|
14
|
+
:run_all => {}
|
15
|
+
}.merge(options)
|
16
|
+
|
17
|
+
@runner = Runner.new(@options)
|
18
|
+
end
|
19
|
+
|
20
|
+
def start
|
21
|
+
UI.info "Guard::Gotest is running"
|
22
|
+
run_all if @options[:all_on_start]
|
23
|
+
end
|
24
|
+
|
25
|
+
def stop
|
26
|
+
@runner.stop
|
27
|
+
UI.info "Stopping Guard::Gotest"
|
28
|
+
end
|
29
|
+
|
30
|
+
def run_all
|
31
|
+
# TODO
|
32
|
+
end
|
33
|
+
|
34
|
+
def run_on_changes(paths)
|
35
|
+
@runner.run(paths)
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
metadata
ADDED
@@ -0,0 +1,110 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: guard-gotest
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Jon Doveston
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2013-05-02 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: guard
|
16
|
+
version_requirements: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '1.8'
|
22
|
+
requirement: !ruby/object:Gem::Requirement
|
23
|
+
none: false
|
24
|
+
requirements:
|
25
|
+
- - ! '>='
|
26
|
+
- !ruby/object:Gem::Version
|
27
|
+
version: '1.8'
|
28
|
+
type: :runtime
|
29
|
+
prerelease: false
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: bundler
|
32
|
+
version_requirements: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - ~>
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '1.3'
|
38
|
+
requirement: !ruby/object:Gem::Requirement
|
39
|
+
none: false
|
40
|
+
requirements:
|
41
|
+
- - ~>
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: '1.3'
|
44
|
+
type: :development
|
45
|
+
prerelease: false
|
46
|
+
- !ruby/object:Gem::Dependency
|
47
|
+
name: rake
|
48
|
+
version_requirements: !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
50
|
+
requirements:
|
51
|
+
- - ! '>='
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '0'
|
54
|
+
requirement: !ruby/object:Gem::Requirement
|
55
|
+
none: false
|
56
|
+
requirements:
|
57
|
+
- - ! '>='
|
58
|
+
- !ruby/object:Gem::Version
|
59
|
+
version: '0'
|
60
|
+
type: :development
|
61
|
+
prerelease: false
|
62
|
+
description: Guard gem for Go test
|
63
|
+
email:
|
64
|
+
- jon@doveston.me.uk
|
65
|
+
executables: []
|
66
|
+
extensions: []
|
67
|
+
extra_rdoc_files: []
|
68
|
+
files:
|
69
|
+
- .gitignore
|
70
|
+
- Gemfile
|
71
|
+
- LICENSE.txt
|
72
|
+
- README.md
|
73
|
+
- Rakefile
|
74
|
+
- guard-gotest.gemspec
|
75
|
+
- lib/guard/gotest.rb
|
76
|
+
- lib/guard/gotest/runner.rb
|
77
|
+
- lib/guard/gotest/templates/Guardfile
|
78
|
+
- lib/guard/gotest/version.rb
|
79
|
+
homepage: https://github.com/hatoishi/guard-gotest
|
80
|
+
licenses:
|
81
|
+
- MIT
|
82
|
+
post_install_message:
|
83
|
+
rdoc_options: []
|
84
|
+
require_paths:
|
85
|
+
- lib
|
86
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
87
|
+
none: false
|
88
|
+
requirements:
|
89
|
+
- - ! '>='
|
90
|
+
- !ruby/object:Gem::Version
|
91
|
+
version: '0'
|
92
|
+
hash: 2274346136403074908
|
93
|
+
segments:
|
94
|
+
- 0
|
95
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
96
|
+
none: false
|
97
|
+
requirements:
|
98
|
+
- - ! '>='
|
99
|
+
- !ruby/object:Gem::Version
|
100
|
+
version: '0'
|
101
|
+
hash: 2274346136403074908
|
102
|
+
segments:
|
103
|
+
- 0
|
104
|
+
requirements: []
|
105
|
+
rubyforge_project:
|
106
|
+
rubygems_version: 1.8.24
|
107
|
+
signing_key:
|
108
|
+
specification_version: 3
|
109
|
+
summary: Automatically runs go test in the directories of changed files.
|
110
|
+
test_files: []
|