rake-namespace_group 0.0.2 → 0.0.3
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.
- checksums.yaml +4 -4
- data/Rakefile +26 -6
- data/lib/rake/namespace_group/dsl.rb +13 -1
- data/lib/rake/namespace_group/grouped_error.rb +23 -0
- data/lib/rake/namespace_group/version.rb +1 -1
- data/spec/rakefile_spec.rb +16 -0
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 801f922f9a72303042a9b6bd4bf3fa430b273d12
|
4
|
+
data.tar.gz: 19ccd9c74b7a707ea98ff4bacfd1542b0f5d4026
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 39ca59090c16a53fc36cbbd8d971559902ffc90ee3e8b02f63a9c2e0420d7692c72115b0c18a47c430982a823ac42a60eaa8439c4a1ea4af07b1e1c3a7d7c286
|
7
|
+
data.tar.gz: 6be5b24c26273766b484aa0960c47ed96b2e01fa228ade4f243be27c87df7c2a4844f78d1059ff96c9b8d7a24966bfbfaad766fe544c47c317a64b5a55326c3d
|
data/Rakefile
CHANGED
@@ -8,40 +8,60 @@ end
|
|
8
8
|
|
9
9
|
namespace_group :default, :all => true
|
10
10
|
namespace :default do
|
11
|
-
desc "Namespace 'default' task 'foo'"
|
12
11
|
task :foo do
|
13
12
|
puts "Namespace 'default' task 'foo'"
|
14
13
|
end
|
15
|
-
desc "Namespace 'default' task 'bar'"
|
16
14
|
task :bar do
|
17
15
|
puts "Namespace 'default' task 'bar'"
|
18
16
|
end
|
19
17
|
end
|
20
18
|
|
21
19
|
namespace :original do
|
22
|
-
desc "Namespace 'original' do task 'regular'"
|
23
20
|
task :regular do
|
24
21
|
puts "Namespace 'original' task 'regular'"
|
25
22
|
end
|
26
23
|
end
|
27
24
|
|
28
25
|
namespace_group :original do
|
29
|
-
desc "Namespace 'original' task 'foo'"
|
30
26
|
task :foo do
|
31
27
|
puts "Namespace 'original' task 'foo'"
|
32
28
|
end
|
33
29
|
end
|
34
30
|
|
35
31
|
namespace_group :original do
|
36
|
-
desc "Namespace 'original' task 'bar'"
|
37
32
|
task :bar do
|
38
33
|
puts "Namespace 'original' task 'bar'"
|
39
34
|
end
|
40
35
|
end
|
41
36
|
|
42
37
|
namespace_group :arguments, :arguments => :bar do
|
43
|
-
desc "Namespace 'arguments' task 'foo'"
|
44
38
|
task :foo, :bar, :ext do |task, args|
|
45
39
|
puts "Namespace 'arguments' task 'foo' argument: '#{args[:bar]}'"
|
46
40
|
end
|
47
41
|
end
|
42
|
+
|
43
|
+
namespace_group :failures, :keep_going => false do
|
44
|
+
task :bar do |task|
|
45
|
+
puts "Namespace 'failures' task 'bar'"
|
46
|
+
raise "BAR NO PLAY EITHER"
|
47
|
+
end
|
48
|
+
|
49
|
+
task :foo do |task|
|
50
|
+
puts "Namespace 'failures' task 'foo'"
|
51
|
+
raise "FOO NO PLAY"
|
52
|
+
end
|
53
|
+
end
|
54
|
+
# Fix ordering for tests
|
55
|
+
task :failures => ['failures:foo', 'failures:bar' ]
|
56
|
+
|
57
|
+
namespace_group :aggregate_failure, :keep_going => true do
|
58
|
+
task :foo do |task|
|
59
|
+
puts "Namespace 'aggregate_failures' task 'foo'"
|
60
|
+
raise "FOO NO PLAY"
|
61
|
+
end
|
62
|
+
|
63
|
+
task :bar do |task|
|
64
|
+
puts "Namespace 'aggregate_failures' task 'bar'"
|
65
|
+
raise "BAR NO PLAY EITHER"
|
66
|
+
end
|
67
|
+
end
|
@@ -1,4 +1,5 @@
|
|
1
1
|
require 'rake/namespace_group/group_task'
|
2
|
+
require 'rake/namespace_group/grouped_error'
|
2
3
|
|
3
4
|
module Rake
|
4
5
|
module DSL
|
@@ -39,11 +40,22 @@ module Rake
|
|
39
40
|
desc options[:desc] || "Execute all tasks in group #{ns_name}"
|
40
41
|
task ns_name, (options[:arguments] || []) do |_self, args|
|
41
42
|
tasklist = Rake.application.tasks_in_scope(scope)
|
43
|
+
exception_list = GroupedError.new(ns_name)
|
42
44
|
tasklist.each do |task|
|
43
45
|
if options[:all] or task.is_a?(Rake::GroupTask)
|
44
|
-
|
46
|
+
begin
|
47
|
+
task.invoke(*args)
|
48
|
+
rescue Exception => ex
|
49
|
+
exception_list.add_exception(task, ex)
|
50
|
+
unless options[:keep_going]
|
51
|
+
raise ex
|
52
|
+
end
|
53
|
+
end
|
45
54
|
end
|
46
55
|
end
|
56
|
+
if exception_list.has_exceptions?
|
57
|
+
raise exception_list
|
58
|
+
end
|
47
59
|
end
|
48
60
|
end
|
49
61
|
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
class GroupedError < Exception
|
2
|
+
attr_reader :exceptions
|
3
|
+
|
4
|
+
def initialize(message)
|
5
|
+
@exceptions = {}
|
6
|
+
end
|
7
|
+
|
8
|
+
def add_exception(task, exception)
|
9
|
+
@exceptions[task.name.to_s] = { :task => task, :exception => exception }
|
10
|
+
end
|
11
|
+
|
12
|
+
def print
|
13
|
+
exceptions.each do |name, ex|
|
14
|
+
puts "[Task: #{name}]: Exception[#{ex[:exception].class}] #{ex[:exception].message}"
|
15
|
+
print ex[:exception].backtrace
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
def has_exceptions?
|
20
|
+
exceptions.size > 0
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
data/spec/rakefile_spec.rb
CHANGED
@@ -38,4 +38,20 @@ describe 'Rakefile' do
|
|
38
38
|
Rake::Task[:arguments].invoke('xxfoobarxx')
|
39
39
|
end
|
40
40
|
end
|
41
|
+
|
42
|
+
context "namespace failures" do
|
43
|
+
it 'should stop at first fail' do
|
44
|
+
expect($stdout).to receive(:puts).with("Namespace 'failures' task 'foo'")
|
45
|
+
expect { Rake::Task[:failures].invoke }.to raise_error(RuntimeError, "FOO NO PLAY")
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
context "namespace aggregate_failures" do
|
50
|
+
it 'should stop after all tasks' do
|
51
|
+
expect($stdout).to receive(:puts).with("Namespace 'aggregate_failures' task 'foo'")
|
52
|
+
expect($stdout).to receive(:puts).with("Namespace 'aggregate_failures' task 'bar'")
|
53
|
+
expect { Rake::Task[:aggregate_failure].invoke }.to raise_error(GroupedError)
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
41
57
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rake-namespace_group
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jan Vansteenkiste
|
@@ -67,6 +67,7 @@ files:
|
|
67
67
|
- lib/rake/namespace_group.rb
|
68
68
|
- lib/rake/namespace_group/dsl.rb
|
69
69
|
- lib/rake/namespace_group/group_task.rb
|
70
|
+
- lib/rake/namespace_group/grouped_error.rb
|
70
71
|
- lib/rake/namespace_group/version.rb
|
71
72
|
- rake-namespace_group.gemspec
|
72
73
|
- spec/rakefile_spec.rb
|