rake-funnel 0.3.2.pre → 0.4.0.pre
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/.rspec +2 -2
- data/Gemfile +4 -0
- data/README.md +2 -2
- data/lib/rake/funnel/ambiguous_file_error.rb +31 -29
- data/lib/rake/funnel/execution_error.rb +28 -26
- data/lib/rake/funnel/extensions/case/camel_case.rb +24 -19
- data/lib/rake/funnel/extensions/case/pascal_case.rb +24 -19
- data/lib/rake/funnel/extensions/case.rb +3 -3
- data/lib/rake/funnel/extensions/common_path.rb +60 -52
- data/lib/rake/funnel/extensions/disable_colors.rb +33 -27
- data/lib/rake/funnel/extensions/rexml.rb +27 -23
- data/lib/rake/funnel/extensions/shell.rb +92 -56
- data/lib/rake/funnel/extensions/windows_path.rb +15 -11
- data/lib/rake/funnel/framework.rb +11 -16
- data/lib/rake/funnel/integration/progress_report.rb +72 -70
- data/lib/rake/funnel/integration/sync_output.rb +12 -8
- data/lib/rake/funnel/integration/teamcity/nunit_plugin.rb +61 -55
- data/lib/rake/funnel/integration/teamcity/progress_report.rb +39 -33
- data/lib/rake/funnel/integration/teamcity/service_messages.rb +46 -40
- data/lib/rake/funnel/integration/teamcity/teamcity.rb +19 -15
- data/lib/rake/funnel/integration/teamcity.rb +3 -5
- data/lib/rake/funnel/support/argument_mapper/key_value_pair.rb +16 -10
- data/lib/rake/funnel/support/argument_mapper/styles/default.rb +39 -31
- data/lib/rake/funnel/support/argument_mapper/styles/msbuild.rb +41 -33
- data/lib/rake/funnel/support/argument_mapper/styles/msdeploy.rb +55 -47
- data/lib/rake/funnel/support/argument_mapper/styles/nunit.rb +41 -33
- data/lib/rake/funnel/support/argument_mapper/styles.rb +3 -5
- data/lib/rake/funnel/support/argument_mapper/switch.rb +16 -10
- data/lib/rake/funnel/support/argument_mapper/value.rb +16 -10
- data/lib/rake/funnel/support/assembly_version/from_version_files.rb +39 -35
- data/lib/rake/funnel/support/assembly_version/languages/cs +5 -5
- data/lib/rake/funnel/support/assembly_version/languages/fs +12 -12
- data/lib/rake/funnel/support/assembly_version/languages/vb +5 -5
- data/lib/rake/funnel/support/assembly_version_writer.rb +56 -52
- data/lib/rake/funnel/support/binary_version_reader.rb +37 -32
- data/lib/rake/funnel/support/copier.rb +31 -27
- data/lib/rake/funnel/support/environments/loader.rb +46 -40
- data/lib/rake/funnel/support/environments.rb +3 -3
- data/lib/rake/funnel/support/internal/finder.rb +55 -51
- data/lib/rake/funnel/support/internal/instantiate_symbol.rb +38 -34
- data/lib/rake/funnel/support/mapper.rb +57 -53
- data/lib/rake/funnel/support/mono.rb +21 -17
- data/lib/rake/funnel/support/msbuild/build_tool.rb +30 -24
- data/lib/rake/funnel/support/msbuild.rb +3 -3
- data/lib/rake/funnel/support/msdeploy/registry_patch.rb +90 -84
- data/lib/rake/funnel/support/msdeploy.rb +3 -3
- data/lib/rake/funnel/support/patch.rb +41 -37
- data/lib/rake/funnel/support/specs_remover.rb +66 -62
- data/lib/rake/funnel/support/template_engine.rb +30 -26
- data/lib/rake/funnel/support/timing/report.rb +95 -89
- data/lib/rake/funnel/support/timing/statistics.rb +32 -26
- data/lib/rake/funnel/support/timing.rb +3 -3
- data/lib/rake/funnel/support/version_info.rb +103 -72
- data/lib/rake/funnel/support/which.rb +19 -15
- data/lib/rake/funnel/support/zipper.rb +53 -49
- data/lib/rake/funnel/tasks/assembly_version.rb +44 -40
- data/lib/rake/funnel/tasks/bin_path.rb +45 -41
- data/lib/rake/funnel/tasks/copy.rb +43 -39
- data/lib/rake/funnel/tasks/environments.rb +89 -89
- data/lib/rake/funnel/tasks/msbuild.rb +55 -51
- data/lib/rake/funnel/tasks/msdeploy.rb +54 -50
- data/lib/rake/funnel/tasks/nunit.rb +52 -48
- data/lib/rake/funnel/tasks/paket.rb +51 -47
- data/lib/rake/funnel/tasks/quick_template.rb +53 -49
- data/lib/rake/funnel/tasks/side_by_side_specs.rb +41 -37
- data/lib/rake/funnel/tasks/timing.rb +108 -104
- data/lib/rake/funnel/tasks/zip.rb +46 -42
- data/lib/rake/funnel/version.rb +1 -1
- data/lib/rake/funnel.rb +7 -7
- data/rake-funnel.gemspec +12 -3
- data/spec/rake/funnel/execution_error_spec.rb +67 -67
- data/spec/rake/funnel/extensions/case/camel_case_spec.rb +17 -17
- data/spec/rake/funnel/extensions/case/pascal_case_spec.rb +17 -17
- data/spec/rake/funnel/extensions/common_path_spec.rb +56 -56
- data/spec/rake/funnel/extensions/disable_colors_spec.rb +33 -33
- data/spec/rake/funnel/extensions/rexml_spec.rb +20 -20
- data/spec/rake/funnel/extensions/shell_spec.rb +237 -237
- data/spec/rake/funnel/extensions/windows_path_spec.rb +5 -5
- data/spec/rake/funnel/integration/progress_report_spec.rb +149 -149
- data/spec/rake/funnel/integration/sync_output_spec.rb +16 -16
- data/spec/rake/funnel/integration/teamcity/nunit_plugin_spec.rb +110 -110
- data/spec/rake/funnel/integration/teamcity/progress_report_spec.rb +174 -174
- data/spec/rake/funnel/integration/teamcity/service_messages_spec.rb +136 -136
- data/spec/rake/funnel/integration/teamcity/teamcity_spec.rb +34 -34
- data/spec/rake/funnel/support/argument_mapper/styles/msdeploy_spec.rb +222 -222
- data/spec/rake/funnel/support/argument_mapper/styles/nunit_spec.rb +25 -25
- data/spec/rake/funnel/support/argument_mapper/styles/styles_spec.rb +214 -214
- data/spec/rake/funnel/support/assembly_version/from_version_files_spec.rb +66 -61
- data/spec/rake/funnel/support/assembly_version_writer_spec.rb +140 -140
- data/spec/rake/funnel/support/binary_version_reader_spec.rb +29 -29
- data/spec/rake/funnel/support/copier_spec.rb +58 -58
- data/spec/rake/funnel/support/environments/loader_spec.rb +143 -143
- data/spec/rake/funnel/support/internal/finder_spec.rb +229 -229
- data/spec/rake/funnel/support/internal/instantiate_symbol_spec.rb +182 -183
- data/spec/rake/funnel/support/mapper_spec.rb +87 -87
- data/spec/rake/funnel/support/mono_spec.rb +57 -57
- data/spec/rake/funnel/support/msbuild/build_tool_spec.rb +21 -21
- data/spec/rake/funnel/support/msdeploy/registry_patch_spec.rb +139 -139
- data/spec/rake/funnel/support/patch_spec.rb +108 -108
- data/spec/rake/funnel/support/specs_remover/Sample.csproj +28 -28
- data/spec/rake/funnel/support/specs_remover_spec.rb +116 -116
- data/spec/rake/funnel/support/template_engine_spec.rb +65 -65
- data/spec/rake/funnel/support/timing/report_spec.rb +129 -129
- data/spec/rake/funnel/support/version_info_spec.rb +333 -228
- data/spec/rake/funnel/support/which_spec.rb +65 -65
- data/spec/rake/funnel/support/zipper_spec.rb +77 -77
- data/spec/rake/funnel/tasks/assembly_version_spec.rb +45 -45
- data/spec/rake/funnel/tasks/bin_path_spec.rb +52 -52
- data/spec/rake/funnel/tasks/copy_spec.rb +44 -44
- data/spec/rake/funnel/tasks/environments_spec.rb +249 -247
- data/spec/rake/funnel/tasks/msbuild_spec.rb +91 -91
- data/spec/rake/funnel/tasks/msdeploy_spec.rb +220 -220
- data/spec/rake/funnel/tasks/nunit_spec.rb +74 -74
- data/spec/rake/funnel/tasks/paket_spec.rb +140 -142
- data/spec/rake/funnel/tasks/quick_template_spec.rb +62 -62
- data/spec/rake/funnel/tasks/side_by_side_specs_spec.rb +58 -58
- data/spec/rake/funnel/tasks/timing_spec.rb +133 -133
- data/spec/rake/funnel/tasks/zip_spec.rb +50 -50
- data/spec/spec_helper.rb +43 -33
- metadata +2 -3
- data/lib/rake/funnel/support/side_by_side_specs.rb +0 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a8f5640c14dff5bf858d39fc9ae5bac6be7871ee
|
4
|
+
data.tar.gz: 03a44a3c45f0a6f9ccaf71a2ac87e4c73accab58
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8759d1624ab1c1f6cb18693966e263cde514d516ce02d2250fe2da279b32561b13ad3e68785349ca5041d8beaba3622d2dac9aa1b34d43d6e8b665a20461c6c1
|
7
|
+
data.tar.gz: 99aaf5c647d45208a2056514b824e2795f7c90e053be7c7d665cb44eccc0384f4fca5520e6a024bec8ca9a37ea13a35ebce2a886d70fd849e65c6e4f8b39cb08
|
data/.rspec
CHANGED
@@ -1,2 +1,2 @@
|
|
1
|
-
--require spec_helper
|
2
|
-
--tag ~@draft
|
1
|
+
--require spec_helper
|
2
|
+
--tag ~@draft
|
data/Gemfile
CHANGED
@@ -7,6 +7,7 @@ gemspec
|
|
7
7
|
group :development do
|
8
8
|
gem 'guard-bundler', require: false
|
9
9
|
gem 'guard-rspec', require: false
|
10
|
+
gem 'guard-rubocop', require: false
|
10
11
|
|
11
12
|
case RbConfig::CONFIG['target_os']
|
12
13
|
when /windows|bccwin|cygwin|djgpp|mingw|mswin|wince/i
|
@@ -26,4 +27,7 @@ group :development, :ci do
|
|
26
27
|
gem 'rspec-collection_matchers', require: false
|
27
28
|
gem 'coveralls', require: false
|
28
29
|
gem 'codeclimate-test-reporter', require: false
|
30
|
+
gem 'rubocop', require: false
|
31
|
+
gem 'rubocop-rspec', require: false
|
32
|
+
gem 'simplecov-teamcity-summary', require: false
|
29
33
|
end
|
data/README.md
CHANGED
@@ -1,10 +1,10 @@
|
|
1
1
|
# rake-funnel
|
2
2
|
|
3
|
-
[](http://badge.fury.io/rb/rake-funnel) [](https://travis-ci.org/agross/rake-funnel) [](https://gemnasium.com/agross/rake-funnel) [](https://codeclimate.com/github/agross/rake-funnel) [](https://coveralls.io/r/agross/rake-funnel)
|
4
4
|
|
5
5
|
rake-funnel is my set of rake tasks, mostly targeted at .NET development.
|
6
6
|
|
7
|
-
* Tested against Ruby 2.0.0, 2.1.0
|
7
|
+
* Tested against Ruby 2.0.0, 2.1.0 through 2.2.1 and ruby-head
|
8
8
|
* Ruby < 2.0 is not supported
|
9
9
|
|
10
10
|
## Installation
|
@@ -1,29 +1,31 @@
|
|
1
|
-
module Rake
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
end
|
1
|
+
module Rake
|
2
|
+
module Funnel
|
3
|
+
class AmbiguousFileError < StandardError
|
4
|
+
attr_reader :task_name, :search_pattern, :candidates, :description
|
5
|
+
|
6
|
+
def initialize(message, task_name, search_pattern, candidates)
|
7
|
+
description = "Could not run task '#{task_name}'. #{message}"
|
8
|
+
super(description)
|
9
|
+
|
10
|
+
@description = description
|
11
|
+
@task_name = task_name
|
12
|
+
@search_pattern = search_pattern
|
13
|
+
@candidates = candidates
|
14
|
+
end
|
15
|
+
|
16
|
+
def to_s
|
17
|
+
msg = []
|
18
|
+
(msg << description) if description
|
19
|
+
(msg << "Search pattern used: #{@search_pattern}") if @search_pattern
|
20
|
+
unless (@candidates || []).empty?
|
21
|
+
msg << 'Candidates:'
|
22
|
+
msg << @candidates.map { |c| " - #{c}" }
|
23
|
+
end
|
24
|
+
|
25
|
+
msg = [super.to_s] if msg.empty?
|
26
|
+
|
27
|
+
msg.join("\n")
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -1,26 +1,28 @@
|
|
1
|
-
module Rake
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
end
|
1
|
+
module Rake
|
2
|
+
module Funnel
|
3
|
+
class ExecutionError < StandardError
|
4
|
+
attr_reader :command, :exit_code, :output, :description
|
5
|
+
|
6
|
+
def initialize(command = nil, exit_code = nil, output = nil, description = nil)
|
7
|
+
super(description)
|
8
|
+
|
9
|
+
@description = description
|
10
|
+
@command = command
|
11
|
+
@exit_code = exit_code
|
12
|
+
@output = output
|
13
|
+
end
|
14
|
+
|
15
|
+
def to_s
|
16
|
+
msg = []
|
17
|
+
(msg << description << nil) if description
|
18
|
+
(msg << 'Error executing:' << command << nil) if command
|
19
|
+
(msg << "Exit code: #{exit_code}" << nil) if exit_code
|
20
|
+
(msg << 'Command output (last 10 lines):' << output.split("\n").last(10) << nil) if output
|
21
|
+
|
22
|
+
msg = [super.to_s] if msg.empty?
|
23
|
+
|
24
|
+
msg.join("\n")
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -1,19 +1,24 @@
|
|
1
|
-
module Rake
|
2
|
-
module
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
end
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
end
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
1
|
+
module Rake
|
2
|
+
module Funnel
|
3
|
+
module Extensions
|
4
|
+
module Case
|
5
|
+
module CamelCase
|
6
|
+
def camelize
|
7
|
+
to_s
|
8
|
+
.split('_')
|
9
|
+
.inject([]) { |buffer, e| buffer.push(buffer.empty? ? e : e.capitalize) }
|
10
|
+
.join
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
class String
|
19
|
+
include Rake::Funnel::Extensions::Case::CamelCase
|
20
|
+
end
|
21
|
+
|
22
|
+
class Symbol
|
23
|
+
include Rake::Funnel::Extensions::Case::CamelCase
|
24
|
+
end
|
@@ -1,19 +1,24 @@
|
|
1
|
-
module Rake
|
2
|
-
module
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
end
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
end
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
1
|
+
module Rake
|
2
|
+
module Funnel
|
3
|
+
module Extensions
|
4
|
+
module Case
|
5
|
+
module PascalCase
|
6
|
+
def pascalize
|
7
|
+
to_s
|
8
|
+
.split('_')
|
9
|
+
.inject([]) { |buffer, e| buffer.push(e.slice(0, 1).capitalize + e.slice(1..-1)) }
|
10
|
+
.join
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
class String
|
19
|
+
include Rake::Funnel::Extensions::Case::PascalCase
|
20
|
+
end
|
21
|
+
|
22
|
+
class Symbol
|
23
|
+
include Rake::Funnel::Extensions::Case::PascalCase
|
24
|
+
end
|
@@ -1,3 +1,3 @@
|
|
1
|
-
Dir["#{File.dirname(__FILE__)}/case/*.rb"].each do |path|
|
2
|
-
require path
|
3
|
-
end
|
1
|
+
Dir["#{File.dirname(__FILE__)}/case/*.rb"].each do |path|
|
2
|
+
require path
|
3
|
+
end
|
@@ -1,52 +1,60 @@
|
|
1
|
-
require 'abbrev'
|
2
|
-
require 'pathname'
|
3
|
-
|
4
|
-
module Rake
|
5
|
-
module
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
end
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
1
|
+
require 'abbrev'
|
2
|
+
require 'pathname'
|
3
|
+
|
4
|
+
module Rake
|
5
|
+
module Funnel
|
6
|
+
module Extensions
|
7
|
+
module CommonPath
|
8
|
+
def common_path
|
9
|
+
list = to_a
|
10
|
+
.compact
|
11
|
+
.map { |x| components(x) }
|
12
|
+
|
13
|
+
min = list.min_by(&:length)
|
14
|
+
|
15
|
+
matches = find_matches(list, min)
|
16
|
+
matches.min_by(&:length) || ''
|
17
|
+
end
|
18
|
+
|
19
|
+
private
|
20
|
+
def components(path)
|
21
|
+
paths = []
|
22
|
+
Pathname.new(path).descend do |p|
|
23
|
+
paths << p
|
24
|
+
end
|
25
|
+
|
26
|
+
paths = paths.inject([]) { |components, p|
|
27
|
+
relative = p.relative_path_from(components.last[:absolute]) if components.any?
|
28
|
+
|
29
|
+
components << { absolute: p, relative: relative || p }
|
30
|
+
}
|
31
|
+
|
32
|
+
paths.map { |component| component[:relative].to_s }
|
33
|
+
end
|
34
|
+
|
35
|
+
def find_matches(list, min)
|
36
|
+
list.map do |path|
|
37
|
+
longest_prefix = []
|
38
|
+
|
39
|
+
path.zip(min).each do |left, right|
|
40
|
+
next if left != right
|
41
|
+
longest_prefix << right
|
42
|
+
end
|
43
|
+
|
44
|
+
File.join(longest_prefix)
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
class Array
|
53
|
+
include Rake::Funnel::Extensions::CommonPath
|
54
|
+
end
|
55
|
+
|
56
|
+
module Rake
|
57
|
+
class FileList
|
58
|
+
include Rake::Funnel::Extensions::CommonPath
|
59
|
+
end
|
60
|
+
end
|
@@ -1,27 +1,33 @@
|
|
1
|
-
require 'smart_colored'
|
2
|
-
require 'smart_colored/extend'
|
3
|
-
|
4
|
-
module Rake
|
5
|
-
module
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
end
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
end
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
1
|
+
require 'smart_colored'
|
2
|
+
require 'smart_colored/extend'
|
3
|
+
|
4
|
+
module Rake
|
5
|
+
module Funnel
|
6
|
+
module Extensions
|
7
|
+
module DisableColors
|
8
|
+
def self.included(klass)
|
9
|
+
original_apply_format = klass.instance_method(:apply_format)
|
10
|
+
|
11
|
+
define_method(:apply_format) do |format|
|
12
|
+
return self unless $stdout.tty?
|
13
|
+
|
14
|
+
bind_to = self
|
15
|
+
bind_to = SmartColored::String.new(self) if klass == SmartColored::String
|
16
|
+
|
17
|
+
original_apply_format.bind(bind_to).call(format)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
module SmartColored
|
26
|
+
class String
|
27
|
+
include Rake::Funnel::Extensions::DisableColors
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
class String
|
32
|
+
include Rake::Funnel::Extensions::DisableColors
|
33
|
+
end
|
@@ -1,23 +1,27 @@
|
|
1
|
-
require 'rexml/document'
|
2
|
-
|
3
|
-
module Rake
|
4
|
-
module
|
5
|
-
module
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
end
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
1
|
+
require 'rexml/document'
|
2
|
+
|
3
|
+
module Rake
|
4
|
+
module Funnel
|
5
|
+
module Extensions
|
6
|
+
module REXML
|
7
|
+
module Functions
|
8
|
+
def lower_case(string)
|
9
|
+
string.first.to_s.downcase
|
10
|
+
end
|
11
|
+
|
12
|
+
def matches(string, test)
|
13
|
+
File.fnmatch?(test, string.first.to_s, File::FNM_CASEFOLD)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
module REXML
|
22
|
+
module Functions
|
23
|
+
class << self
|
24
|
+
include Rake::Funnel::Extensions::REXML::Functions
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -1,56 +1,92 @@
|
|
1
|
-
require 'rake'
|
2
|
-
require 'open3'
|
3
|
-
require 'smart_colored/extend'
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
end
|
1
|
+
require 'rake'
|
2
|
+
require 'open3'
|
3
|
+
require 'smart_colored/extend'
|
4
|
+
require 'stringio'
|
5
|
+
|
6
|
+
module Rake
|
7
|
+
module Funnel
|
8
|
+
module Extensions
|
9
|
+
module Shell
|
10
|
+
def shell(*cmd, log_file: nil, error_lines: nil, &block)
|
11
|
+
mkdir_p(File.dirname(log_file)) if log_file
|
12
|
+
|
13
|
+
run(cmd, log_file, error_lines) do |success, readable_cmd, result, log|
|
14
|
+
if block
|
15
|
+
block.call(success, readable_cmd, result, log)
|
16
|
+
return
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
private
|
22
|
+
def run(cmd, log_file, error_lines)
|
23
|
+
cmd, readable_cmd = normalize(cmd)
|
24
|
+
|
25
|
+
Rake.rake_output_message(readable_cmd)
|
26
|
+
|
27
|
+
Open3.popen2e(*cmd) do |_, stdout_and_stderr, wait_thread|
|
28
|
+
log, error_logged = log_output(stdout_and_stderr, log_file, error_lines)
|
29
|
+
success = wait_thread.value.success? && error_logged == false
|
30
|
+
|
31
|
+
result = [readable_cmd, wait_thread.value.exitstatus, log]
|
32
|
+
|
33
|
+
yield(success, *result) if block_given?
|
34
|
+
|
35
|
+
fail Rake::Funnel::ExecutionError.new(*result) unless success
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
def normalize(cmd)
|
40
|
+
cmd = cmd.flatten.reject(&:nil?)
|
41
|
+
readable_cmd = cmd.join(' ')
|
42
|
+
|
43
|
+
[cmd, readable_cmd]
|
44
|
+
end
|
45
|
+
|
46
|
+
def log_output(stdout_and_stderr, log_file, error_lines)
|
47
|
+
log_string = StringIO.new
|
48
|
+
|
49
|
+
begin
|
50
|
+
statuses = log_lines(stdout_and_stderr, log_file, error_lines, log_string)
|
51
|
+
|
52
|
+
[log_string.string, statuses.any? { |s| s == :error }]
|
53
|
+
ensure
|
54
|
+
log_string.close
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
def log_lines(stdout_and_stderr, log_file, error_lines, log_string)
|
59
|
+
stdout_and_stderr.map do |line|
|
60
|
+
log_string.write(line)
|
61
|
+
File.open(log_file, 'a') { |f| f.write(line) } if log_file
|
62
|
+
|
63
|
+
handle_line(line, error_lines)
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
def handle_line(line, error_lines)
|
68
|
+
to_stderr(line, error_lines) || to_stdout(line)
|
69
|
+
end
|
70
|
+
|
71
|
+
def to_stdout(line)
|
72
|
+
$stdout.puts line.sub(/\n$/, '').green
|
73
|
+
:success
|
74
|
+
end
|
75
|
+
|
76
|
+
def to_stderr(line, error_lines)
|
77
|
+
return unless error_lines && line =~ error_lines
|
78
|
+
|
79
|
+
$stderr.puts line.sub(/\n$/, '').bold.red
|
80
|
+
:error
|
81
|
+
end
|
82
|
+
end
|
83
|
+
end
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
87
|
+
module Rake
|
88
|
+
module DSL
|
89
|
+
include Rake::Funnel::Extensions::Shell
|
90
|
+
private(*Rake::Funnel::Extensions::Shell.instance_methods(false))
|
91
|
+
end
|
92
|
+
end
|