rake-funnel 0.18.0 → 0.19.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (99) hide show
  1. checksums.yaml +4 -4
  2. data/.rspec +1 -0
  3. data/.simplecov +24 -0
  4. data/Gemfile +27 -19
  5. data/README.md +1 -1
  6. data/lib/rake/funnel/ambiguous_file_error.rb +1 -0
  7. data/lib/rake/funnel/execution_error.rb +1 -0
  8. data/lib/rake/funnel/extensions/common_path.rb +5 -4
  9. data/lib/rake/funnel/extensions/shell.rb +3 -2
  10. data/lib/rake/funnel/integration/progress_report.rb +3 -2
  11. data/lib/rake/funnel/integration/sync_output.rb +1 -0
  12. data/lib/rake/funnel/integration/teamcity/nunit_plugin.rb +2 -1
  13. data/lib/rake/funnel/integration/teamcity/progress_report.rb +1 -1
  14. data/lib/rake/funnel/integration/teamcity/service_messages.rb +8 -3
  15. data/lib/rake/funnel/integration/teamcity/teamcity.rb +5 -4
  16. data/lib/rake/funnel/support/argument_mapper/styles/default.rb +5 -4
  17. data/lib/rake/funnel/support/argument_mapper/styles/msbuild.rb +6 -5
  18. data/lib/rake/funnel/support/argument_mapper/styles/msdeploy.rb +13 -12
  19. data/lib/rake/funnel/support/argument_mapper/styles/nunit.rb +6 -5
  20. data/lib/rake/funnel/support/assembly_version/from_version_files.rb +2 -1
  21. data/lib/rake/funnel/support/assembly_version_writer.rb +1 -0
  22. data/lib/rake/funnel/support/binary_version_reader.rb +14 -7
  23. data/lib/rake/funnel/support/copier.rb +1 -0
  24. data/lib/rake/funnel/support/environments/loader.rb +13 -8
  25. data/lib/rake/funnel/support/internal/finder.rb +2 -1
  26. data/lib/rake/funnel/support/internal/instantiate_symbol.rb +9 -4
  27. data/lib/rake/funnel/support/mapper.rb +7 -6
  28. data/lib/rake/funnel/support/mono.rb +1 -3
  29. data/lib/rake/funnel/support/msbuild/build_tool.rb +35 -12
  30. data/lib/rake/funnel/support/msdeploy/registry_patch.rb +14 -17
  31. data/lib/rake/funnel/support/patch.rb +1 -0
  32. data/lib/rake/funnel/support/specs_remover.rb +14 -11
  33. data/lib/rake/funnel/support/template_engine.rb +1 -0
  34. data/lib/rake/funnel/support/timing/report.rb +11 -10
  35. data/lib/rake/funnel/support/version_info.rb +8 -9
  36. data/lib/rake/funnel/support/zipper.rb +1 -0
  37. data/lib/rake/funnel/tasks/assembly_version.rb +4 -3
  38. data/lib/rake/funnel/tasks/bin_path.rb +3 -2
  39. data/lib/rake/funnel/tasks/copy.rb +2 -1
  40. data/lib/rake/funnel/tasks/environments.rb +13 -9
  41. data/lib/rake/funnel/tasks/msbuild.rb +4 -6
  42. data/lib/rake/funnel/tasks/msdeploy.rb +6 -5
  43. data/lib/rake/funnel/tasks/nunit.rb +3 -2
  44. data/lib/rake/funnel/tasks/paket.rb +2 -1
  45. data/lib/rake/funnel/tasks/quick_template.rb +3 -2
  46. data/lib/rake/funnel/tasks/side_by_side_specs.rb +2 -1
  47. data/lib/rake/funnel/tasks/timing.rb +7 -6
  48. data/lib/rake/funnel/tasks/zip.rb +3 -2
  49. data/lib/rake/funnel/version.rb +1 -1
  50. data/rake-funnel.gemspec +11 -11
  51. data/spec/rake/funnel/execution_error_spec.rb +2 -2
  52. data/spec/rake/funnel/extensions/rexml_spec.rb +5 -2
  53. data/spec/rake/funnel/extensions/shell_spec.rb +26 -17
  54. data/spec/rake/funnel/integration/progress_report_spec.rb +32 -36
  55. data/spec/rake/funnel/integration/sync_output_spec.rb +5 -5
  56. data/spec/rake/funnel/integration/teamcity/nunit_plugin_spec.rb +32 -20
  57. data/spec/rake/funnel/integration/teamcity/progress_report_spec.rb +31 -25
  58. data/spec/rake/funnel/integration/teamcity/service_messages_spec.rb +56 -20
  59. data/spec/rake/funnel/integration/teamcity/teamcity_spec.rb +7 -5
  60. data/spec/rake/funnel/support/argument_mapper/styles/msdeploy_spec.rb +2 -0
  61. data/spec/rake/funnel/support/argument_mapper/styles/nunit_spec.rb +6 -4
  62. data/spec/rake/funnel/support/argument_mapper/styles/styles_spec.rb +76 -67
  63. data/spec/rake/funnel/support/assembly_version/from_version_files_spec.rb +17 -19
  64. data/spec/rake/funnel/support/assembly_version_writer_spec.rb +49 -52
  65. data/spec/rake/funnel/support/binary_version_reader_spec.rb +2 -2
  66. data/spec/rake/funnel/support/copier_spec.rb +5 -5
  67. data/spec/rake/funnel/support/environments/loader_spec.rb +32 -32
  68. data/spec/rake/funnel/support/internal/finder_spec.rb +8 -6
  69. data/spec/rake/funnel/support/internal/instantiate_symbol_spec.rb +27 -27
  70. data/spec/rake/funnel/support/mapper_spec.rb +4 -3
  71. data/spec/rake/funnel/support/mono_spec.rb +7 -7
  72. data/spec/rake/funnel/support/msbuild/build_tool_spec.rb +13 -10
  73. data/spec/rake/funnel/support/msdeploy/registry_patch_spec.rb +47 -41
  74. data/spec/rake/funnel/support/patch_spec.rb +11 -11
  75. data/spec/rake/funnel/support/specs_remover/project/paket.references +3 -3
  76. data/spec/rake/funnel/support/specs_remover/project/uncompiled-code/paket.references +3 -3
  77. data/spec/rake/funnel/support/specs_remover/project-specific paket.references/Sample.csproj.paket.references +3 -3
  78. data/spec/rake/funnel/support/specs_remover/project-specific paket.references/paket.references +3 -3
  79. data/spec/rake/funnel/support/specs_remover_spec.rb +31 -33
  80. data/spec/rake/funnel/support/template_engine_spec.rb +6 -3
  81. data/spec/rake/funnel/support/timing/report_spec.rb +19 -20
  82. data/spec/rake/funnel/support/trace_spec.rb +6 -6
  83. data/spec/rake/funnel/support/version_info_spec.rb +8 -6
  84. data/spec/rake/funnel/support/which_spec.rb +7 -7
  85. data/spec/rake/funnel/support/zipper_spec.rb +8 -8
  86. data/spec/rake/funnel/tasks/assembly_version_spec.rb +9 -9
  87. data/spec/rake/funnel/tasks/bin_path_spec.rb +23 -21
  88. data/spec/rake/funnel/tasks/copy_spec.rb +10 -10
  89. data/spec/rake/funnel/tasks/environments_spec.rb +48 -46
  90. data/spec/rake/funnel/tasks/msbuild_spec.rb +21 -17
  91. data/spec/rake/funnel/tasks/msdeploy_spec.rb +31 -31
  92. data/spec/rake/funnel/tasks/nunit_spec.rb +12 -10
  93. data/spec/rake/funnel/tasks/paket_spec.rb +25 -21
  94. data/spec/rake/funnel/tasks/quick_template_spec.rb +7 -7
  95. data/spec/rake/funnel/tasks/side_by_side_specs_spec.rb +12 -12
  96. data/spec/rake/funnel/tasks/timing_spec.rb +12 -12
  97. data/spec/rake/funnel/tasks/zip_spec.rb +16 -16
  98. data/spec/spec_helper.rb +5 -31
  99. metadata +7 -6
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 0e62b12985fc2bbeb76d573e7085d7baf9a3eae8
4
- data.tar.gz: 95eadbea48e9d562e5247b2309422cfdc97e4e0b
3
+ metadata.gz: d994a7aee19d9d6394f52bd560fceb3e7c1d0dba
4
+ data.tar.gz: 845d2b7a7862dcb29bfbdc3c06bc7a4620ccb585
5
5
  SHA512:
