build 1.0.0 → 1.0.1
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/lib/build/controller.rb +16 -1
- data/lib/build/logger.rb +14 -8
- data/lib/build/version.rb +1 -1
- data/spec/build/controller_spec.rb +26 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0672d1e74b4a1753f505fe1caaf2f8af65d6852f
|
4
|
+
data.tar.gz: 469d82145d094b22728592dec37206a389eecb55
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 369f70d27a19a9d6baea48c338bab9452969cc1c74d5c358cf270b299be29a7f98e8a6212cd4c9c88e2c6310001b892216a0997814f3fd604badbccba54d65fe
|
7
|
+
data.tar.gz: 34847f234674d9327e337a92bd9e5774fea0ad628a9eb098f4c7b7aafb3facd30497d5d6ae33e43030cebd78c579c3ea89d0805d64f54c8383be8f01e69241b8
|
data/lib/build/controller.rb
CHANGED
@@ -19,6 +19,7 @@
|
|
19
19
|
# THE SOFTWARE.
|
20
20
|
|
21
21
|
require_relative 'rulebook'
|
22
|
+
require_relative 'name'
|
22
23
|
|
23
24
|
require 'build/files'
|
24
25
|
require 'build/graph'
|
@@ -82,6 +83,20 @@ module Build
|
|
82
83
|
|
83
84
|
# This task class serves as the base class for the environment specific task classes genearted when adding targets.
|
84
85
|
class Task < Graph::Task
|
86
|
+
class CommandFailure < StandardError
|
87
|
+
def initialize(task, arguments, status)
|
88
|
+
@task = task
|
89
|
+
@arguments = arguments
|
90
|
+
@status = status
|
91
|
+
|
92
|
+
super "#{@arguments.first} exited with status #{@status}"
|
93
|
+
end
|
94
|
+
|
95
|
+
attr :task
|
96
|
+
attr :arguments
|
97
|
+
attr :status
|
98
|
+
end
|
99
|
+
|
85
100
|
def initialize(walker, node, group, logger: nil)
|
86
101
|
super(walker, node)
|
87
102
|
|
@@ -100,7 +115,7 @@ module Build
|
|
100
115
|
status = @group.spawn(*arguments)
|
101
116
|
|
102
117
|
if status != 0
|
103
|
-
raise
|
118
|
+
raise CommandFailure.new(self, arguments, status)
|
104
119
|
end
|
105
120
|
end
|
106
121
|
end
|
data/lib/build/logger.rb
CHANGED
@@ -41,18 +41,24 @@ module Build
|
|
41
41
|
end
|
42
42
|
end
|
43
43
|
|
44
|
-
def format_command(
|
45
|
-
|
46
|
-
|
44
|
+
def format_command(arguments)
|
45
|
+
if arguments.last.is_a? Hash
|
46
|
+
options = arguments.last
|
47
|
+
arguments = arguments[0...-1]
|
48
|
+
else
|
49
|
+
options = {}
|
50
|
+
end
|
51
|
+
|
52
|
+
arguments = arguments.flatten.collect &:to_s
|
47
53
|
|
48
|
-
Rainbow(
|
54
|
+
Rainbow(arguments.join(' ')).blue + chdir_string(options)
|
49
55
|
end
|
50
56
|
|
51
|
-
def call(severity, datetime, progname,
|
52
|
-
if progname == 'shell' and Array ===
|
53
|
-
"#{time_offset_string}: #{format_command(
|
57
|
+
def call(severity, datetime, progname, message)
|
58
|
+
if progname == 'shell' and Array === message
|
59
|
+
"#{time_offset_string}: #{format_command(message)}\n"
|
54
60
|
else
|
55
|
-
"#{time_offset_string}: #{
|
61
|
+
"#{time_offset_string}: #{message}\n"
|
56
62
|
end
|
57
63
|
end
|
58
64
|
end
|
data/lib/build/version.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
#!/usr/bin/env rspec
|
2
|
+
|
1
3
|
# Copyright, 2015, by Samuel G. D. Williams. <http://www.codeotaku.com>
|
2
4
|
#
|
3
5
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
@@ -38,6 +40,30 @@ module Build::ControllerSpec
|
|
38
40
|
end
|
39
41
|
|
40
42
|
describe Build::Controller do
|
43
|
+
it "should fail with exception" do
|
44
|
+
environment = Build::Environment.new do
|
45
|
+
define Build::Rule, "make.file" do
|
46
|
+
output :destination
|
47
|
+
|
48
|
+
apply do |parameters|
|
49
|
+
run "exit -1"
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
target = Target.new('fail')
|
55
|
+
target.build do
|
56
|
+
foo_path = Build::Files::Path['foo']
|
57
|
+
make destination: foo_path
|
58
|
+
end
|
59
|
+
|
60
|
+
controller = Build::Controller.new do |controller|
|
61
|
+
controller.add_target(target, environment)
|
62
|
+
end
|
63
|
+
|
64
|
+
expect{controller.update}.to raise_error(Build::Task::CommandFailure)
|
65
|
+
end
|
66
|
+
|
41
67
|
it "should execute the build graph" do
|
42
68
|
environment = Build::Environment.new do
|
43
69
|
define Build::Rule, "make.file" do
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: build
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Samuel Williams
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-06
|
11
|
+
date: 2015-08-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: build-graph
|