build 2.2.0 → 2.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1cf5613f93850130355cc50e62df0c8dddc93f4c297d71170f57a45cb37519ff
4
- data.tar.gz: 14521dbf2a1231e8fa6e9837c22b0560284b1ce2de00d0b03c0650c1d848ac4d
3
+ metadata.gz: 3b19e67cd76f4bd488029dcb8135bcc850eb615159844e944d2fb681b3c9b7b8
4
+ data.tar.gz: cdc7dd22f324d150f6e01c4d44f0669ba1cdc86d8d0933559c1fc3d07209d2df
5
5
  SHA512:
6
- metadata.gz: c708de2260aa75d700ab9a7d55a137cd327055f6d477949d70f1f8647eade97d3be64ca3ec2cd0ebb42f34a9072105d96fbfa97dbe35211b0b23077f3233bf34
7
- data.tar.gz: 5adfdde18fddfb66ceb987b7969a40b6a7ee0fdc144a6f61653c22c88eaa949958625528388f799e4e958e1c4da9cfc8fdb05943e1350f40e73c923affbb35dc
6
+ metadata.gz: 541389b0145a378284f6b97ade7b1956dee8dde448d9039d2ce6f907195ae2db64c42af24b714f00f8d05ab09626b82b2dcd72dd8434278099366edea1de71e9
7
+ data.tar.gz: 821824ac2ec275383fe3d4a47d571145daf70d1017642d3722dcfddc8a487bfa26563c38fb5751c80dffdec8be2f9fde57d84bf8a91d58652c694a1ea053d2ca
data/README.md CHANGED
@@ -10,15 +10,15 @@ Build is a ruby gem providing systems for building task driven build systems sim
10
10
 
11
11
  Add this line to your application's Gemfile:
12
12
 
13
- gem 'build'
13
+ gem 'build'
14
14
 
15
15
  And then execute:
16
16
 
17
- $ bundle
17
+ $ bundle
18
18
 
19
19
  Or install it yourself as:
20
20
 
21
- $ gem install build
21
+ $ gem install build
22
22
 
23
23
  ## Usage
24
24
 
data/build.gemspec CHANGED
@@ -17,12 +17,13 @@ Gem::Specification.new do |spec|
17
17
 
18
18
  spec.required_ruby_version = '>= 2.0'
19
19
 
20
- spec.add_dependency "build-graph", "~> 1.2"
20
+ spec.add_dependency "build-graph", "~> 1.3"
21
21
  spec.add_dependency "build-environment", "~> 1.3"
22
22
  spec.add_dependency "build-dependency", "~> 1.4"
23
23
  spec.add_dependency "build-makefile", "~> 1.0"
24
24
 
25
- spec.add_dependency "graphviz"
25
+ spec.add_dependency "graphviz", "~> 1.0"
26
+ spec.add_dependency "event", "~> 1.0"
26
27
 
27
28
  spec.add_development_dependency "covered"
28
29
  spec.add_development_dependency "bundler"
@@ -30,17 +30,14 @@ require_relative 'rule_node'
30
30
  require_relative 'chain_node'
31
31
  require_relative 'task'
32
32
 
33
- require_relative 'logger'
33
+ require 'event/console'
34
34
 
35
35
  module Build
36
36
  class Controller
37
- def initialize(logger: nil, limit: nil)
37
+ def initialize(logger: Event::Console.logger, limit: nil)
38
38
  @module = Module.new
39
39
 
40
- @logger = logger || Logger.new($stdout).tap do |logger|
41
- logger.level = Logger::INFO
42
- logger.formatter = CompactFormatter.new
43
- end
40
+ @logger = logger
44
41
 
45
42
  # Top level nodes, for sanity this is a static list.
46
43
  @nodes = []
data/lib/build/task.rb CHANGED
@@ -21,6 +21,8 @@
21
21
  require 'fileutils'
22
22
  require 'build/graph'
23
23
 
24
+ require 'event/shell'
25
+
24
26
  module Build
25
27
  # This task class serves as the base class for the environment specific task classes genearted when adding targets.
26
28
  class Task < Graph::Task
