Class: FeatureMap::Private::AssignmentMappers::DirectoryAssignment

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

Constant Summary collapse

FEATURE_DIRECTORY_ASSIGNMENT_FILE_NAME =
'.feature'
@@directory_cache =

rubocop:disable Style/ClassVars

{}

Instance Method Summary collapse

Methods included from Mapper

all, included, to_glob_cache

Instance Method Details

#bust_caches!Object



44
45
46
# File 'lib/feature_map/private/assignment_mappers/directory_assignment.rb', line 44

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

#descriptionObject



40
41
42
# File 'lib/feature_map/private/assignment_mappers/directory_assignment.rb', line 40

def description
  'Feature Assigned in .feature'
end

#globs_to_feature(files) ⇒ Object

Directory assignment ignores the passed in files when generating feature assignment lines. This is because directory assignment knows that the fastest way to find features for directory based assignment is to simply iterate over the directories and grab the feature, rather than iterating over each file just to get what directory it is in In theory this means that we may generate feature lines that cover files that are not in the passed in argument, but in practice this is not of consequence because in reality we never really want to generate feature assignments for only a subset of files, but rather we want feature assignments for all files.



29
30
31
32
33
34
35
36
37
38
# File 'lib/feature_map/private/assignment_mappers/directory_assignment.rb', line 29

def globs_to_feature(files)
  Pathname
    .glob(File.join('**/', FEATURE_DIRECTORY_ASSIGNMENT_FILE_NAME))
    .map(&:cleanpath)
    .each_with_object({}) do |pathname, res|
    feature = feature_for_directory_assignment_file(pathname)
    glob = glob_for_directory_assignment_file(pathname)
    res[glob] = feature
  end
end

#map_file_to_feature(file) ⇒ Object



13
14
15
# File 'lib/feature_map/private/assignment_mappers/directory_assignment.rb', line 13

def map_file_to_feature(file)
  map_file_to_relevant_feature(file)
end

#update_cache(cache, files) ⇒ Object



17
18
19
# File 'lib/feature_map/private/assignment_mappers/directory_assignment.rb', line 17

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