guard-zeus-client 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/Guardfile +0 -0
- data/LICENSE.txt +22 -0
- data/README.md +4 -0
- data/Rakefile +1 -0
- data/guard-zeus-client.gemspec +22 -0
- data/lib/guard/zeus-client.rb +48 -0
- data/lib/guard/zeus-client/runner.rb +91 -0
- data/lib/guard/zeus-client/templates/Guardfile +42 -0
- data/lib/guard/zeus-client/version.rb +5 -0
- metadata +90 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/Guardfile
ADDED
File without changes
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2012 Ryan Schlesinger
|
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
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'guard/zeus-client/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |gem|
|
7
|
+
gem.name = "guard-zeus-client"
|
8
|
+
gem.version = Guard::ZeusClientVersion::VERSION
|
9
|
+
gem.authors = ["Ryan Schlesinger"]
|
10
|
+
gem.email = ["ryan@aceofsales.com"]
|
11
|
+
gem.description = %q{Guard::ZeusClient automatically runs a zeus command (test by default) when your files change. Does not run zeus server.}
|
12
|
+
gem.summary = %q{Guard gem for Zeus}
|
13
|
+
gem.homepage = "https://github.com/aceofsales/guard-zeus-client"
|
14
|
+
|
15
|
+
gem.files = `git ls-files`.split($/)
|
16
|
+
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
17
|
+
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
18
|
+
gem.require_paths = ["lib"]
|
19
|
+
|
20
|
+
gem.add_dependency 'guard', '>= 1.1'
|
21
|
+
gem.add_dependency 'zeus'
|
22
|
+
end
|
@@ -0,0 +1,48 @@
|
|
1
|
+
require 'guard'
|
2
|
+
require 'guard/guard'
|
3
|
+
|
4
|
+
module Guard
|
5
|
+
class ZeusClient < Guard
|
6
|
+
|
7
|
+
autoload :Runner, 'guard/zeus-client/runner'
|
8
|
+
attr_accessor :runner
|
9
|
+
|
10
|
+
# Initialize a Guard.
|
11
|
+
# @param [Array<Guard::Watcher>] watchers the Guard file watchers
|
12
|
+
# @param [Hash] options the custom Guard options
|
13
|
+
def initialize(watchers = [], options = {})
|
14
|
+
super
|
15
|
+
|
16
|
+
@options = {
|
17
|
+
:all_on_start => true
|
18
|
+
}.merge(options)
|
19
|
+
|
20
|
+
@runner = Runner.new(@options)
|
21
|
+
end
|
22
|
+
|
23
|
+
# Call once when Guard starts. Please override initialize method to init stuff.
|
24
|
+
# @raise [:task_has_failed] when start has failed
|
25
|
+
def start
|
26
|
+
UI.info 'Guard::ZeusClient is running'
|
27
|
+
run_all if @options[:all_on_start]
|
28
|
+
end
|
29
|
+
|
30
|
+
# Called when just `enter` is pressed
|
31
|
+
# This method should be principally used for long action like running all specs/tests/...
|
32
|
+
# @raise [:task_has_failed] when run_all has failed
|
33
|
+
def run_all
|
34
|
+
unless runner.run_all
|
35
|
+
throw :task_has_failed
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
# Called on file(s) modifications that the Guard watches.
|
40
|
+
# @param [Array<String>] paths the changes files or paths
|
41
|
+
# @raise [:task_has_failed] when run_on_change has failed
|
42
|
+
def run_on_changes(paths)
|
43
|
+
unless runner.run(paths)
|
44
|
+
throw :task_has_failed
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
@@ -0,0 +1,91 @@
|
|
1
|
+
module Guard
|
2
|
+
class ZeusClient
|
3
|
+
class Runner
|
4
|
+
def initialize(options = {})
|
5
|
+
@options = {
|
6
|
+
:zeus_options => nil,
|
7
|
+
:zeus_subcommand => 'test',
|
8
|
+
:zeus_subcommand_options => nil,
|
9
|
+
:run_all_test_dirs => nil,
|
10
|
+
:notification => true
|
11
|
+
}.merge(options)
|
12
|
+
end
|
13
|
+
|
14
|
+
def run(paths, options = {})
|
15
|
+
return false if paths.empty?
|
16
|
+
|
17
|
+
message = options[:message] || "Zeus running: #{paths.join(' ')}"
|
18
|
+
UI.info(message, :reset => true)
|
19
|
+
|
20
|
+
options = @options.merge(options)
|
21
|
+
|
22
|
+
run_via_shell paths, options
|
23
|
+
end
|
24
|
+
|
25
|
+
def run_all
|
26
|
+
run(@options[:run_all_test_dirs] || test_dirs, :message => 'Zeus running all')
|
27
|
+
end
|
28
|
+
|
29
|
+
def zeus_executable
|
30
|
+
@zeus_executable ||= 'zeus'
|
31
|
+
end
|
32
|
+
|
33
|
+
private
|
34
|
+
def run_via_shell(paths, options)
|
35
|
+
success = system(zeus_command(paths, options))
|
36
|
+
|
37
|
+
if @options[:notification] && !success && zeus_command_exited_with_a_failure?
|
38
|
+
Notifier.notify("Failed", :title => "Zeus results", :image => :failed, :priority => 2)
|
39
|
+
end
|
40
|
+
|
41
|
+
success
|
42
|
+
end
|
43
|
+
|
44
|
+
def zeus_arguments(paths, options)
|
45
|
+
arg_parts = []
|
46
|
+
arg_parts << options[:zeus_options]
|
47
|
+
arg_parts << zeus_subcommand
|
48
|
+
arg_parts << options[:zeus_subcommand_options]
|
49
|
+
arg_parts << paths.join(' ')
|
50
|
+
|
51
|
+
arg_parts.compact.join(' ')
|
52
|
+
end
|
53
|
+
|
54
|
+
def zeus_command(paths, options)
|
55
|
+
cmd_parts = []
|
56
|
+
cmd_parts << zeus_executable
|
57
|
+
cmd_parts << zeus_arguments(paths, options)
|
58
|
+
|
59
|
+
cmd_parts.compact.join(' ')
|
60
|
+
end
|
61
|
+
|
62
|
+
def zeus_subcommand
|
63
|
+
@options[:zeus_subcommand] || 'test'
|
64
|
+
end
|
65
|
+
|
66
|
+
def zeus_command_exited_with_a_failure?
|
67
|
+
$?.exitstatus != 0
|
68
|
+
end
|
69
|
+
|
70
|
+
def test_dirs
|
71
|
+
if File.exists?(ROOT_PATH + "/spec/spec_helper.rb")
|
72
|
+
['spec']
|
73
|
+
elsif File.exist?(ROOT_PATH + "/test/minitest_helper.rb")
|
74
|
+
minitest_dirs
|
75
|
+
else
|
76
|
+
Dir['test/**/*_test.rb'] + Dir['test/**/test_*.rb']
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
def minitest_dirs
|
81
|
+
dirs = %w[test spec]
|
82
|
+
patterns = %w[*_test.rb test_*.rb *_spec.rb]
|
83
|
+
dirs.map do |dir|
|
84
|
+
patterns.map do |pattern|
|
85
|
+
Dir["#{dir}/**/#{pattern}"]
|
86
|
+
end.flatten
|
87
|
+
end.flatten
|
88
|
+
end
|
89
|
+
end
|
90
|
+
end
|
91
|
+
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
guard 'zeus-client' do
|
2
|
+
ignore %r{^\.zeus\.sock$}
|
3
|
+
|
4
|
+
# rspec
|
5
|
+
# watch(%r{^spec/.+_spec\.rb$})
|
6
|
+
# watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" }
|
7
|
+
# watch('spec/spec_helper.rb') { "spec" }
|
8
|
+
|
9
|
+
# rspec Rails example
|
10
|
+
# watch(%r{^app/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
|
11
|
+
# watch(%r{^app/(.*)(\.erb|\.haml)$}) { |m| "spec/#{m[1]}#{m[2]}_spec.rb" }
|
12
|
+
# watch(%r{^app/controllers/(.+)_(controller)\.rb$}) { |m| ["spec/routing/#{m[1]}_routing_spec.rb", "spec/#{m[2]}s/#{m[1]}_#{m[2]}_spec.rb", "spec/acceptance/#{m[1]}_spec.rb"] }
|
13
|
+
# watch(%r{^spec/support/(.+)\.rb$}) { "spec" }
|
14
|
+
# watch('config/routes.rb') { "spec/routing" }
|
15
|
+
# watch('app/controllers/application_controller.rb') { "spec/controllers" }
|
16
|
+
|
17
|
+
# with Minitest::Unit
|
18
|
+
# watch(%r|^test/(.*)\/?test_(.*)\.rb|)
|
19
|
+
# watch(%r|^lib/(.*)([^/]+)\.rb|) { |m| "test/#{m[1]}test_#{m[2]}.rb" }
|
20
|
+
# watch(%r|^test/test_helper\.rb|) { "test" }
|
21
|
+
|
22
|
+
# with Minitest::Spec
|
23
|
+
# watch(%r|^spec/(.*)_spec\.rb|)
|
24
|
+
# watch(%r|^lib/(.*)([^/]+)\.rb|) { |m| "spec/#{m[1]}#{m[2]}_spec.rb" }
|
25
|
+
# watch(%r|^spec/spec_helper\.rb|) { "spec" }
|
26
|
+
|
27
|
+
# Minitest Rails 3.2
|
28
|
+
# watch(%r|^app/controllers/(.*)\.rb|) { |m| "test/controllers/#{m[1]}_test.rb" }
|
29
|
+
# watch(%r|^app/helpers/(.*)\.rb|) { |m| "test/helpers/#{m[1]}_test.rb" }
|
30
|
+
# watch(%r|^app/models/(.*)\.rb|) { |m| "test/unit/#{m[1]}_test.rb" }
|
31
|
+
|
32
|
+
# Test::Unit
|
33
|
+
# watch(%r{^lib/(.+)\.rb$}) { |m| "test/#{m[1]}_test.rb" }
|
34
|
+
# watch(%r{^test/.+_test\.rb$})
|
35
|
+
# watch('test/test_helper.rb') { "test" }
|
36
|
+
|
37
|
+
# Test::Unit Rails example
|
38
|
+
# watch(%r{^app/models/(.+)\.rb$}) { |m| "test/unit/#{m[1]}_test.rb" }
|
39
|
+
# watch(%r{^app/controllers/(.+)\.rb$}) { |m| "test/functional/#{m[1]}_test.rb" }
|
40
|
+
# watch(%r{^app/views/.+\.rb$}) { "test/integration" }
|
41
|
+
# watch('app/controllers/application_controller.rb') { ["test/functional", "test/integration"] }
|
42
|
+
end
|
metadata
ADDED
@@ -0,0 +1,90 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: guard-zeus-client
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Ryan Schlesinger
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2012-10-03 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: guard
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '1.1'
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ! '>='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '1.1'
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: zeus
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - ! '>='
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '0'
|
38
|
+
type: :runtime
|
39
|
+
prerelease: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ! '>='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '0'
|
46
|
+
description: Guard::ZeusClient automatically runs a zeus command (test by default)
|
47
|
+
when your files change. Does not run zeus server.
|
48
|
+
email:
|
49
|
+
- ryan@aceofsales.com
|
50
|
+
executables: []
|
51
|
+
extensions: []
|
52
|
+
extra_rdoc_files: []
|
53
|
+
files:
|
54
|
+
- .gitignore
|
55
|
+
- Gemfile
|
56
|
+
- Guardfile
|
57
|
+
- LICENSE.txt
|
58
|
+
- README.md
|
59
|
+
- Rakefile
|
60
|
+
- guard-zeus-client.gemspec
|
61
|
+
- lib/guard/zeus-client.rb
|
62
|
+
- lib/guard/zeus-client/runner.rb
|
63
|
+
- lib/guard/zeus-client/templates/Guardfile
|
64
|
+
- lib/guard/zeus-client/version.rb
|
65
|
+
homepage: https://github.com/aceofsales/guard-zeus-client
|
66
|
+
licenses: []
|
67
|
+
post_install_message:
|
68
|
+
rdoc_options: []
|
69
|
+
require_paths:
|
70
|
+
- lib
|
71
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
72
|
+
none: false
|
73
|
+
requirements:
|
74
|
+
- - ! '>='
|
75
|
+
- !ruby/object:Gem::Version
|
76
|
+
version: '0'
|
77
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
78
|
+
none: false
|
79
|
+
requirements:
|
80
|
+
- - ! '>='
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
requirements: []
|
84
|
+
rubyforge_project:
|
85
|
+
rubygems_version: 1.8.24
|
86
|
+
signing_key:
|
87
|
+
specification_version: 3
|
88
|
+
summary: Guard gem for Zeus
|
89
|
+
test_files: []
|
90
|
+
has_rdoc:
|