6
- metadata.gz: 098b0d7d52d681f269d25379f6512a3de25b223ceb27a1b87fb74592a4351249e3a30d36cfab132544ef4a2c4803633d1e95edccdd4890333b6944a5620e06a9
7
- data.tar.gz: 399b67b3b78e6fe13ead61f39ec9d38a71120734e9e6a8841e025255aa11479ab5312870ddd6ee31908c569ec0a2319d8383fd95755e9a6bea6972df7512d333
6
+ metadata.gz: f473e9b4620d0c95e97a729ae1eb65fd148e5088203218a377ece7900f5283d38f57b57fa04411a669e05b7d185096e045fb63af063f1084eeaf777f8fd3d8b6
7
+ data.tar.gz: 8dad0dae6e75d942e9e04045ff3d1cdf0d6e953bba0001d3dd87f548f721f29711f0698481eb56addcbca58ab23b57c5acc91da0428952a7b9c0c4d7c464d491
data/.rspec CHANGED
@@ -1,2 +1,3 @@
1
+ --color
1
2
  --require spec_helper
2
3
  --tag ~@draft
data/.simplecov ADDED
@@ -0,0 +1,24 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'pathname'
4
+ require 'coveralls'
5
+ require 'simplecov-teamcity-summary'
6
+
7
+ SimpleCov.start do
8
+ track_files('lib/**/*.rb')
9
+
10
+ add_filter do |file|
11
+ relative_path = Pathname.new(file.filename)
12
+ .relative_path_from(Pathname.new(SimpleCov.root))
13
+ relative_path.to_s =~ %r{^spec/}
14
+ end
15
+
16
+ coverage_dir('build/coverage')
17
+
18
+ format = [::SimpleCov::Formatter::HTMLFormatter]
19
+
20
+ format << Coveralls::SimpleCov::Formatter if Coveralls.will_run?
21
+ format << SimpleCov::Formatter::TeamcitySummaryFormatter if ENV['TEAMCITY_PROJECT_NAME']
22
+
23
+ formatter(::SimpleCov::Formatter::MultiFormatter.new(format))
24
+ end
data/Gemfile CHANGED
@@ -1,33 +1,41 @@
1
- require 'rbconfig'
2
-
3
1
  source 'https://rubygems.org'
