Module: Fiat
- Defined in:
- lib/fiat.rb,
lib/fiat/version.rb
Constant Summary collapse
- VERSION =
"0.0.3"
Class Method Summary collapse
- .anything_changed?(filenames, ctimes) ⇒ Boolean
- .crashed?(process) ⇒ Boolean
- .dep_tree ⇒ Object
- .deps(key, tree) ⇒ Object
- .file_ctimes(filenames) ⇒ Object
- .passed_tests?(result_string, failure_terms) ⇒ Boolean
- .run_tests(dependencies, ctimes, instruction, failure_terms) ⇒ Object
Class Method Details
.anything_changed?(filenames, ctimes) ⇒ Boolean
37 38 39 |
# File 'lib/fiat.rb', line 37 def self.anything_changed?(filenames, ctimes) ctimes != file_ctimes(filenames) end |
.crashed?(process) ⇒ Boolean
45 46 47 |
# File 'lib/fiat.rb', line 45 def self.crashed?(process) process.exitstatus != 0 end |
.dep_tree ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 |
# File 'lib/fiat.rb', line 5 def self.dep_tree tree = {} task_headers = IO.readlines("Makefile").select{ |l| l.include? ":" } task_headers.each do |line| k = line.split(":").first reqs = line.split(":")[1..-1].join(":") tree[k] = reqs.strip.split end tree end |
.deps(key, tree) ⇒ Object
18 19 20 21 22 23 24 |
# File 'lib/fiat.rb', line 18 def self.deps(key, tree) if tree.include? key tree[key].map{ |d| deps(d, tree) }.flatten.uniq else key end end |
.file_ctimes(filenames) ⇒ Object
26 27 28 29 30 31 32 33 34 35 |
# File 'lib/fiat.rb', line 26 def self.file_ctimes(filenames) hash = {} real_files = filenames.select{ |f| File.exists? f } real_files.each do |f| hash[f] = File.ctime(f) end hash end |
.passed_tests?(result_string, failure_terms) ⇒ Boolean
41 42 43 |
# File 'lib/fiat.rb', line 41 def self.passed_tests?(result_string, failure_terms) failure_terms.select{ |term| result_string.include? term }.empty? end |
.run_tests(dependencies, ctimes, instruction, failure_terms) ⇒ Object
49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/fiat.rb', line 49 def self.run_tests(dependencies, ctimes, instruction, failure_terms) results = `make #{instruction}` puts results + "\n" = "#" * 40 if crashed?($?) or not passed_tests?(results, failure_terms) puts .red else puts .green end end |