Skip to content

Commit

Permalink
Merge pull request #23160 from kbrock/feature_supports_matrix
Browse files Browse the repository at this point in the history
fix tools/feature_supports_matrix
  • Loading branch information
Fryguy authored Aug 19, 2024
2 parents 4304ce4 + 015a7fd commit 0e0a51c
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions tools/feature_support_matrix.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#!/usr/bin/env ruby
require File.expand_path('../config/environment', __dir__)
require 'csv'
require 'set'

def usage
<<-USAGE
Expand All @@ -22,13 +23,16 @@ def accept(visitor)
end
end

$all_features = Set.new

def matrix_for(model)
matrix = FeatureMatrix.new
matrix.model = model

if model.included_modules.include?(SupportsFeatureMixin)
matrix.features = SupportsFeatureMixin::QUERYABLE_FEATURES.keys.each_with_object({}) do |feature, features|
matrix.features = model.supports_features.keys.each_with_object({}) do |feature, features|
features[feature] = model.supports?(feature)
$all_features << feature
end
end

Expand Down Expand Up @@ -56,7 +60,7 @@ def visit(subject)
def to_s
headers = @rows.first.headers
CSV.generate('', :headers => headers) do |csv|
header_row = CSV::Row.new(headers, %w[Model] + SupportsFeatureMixin::QUERYABLE_FEATURES.values)
header_row = CSV::Row.new(headers, %w[Model] + $all_features.to_a)
csv << header_row
@rows.each { |row| csv << row }
end
Expand Down

0 comments on commit 0e0a51c

Please sign in to comment.