4
2
 
5
3
  gemspec
6
4
 
7
- group :development do
5
+ group :coverage do
6
+ gem 'codeclimate-test-reporter'
7
+ gem 'coveralls'
8
+ gem 'simplecov-teamcity-summary'
9
+ end
10
+
11
+ group :style do
12
+ gem 'rubocop', '~> 0.46'
13
+ gem 'rubocop-rspec'
14
+ end
15
+
16
+ group :test do
17
+ gem 'rspec', '~> 3.0'
18
+ gem 'rspec-collection_matchers'
19
+ gem 'rspec-its'
20
+ end
21
+
22
+ group :development, :guard do
8
23
  gem 'guard-bundler'
9
24
  gem 'guard-rspec'
10
25
  gem 'guard-rubocop'
11
26
 
12
- case RbConfig::CONFIG['target_os']
13
- when /windows|bccwin|cygwin|djgpp|mingw|mswin|wince/i
27
+ # guard notifications.
28
+ install_if(-> { Gem.win_platform? }) do
14
29
  gem 'ruby_gntp'
15
30
  gem 'wdm'
16
- when /linux/i
31
+ end
32
+
33
+ install_if(-> { RbConfig::CONFIG['target_os'] =~ /linux/i }) do
17
34
  gem 'rb-inotify'
