Class: QuietQuality::ChangedFiles

Inherits:
Object
  • Object
show all
Defined in:
lib/quiet_quality/changed_files.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(files) ⇒ ChangedFiles

Returns a new instance of ChangedFiles.



5
6
7
# File 'lib/quiet_quality/changed_files.rb', line 5

def initialize(files)
  @files = files
end

Instance Attribute Details

#filesObject (readonly)

Returns the value of attribute files.



3
4
5
# File 'lib/quiet_quality/changed_files.rb', line 3

def files
  @files
end

Instance Method Details

#file(path) ⇒ Object



13
14
15
# File 'lib/quiet_quality/changed_files.rb', line 13

def file(path)
  files_by_path.fetch(path, nil)
end

#include?(path) ⇒ Boolean

Returns:

  • (Boolean)


17
18
19
# File 'lib/quiet_quality/changed_files.rb', line 17

def include?(path)
  files_by_path.include?(path)
end

#merge(other) ⇒ Object



21
22
23
24
25
26
27
# File 'lib/quiet_quality/changed_files.rb', line 21

def merge(other)
  merged_files = []
  (files + other.files)
    .group_by(&:path)
    .each_pair { |_path, pfiles| merged_files << pfiles.reduce(&:merge) }
  self.class.new(merged_files)
end

#pathsObject



9
10
11
# File 'lib/quiet_quality/changed_files.rb', line 9

def paths
  @_paths ||= files.map(&:path)
end