@@ -62,7 +64,7 @@ module Build
62
64
 
63
65
  def spawn(*arguments)
64
66
  if wet?
65
- @logger&.info(:shell) {arguments}
67
+ @logger&.info(self) {Event::Shell.for(*arguments)}
66
68
  status = @group.spawn(*arguments)
67
69
 
68
70
  if status != 0
@@ -82,21 +84,21 @@ module Build
82
84
  def touch(path)
83
85
  return unless wet?
84
86
 
85
- @logger&.info(:shell) {['touch', path]}
87
+ @logger&.info(self) {Event::Shell.for('touch', path)}
86
88
  FileUtils.touch(path)
87
89
  end
88
90
 
89
91
  def cp(source_path, destination_path)
90
92
  return unless wet?
91
93
 
92
- @logger&.info(:shell) {['cp', source_path, destination_path]}
94
+ @logger&.info(self) {Event::Shell.for('cp', source_path, destination_path)}
93
95
  FileUtils.copy(source_path, destination_path)
94
96
  end
95
97
 
96
98
  def rm(path)
97
99
  return unless wet?
98
100
 
99
- @logger&.info(:shell) {['rm -rf', path]}
101
+ @logger&.info(self) {Event::Shell.for('rm -rf', path)}
100
102
  FileUtils.rm_rf(path)
101
103
  end
102
104
 
@@ -104,7 +106,7 @@ module Build
104
106
  return unless wet?
105
107
 
106
108
  unless File.exist?(path)
107
- @logger&.info(:shell) {['mkpath', path]}
109
+ @logger&.info(self) {Event::Shell.for('mkpath', path)}
108
110
  FileUtils.mkpath(path)
109
111
  end
110
112
  end
@@ -112,14 +114,14 @@ module Build
112
114
  def install(source_path, destination_path)
113
115
  return unless wet?
114
116
 
115
- @logger&.info(:shell) {['install', source_path, destination_path]}
117
+ @logger&.info(self) {Event::Shell.for('install', source_path, destination_path)}
116
118
  FileUtils.install(source_path, destination_path)
117
119
  end
118
120
 
119
121
  def write(path, data, mode = "w")
120
122
  return unless wet?
121
123
 
122
- @logger&.info(:shell) {["write", path, "#{data.size}bytes"]}
124
+ @logger&.info(self) {Event::Shell.for("write", path, "#{data.size}bytes")}
123
125
  File.open(path, mode) do |file|
124
126
  file.write(data)
125
127
  end
@@ -132,13 +134,13 @@ module Build
132
134
  def invoke_rule(rule, arguments, &block)
133
135
  arguments = rule.normalize(arguments, self)
134
136
 
135
- @logger&.debug(:invoke) {"-> #{rule}(#{arguments.inspect})"}
137
+ @logger&.debug(self) {"-> #{rule}(#{arguments.inspect})"}
136
138
 
137
139
  invoke(
138
140
  RuleNode.new(rule, arguments, &block)
139
141
  )
140
142
 
141
- @logger&.debug(:invoke) {"<- #{rule}(...) -> #{rule.result(arguments)}"}
143
+ @logger&.debug(self) {"<- #{rule}(...) -> #{rule.result(arguments)}"}
142
144
 
143
145
  return rule.result(arguments)
144
146
  end
data/lib/build/version.rb CHANGED
@@ -19,5 +19,5 @@
19
19
  # THE SOFTWARE.
20
20
 
21
21
  module Build
22
- VERSION = "2.2.0"
22
+ VERSION = "2.3.0"
23
23
  end
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: 2.2.0
4
+ version: 2.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Samuel Williams
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-03-06 00:00:00.000000000 Z
11
+ date: 2019-03-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: build-graph
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '1.2'
19
+ version: '1.3'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '1.2'
26
+ version: '1.3'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: build-environment
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -70,16 +70,30 @@ dependencies:
70
70
  name: graphviz
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
- - - ">="
73
+ - - "~>"
74
74
  - !ruby/object:Gem::Version
