Class: FeatureMap::Private::AssignmentMappers::FeatureDefinitionAssignment

Inherits:
Object
  • Object
show all
Includes:
Mapper
Defined in:
lib/feature_map/private/assignment_mappers/feature_definition_assignment.rb

Constant Summary collapse

@@map_files_to_features =

rubocop:disable Style/ClassVars

{}

Instance Method Summary collapse

Methods included from Mapper

all, included, to_glob_cache

Instance Method Details

#bust_caches!Object



48
49
50
# File 'lib/feature_map/private/assignment_mappers/feature_definition_assignment.rb', line 48

def bust_caches!
  @@map_files_to_features = {} # rubocop:disable Style/ClassVars
end

#descriptionObject



56
57
58
# File 'lib/feature_map/private/assignment_mappers/feature_definition_assignment.rb', line 56

def description
  'Feature definition file assignment'
end

#globs_to_feature(files) ⇒ Object



33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/feature_map/private/assignment_mappers/feature_definition_assignment.rb', line 33

def globs_to_feature(files)
  return {} if Private.configuration.ignore_feature_definitions

  CodeFeatures.all.each_with_object({}) do |feature, map|
    # NOTE:  The FeatureDefinitionAssignment naively assumes that all
    #        features will have a definition yaml file.  This comes from
    #        the CodeOwnership implementation which does require these
    #        files to exist.  This is not true in repositories using the
    #        feature_definitions.csv style of feature definition.
    next if feature.config_yml.nil?

    map[feature.config_yml] = feature
  end
end

#map_file_to_feature(file) ⇒ Object



27
28
29
30
31
# File 'lib/feature_map/private/assignment_mappers/feature_definition_assignment.rb', line 27

def map_file_to_feature(file)
  return nil if Private.configuration.ignore_feature_definitions

  map_files_to_features([file])[file]
end

#map_files_to_features(files) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/feature_map/private/assignment_mappers/feature_definition_assignment.rb', line 12

def map_files_to_features(files)
  return @@map_files_to_features if @@map_files_to_features&.keys && @@map_files_to_features.keys.count.positive?

  @@map_files_to_features = CodeFeatures.all.each_with_object({}) do |feature, map| # rubocop:disable Style/ClassVars
    # NOTE:  The FeatureDefinitionAssignment naively assumes that all
    #        features will have a definition yaml file.  This comes from
    #        the CodeOwnership implementation which does require these
    #        files to exist.  This is not true in repositories using the
    #        feature_definitions.csv style of feature definition.
    next if feature.config_yml.nil?

    map[feature.config_yml] = feature
  end
end

#update_cache(cache, files) ⇒ Object



52
53
54
# File 'lib/feature_map/private/assignment_mappers/feature_definition_assignment.rb', line 52

def update_cache(cache, files)
  globs_to_feature(files)
end