js_rake_tasks 0.0.3 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/js_rake_tasks.rb +26 -5
- metadata +72 -9
data/lib/js_rake_tasks.rb
CHANGED
@@ -2,14 +2,35 @@ include Rake::DSL if defined?(Rake::DSL)
|
|
2
2
|
|
3
3
|
namespace 'coffee' do
|
4
4
|
task "compile", [:flags] do |t,args|
|
5
|
+
require 'json'
|
6
|
+
|
7
|
+
source_code = FileList.new('src/**/*.coffee').map { |file_path| File.read(file_path) }.join("\n")
|
8
|
+
|
5
9
|
package_json = JSON.parse(File.read("package.json"))
|
10
|
+
uncompressed_output = filter_output(compile_coffee_script(source_code), package_json)
|
11
|
+
File.open(file_name(package_json), "w") { |file| file.puts uncompressed_output }
|
12
|
+
File.open(file_name(package_json, true), "w") { |file| file.puts uglify(uncompressed_output) }
|
13
|
+
end
|
14
|
+
|
15
|
+
def file_name(package_json, minified = false)
|
16
|
+
File.join("dist","#{package_json["name"]}#{minified ? "-min" : ""}.js")
|
17
|
+
end
|
6
18
|
|
7
|
-
|
19
|
+
def compile_coffee_script(coffee_script)
|
20
|
+
require 'execjs'
|
21
|
+
require 'coffee-script'
|
22
|
+
|
23
|
+
context = ExecJS.compile(File.read(CoffeeScript::Source.bundled_path))
|
24
|
+
context.call("CoffeeScript.compile", coffee_script, :bare => false)
|
25
|
+
end
|
26
|
+
|
27
|
+
def filter_output(compiled_output, package_json)
|
28
|
+
compiled_output.gsub(/@@VERSION@@/, package_json["version"])
|
29
|
+
end
|
8
30
|
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
File.open(file_name, "w") {|file| file.puts filtered}
|
31
|
+
def uglify(uncompressed_javascript)
|
32
|
+
require 'uglifier'
|
33
|
+
Uglifier.compile(uncompressed_javascript)
|
13
34
|
end
|
14
35
|
end
|
15
36
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: js_rake_tasks
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2011-02-05 00:00:00.
|
12
|
+
date: 2011-02-05 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: json_pure
|
16
|
-
requirement:
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ~>
|
@@ -21,10 +21,31 @@ dependencies:
|
|
21
21
|
version: 1.6.1
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements:
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ~>
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: 1.6.1
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: execjs
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - ~>
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: 1.3.2
|
38
|
+
type: :runtime
|
39
|
+
prerelease: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ~>
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: 1.3.2
|
25
46
|
- !ruby/object:Gem::Dependency
|
26
47
|
name: semver
|
27
|
-
requirement:
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
28
49
|
none: false
|
29
50
|
requirements:
|
30
51
|
- - ~>
|
@@ -32,18 +53,60 @@ dependencies:
|
|
32
53
|
version: 1.0.1
|
33
54
|
type: :runtime
|
34
55
|
prerelease: false
|
35
|
-
version_requirements:
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ~>
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: 1.0.1
|
36
62
|
- !ruby/object:Gem::Dependency
|
37
63
|
name: git
|
38
|
-
requirement:
|
64
|
+
requirement: !ruby/object:Gem::Requirement
|
65
|
+
none: false
|
66
|
+
requirements:
|
67
|
+
- - ~>
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: 1.2.5
|
70
|
+
type: :runtime
|
71
|
+
prerelease: false
|
72
|
+
version_requirements: !ruby/object:Gem::Requirement
|
39
73
|
none: false
|
40
74
|
requirements:
|
41
75
|
- - ~>
|
42
76
|
- !ruby/object:Gem::Version
|
43
77
|
version: 1.2.5
|
78
|
+
- !ruby/object:Gem::Dependency
|
79
|
+
name: coffee-script-source
|
80
|
+
requirement: !ruby/object:Gem::Requirement
|
81
|
+
none: false
|
82
|
+
requirements:
|
83
|
+
- - ~>
|
84
|
+
- !ruby/object:Gem::Version
|
85
|
+
version: 1.3.3
|
86
|
+
type: :runtime
|
87
|
+
prerelease: false
|
88
|
+
version_requirements: !ruby/object:Gem::Requirement
|
89
|
+
none: false
|
90
|
+
requirements:
|
91
|
+
- - ~>
|
92
|
+
- !ruby/object:Gem::Version
|
93
|
+
version: 1.3.3
|
94
|
+
- !ruby/object:Gem::Dependency
|
95
|
+
name: uglifier
|
96
|
+
requirement: !ruby/object:Gem::Requirement
|
97
|
+
none: false
|
98
|
+
requirements:
|
99
|
+
- - ~>
|
100
|
+
- !ruby/object:Gem::Version
|
101
|
+
version: 1.2.4
|
44
102
|
type: :runtime
|
45
103
|
prerelease: false
|
46
|
-
version_requirements:
|
104
|
+
version_requirements: !ruby/object:Gem::Requirement
|
105
|
+
none: false
|
106
|
+
requirements:
|
107
|
+
- - ~>
|
108
|
+
- !ruby/object:Gem::Version
|
109
|
+
version: 1.2.4
|
47
110
|
description: Rake tasks for little JavaScript projects
|
48
111
|
email: searls@gmail.com
|
49
112
|
executables: []
|
@@ -71,7 +134,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
71
134
|
version: '0'
|
72
135
|
requirements: []
|
73
136
|
rubyforge_project:
|
74
|
-
rubygems_version: 1.8.
|
137
|
+
rubygems_version: 1.8.24
|
75
138
|
signing_key:
|
76
139
|
specification_version: 3
|
77
140
|
summary: Provides a few tasks for managing CoffeeScript/JavaScript projects
|