guard-titan 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,15 @@
1
+ ---
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ NjVjYjljMDQ0MTM2MzI4Y2YzMmM3Yjg5NzVmMDNkZmQ3M2E2YTVlZQ==
5
+ data.tar.gz: !binary |-
6
+ NmY4MDkyZDZlY2YwZDk3NDczOTc2YjEyYTI3YjlkMWIxZjRhMDk0ZQ==
7
+ !binary "U0hBNTEy":
8
+ metadata.gz: !binary |-
9
+ NjMwNDNiZTBhNWM1Y2Y4ZTM2OGI0YjExYWQ3YmJlNDVkNmFjYTBkYmIyYTU1
10
+ NTZlYWVlZTI3N2RlMWIzYzMwNjdjNDQ5YmZmNmM2NzIyYjU5NmMzODA0MmM0
11
+ NWEwNjI0MTBmZDM1NzJhZDg4YThmZjk2YzRhZGYzNDliYjM4OTc=
12
+ data.tar.gz: !binary |-
13
+ YmE0ZWFmYzJmOGFhNDg0MWRmYzAzZjU4NmJiZTgyZWEzMTVlMjdiMTM4NWEy
14
+ NTc4MWM4ODJlYzI1ZTY0YmFlYTk1YTJmM2U3NDQ2ZDgwNTQ2NmQ0ODcxOWZl
15
+ ZThmMmY2ODhlOWEzMWJiN2JiNzU1YTBlZTIzM2QzNzcxYWQ5Nzg=
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2013 David Conner
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.
@@ -0,0 +1,5 @@
1
+ # Guard::Titan
2
+
3
+ read lib/guard/titan/templates/Guardfile
4
+
5
+ https://github.com/burke/zeus/issues/233 hmmmm
@@ -0,0 +1,141 @@
1
+ require 'guard'
2
+ require 'guard/guard'
3
+ #require 'zeus/rails'
4
+
5
+ module Guard
6
+ class Titan < Guard
7
+
8
+ VERSION = '0.0.1'
9
+
10
+ attr_accessor :cmds, :root, :using
11
+ attr_accessor :on_run_all, :all_cmd
12
+ attr_accessor :exclude_from_all
13
+
14
+ def initialize(watchers = [], opts = {})
15
+ super
16
+ @using = opts[:using] || :minitest
17
+ @exclude_from_all = opts[:exclude_from_all] || []
18
+ @on_run_all = opts[:on_run_all] || :recent # || :all || :all_keys
19
+ @root = File.dirname(opts[:root])
20
+ @cmds = get_scripts
21
+ @all_cmd = cmds.delete(:all)
22
+ @all_cmd = zeus_test_all_default if (all_cmd.nil? || all_cmd.empty?)
23
+ end
24
+
25
+ def run_all
26
+ case on_run_all
27
+ when :all
28
+ put_and_notify("All:", all_cmd)
29
+ run(all_cmd)
30
+ when :all_keys
31
+ put_and_notify("All_Keys:", all_cmd_keys.join(','))
32
+ commands = all_cmd_keys.map {|k| cmds[k] }
33
+ commands.each do |c|
34
+ run(c)
35
+ end
36
+ when :recent
37
+ put_and_notify("All Recent:", zeus_recent_cmd)
38
+ run(zeus_recent_cmd)
39
+ else
40
+ put_and_notify("All Recent:", zeus_recent_cmd)
41
+ run(zeus_recent_cmd)
42
+ end
43
+ end
44
+
45
+ def zeus_test(file)
46
+ "zeus #{zeus_test_cmd} #{root}/#{file}"
47
+ end
48
+
49
+ def zeus_test_all_default
50
+ zeus_test("#{zeus_test_root}**/*_test.rb")
51
+ end
52
+
53
+ def zeus_test_cmd
54
+ case using
55
+ when :minitest then "test"
56
+ when :rspec then "spec"
57
+ when :testunit then "test"
58
+ else "test/"
59
+ end
60
+ end
61
+
62
+ def zeus_test_root
63
+ case using
64
+ when :minitest then "test/"
65
+ when :rspec then "spec/"
66
+ when :testunit then "test/"
67
+ else "test/"
68
+ end
69
+ end
70
+
71
+ def run(cmd, opts = {})
72
+ puts '='*40
73
+ puts "Running: #{cmd}"
74
+ output = `#{cmd}`
75
+ puts output
76
+ end
77
+
78
+ def all_cmd_keys(opts = {})
79
+ cmds.keys - (['all'] + exclude_from_all.map(&:to_s))
80
+ end
81
+
82
+ # TODO: run at guard command prompt
83
+ def zeus_recent_cmd(opts = {})
84
+ # run tests that have changed since last commit
85
+ "zeus test #{since_last_commit.join(' ')}"
86
+ end
87
+
88
+ def run_on_changes(paths)
89
+ put_and_notify("Changed:", paths.join(', '))
90
+
91
+ test_all = false
92
+ dot_tee = []
93
+ normal_tests = paths.inject(Array.new) do |memo, p|
94
+ if (p =~ /\.t\/(.*)$/)
95
+ test_all = true if ($1=='all')
96
+ dot_tee.push($1)
97
+ else
98
+ memo.push(p)
99
+ end
100
+ memo
101
+ end
102
+
103
+ if test_all
104
+ run_all
105
+ else
106
+ run(zeus_test(normal_tests.join(' '))) if normal_tests.any?
107
+ run(dot_tee.map { |k| cmds[k] }.join(' ; ')) if dot_tee.any?
108
+ end
109
+ end
110
+
111
+ private
112
+
113
+ def since_last_commit
114
+ `git status --porcelain |
115
+ grep 'test' | grep -v 'factories' |
116
+ cut -c4- | sort | uniq`.split("\n")
117
+ end
118
+
119
+ def self.get_scripts(root)
120
+ Dir.glob(File.join(root, ".t/*")).inject(Hash.new) do |memo,f|
121
+ key = f.gsub(/^(.*)\/.t\//, '')
122
+ command = File.read(f)
123
+ memo[key] = command
124
+ memo
125
+ end
126
+ end
127
+
128
+ def get_scripts
129
+ self.class.get_scripts(root)
130
+ end
131
+
132
+ def put_and_notify(a,b)
133
+ puts "#{a} #{b}"
134
+ # p a, b
135
+ # n a, b
136
+ # hmm getting problems with notify here
137
+ # puts(*args)
138
+ # notify(*args)
139
+ end
140
+ end
141
+ end
@@ -0,0 +1,32 @@
1
+ require 'zeus/rails'
2
+ require 'guard/titan'
3
+
4
+ # unless you use :recent,
5
+ # you'll need to set up groups of scripts to run
6
+ # in the $PROJECT_ROOT/.t folder
7
+ #
8
+ # e.g.:
9
+ # make scripts: `echo 'zeus test test/models/**/*_test_rb' > .t/models`
10
+ # run a group: `touch .t/models .t/controllers` # or .t/mo .t/co
11
+ # run all groups: 'touch .t/all'
12
+
13
+ # on_run_all: :recent
14
+ # when you hit enter, guard only runs
15
+ # the files changed since last commit
16
+
17
+ # on_run_all: :all_keys
18
+ # when you hit enter, guard runs each script
19
+ # in .t folder.
20
+ # (except all + any keys in :exclude_from_all)
21
+
22
+ # on_run_all: :all
23
+ # runs ALL the tests...
24
+ # but zeus's arguments can only be so long..
25
+ # too many tests and you'll see: 'zeusclient.go:86: EOF'
26
+
27
+ group :zeus do
28
+ guard :titan, root: __FILE__, on_run_all: :all_keys, exclude_from_all: %w(ob mail) do
29
+ watch(/^(.t\/(.*))$/)
30
+ watch(%r|^test/(.*)_test\.rb|)
31
+ end
32
+ end
metadata ADDED
@@ -0,0 +1,76 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: guard-titan
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - David Conner
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2013-03-10 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: guard
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ! '>='
18
+ - !ruby/object:Gem::Version
19
+ version: 0.2.0
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ! '>='
25
+ - !ruby/object:Gem::Version
26
+ version: 0.2.0
27
+ - !ruby/object:Gem::Dependency
28
+ name: guard-shell
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ! '>='
32
+ - !ruby/object:Gem::Version
33
+ version: 0.5.0
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ! '>='
39
+ - !ruby/object:Gem::Version
40
+ version: 0.5.0
41
+ description: Run tests with Zeus using Guard Shell
42
+ email:
43
+ - dconner.pro@gmail.com
44
+ executables: []
45
+ extensions: []
46
+ extra_rdoc_files: []
47
+ files:
48
+ - Readme.md
49
+ - LICENSE.txt
50
+ - lib/guard/titan/templates/Guardfile
51
+ - lib/guard/titan.rb
52
+ homepage: https://github.com/dcunited001/guard-titan
53
+ licenses:
54
+ - LICENSE.txt
55
+ metadata: {}
56
+ post_install_message:
57
+ rdoc_options: []
58
+ require_paths:
59
+ - lib
60
+ required_ruby_version: !ruby/object:Gem::Requirement
61
+ requirements:
62
+ - - ! '>='
63
+ - !ruby/object:Gem::Version
64
+ version: '0'
65
+ required_rubygems_version: !ruby/object:Gem::Requirement
66
+ requirements:
67
+ - - ! '>='
68
+ - !ruby/object:Gem::Version
69
+ version: '0'
70
+ requirements: []
71
+ rubyforge_project:
72
+ rubygems_version: 2.0.0
73
+ signing_key:
74
+ specification_version: 4
75
+ summary: Run tests with Zeus using Guard Shell!
76
+ test_files: []