18
- when /mac|darwin/i
19
- gem 'rb-fsevent'
20
- gem 'growl'
21
35
  end
22
- end
23
36
 
24
- group :development, :ci do
25
- gem 'rspec', '~> 3.0'
26
- gem 'rspec-its'
27
- gem 'rspec-collection_matchers'
28
- gem 'coveralls'
29
- gem 'codeclimate-test-reporter'
30
- gem 'rubocop', '~> 0.37.2'
31
- gem 'rubocop-rspec'
32
- gem 'simplecov-teamcity-summary'
37
+ install_if(-> { RbConfig::CONFIG['target_os'] =~ /mac|darwin/i }) do
38
+ gem 'rb-fsevent'
39
+ gem 'terminal-notifier-guard'
40
+ end
33
41
  end
data/README.md CHANGED
@@ -4,7 +4,7 @@
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 through 2.2.1 and ruby-head
7
+ * Tested against Ruby 2.0.0, 2.1.0, 2.2.0, 2.3.0, 2.4.0 and ruby-head
8
8
  * Ruby < 2.0 is not supported
9
9
 
10
10
  ## Installation
@@ -22,6 +22,7 @@ module Rake
22
22
  end
23
23
 
24
24
  private
25
+
25
26
  def inspect_description
26
27
  [description] if description
27
28
  end
@@ -21,6 +21,7 @@ module Rake
21
21
  end
22
22
 
23
23
  private
24
+
24
25
  def inspect_description
25
26
  [description] if description
26
27
  end
@@ -7,8 +7,8 @@ module Rake
7
7
  module CommonPath
8
8
  def common_path
9
9
  list = to_a
10
- .compact
11
- .map { |x| components(x) }
10
+ .compact
11
+ .map { |x| components(x) }
12
12
 
13
13
  min = list.min_by(&:length)
14
14
 
@@ -17,17 +17,18 @@ module Rake
17
17
  end
18
18
 
19
19
  private
20
+
20
21
  def components(path)
21
22
  paths = []
22
23
  Pathname.new(path).descend do |p|
23
24
  paths << p
24
25
  end
25
26
 
26
- paths = paths.inject([]) { |components, p|
27
+ paths = paths.inject([]) do |components, p|
27
28
  relative = p.relative_path_from(components.last[:absolute]) if components.any?
28
29
 
29
30
  components << { absolute: p, relative: relative || p }
30
- }
31
+ end
31
32
 
32
33
  paths.map { |component| component[:relative].to_s }
33
34
  end
@@ -12,13 +12,14 @@ module Rake
12
12
 
13
13
  run(cmd, log_file, error_lines) do |success, readable_cmd, result, log|
14
14
  if block
15
- block.call(success, readable_cmd, result, log)
15
+ yield(success, readable_cmd, result, log)
16
16
  return
17
17
  end
18
18
  end
19
19
  end
20
20
 
21
21
  private
22
+
22
23
  def run(cmd, log_file, error_lines)
23
24
  cmd, readable_cmd = normalize(cmd)
24
25
 
@@ -32,7 +33,7 @@ module Rake
32
33
 
33
34
  yield(success, *result) if block_given?
34
35
 
35
- fail Rake::Funnel::ExecutionError.new(*result) unless success
36
+ raise Rake::Funnel::ExecutionError.new(*result) unless success
36
37
  end
37
38
  end
38
39
 
@@ -29,11 +29,12 @@ module Rake
29
29
  end
30
30
 
31
31
  private
32
+
32
33
  def patch
33
34
  @patch ||= create_patch
34
35
  end
35
36
 
