feature_map 1.2.9 → 1.3.0

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.
@@ -24,8 +24,8 @@ module FeatureMap
24
24
  metrics = file_paths.map { |file| calculate_for_file(file) }
25
25
 
26
26
  # Handle numeric metrics
27
- aggregate_metrics = [ABC_SIZE_METRIC, CYCLOMATIC_COMPLEXITY_METRIC, LINES_OF_CODE_METRIC].each_with_object({}) do |metric_key, agg|
28
- agg[metric_key] = metrics.sum { |m| m[metric_key] || 0 }
27
+ aggregate_metrics = [ABC_SIZE_METRIC, CYCLOMATIC_COMPLEXITY_METRIC, LINES_OF_CODE_METRIC].to_h do |metric_key|
28
+ [metric_key, metrics.sum { |m| m[metric_key] || 0 }]
29
29
  end
30
30
 
31
31
  # Handle additional supported metrics
@@ -5,8 +5,8 @@ module FeatureMap
5
5
  class << self
6
6
  def map_tests_by_assignment(test_suites, assignments)
7
7
  # Transform test suites into a hash of filepath => assertion results
8
- tests_by_path = test_suites.each_with_object({}) do |suite, result|
9
- result[filepath(suite['name'])] = suite['assertionResults']
8
+ tests_by_path = test_suites.to_h do |suite|
9
+ [filepath(suite['name']), suite['assertionResults']]
10
10
  end
11
11
 
12
12
  assignments.each_with_object({}) do |(feature_name, files), result|
@@ -38,15 +38,15 @@ module FeatureMap
38
38
  end
39
39
 
40
40
  def self.generate_content(unit_by_feature, integration_by_feature, regression_by_feature)
41
- CodeFeatures.all.map(&:name).each_with_object({}) do |feature_name, content|
42
- content[feature_name] = {
41
+ CodeFeatures.all.map(&:name).to_h do |feature_name|
42
+ [feature_name, {
43
43
  'unit_count' => unit_by_feature.dig(feature_name, :count) || 0,
44
44
  'unit_pending' => unit_by_feature.dig(feature_name, :pending) || 0,
45
45
  'integration_count' => integration_by_feature.dig(feature_name, :count) || 0,
46
46
  'integration_pending' => integration_by_feature.dig(feature_name, :pending) || 0,
47
47
  'regression_count' => regression_by_feature.dig(feature_name, :count) || 0,
48
48
  'regression_pending' => regression_by_feature.dig(feature_name, :pending) || 0
49
- }
49
+ }]
50
50
  end
51
51
  end
52
52
 
data/lib/feature_map.rb CHANGED
@@ -137,12 +137,15 @@ module FeatureMap
137
137
  #
138
138
  # ./app/controllers/some_controller.rb:43:in `block (3 levels) in create'
139
139
  #
140
+ # Ruby 3.4 changed the opening quote around the function name from a
141
+ # backtick to a single quote (`block ...'` -> `'block ...'`), so both
142
+ # delimiters are matched to remain compatible across Ruby versions.
140
143
  backtrace_line = %r{\A(#{Pathname.pwd}/|\./)?
141
- (?<file>.+) # Matches 'app/controllers/some_controller.rb'
144
+ (?<file>.+) # Matches 'app/controllers/some_controller.rb'
142
145
  :
143
- (?<line>\d+) # Matches '43'
146
+ (?<line>\d+) # Matches '43'
144
147
  :in\s
145
- `(?<function>.*)' # Matches "`block (3 levels) in create'"
148
+ [`'](?<function>.*)' # Matches "`block (3 levels) in create'" or "'block (3 levels) in create'"
146
149
  \z}x
147
150
 
148
151
  backtrace.lazy.filter_map do |line|
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: feature_map
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.9
4
+ version: 1.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Beyond Finance