Class: GitSpec::Status

Inherits:
Object
  • Object
show all
Defined in:
lib/git_spec/status.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(logger = GitSpec.logger) ⇒ Status

Returns a new instance of Status.



3
4
5
# File 'lib/git_spec/status.rb', line 3

def initialize(logger = GitSpec.logger)
  @logger = logger
end

Class Method Details

.changed_filesObject



26
27
28
# File 'lib/git_spec/status.rb', line 26

def self.changed_files
  new.changed_files
end

Instance Method Details

#changed_filesObject



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/git_spec/status.rb', line 7

def changed_files
  changed_files = (filenames).each_with_object([]) do |filename, changed|
    file = File.new(filename)

    excluded, excluded_reason = file.excluded?
    if excluded
      @logger.debug "Excluding #{file.spec_path} with reason: #{excluded_reason}"
    else
      changed << file
      @logger.debug "Including #{file.spec_path}"
    end
  end

  changed_files.uniq{|f| f.spec_path}
rescue => e
  # TODO: Log helpful info when this happens
  raise
end