36
- def create_patch
37
+ def create_patch # rubocop:disable Metrics/MethodLength, Metrics/AbcSize
37
38
  Rake::Funnel::Support::Patch.new(self) do |p|
38
39
  p.setup do |context|
39
40
  Rake::Task.class_eval do
@@ -49,7 +50,7 @@ module Rake
49
50
  error = e
50
51
  ensure
51
52
  context.finished.call(self, args, error) if context.finished
52
- fail error if error
53
+ raise error if error
53
54
  end
54
55
  end
55
56
 
@@ -8,6 +8,7 @@ module Rake
8
8
  end
9
9
 
10
10
  private
11
+
11
12
  def sync(stream)
12
13
  stream.sync = true
13
14
  rescue => e
@@ -3,7 +3,7 @@ module Rake
3
3
  module Integration
4
4
  module TeamCity
5
5
  class NUnitPlugin
6
- ENV_VAR = 'teamcity.dotnet.nunitaddin'
6
+ ENV_VAR = 'teamcity.dotnet.nunitaddin'.freeze
7
7
 
8
8
  class << self
9
9
  def setup(nunit_executable)
@@ -16,6 +16,7 @@ module Rake
16
16
  end
17
17
 
18
18
  private
19
+
19
20
  def get_addin_dir(source)
20
21
  return nil unless source
21
22
 
@@ -7,7 +7,7 @@ module Rake
7
7
  class ProgressReport < Rake::Funnel::Integration::ProgressReport
8
8
  include Rake::Funnel::Integration
9
9
 
10
- def initialize
10
+ def initialize # rubocop:disable Metrics/MethodLength, Metrics/AbcSize, Metrics/CyclomaticComplexity
11
11
  super do
12
12
  task_starting do |task, _args|
13
13
  next unless TeamCity.running?
@@ -4,14 +4,19 @@ module Rake
4
4
  module TeamCity
5
5
  class ServiceMessages
6
6
  class << self
7
- def method_missing(method, *args, &_block)
7
+ def respond_to_missing?(_method, _include_private = false)
8
+ true
9
+ end
10
+
11
+ def method_missing(method, *args, &_block) # rubocop:disable Style/MethodMissing
8
12
  return unless Rake::Funnel::Integration::TeamCity.running?
9
13
 
10
14
  message_name = method.camelize
11
- publish message_name, args[0]
15
+ publish(message_name, args[0])
12
16
  end
13
17
 
14
18
  private
19
+
15
20
  def publish(message_name, args)
16
21
  args = [message_name] << escaped_array_of(args)
17
22
  args = args.flatten.reject(&:nil?)
@@ -19,7 +24,7 @@ module Rake
19
24
  puts "##teamcity[#{args.join(' ')}]"
20
25
  end
21
26
 
22
- def escape(string)
27
+ def escape(string) # rubocop:disable Metrics/MethodLength
23
28
  string
24
29
  .to_s
25
30
  .gsub(/\|/, '||')
@@ -2,8 +2,8 @@ module Rake
2
2
  module Funnel
3
3
  module Integration
4
4
  module TeamCity
5
- PROJECT_ENV_VAR = 'TEAMCITY_PROJECT_NAME'
6
- JRE_ENV_VAR = 'TEAMCITY_JRE'
5
+ PROJECT_ENV_VAR = 'TEAMCITY_PROJECT_NAME'.freeze
6
+ JRE_ENV_VAR = 'TEAMCITY_JRE'.freeze
7
7
 
8
8
  class << self
9
9
  def running?
@@ -14,7 +14,7 @@ module Rake
14
14
  running? && Object.const_defined?('Rake') && Rake.const_defined?('TeamCityApplication')
15
15
  end
16
16
 
17
- def with_java_runtime(&block)
17
+ def with_java_runtime
18
18
  return unless block_given?
19
19
 
20
20
  begin
@@ -22,13 +22,14 @@ module Rake
22
22
 
23
23
  ENV['PATH'] = ([] << ENV['PATH'] << teamcity_jre).compact.join(File::PATH_SEPARATOR)
24
24
 
25
- block.call
25
+ yield
26
26
  ensure
27
27
  ENV['PATH'] = original_path
28
28
  end
29
29
  end
30
30
 
31
31
  private
32
+
32
33
  def teamcity_jre
33
34
  return nil unless ENV.include?(JRE_ENV_VAR)
34
35
  File.join(ENV[JRE_ENV_VAR], 'bin')
@@ -12,14 +12,15 @@ module Rake
12
12
  end
13
13
 
14
14
  def generate_from(model)
15
- model.map { |switch|
16
- switch.values.flatten.map { |value|
15
+ model.map do |switch|
16
+ switch.values.flatten.map do |value|
17
17
  [top_level(switch), nested(value)].reject(&:empty?)
18
- }
19
- }.flatten(2)
18
+ end
19
+ end.flatten(2)
20
20
  end
21
21
 
22
22
  private
23
+
23
24
  def top_level(switch)
24
25
  [prefix, switch.switch]
25
26
  end
@@ -13,19 +13,20 @@ module Rake
13
13
  end
14
14
 
15
15
  def generate_from(model)
16
- model.map { |switch|
17
- switch.values.flatten.map { |value|
16
+ model.flat_map do |switch|
17
+ switch.values.flatten.map do |value|
18
18
  top_level(switch) + nested(value)
19
- }
20
- }.flatten(1)
19
+ end
20
+ end
21
21
  end
22
22
 
23
23
  private
24
+
24
25
  def top_level(switch)
25
26
  [prefix, switch.switch]
26
27
  end
27
28
 
28
- def nested(value)
29
+ def nested(value) # rubocop:disable Metrics/AbcSize
29
30
  res = []
30
31
  res << separator unless value.key.nil? && value.value.nil?
31
32
  res << value.key
@@ -14,27 +14,28 @@ module Rake
14
14
  end
15
15
 
16
16
  def generate_from(model)
17
- model.map { |switch|
18
- switch.values.map { |item|
19
- if item.is_a?(Enumerable)
20
- values = item.map.with_index { |nested, index| nested(nested, index) }
21
- else
22
- values = nested(item)
23
- end
17
+ model.flat_map do |switch|
18
+ switch.values.map do |item|
19
+ values = if item.is_a?(Enumerable)
20
+ item.map.with_index { |nested, index| nested(nested, index) }
21
+ else
22
+ nested(item)
23
+ end
24
24
 
25
25
  (top_level(switch) + values).flatten
26
- }
27
- }.flatten(1)
26
+ end
27
+ end
28
28
  end
29
29
 
30
30
  private
31
+
31
32
  def top_level(switch)
32
33
  [prefix, quote(switch.switch)]
33
34
  end
34
35
 
35
- def nested(value, index = 0)
36
+ def nested(value, index = 0) # rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity
36
37
  res = []
37
- res << value_list_separator unless index == 0
38
+ res << value_list_separator unless index.zero?
38
39
  res << separator unless value.key.nil? && value.value.nil? || index != 0
39
40
  res << quote(value.key)
40
41
  res << value_separator unless value.key.nil? || value.value.nil?
@@ -44,7 +45,7 @@ module Rake
44
45
 
45
46
  def quote(value)
