Permalink
Browse files

Implementing output logging in the executable using published event h…

…ooks.
  • Loading branch information...
1 parent ef1c8da commit c3948d4f9026f138ff14006852f208403d8e9a60 @jcoglan committed Jun 18, 2009
Showing with 17 additions and 3 deletions.
  1. +15 −1 bin/jake
  2. +2 −2 lib/jake/buildable.rb
View
@@ -27,5 +27,19 @@ begin; opts = spec.parse
rescue Oyster::HelpRendered; exit
end
-Jake.build!(File.expand_path(opts[:unclaimed].first || '.'), opts)
+LOG_FORMAT = "%-020s %-06s %-032s %07s"
+
+dir = File.expand_path(opts[:unclaimed].first || '.')
+build = Jake::Build.new(dir, opts)
+
+build.on(:file_created) do |build, pkg, build_type, path|
+ size = (File.size(path) / 1024.0).ceil
+ puts LOG_FORMAT % [pkg.name, build_type, path.gsub(dir, ''), "#{ size } kb"]
+end
+
+build.on(:file_not_changed) do |build, pkg, build_type, path|
+ puts LOG_FORMAT % [pkg.name, build_type, path.gsub(dir, ''), 'UP-TO-DATE']
+end
+
+build.run!
View
@@ -80,10 +80,10 @@ def meta
# been forced.
def write!
@build.each do |name, settings|
- next unless build_needed?(name)
+ path = build_path(name)
+ @build.fire(:file_not_changed, self, name, path) and next unless build_needed?(name)
@build.helper.build = name.to_s
- path = build_path(name)
FileUtils.mkdir_p(File.dirname(path))
File.open(path, 'wb') { |f| f.write( (header + "\n\n" + code(name)).strip ) }

0 comments on commit c3948d4

Please sign in to comment.