fiat 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/.gitignore ADDED
@@ -0,0 +1,4 @@
1
+ *.gem
2
+ .bundle
3
+ Gemfile.lock
4
+ pkg/*
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "http://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in fiat.gemspec
4
+ gemspec
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
data/bin/fiat ADDED
@@ -0,0 +1,42 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ $LOAD_PATH.unshift File.dirname(__FILE__) + '/../lib'
4
+ require 'fiat'
5
+
6
+ instruction = "test"
7
+ failing_words = ["Failed"]
8
+ poll_interval = 0.5 # seconds
9
+
10
+ if File.exists? ".fiatrc"
11
+ eval File.open(".fiatrc").read
12
+ end
13
+
14
+ instruction = ARGV.length == 1 ? ARGV[0] : instruction
15
+
16
+ unless File.exists? "Makefile"
17
+ $stderr.puts "Can't run without a Makefile!"
18
+ exit false
19
+ end
20
+
21
+ unless Fiat::dep_tree.include? instruction
22
+ $stderr.puts "Can't find \"make #{instruction}\" in Makefile! Aborting."
23
+ exit false
24
+ end
25
+
26
+ puts "Running \"make #{instruction}\" on changes..."
27
+
28
+ dependencies = Fiat::deps(instruction, Fiat::dep_tree)
29
+ ctimes = Fiat::file_ctimes(dependencies)
30
+ Fiat::run_tests(dependencies, ctimes, instruction)
31
+
32
+ begin
33
+ while true
34
+ if Fiat::anything_changed?(dependencies, ctimes)
35
+ Fiat::run_tests(dependencies, ctimes, instruction)
36
+ ctimes = Fiat::file_ctimes(dependencies)
37
+ end
38
+ sleep poll_interval
39
+ end
40
+ rescue SystemExit, Interrupt
41
+ puts "\nShutting down..."
42
+ end
data/fiat.gemspec ADDED
@@ -0,0 +1,22 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require "fiat/version"
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = "fiat"
7
+ s.version = Fiat::VERSION
8
+ s.authors = ["Harry Schwartz"]
9
+ s.email = ["hrs@cs.wm.edu"]
10
+ s.homepage = ""
11
+ s.summary = %q{The "auto-Maker."}
12
+ s.description = %q{Autotest for Makefiles: fiat automatically and repeatedly executes a given make task every time one of the task's dependencies changes.}
13
+
14
+ s.rubyforge_project = "fiat"
15
+
16
+ s.files = `git ls-files`.split("\n")
17
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
18
+ s.executables = ["fiat"]
19
+ s.require_paths = ["lib"]
20
+
21
+ s.add_dependency "colorize"
22
+ end
data/lib/fiat.rb ADDED
@@ -0,0 +1,62 @@
1
+ require "fiat/version"
2
+ require 'colorize'
3
+
4
+ module Fiat
5
+ def self.dep_tree
6
+ tree = {}
7
+ IO.readlines("Makefile").each do |line|
8
+ if line.include? ":"
9
+ k = line.split(":").first
10
+ line = line.split(":")[1..-1].join(":")
11
+ tree[k] = line.strip.split
12
+ end
13
+ end
14
+ tree
15
+ end
16
+
17
+ def self.deps(key, tree)
18
+ if tree.include? key
19
+ tree[key].map { |d| deps(d, tree) }.flatten.uniq
20
+ else
21
+ key
22
+ end
23
+ end
24
+
25
+ def self.file_ctimes(filenames)
26
+ hash = {}
27
+ filenames.each do |f|
28
+ if File.exists? f
29
+ hash[f] = File.ctime(f)
30
+ end
31
+ end
32
+ hash
33
+ end
34
+
35
+ def self.anything_changed?(filenames, ctimes)
36
+ ctimes != file_ctimes(filenames)
37
+ end
38
+
39
+ def self.passed_tests?(result_string)
40
+ $failing_words.each do |f|
41
+ if result_string.include? f
42
+ return false
43
+ end
44
+ end
45
+ true
46
+ end
47
+
48
+ def self.crashed?(process)
49
+ process.exitstatus != 0
50
+ end
51
+
52
+ def self.run_tests(dependencies, ctimes, instruction)
53
+ results = `make #{instruction}`
54
+ puts results + "\n"
55
+
56
+ if crashed?($?) or not passed_tests?(results)
57
+ puts ("#" * 40).red
58
+ else
59
+ puts ("#" * 40).green
60
+ end
61
+ end
62
+ end
@@ -0,0 +1,3 @@
1
+ module Fiat
2
+ VERSION = "0.0.1"
3
+ end
metadata ADDED
@@ -0,0 +1,65 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: fiat
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Harry Schwartz
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2011-11-06 00:00:00.000000000Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: colorize
16
+ requirement: &70336088014720 !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: *70336088014720
25
+ description: ! 'Autotest for Makefiles: fiat automatically and repeatedly executes
26
+ a given make task every time one of the task''s dependencies changes.'
27
+ email:
28
+ - hrs@cs.wm.edu
29
+ executables:
30
+ - fiat
31
+ extensions: []
32
+ extra_rdoc_files: []
33
+ files:
34
+ - .gitignore
35
+ - Gemfile
36
+ - Rakefile
37
+ - bin/fiat
38
+ - fiat.gemspec
39
+ - lib/fiat.rb
40
+ - lib/fiat/version.rb
41
+ homepage: ''
42
+ licenses: []
43
+ post_install_message:
44
+ rdoc_options: []
45
+ require_paths:
46
+ - lib
47
+ required_ruby_version: !ruby/object:Gem::Requirement
48
+ none: false
49
+ requirements:
50
+ - - ! '>='
51
+ - !ruby/object:Gem::Version
52
+ version: '0'
53
+ required_rubygems_version: !ruby/object:Gem::Requirement
54
+ none: false
55
+ requirements:
56
+ - - ! '>='
57
+ - !ruby/object:Gem::Version
58
+ version: '0'
59
+ requirements: []
60
+ rubyforge_project: fiat
61
+ rubygems_version: 1.8.6
62
+ signing_key:
63
+ specification_version: 3
64
+ summary: The "auto-Maker."
65
+ test_files: []