46
47
  value = value.gsub(/"/, '""') if value.is_a?(String)
47
- return %{"#{value}"} if value =~ /\s/
48
+ return %("#{value}") if value =~ /\s/
48
49
  value
49
50
  end
50
51
  end
@@ -13,19 +13,20 @@ module Rake
13
13
  end
14
14
 
15
15
  def generate_from(model)
16
- model.map { |switch|
17
- switch.values.flatten.map { |value|
16
+ model.flat_map do |switch|
17
+ switch.values.flatten.map do |value|
18
18
  top_level(switch) + nested(value)
19
- }
20
- }.flatten(1)
19
+ end
20
+ end
21
21
  end
22
22
 
23
23
  private
24
+
24
25
  def top_level(switch)
25
26
  [prefix, switch.switch]
26
27
  end
27
28
 
28
- def nested(value)
29
+ def nested(value) # rubocop:disable Metrics/AbcSize
29
30
  res = []
30
31
  res << separator unless value.key.nil? && value.value.nil?
31
32
  res << value.key
@@ -14,7 +14,7 @@ module Rake
14
14
  end
15
15
 
16
16
  def each
17
- block_given? or return enum_for(__method__)
17
+ block_given? || (return enum_for(__method__))
18
18
 
19
19
  files.each do |file|
20
20
  Rake.rake_output_message("Reading #{file}")
@@ -29,6 +29,7 @@ module Rake
29
29
  end
30
30
 
31
31
  private
32
+
32
33
  def files
33
34
  Finder.new(search_pattern, self, 'No version files found.').all_or_default
34
35
  end
@@ -32,6 +32,7 @@ module Rake
32
32
  end
33
33
 
34
34
  private
35
+
35
36
  def evaluate_erb(language, version_info, target)
36
37
  template = template_for(language)
37
38
 
@@ -3,32 +3,39 @@ module Rake
3
3
  module Support
4
4
  class BinaryVersionReader
5
5
  class << self
6
- KNOWN_ATTRIBUTES = [:company_name, :file_description, :file_version, :legal_copyright, :product_name, :product_version, :assembly_version]
7
- SEPARATOR = "\0"
6
+ KNOWN_ATTRIBUTES = %i(company_name
7
+ file_description
8
+ file_version
9
+ legal_copyright
10
+ product_name
11
+ product_version
12
+ assembly_version).freeze
13
+ SEPARATOR = "\0".freeze
8
14
  TERMINATOR = "\0" * 3
9
15
 
10
16
  def read_from(assembly)
11
17
  binary = File.binread(assembly)
12
18
 
13
- attributes = KNOWN_ATTRIBUTES.map { |attr|
19
+ attributes = KNOWN_ATTRIBUTES.map do |attr|
14
20
  read_attribute(binary, attr)
15
- }
21
+ end
16
22
 
17
- hash = attributes.inject({}) { |memo, attr|
23
+ hash = attributes.inject({}) do |memo, attr|
18
24
  memo.merge(attr)
19
- }
25
+ end
20
26
 
21
27
  VersionInfo.new(hash)
22
28
  end
23
29
 
24
30
  private
31
+
25
32
  def read_attribute(binary, attr)
26
33
  binary_attr = attr.pascalize.gsub(/(.)/) { |match| match + SEPARATOR }
27
34
 
28
35
  data = binary.match(/#{binary_attr}#{SEPARATOR}+(.*?)#{TERMINATOR}/)
29
36
  return {} if data.nil?
30
37
 
31
- { "#{attr}" => data[1].gsub(/#{SEPARATOR}/, '') }
38
+ { attr.to_s => data[1].gsub(/#{SEPARATOR}/, '') }
32
39
  end
33
40
  end
34
41
  end
@@ -20,6 +20,7 @@ module Rake
20
20
  end
21
21
 
22
22
  private
23
+
23
24
  def target_path(file, common_path, target)
24
25
  target_relative = Pathname.new(file).relative_path_from(Pathname.new(common_path)).to_s
25
26
  File.join(target, target_relative)
@@ -13,7 +13,19 @@ module Rake
13
13
  store.reset!
14
14
 
15
15
  store.env = config[:name]
16
+ load(config, store)
16
17
 
18
+ customizer.call(store) if customizer && customizer.respond_to?(:call)
19
+
20
+ store.lock!
21
+
22
+ Rake.rake_output_message('')
23
+ Rake.rake_output_message(store.inspect)
24
+ end
25
+
26
+ private
27
+
28
+ def load(config, store)
17
29
  operation = 'Loading'
18
30
  config.fetch(:config_files, []).each do |file|
19
31
  Rake.rake_output_message("#{operation} #{file}")
@@ -21,16 +33,9 @@ module Rake
21
33
 
22
34
  yaml = File.read(file)
23
35
  yaml = evaluate_erb(yaml, file)
24
- yaml = YAML.load(yaml) || {}
36
+ yaml = YAML.load(yaml) || {} # rubocop:disable Security/YAMLLoad
25
37
  store.configure_from_hash(yaml)
26
38
  end
27
-
28
- customizer.call(store) if customizer && customizer.respond_to?(:call)
29
-
30
- store.lock!
31
-
32
- Rake.rake_output_message('')
33
- Rake.rake_output_message(store.inspect)
34
39
  end
35
40
 
36
41
  def evaluate_erb(yaml, filename)
@@ -11,7 +11,7 @@ module Rake
11
11
  end
12
12
 
13
13
  def each
14
- block_given? or return enum_for(__method__)
14
+ block_given? || (return enum_for(__method__))
15
15
  all_or_default.each { |x| yield x }
16
16
  end
17
17
 
@@ -40,6 +40,7 @@ module Rake
40
40
  end
41
41
 
42
42
  private
43
+
43
44
  def first_sln
44
45
  return candidates.first if candidates.one?
45
46
 
@@ -11,20 +11,25 @@ module Rake
11
11
  attr_reader :module
12
12
 
13
13
  private
14
+
14
15
  def instantiate(mod)
15
16
  @module = mod
16
17
  end
17
18
  end
18
19
 
19
20
  private
20
- def create(sym, *args)
21
+
22
+ def create(sym, *args) # rubocop:disable Metrics/AbcSize
21
23
  return sym unless sym.is_a?(Symbol)
22
24
 
23
25
  found = [sym, sym.pascalize.to_sym]
24
- .select { |candidate| mod.constants.include?(candidate) }
25
- .first
26
+ .select { |candidate| mod.constants.include?(candidate) }
27
+ .first
26
28
 
27
- raise NameError, "Unknown type to instantiate: #{sym.inspect}. Available types are: #{available.inspect}" if found.nil?
29
+ if found.nil?
30
+ raise NameError,
31
+ "Unknown type to instantiate: #{sym.inspect}. Available types are: #{available.inspect}"
32
+ end
28
33
 
29
34
  type = mod.const_get(found)
30
35
  type.new(*args)
@@ -16,8 +16,8 @@ module Rake
16
16
  @style = create(style)
17
17
  end
18
18
 
19
- def map(args = {})
20
- model = (args || {}).map { |switch, value|
19
+ def map(args = {}) # rubocop:disable Metrics/MethodLength
20
+ model = (args || {}).map do |switch, value|
21
21
  value = [value] unless value.is_a?(Array)
22
22
 
23
23
  values = value.map do |val|
@@ -25,20 +25,21 @@ module Rake
25
25
  end
26
26
 
27
27
  Switch.new(switch, values)
28
- }.flatten
28
+ end.flatten
29
29
 
30
30
  @style
31
31
  .generate_from(model)
32
- .map { |args| args.map { |arg| camel_case_symbols(arg) } }
32
+ .map { |arguments| arguments.map { |arg| camel_case_symbols(arg) } }
33
33
  .map(&:join)
34
34
  end
35
35
 
36
36
  private
37
+
37
38
  def get_values(value)
38
39
  if value.is_a?(Enumerable)
39
- pairs = value.map { |k, v|
40
+ pairs = value.map do |k, v|
40
41
  KeyValuePair.new(k, v)
41
- }
42
+ end
42
43
 
43
44
  return Array.new(pairs) if value.is_a?(Array)
44
45
  pairs
@@ -6,9 +6,7 @@ module Rake
6
6
  def invocation(executable, *args)
7
7
  exe_args = ([executable] << args).flatten.compact
8
8
 
9
- if Rake::Win32.windows?
10
- return exe_args
11
- end
9
+ return exe_args if Rake::Win32.windows?
12
10
 
13
11
  executable = exe_args.shift
14
12
  found = Which.which(executable) || executable