jake 1.0.1 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +5 -0
- data/README.rdoc +273 -0
- data/bin/jake +9 -6
- data/lib/jake.rb +10 -20
- data/lib/jake/build.rb +7 -26
- data/lib/jake/buildable.rb +17 -24
- data/lib/jake/bundle.rb +13 -11
- data/lib/jake/helper.rb +0 -2
- data/lib/jake/package.rb +51 -13
- metadata +72 -101
- data/Manifest.txt +0 -33
- data/README.txt +0 -284
- data/Rakefile +0 -13
- data/test/Jakefile +0 -22
- data/test/expected/LISTING +0 -10
- data/test/expected/README +0 -1
- data/test/expected/basic-min.js +0 -7
- data/test/expected/basic.js +0 -14
- data/test/expected/combo/box-min.js +0 -8
- data/test/expected/combo/box.js +0 -28
- data/test/expected/ext-min.js +0 -7
- data/test/expected/ext.js +0 -17
- data/test/expected/sub/dir/foo-min.js +0 -7
- data/test/expected/sub/dir/foo.js +0 -15
- data/test/expected/sub/path/bar-min.js +0 -3
- data/test/expected/sub/path/bar.js +0 -5
- data/test/jake.yml +0 -38
- data/test/packages.erb +0 -8
- data/test/src/basic-ext.js +0 -2
- data/test/src/basic.js +0 -9
- data/test/src/foo/bar.js +0 -4
- data/test/src/foo/foo.js +0 -10
- data/test/src/head.js +0 -6
- data/test/src/head2.js +0 -7
- data/test/test_jake.rb +0 -29
data/lib/jake/buildable.rb
CHANGED
@@ -1,15 +1,8 @@
|
|
1
1
|
module Jake
|
2
|
-
# A +Buildable+ represents a group of files that may be merged to form a single
|
3
|
-
# build file. There are two subtypes of +Buildable+; a +Package+ takes several
|
4
|
-
# source files and produces a build file, and a +Bundle+ takes several +Package+
|
5
|
-
# build files to produce another build file. This class should be considered
|
6
|
-
# abstract as some of its methods must be filled in by subtypes.
|
7
2
|
class Buildable
|
8
3
|
|
9
4
|
attr_reader :name
|
10
5
|
|
11
|
-
# Create a new +Buildable+ using a +Build+ container, a name and a configuration
|
12
|
-
# hash, typically a subsection of jake.yml.
|
13
6
|
def initialize(build, name, config)
|
14
7
|
@build, @name = build, name
|
15
8
|
@config = case config
|
@@ -20,21 +13,17 @@ module Jake
|
|
20
13
|
@code = {}
|
21
14
|
end
|
22
15
|
|
23
|
-
# Returns the parent +Buildable+ set using the +extends+ option, or +nil+ if
|
24
|
-
# there is no parent.
|
25
16
|
def parent
|
26
17
|
return nil unless @config[:extends]
|
27
18
|
@parent ||= @build.package(@config[:extends])
|
28
19
|
end
|
29
20
|
|
30
|
-
# Returns the source directory for this package.
|
31
21
|
def directory
|
32
22
|
dir = @config[:directory]
|
33
23
|
return parent.directory if parent && !dir
|
34
24
|
Jake.path(@build.source_directory, @config[:directory])
|
35
25
|
end
|
36
26
|
|
37
|
-
# Returns the path to the output file from this package for the given build name.
|
38
27
|
def build_path(build_name)
|
39
28
|
suffix = @build.use_suffix?(build_name) ? "-#{ build_name }" : ""
|
40
29
|
@build.layout == 'together' ?
|
@@ -42,42 +31,38 @@ module Jake
|
|
42
31
|
Jake.path(@build.build_directory, build_name, "#{ @name }.js")
|
43
32
|
end
|
44
33
|
|
45
|
-
# Returns +true+ if the build file for the given build name is out of date and
|
46
|
-
# should be regenerated.
|
47
34
|
def build_needed?(name)
|
48
35
|
return true if @build.forced?
|
49
36
|
path = build_path(name)
|
50
37
|
return true unless File.file?(path)
|
51
38
|
build_time = File.mtime(path)
|
52
|
-
|
39
|
+
|
40
|
+
input_files = files + @build.config_files
|
41
|
+
input_files.any? { |path| File.mtime(path) > build_time }
|
53
42
|
end
|
54
43
|
|
55
|
-
# Returns the header string being used for this package.
|
56
44
|
def header
|
57
45
|
content = @config[:header] ?
|
58
46
|
Jake.read(Jake.path( directory, @config[:header])) :
|
59
47
|
(parent ? parent.header : @build.header)
|
60
|
-
|
48
|
+
|
49
|
+
header = Jake.erb(content).result(@build.helper.scope)
|
50
|
+
return nil if header == ''
|
51
|
+
header
|
61
52
|
end
|
62
53
|
|
63
|
-
# Returns the PackR settings to use for this package during the given build.
|
64
54
|
def packer_settings(build_name)
|
65
55
|
global = @build.packer_settings(build_name)
|
66
56
|
local = @config[:packer]
|
67
57
|
return parent.packer_settings(build_name) if parent && !local
|
68
|
-
return false if global == false or local == false
|
58
|
+
return {:minify => false} if global == false or local == false
|
69
59
|
{}.merge(global || {}).merge(local || {})
|
70
60
|
end
|
71
61
|
|
72
|
-
# Returns a hash containing any metadata attached to the package in the config.
|
73
62
|
def meta
|
74
63
|
@config[:meta] || {}
|
75
64
|
end
|
76
65
|
|
77
|
-
# Generates all the build files for this package by looping over all the
|
78
|
-
# required builds and compressing the source code using each set of minification
|
79
|
-
# options. Files are only generated if they are out of date or the build has
|
80
|
-
# been forced.
|
81
66
|
def write!
|
82
67
|
@build.each do |name, settings|
|
83
68
|
path = build_path(name)
|
@@ -85,7 +70,15 @@ module Jake
|
|
85
70
|
|
86
71
|
@build.helper.build = name.to_s
|
87
72
|
FileUtils.mkdir_p(File.dirname(path))
|
88
|
-
|
73
|
+
|
74
|
+
output_code = code(name)
|
75
|
+
source_map = output_code.source_map if output_code.respond_to?(:source_map)
|
76
|
+
|
77
|
+
File.open(path, 'w') { |f| f.write(output_code) }
|
78
|
+
|
79
|
+
if source_map and source_map.enabled?
|
80
|
+
File.open(source_map.filename, 'w') { |f| f.write(source_map.to_s) }
|
81
|
+
end
|
89
82
|
|
90
83
|
@build.fire(:file_created, self, name, path)
|
91
84
|
|
data/lib/jake/bundle.rb
CHANGED
@@ -1,25 +1,27 @@
|
|
1
1
|
module Jake
|
2
2
|
class Bundle < Buildable
|
3
3
|
|
4
|
-
# Returns a list of paths to all the files used to build this package.
|
5
4
|
def files
|
6
5
|
base = parent ? parent.files : []
|
7
6
|
base + @config[:files].map { |pkg| @build.package(pkg).files }.flatten
|
8
7
|
end
|
9
8
|
|
10
|
-
# Returns the full uncompressed source code of this package, before
|
11
|
-
# ERB processing. ERB output will be build-dependent; this method
|
12
|
-
# simply builds the raw template for further processing by other
|
13
|
-
# methods.
|
14
9
|
def source
|
15
|
-
@source ||= @config[:files].map { |pkg| @build.package(pkg).source }.join("\n
|
10
|
+
@source ||= @config[:files].map { |pkg| @build.package(pkg).source }.join("\n")
|
16
11
|
end
|
17
12
|
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
13
|
+
def code(build_name)
|
14
|
+
return @code[build_name] if @code[build_name]
|
15
|
+
|
16
|
+
packer = packer_settings(build_name)
|
17
|
+
joiner = (packer[:minify] == false) ? "\n" : ""
|
18
|
+
|
19
|
+
code = @config[:files].map { |pkg| @build.package(pkg).code(build_name, false) }.join(joiner)
|
20
|
+
if head = header
|
21
|
+
code = head + code
|
22
|
+
end
|
23
|
+
|
24
|
+
@code[build_name] = code
|
23
25
|
end
|
24
26
|
|
25
27
|
end
|
data/lib/jake/helper.rb
CHANGED
data/lib/jake/package.rb
CHANGED
@@ -1,7 +1,6 @@
|
|
1
1
|
module Jake
|
2
2
|
class Package < Buildable
|
3
3
|
|
4
|
-
# Returns a list of paths to all the files used to build this package.
|
5
4
|
def files
|
6
5
|
base = parent ? parent.files : []
|
7
6
|
base + @config[:files].map do |path|
|
@@ -10,21 +9,60 @@ module Jake
|
|
10
9
|
end
|
11
10
|
end
|
12
11
|
|
13
|
-
# Returns the full uncompressed source code of this package, before
|
14
|
-
# ERB processing. ERB output will be build-dependent; this method
|
15
|
-
# simply builds the raw template for further processing by other
|
16
|
-
# methods.
|
17
12
|
def source
|
18
|
-
@source ||= files.map { |path| Jake.read(path) }.join("\n
|
13
|
+
@source ||= files.map { |path| Jake.read(path) }.join("\n")
|
19
14
|
end
|
20
15
|
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
16
|
+
def code(build_name, with_header = true)
|
17
|
+
if cached = @code[build_name]
|
18
|
+
return with_header ? cached : cached.code
|
19
|
+
end
|
20
|
+
|
21
|
+
packer = packer_settings(build_name)
|
22
|
+
|
23
|
+
head = header
|
24
|
+
head = head.strip unless packer[:minify] == false
|
25
|
+
|
26
|
+
packer = packer.merge(:header => head)
|
27
|
+
code = code_for_packer(packer, build_name)
|
28
|
+
|
29
|
+
cached = @code[build_name] = code
|
30
|
+
with_header ? code : code.code
|
31
|
+
end
|
32
|
+
|
33
|
+
private
|
34
|
+
|
35
|
+
def code_for_packer(packer, build_name)
|
36
|
+
if source_map = packer.delete(:source_map)
|
37
|
+
code = code_for_source_map(packer, build_path(build_name), source_map)
|
38
|
+
else
|
39
|
+
code = compile_erb(source)
|
40
|
+
end
|
41
|
+
Packr.pack(code, packer)
|
42
|
+
end
|
43
|
+
|
44
|
+
def code_for_source_map(packer, output_path, source_map)
|
45
|
+
packer.update(:output_file => output_path)
|
46
|
+
|
47
|
+
if source_map == :source
|
48
|
+
code_for_original_map(packer)
|
49
|
+
else
|
50
|
+
source_path = Packr::FileSystem.relative_path(build_path(source_map), output_path)
|
51
|
+
[{:code => code(source_map), :source => source_path}]
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
def code_for_original_map(packer)
|
56
|
+
files.map do |file|
|
57
|
+
{
|
58
|
+
:code => compile_erb(Jake.read(file)),
|
59
|
+
:source => Packr::FileSystem.relative_path(file, packer[:output_file])
|
60
|
+
}
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
def compile_erb(template)
|
65
|
+
Jake.erb(template).result(@build.helper.scope)
|
28
66
|
end
|
29
67
|
|
30
68
|
end
|
metadata
CHANGED
@@ -1,130 +1,101 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: jake
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.1.0
|
5
|
+
prerelease:
|
5
6
|
platform: ruby
|
6
|
-
authors:
|
7
|
+
authors:
|
7
8
|
- James Coglan
|
8
9
|
autorequire:
|
9
10
|
bindir: bin
|
10
11
|
cert_chain: []
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
dependencies:
|
15
|
-
- !ruby/object:Gem::Dependency
|
12
|
+
date: 2012-04-11 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
16
15
|
name: eventful
|
16
|
+
requirement: &10784480 !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: 1.0.0
|
17
22
|
type: :runtime
|
18
|
-
|
19
|
-
version_requirements:
|
20
|
-
|
21
|
-
- - ">="
|
22
|
-
- !ruby/object:Gem::Version
|
23
|
-
version: "0"
|
24
|
-
version:
|
25
|
-
- !ruby/object:Gem::Dependency
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: *10784480
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
26
|
name: packr
|
27
|
+
requirement: &10783700 !ruby/object:Gem::Requirement
|
28
|
+
none: false
|
29
|
+
requirements:
|
30
|
+
- - ! '>='
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: 3.2.0
|
27
33
|
type: :runtime
|
28
|
-
|
29
|
-
version_requirements:
|
30
|
-
|
31
|
-
- - ">="
|
32
|
-
- !ruby/object:Gem::Version
|
33
|
-
version: "0"
|
34
|
-
version:
|
35
|
-
- !ruby/object:Gem::Dependency
|
34
|
+
prerelease: false
|
35
|
+
version_requirements: *10783700
|
36
|
+
- !ruby/object:Gem::Dependency
|
36
37
|
name: oyster
|
38
|
+
requirement: &10869700 !ruby/object:Gem::Requirement
|
39
|
+
none: false
|
40
|
+
requirements:
|
41
|
+
- - ! '>='
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: 0.9.5
|
37
44
|
type: :runtime
|
38
|
-
|
39
|
-
version_requirements:
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
- !
|
46
|
-
|
45
|
+
prerelease: false
|
46
|
+
version_requirements: *10869700
|
47
|
+
- !ruby/object:Gem::Dependency
|
48
|
+
name: test-unit
|
49
|
+
requirement: &10868800 !ruby/object:Gem::Requirement
|
50
|
+
none: false
|
51
|
+
requirements:
|
52
|
+
- - ! '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
47
55
|
type: :development
|
48
|
-
|
49
|
-
version_requirements:
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
version: 2.3.3
|
54
|
-
version:
|
55
|
-
description: ""
|
56
|
-
email:
|
57
|
-
- jcoglan@googlemail.com
|
58
|
-
executables:
|
56
|
+
prerelease: false
|
57
|
+
version_requirements: *10868800
|
58
|
+
description:
|
59
|
+
email: jcoglan@gmail.com
|
60
|
+
executables:
|
59
61
|
- jake
|
60
62
|
extensions: []
|
61
|
-
|
62
|
-
|
63
|
+
extra_rdoc_files:
|
64
|
+
- README.rdoc
|
65
|
+
files:
|
63
66
|
- History.txt
|
64
|
-
-
|
65
|
-
- README.txt
|
66
|
-
files:
|
67
|
-
- History.txt
|
68
|
-
- Manifest.txt
|
69
|
-
- README.txt
|
70
|
-
- Rakefile
|
67
|
+
- README.rdoc
|
71
68
|
- bin/jake
|
72
69
|
- lib/jake.rb
|
70
|
+
- lib/jake/bundle.rb
|
73
71
|
- lib/jake/helper.rb
|
74
72
|
- lib/jake/build.rb
|
75
|
-
- lib/jake/buildable.rb
|
76
73
|
- lib/jake/package.rb
|
77
|
-
- lib/jake/
|
78
|
-
- test/test_jake.rb
|
79
|
-
- test/jake.yml
|
80
|
-
- test/Jakefile
|
81
|
-
- test/packages.erb
|
82
|
-
- test/expected/combo/box.js
|
83
|
-
- test/expected/combo/box-min.js
|
84
|
-
- test/expected/sub/dir/foo.js
|
85
|
-
- test/expected/sub/dir/foo-min.js
|
86
|
-
- test/expected/sub/path/bar.js
|
87
|
-
- test/expected/sub/path/bar-min.js
|
88
|
-
- test/expected/basic.js
|
89
|
-
- test/expected/basic-min.js
|
90
|
-
- test/expected/ext.js
|
91
|
-
- test/expected/ext-min.js
|
92
|
-
- test/expected/LISTING
|
93
|
-
- test/expected/README
|
94
|
-
- test/src/foo/bar.js
|
95
|
-
- test/src/foo/foo.js
|
96
|
-
- test/src/basic.js
|
97
|
-
- test/src/basic-ext.js
|
98
|
-
- test/src/head.js
|
99
|
-
- test/src/head2.js
|
100
|
-
has_rdoc: true
|
74
|
+
- lib/jake/buildable.rb
|
101
75
|
homepage: http://github.com/jcoglan/jake
|
102
76
|
licenses: []
|
103
|
-
|
104
77
|
post_install_message:
|
105
|
-
rdoc_options:
|
78
|
+
rdoc_options:
|
106
79
|
- --main
|
107
|
-
- README.
|
108
|
-
require_paths:
|
80
|
+
- README.rdoc
|
81
|
+
require_paths:
|
109
82
|
- lib
|
110
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
83
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
84
|
+
none: false
|
85
|
+
requirements:
|
86
|
+
- - ! '>='
|
87
|
+
- !ruby/object:Gem::Version
|
88
|
+
version: '0'
|
89
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
90
|
+
none: false
|
91
|
+
requirements:
|
92
|
+
- - ! '>='
|
93
|
+
- !ruby/object:Gem::Version
|
94
|
+
version: '0'
|
122
95
|
requirements: []
|
123
|
-
|
124
|
-
|
125
|
-
rubygems_version: 1.3.3
|
96
|
+
rubyforge_project:
|
97
|
+
rubygems_version: 1.8.17
|
126
98
|
signing_key:
|
127
99
|
specification_version: 3
|
128
|
-
summary:
|
129
|
-
test_files:
|
130
|
-
- test/test_jake.rb
|
100
|
+
summary: Build tools for JavaScript projects
|
101
|
+
test_files: []
|
data/Manifest.txt
DELETED
@@ -1,33 +0,0 @@
|
|
1
|
-
History.txt
|
2
|
-
Manifest.txt
|
3
|
-
README.txt
|
4
|
-
Rakefile
|
5
|
-
bin/jake
|
6
|
-
lib/jake.rb
|
7
|
-
lib/jake/helper.rb
|
8
|
-
lib/jake/build.rb
|
9
|
-
lib/jake/buildable.rb
|
10
|
-
lib/jake/package.rb
|
11
|
-
lib/jake/bundle.rb
|
12
|
-
test/test_jake.rb
|
13
|
-
test/jake.yml
|
14
|
-
test/Jakefile
|
15
|
-
test/packages.erb
|
16
|
-
test/expected/combo/box.js
|
17
|
-
test/expected/combo/box-min.js
|
18
|
-
test/expected/sub/dir/foo.js
|
19
|
-
test/expected/sub/dir/foo-min.js
|
20
|
-
test/expected/sub/path/bar.js
|
21
|
-
test/expected/sub/path/bar-min.js
|
22
|
-
test/expected/basic.js
|
23
|
-
test/expected/basic-min.js
|
24
|
-
test/expected/ext.js
|
25
|
-
test/expected/ext-min.js
|
26
|
-
test/expected/LISTING
|
27
|
-
test/expected/README
|
28
|
-
test/src/foo/bar.js
|
29
|
-
test/src/foo/foo.js
|
30
|
-
test/src/basic.js
|
31
|
-
test/src/basic-ext.js
|
32
|
-
test/src/head.js
|
33
|
-
test/src/head2.js
|