Class: SmartTest::Filter
- Inherits:
-
Object
- Object
- SmartTest::Filter
- Defined in:
- lib/smart_test/filter.rb
Instance Attribute Summary collapse
-
#project ⇒ Object
readonly
Returns the value of attribute project.
Instance Method Summary collapse
- #diff(str) ⇒ Object
-
#initialize(project) ⇒ Filter
constructor
A new instance of Filter.
- #mtime(num) ⇒ Object
Constructor Details
#initialize(project) ⇒ Filter
Returns a new instance of Filter.
5 6 7 |
# File 'lib/smart_test/filter.rb', line 5 def initialize(project) @project = project end |
Instance Attribute Details
#project ⇒ Object (readonly)
Returns the value of attribute project.
3 4 5 |
# File 'lib/smart_test/filter.rb', line 3 def project @project end |
Instance Method Details
#diff(str) ⇒ Object
16 17 18 19 |
# File 'lib/smart_test/filter.rb', line 16 def diff(str) raise NotGitRepoError unless project.using_git? `git diff #{str} --name-only`.split("\n").select { |file| project.test_file? file } end |
#mtime(num) ⇒ Object
9 10 11 12 13 14 |
# File 'lib/smart_test/filter.rb', line 9 def mtime(num) project.test_files.map { |file| [file, File.mtime(file)] }. sort_by(&:last). last(num). map &:first end |