jake 0.9.1 → 0.9.2

Sign up to get free protection for your applications and to get access to all the features.
data/lib/jake.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  module Jake
2
- VERSION = '0.9.1'
2
+ VERSION = '0.9.2'
3
3
 
4
4
  CONFIG_FILE = 'jake.yml'
5
5
  HELPER_FILE = 'Jakefile'
@@ -26,14 +26,15 @@ module Jake
26
26
 
27
27
  class Helper
28
28
  attr_accessor :build
29
- def get_binding; binding; end
29
+ def scope; binding; end
30
30
  end
31
31
  end
32
32
 
33
- require File.dirname(__FILE__) + '/jake/build'
34
- require File.dirname(__FILE__) + '/jake/buildable'
35
- require File.dirname(__FILE__) + '/jake/package'
36
- require File.dirname(__FILE__) + '/jake/bundle'
33
+ require 'erb'
34
+
35
+ %w(build buildable package bundle).each do |file|
36
+ require File.dirname(__FILE__) + '/jake/' + file
37
+ end
37
38
 
38
39
  def jake(name, &block)
39
40
  Jake::Helper.class_eval do
data/lib/jake/build.rb CHANGED
@@ -14,7 +14,9 @@ module Jake
14
14
  @helper = Helper.new
15
15
 
16
16
  path = "#{dir}/#{CONFIG_FILE}"
17
- @config = Jake.symbolize_hash( config || YAML.load(File.read(path)) )
17
+ yaml = File.read(path)
18
+
19
+ @config = Jake.symbolize_hash( config || YAML.load(ERB.new(yaml).result(@helper.scope)) )
18
20
 
19
21
  helpers = "#{dir}/#{HELPER_FILE}"
20
22
  load helpers if File.file?(helpers)
@@ -45,13 +47,13 @@ module Jake
45
47
  end
46
48
 
47
49
  def package(name)
48
- @packages[name.to_sym]
50
+ @packages[name.to_sym] || @bundles[name.to_sym]
49
51
  end
50
52
 
51
53
  def run!
52
54
  @packages.each { |name, pkg| pkg.write! }
53
55
  @bundles.each { |name, pkg| pkg.write! }
54
- @helper.after_build(self) if @helper.respond_to? :after_build
56
+ @helper.after_build(self) if @helper.respond_to?(:after_build)
55
57
  end
56
58
 
57
59
  def build_directory
@@ -69,7 +71,15 @@ module Jake
69
71
  end
70
72
 
71
73
  def packer_settings(build_name)
72
- @builds[build_name] || false
74
+ build = @builds[build_name.to_sym]
75
+ return false unless build
76
+ build[:packer].nil? ? build : build[:packer]
77
+ end
78
+
79
+ def use_suffix?(build_name)
80
+ build = @builds[build_name.to_sym]
81
+ return true unless build
82
+ build[:suffix] != false
73
83
  end
74
84
 
75
85
  def layout
@@ -21,8 +21,9 @@ module Jake
21
21
  end
22
22
 
23
23
  def build_path(build_name)
24
+ suffix = @build.use_suffix?(build_name) ? "-#{ build_name }" : ""
24
25
  @build.layout == 'together' ?
25
- "#{ @build.build_directory }/#{ @name }-#{ build_name }.js" :
26
+ "#{ @build.build_directory }/#{ @name }#{ suffix }.js" :
26
27
  "#{ @build.build_directory }/#{ build_name }/#{ @name }.js"
27
28
  end
28
29
 
@@ -38,7 +39,7 @@ module Jake
38
39
  content = @config[:header] ?
39
40
  Jake.read("#{ directory }/#{ @config[:header] }") :
40
41
  @build.header
41
- ERB.new(content).result(@build.helper.get_binding)
42
+ ERB.new(content).result(@build.helper.scope).strip
42
43
  end
43
44
 
44
45
  def packer_settings(build_name)
data/lib/jake/package.rb CHANGED
@@ -1,5 +1,3 @@
1
- require 'erb'
2
-
3
1
  module Jake
4
2
  class Package < Buildable
5
3
 
@@ -17,7 +15,7 @@ module Jake
17
15
  def code(name)
18
16
  return @code[name] if @code[name]
19
17
  settings = packer_settings(name)
20
- output = ERB.new(source).result(@build.helper.get_binding)
18
+ output = ERB.new(source).result(@build.helper.scope)
21
19
  @code[name] = settings ? Packr.pack(output, settings) : output
22
20
  end
23
21
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jake
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.1
4
+ version: 0.9.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - James Coglan
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2008-09-11 00:00:00 +01:00
12
+ date: 2008-11-14 00:00:00 +00:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency