Permalink
Browse files

Adding metadata support to package configs, and using this to generat…

…e a JS.Package file from the build.
  • Loading branch information...
1 parent f52cf6d commit 5cc04538bb6a7daffd0602540de304ac44486077 @jcoglan committed Jun 9, 2009
Showing with 25 additions and 2 deletions.
  1. +4 −0 lib/jake/buildable.rb
  2. +6 −0 test/Jakefile
  3. +5 −0 test/jake.yml
  4. +8 −0 test/packages.erb
  5. +2 −2 test/test_jake.rb
@@ -57,6 +57,10 @@ def packer_settings(build_name)
{}.merge(global || {}).merge(local || {})
end
+ def meta
+ @config[:meta] || {}
+ end
+
def write!
puts "Package #{@name}..."
View
@@ -3,9 +3,13 @@ jake_helper :version do
end
FILES = []
+DEPS = {}
+
+DIR = File.dirname(__FILE__)
jake_hook :file_created do |package, build, path|
FILES << File.basename(path)
+ DEPS[path] = package.meta if build == :min
end
jake_hook :build_complete do |build|
@@ -14,5 +18,7 @@ jake_hook :build_complete do |build|
end
write['README', 'Should be generated after build']
write['LISTING', FILES.sort * "\n"]
+
+ write['packages.js', ERB.new(File.read File.join(DIR, 'packages.erb')).result(binding)]
end
View
@@ -17,6 +17,11 @@ packages:
private: false
files:
- basic-ext
+ meta:
+ provides:
+ - Basic
+ requires:
+ - Foo
sub/dir/foo:
- foo/foo
sub/path/bar:
View
@@ -0,0 +1,8 @@
+JS.Packages(function() { with(this) {
+<% DEPS.each do |path, meta| %>
+ file('<%= path %>')
+ .provides(<%= (meta[:provides] || []).map { |p| p.inspect } * ', ' %>)
+ .requires(<%= (meta[:requires] || []).map { |p| p.inspect } * ', ' %>);
+<% end %>
+}});
+
View
@@ -3,9 +3,9 @@
require "fileutils"
require "find"
-DIR = File.dirname(__FILE__)
-
class TestJake < Test::Unit::TestCase
+ DIR = File.dirname(__FILE__)
+
def setup
FileUtils.rm_rf(File.join(DIR, 'output'))
end

0 comments on commit 5cc0453

Please sign in to comment.