75
- version: '0'
75
+ version: '1.0'
76
76
  type: :runtime
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
- - - ">="
80
+ - - "~>"
81
81
  - !ruby/object:Gem::Version
82
- version: '0'
82
+ version: '1.0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: event
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '1.0'
90
+ type: :runtime
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: '1.0'
83
97
  - !ruby/object:Gem::Dependency
84
98
  name: covered
85
99
  requirement: !ruby/object:Gem::Requirement
@@ -155,7 +169,6 @@ files:
155
169
  - lib/build/chain_node.rb
156
170
  - lib/build/controller.rb
157
171
  - lib/build/graphviz.rb
158
- - lib/build/logger.rb
159
172
  - lib/build/name.rb
160
173
  - lib/build/rule.rb
161
174
  - lib/build/rule_node.rb
data/lib/build/logger.rb DELETED
@@ -1,109 +0,0 @@
1
- # Copyright, 2015, by Samuel G. D. Williams. <http://www.codeotaku.com>
2
- #
3
- # Permission is hereby granted, free of charge, to any person obtaining a copy
4
- # of this software and associated documentation files (the "Software"), to deal
5
- # in the Software without restriction, including without limitation the rights
6
- # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
- # copies of the Software, and to permit persons to whom the Software is
8
- # furnished to do so, subject to the following conditions:
9
- #
10
- # The above copyright notice and this permission notice shall be included in
11
- # all copies or substantial portions of the Software.
12
- #
13
- # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
- # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
- # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
- # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
- # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
- # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19
- # THE SOFTWARE.
20
-
21
- require 'logger'
22
- require 'rainbow'
23
-
24
- module Build
25
- class CompactFormatter
26
- def initialize(verbose: true)
27
- @start = Time.now
28
- @verbose = verbose
29
- end
30
-
31
- def time_offset_prefix
32
- offset = Time.now - @start
33
- minutes = (offset/60).floor
34
- seconds = (offset - (minutes*60))
35
-
36
- if minutes > 0
37
- "#{minutes}m#{seconds.floor}s"
38
- else
39
- "#{seconds.round(2)}s"
40
- end.rjust(6)
41
- end
42
-
43
- def chdir_string(options)
44
- if options[:chdir]
45
- " in #{options[:chdir]}"
46
- else
47
- ""
48
- end
49
- end
50
-
51
- def format_command(arguments, buffer)
52
- arguments = arguments.dup
53
-
54
- environment = arguments.first.is_a?(Hash) ? arguments.shift : nil
55
- options = arguments.last.is_a?(Hash) ? arguments.pop : nil
56
-
57
- arguments = arguments.flatten.collect(&:to_s)
58
-
59
- buffer << Rainbow(arguments.join(' ')).bright.blue
60
-
61
- if options
62
- buffer << chdir_string(options)
63
- end
64
-
65
- buffer << "\n"
66
-
67
- if @verbose
68
- if environment
69
- environment.each do |key, value|
70
- buffer << "\texport #{key}=#{value.dump}\n"
71
- end
72
- end
73
- end
74
- end
75
-
76
- def format_exception(exception, buffer)
77
- buffer << Rainbow("#{exception.class}: #{exception}").bright.red << "\n"
78
- exception.backtrace.each do |line|
79
- buffer << "\t" << Rainbow(line).red << "\n"
80
- end
81
- end
82
-
83
- def call(severity, datetime, progname, message)
84
- buffer = []
85
- prefix = ""
86
-
87
- if @verbose
88
- prefix = time_offset_prefix
89
- buffer << Rainbow(prefix).cyan + ": "
90
- prefix = " " * (prefix.size) + "| "
91
- end
92
-
93
- if progname == :shell and message.kind_of? Array
94
- format_command(message, buffer)
95
- elsif message.kind_of? Exception
96
- format_exception(message, buffer)
97
- else
98
- buffer << message << "\n"
99
- end
100
-
101
- result = buffer.join
102
-
103
- # This fancy regex indents lines correctly depending on the prefix:
104
- result.gsub!(/\n(?!$)/, "\n#{prefix}") unless prefix.empty?
105
-
106
- return result
107
- end
108
- end
109
- end