rake-minify 0.3.3 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +17 -0
- data/.travis.yml +8 -0
- data/Gemfile +2 -14
- data/Gemfile.lock +42 -36
- data/LICENSE.txt +4 -2
- data/README.rdoc +36 -1
- data/Rakefile +11 -30
- data/VERSION +1 -1
- data/features/js-sources/c-a-wrapped.js +2 -0
- data/features/js-sources/c-a.js +2 -0
- data/features/minify.feature +41 -0
- data/features/step_definitions/rake-minify_steps.rb +15 -2
- data/features/support/generate_rakefiles.rb +19 -7
- data/lib/rake-minify.rb +0 -1
- data/lib/rake/minify.rb +14 -3
- data/lib/rake/minify/group.rb +10 -2
- data/lib/rake/minify/source.rb +11 -6
- data/rake-minify.gemspec +27 -101
- data/spec/rake/minify/group_spec.rb +13 -0
- data/spec/rake/minify/source_spec.rb +20 -0
- data/spec/rake/minify_spec.rb +19 -0
- data/spec/spec_helper.rb +5 -0
- metadata +120 -164
data/.gitignore
ADDED
data/.travis.yml
ADDED
data/Gemfile
CHANGED
@@ -1,15 +1,3 @@
|
|
1
|
-
source
|
1
|
+
source 'https://rubygems.org'
|
2
2
|
|
3
|
-
|
4
|
-
gem "rake", ">= 0.8.7"
|
5
|
-
|
6
|
-
group :development do
|
7
|
-
gem "rspec", "~> 2.5.0"
|
8
|
-
gem "cucumber", ">= 0"
|
9
|
-
gem "jeweler", "~> 1.5.2"
|
10
|
-
gem 'test_notifier', '~> 0.3.6'
|
11
|
-
gem 'autotest', '~> 4.4'
|
12
|
-
gem "rcov", ">= 0"
|
13
|
-
gem "coffee-script", ">= 2.2.0"
|
14
|
-
gem "therubyracer"
|
15
|
-
end
|
3
|
+
gemspec
|
data/Gemfile.lock
CHANGED
@@ -1,48 +1,55 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
rake-minify (0.4.0)
|
5
|
+
jsmin (~> 1.0.1)
|
6
|
+
rake (>= 0.8.7)
|
7
|
+
|
1
8
|
GEM
|
2
|
-
remote:
|
9
|
+
remote: https://rubygems.org/
|
3
10
|
specs:
|
4
|
-
ZenTest (4.
|
11
|
+
ZenTest (4.8.3)
|
5
12
|
autotest (4.4.6)
|
6
13
|
ZenTest (>= 4.4.1)
|
7
|
-
builder (3.
|
14
|
+
builder (3.1.4)
|
8
15
|
coffee-script (2.2.0)
|
9
16
|
coffee-script-source
|
10
17
|
execjs
|
11
|
-
coffee-script-source (1.
|
12
|
-
cucumber (
|
18
|
+
coffee-script-source (1.4.0)
|
19
|
+
cucumber (1.2.1)
|
13
20
|
builder (>= 2.1.2)
|
14
|
-
diff-lcs (>= 1.1.
|
15
|
-
gherkin (
|
21
|
+
diff-lcs (>= 1.1.3)
|
22
|
+
gherkin (~> 2.11.0)
|
16
23
|
json (>= 1.4.6)
|
17
|
-
|
18
|
-
|
19
|
-
execjs (1.0.0)
|
24
|
+
diff-lcs (1.1.3)
|
25
|
+
execjs (1.4.0)
|
20
26
|
multi_json (~> 1.0)
|
21
|
-
gherkin (2.
|
27
|
+
gherkin (2.11.5)
|
22
28
|
json (>= 1.4.6)
|
23
|
-
git (1.2.5)
|
24
|
-
jeweler (1.5.2)
|
25
|
-
bundler (~> 1.0.0)
|
26
|
-
git (>= 1.2.5)
|
27
|
-
rake
|
28
29
|
jsmin (1.0.1)
|
29
|
-
json (1.5
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
rspec-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
rspec-
|
42
|
-
|
30
|
+
json (1.7.5)
|
31
|
+
libv8 (3.3.10.4)
|
32
|
+
multi_json (1.5.0)
|
33
|
+
notifier (0.4.1)
|
34
|
+
rake (10.0.3)
|
35
|
+
rdoc (3.12)
|
36
|
+
json (~> 1.4)
|
37
|
+
rspec (2.12.0)
|
38
|
+
rspec-core (~> 2.12.0)
|
39
|
+
rspec-expectations (~> 2.12.0)
|
40
|
+
rspec-mocks (~> 2.12.0)
|
41
|
+
rspec-core (2.12.2)
|
42
|
+
rspec-expectations (2.12.1)
|
43
|
+
diff-lcs (~> 1.1.3)
|
44
|
+
rspec-mocks (2.12.1)
|
45
|
+
simplecov (0.7.1)
|
46
|
+
multi_json (~> 1.0)
|
47
|
+
simplecov-html (~> 0.7.1)
|
48
|
+
simplecov-html (0.7.1)
|
43
49
|
test_notifier (0.3.6)
|
44
50
|
notifier
|
45
|
-
therubyracer (0.
|
51
|
+
therubyracer (0.9.10)
|
52
|
+
libv8 (~> 3.3.10)
|
46
53
|
|
47
54
|
PLATFORMS
|
48
55
|
ruby
|
@@ -51,10 +58,9 @@ DEPENDENCIES
|
|
51
58
|
autotest (~> 4.4)
|
52
59
|
coffee-script (>= 2.2.0)
|
53
60
|
cucumber
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
rspec (~> 2.5.0)
|
61
|
+
rake-minify!
|
62
|
+
rdoc (~> 3.12)
|
63
|
+
rspec (~> 2.12.0)
|
64
|
+
simplecov
|
59
65
|
test_notifier (~> 0.3.6)
|
60
66
|
therubyracer
|
data/LICENSE.txt
CHANGED
@@ -1,4 +1,6 @@
|
|
1
|
-
Copyright (c)
|
1
|
+
Copyright (c) 2012 Matteo Collina
|
2
|
+
|
3
|
+
MIT License
|
2
4
|
|
3
5
|
Permission is hereby granted, free of charge, to any person obtaining
|
4
6
|
a copy of this software and associated documentation files (the
|
@@ -17,4 +19,4 @@ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
17
19
|
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
20
|
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
21
|
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
-
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.rdoc
CHANGED
@@ -1,6 +1,8 @@
|
|
1
1
|
= rake-minify
|
2
2
|
|
3
|
-
Rake Minify is an
|
3
|
+
Rake Minify is an extremely simple solution for minifying javascript and coffeescript files using a rake task.
|
4
|
+
|
5
|
+
{<img src="https://secure.travis-ci.org/mcollina/rake-minify.png?branch=master" alt="Build Status" />}[http://travis-ci.org/mcollina/rake-minify]
|
4
6
|
|
5
7
|
== Installation
|
6
8
|
|
@@ -95,6 +97,39 @@ You can specify it:
|
|
95
97
|
add("output.js", "source.coffee", :bare => true)
|
96
98
|
end
|
97
99
|
|
100
|
+
== Combine from ruby block
|
101
|
+
|
102
|
+
With a single file:
|
103
|
+
|
104
|
+
require 'rake/minify'
|
105
|
+
Rake::Minify.new(:minify_single) do
|
106
|
+
dir("path/to/your/dir") do # we specify only the source directory
|
107
|
+
add("output.js") do
|
108
|
+
# this is evaluated during the build
|
109
|
+
"var a = 'hello js!'"
|
110
|
+
end
|
111
|
+
end
|
112
|
+
end
|
113
|
+
|
114
|
+
With a group:
|
115
|
+
|
116
|
+
require 'rake/minify'
|
117
|
+
Rake::Minify.new(:minify_and_combine) do
|
118
|
+
dir("path/to/your/dir") do # we specify only the source directory
|
119
|
+
group("output-first-second.js") do
|
120
|
+
add(:minify => false) do
|
121
|
+
# this is evaluated during the build
|
122
|
+
"var a = 'hello js!'"
|
123
|
+
end
|
124
|
+
|
125
|
+
add(:coffeescript => true) do
|
126
|
+
# this is evaluated as coffescript
|
127
|
+
"(a -> 'hello coffee!')()"
|
128
|
+
end
|
129
|
+
end
|
130
|
+
end
|
131
|
+
end
|
132
|
+
|
98
133
|
== Contributing to rake-minify
|
99
134
|
|
100
135
|
* Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet
|
data/Rakefile
CHANGED
@@ -1,35 +1,16 @@
|
|
1
|
-
require
|
2
|
-
require 'rake'
|
1
|
+
require "bundler/gem_tasks"
|
3
2
|
|
4
|
-
require 'jeweler'
|
5
|
-
Jeweler::Tasks.new do |gem|
|
6
|
-
# gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
|
7
|
-
gem.name = "rake-minify"
|
8
|
-
gem.homepage = "http://github.com/mcollina/rake-minify"
|
9
|
-
gem.license = "MIT"
|
10
|
-
gem.summary = %Q{A rake task to minify javascripts and coffeescripts}
|
11
|
-
gem.description = %Q{A rake task to minify javascripts and coffeescripts}
|
12
|
-
gem.email = "matteo.collina@gmail.com"
|
13
|
-
gem.authors = ["Matteo Collina"]
|
14
|
-
# Include your dependencies below. Runtime dependencies are required when using your gem,
|
15
|
-
# and development dependencies are only needed for development (ie running rake tasks, tests, etc)
|
16
|
-
# gem.add_runtime_dependency 'jabber4r', '> 0.1'
|
17
|
-
# gem.add_development_dependency 'rspec', '> 1.2.3'
|
18
|
-
end
|
19
|
-
Jeweler::RubygemsDotOrgTasks.new
|
20
|
-
|
21
|
-
require 'rspec/core'
|
22
3
|
require 'rspec/core/rake_task'
|
23
|
-
RSpec::Core::RakeTask.new(:spec) do |spec|
|
24
|
-
spec.pattern = FileList['spec/**/*_spec.rb']
|
25
|
-
end
|
26
4
|
|
27
|
-
|
28
|
-
|
29
|
-
spec.rcov = true
|
30
|
-
spec.rcov_opts = ["--text-summary", "--exclude","lib\/rspec,bin\/rspec,lib\/rcov," +
|
31
|
-
"spec,diff-lcs,lib\/cucumber,lib\/gherkin,cucumber,features,rake-0,coffee,json,execjs,jsmin"]
|
5
|
+
desc "Run specs"
|
6
|
+
RSpec::Core::RakeTask.new
|
32
7
|
|
8
|
+
namespace :spec do
|
9
|
+
desc "Create rspec coverage"
|
10
|
+
task :coverage do
|
11
|
+
ENV['COVERAGE'] = 'true'
|
12
|
+
Rake::Task["spec"].execute
|
13
|
+
end
|
33
14
|
end
|
34
15
|
|
35
16
|
require 'cucumber/rake/task'
|
@@ -37,9 +18,9 @@ Cucumber::Rake::Task.new(:features)
|
|
37
18
|
|
38
19
|
task :default => [:features, :spec]
|
39
20
|
|
40
|
-
require '
|
21
|
+
require 'rdoc/task'
|
41
22
|
Rake::RDocTask.new do |rdoc|
|
42
|
-
version = File.
|
23
|
+
version = File.read "VERSION"
|
43
24
|
|
44
25
|
rdoc.rdoc_dir = 'rdoc'
|
45
26
|
rdoc.title = "rake-minify #{version}"
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.4.0
|
data/features/js-sources/c-a.js
CHANGED
data/features/minify.feature
CHANGED
@@ -76,3 +76,44 @@ Feature: Minify Javascripts
|
|
76
76
|
Given we want to add the file "a.js" into "a/dir/a.min.js"
|
77
77
|
When I run rake minify
|
78
78
|
Then "a/dir/a.min.js" should include "a.min.js"
|
79
|
+
|
80
|
+
Scenario: Minify single javascript built by ruby
|
81
|
+
Given we want to add the following javascript into "a.min.js":
|
82
|
+
"""
|
83
|
+
a = "a"
|
84
|
+
"var a = \"hello #{a}\" ;"
|
85
|
+
|
86
|
+
|
87
|
+
|
88
|
+
|
89
|
+
"""
|
90
|
+
When I run rake minify
|
91
|
+
Then "a.min.js" should be minified
|
92
|
+
|
93
|
+
|
94
|
+
Scenario: Minify single coffeescript built by ruby
|
95
|
+
Given we want to add the following coffeescript into "c-a-wrapped.min.js":
|
96
|
+
"""
|
97
|
+
a = "a"
|
98
|
+
"a = \"hello #{a}\""
|
99
|
+
|
100
|
+
|
101
|
+
|
102
|
+
|
103
|
+
"""
|
104
|
+
When I run rake minify
|
105
|
+
Then "c-a-wrapped.min.js" should be minified
|
106
|
+
|
107
|
+
Scenario: Minify multiple javascripts built by ruby
|
108
|
+
Given we want to add the following javascript into "app.min.js":
|
109
|
+
"""
|
110
|
+
a = "a"
|
111
|
+
"var a = \"hello #{a}\" ;"
|
112
|
+
|
113
|
+
|
114
|
+
|
115
|
+
|
116
|
+
"""
|
117
|
+
And we want to add the file "b.js" into "app.min.js"
|
118
|
+
When I run rake minify
|
119
|
+
Then "app.min.js" should include "a.min.js" and "b.min.js"
|
@@ -27,18 +27,22 @@ Then /^"([^"]*)" should include "([^"]*)"(?: and "([^"]*)")?$/ do |result, sourc
|
|
27
27
|
sources << source2 if source2
|
28
28
|
sources.map! do |s|
|
29
29
|
file = File.join(File.dirname(__FILE__), "..", "js-expected", s)
|
30
|
+
minified = true
|
30
31
|
unless File.exists? file
|
31
32
|
file = File.join(File.dirname(__FILE__), "..", "js-sources", s)
|
33
|
+
minified = false
|
32
34
|
end
|
33
35
|
|
34
36
|
open(file) do |e|
|
35
|
-
e.read
|
37
|
+
r = e.read
|
38
|
+
r.gsub!(/\n$/, '') if minified
|
39
|
+
r
|
36
40
|
end
|
37
41
|
end
|
38
42
|
|
39
43
|
open(File.join(@dir, result)) do |result|
|
40
44
|
content = result.read
|
41
|
-
sources.each { |s| content.should include(s
|
45
|
+
sources.each { |s| content.should include(s) }
|
42
46
|
end
|
43
47
|
end
|
44
48
|
|
@@ -61,3 +65,12 @@ end
|
|
61
65
|
Given /^the inner directory "([^"]*)"$/ do |dir|
|
62
66
|
indir(dir)
|
63
67
|
end
|
68
|
+
|
69
|
+
Given /^we want to add the following javascript into "(.*?)":$/ do |output, string|
|
70
|
+
add_to_groups(output, nil, {}, string)
|
71
|
+
end
|
72
|
+
|
73
|
+
Given /^we want to add the following coffeescript into "(.*?)":$/ do |output, string|
|
74
|
+
add_to_groups(output, nil, { :coffeescript => "true" }, string)
|
75
|
+
end
|
76
|
+
|
@@ -9,12 +9,12 @@ class Group
|
|
9
9
|
@sources = []
|
10
10
|
end
|
11
11
|
|
12
|
-
def add(source, options)
|
13
|
-
@sources << GroupElement.new(source, options)
|
12
|
+
def add(source, options, block)
|
13
|
+
@sources << GroupElement.new(source, options, block)
|
14
14
|
end
|
15
15
|
end
|
16
16
|
|
17
|
-
GroupElement = Struct.new(:source, :options)
|
17
|
+
GroupElement = Struct.new(:source, :options, :block)
|
18
18
|
|
19
19
|
def groups
|
20
20
|
@groups ||= Hash.new do |h, k|
|
@@ -22,12 +22,12 @@ def groups
|
|
22
22
|
end
|
23
23
|
end
|
24
24
|
|
25
|
-
def add_to_groups(output, file, options=nil)
|
25
|
+
def add_to_groups(output, file, options=nil, block=nil)
|
26
26
|
options = options.keys.reduce({}) do |hash, key|
|
27
27
|
hash[key.to_sym] = eval(options[key])
|
28
28
|
hash
|
29
29
|
end if options
|
30
|
-
groups[output].add(file, options)
|
30
|
+
groups[output].add(file, options, block)
|
31
31
|
end
|
32
32
|
|
33
33
|
def generate_rakefile
|
@@ -40,14 +40,26 @@ Rake::Minify.new(<%= @name_for_generation %>) do
|
|
40
40
|
<% end %>
|
41
41
|
<% groups.values.each do |group| %>
|
42
42
|
<% if group.sources.size == 1 %>
|
43
|
-
|
43
|
+
<% if group.sources.first.source %>
|
44
|
+
add(<%= group.output.inspect %>, <%= group.sources.first.source.inspect %>, <%= group.sources.first.options.inspect %>)
|
45
|
+
<% else %>
|
46
|
+
add(<%= group.output.inspect %>, <%= group.sources.first.options.inspect %>) do
|
47
|
+
<%= group.sources.first.block %>
|
48
|
+
end
|
49
|
+
<% end %>
|
44
50
|
<% else %>
|
45
51
|
group(<%= group.output.inspect %>) do |group|
|
46
52
|
<% if indir %>
|
47
53
|
dir(<%= indir.inspect %>) do
|
48
54
|
<% end %>
|
49
55
|
<% group.sources.each do |element| %>
|
50
|
-
|
56
|
+
<% if element.source %>
|
57
|
+
add(<%= element.source.inspect %>, <%= element.options.inspect %>)
|
58
|
+
<% else %>
|
59
|
+
add(<%= element.options.inspect %>) do
|
60
|
+
<%= element.block %>
|
61
|
+
end
|
62
|
+
<% end %>
|
51
63
|
<% end %>
|
52
64
|
<% if indir %>
|
53
65
|
end
|
data/lib/rake-minify.rb
CHANGED
data/lib/rake/minify.rb
CHANGED
@@ -19,8 +19,19 @@ class Rake::Minify < Rake::TaskLib
|
|
19
19
|
end
|
20
20
|
end
|
21
21
|
|
22
|
-
def add(output,
|
23
|
-
|
22
|
+
def add(output, *args, &block)
|
23
|
+
source = opts = nil
|
24
|
+
|
25
|
+
if block.nil?
|
26
|
+
source = build_path(args.shift)
|
27
|
+
else
|
28
|
+
source = block
|
29
|
+
end
|
30
|
+
|
31
|
+
opts = args.shift
|
32
|
+
opts ||= { :minify => true }
|
33
|
+
|
34
|
+
add_source(output, Source.new(source, opts, &block))
|
24
35
|
end
|
25
36
|
|
26
37
|
def group(output, &block)
|
@@ -36,7 +47,7 @@ class Rake::Minify < Rake::TaskLib
|
|
36
47
|
end
|
37
48
|
|
38
49
|
def invoke
|
39
|
-
instance_eval
|
50
|
+
instance_eval(&@config) # to be configured like the pros
|
40
51
|
|
41
52
|
@sources.each do |dest, source|
|
42
53
|
FileUtils.mkdir_p(File.dirname(dest))
|
data/lib/rake/minify/group.rb
CHANGED
@@ -10,9 +10,17 @@ class Rake::Minify
|
|
10
10
|
instance_eval &block if block
|
11
11
|
end
|
12
12
|
|
13
|
-
def add(
|
13
|
+
def add(*args, &block)
|
14
|
+
if block
|
15
|
+
source = block
|
16
|
+
else
|
17
|
+
source = parent.build_path(args.shift)
|
18
|
+
end
|
19
|
+
|
20
|
+
opts = args.shift
|
14
21
|
opts ||= { :minify => true }
|
15
|
-
|
22
|
+
|
23
|
+
@sources << Source.new(source, opts)
|
16
24
|
end
|
17
25
|
|
18
26
|
def build
|
data/lib/rake/minify/source.rb
CHANGED
@@ -6,21 +6,26 @@ class Rake::Minify::Source
|
|
6
6
|
@source = source
|
7
7
|
@minify = optional_boolean(options[:minify], true)
|
8
8
|
@coffee_bare = optional_boolean(options[:bare], false)
|
9
|
+
@coffee = options[:coffeescript]
|
9
10
|
end
|
10
11
|
|
11
12
|
def build
|
12
13
|
coffee_script! if coffee?
|
13
14
|
|
14
|
-
|
15
|
-
output =
|
16
|
-
|
17
|
-
output =
|
18
|
-
output
|
15
|
+
if source.respond_to? :call
|
16
|
+
output = source.call
|
17
|
+
else
|
18
|
+
output = Kernel.open(source) { |input| input.read }
|
19
19
|
end
|
20
|
+
|
21
|
+
output = CoffeeScript.compile(output, :bare => @coffee_bare) if coffee?
|
22
|
+
output = JSMin.minify(output).strip if minify
|
23
|
+
|
24
|
+
output
|
20
25
|
end
|
21
26
|
|
22
27
|
def coffee?
|
23
|
-
source =~ /\.coffee$/
|
28
|
+
source =~ /\.coffee$/ or @coffee
|
24
29
|
end
|
25
30
|
|
26
31
|
private
|
data/rake-minify.gemspec
CHANGED
@@ -1,108 +1,34 @@
|
|
1
|
-
# Generated by jeweler
|
2
|
-
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
-
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
1
|
# -*- encoding: utf-8 -*-
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
5
4
|
|
6
|
-
Gem::Specification.new do |
|
7
|
-
|
8
|
-
|
5
|
+
Gem::Specification.new do |gem|
|
6
|
+
gem.name = "rake-minify"
|
7
|
+
gem.version = File.read "VERSION"
|
8
|
+
gem.authors = ["Matteo Collina"]
|
9
|
+
gem.email = ["hello@matteocollina.com"]
|
10
|
+
gem.description = %q{A rake task to minify javascripts and coffeescripts}
|
11
|
+
gem.summary = %q{A rake task to minify javascripts and coffeescripts}
|
12
|
+
gem.homepage = "http://github.com/mcollina/rake-minify"
|
9
13
|
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
s.email = %q{matteo.collina@gmail.com}
|
15
|
-
s.extra_rdoc_files = [
|
16
|
-
"LICENSE.txt",
|
17
|
-
"README.rdoc"
|
18
|
-
]
|
19
|
-
s.files = [
|
20
|
-
".autotest",
|
21
|
-
".document",
|
22
|
-
".rspec",
|
23
|
-
".rvmrc",
|
24
|
-
"Gemfile",
|
25
|
-
"Gemfile.lock",
|
26
|
-
"LICENSE.txt",
|
27
|
-
"README.rdoc",
|
28
|
-
"Rakefile",
|
29
|
-
"VERSION",
|
30
|
-
"features/coffeescript.feature",
|
31
|
-
"features/js-expected/a.min.js",
|
32
|
-
"features/js-expected/b.min.js",
|
33
|
-
"features/js-expected/c-a-bare.min.js",
|
34
|
-
"features/js-expected/c-a-wrapped.min.js",
|
35
|
-
"features/js-expected/c-a.min.js",
|
36
|
-
"features/js-sources/a.js",
|
37
|
-
"features/js-sources/b.js",
|
38
|
-
"features/js-sources/c-a-bare.js",
|
39
|
-
"features/js-sources/c-a-wrapped.js",
|
40
|
-
"features/js-sources/c-a.coffee",
|
41
|
-
"features/js-sources/c-a.js",
|
42
|
-
"features/minify.feature",
|
43
|
-
"features/rake-interface.feature",
|
44
|
-
"features/step_definitions/rake-minify_steps.rb",
|
45
|
-
"features/support/env.rb",
|
46
|
-
"features/support/generate_rakefiles.rb",
|
47
|
-
"lib/rake-minify.rb",
|
48
|
-
"lib/rake/minify.rb",
|
49
|
-
"lib/rake/minify/group.rb",
|
50
|
-
"lib/rake/minify/source.rb",
|
51
|
-
"rake-minify.gemspec",
|
52
|
-
"spec/rake/minify/group_spec.rb",
|
53
|
-
"spec/rake/minify/source_spec.rb",
|
54
|
-
"spec/rake/minify_spec.rb",
|
55
|
-
"spec/spec_helper.rb"
|
56
|
-
]
|
57
|
-
s.homepage = %q{http://github.com/mcollina/rake-minify}
|
58
|
-
s.licenses = ["MIT"]
|
59
|
-
s.require_paths = ["lib"]
|
60
|
-
s.rubygems_version = %q{1.5.3}
|
61
|
-
s.summary = %q{A rake task to minify javascripts and coffeescripts}
|
62
|
-
s.test_files = [
|
63
|
-
"spec/rake/minify/group_spec.rb",
|
64
|
-
"spec/rake/minify/source_spec.rb",
|
65
|
-
"spec/rake/minify_spec.rb",
|
66
|
-
"spec/spec_helper.rb"
|
67
|
-
]
|
14
|
+
gem.files = `git ls-files`.split($/)
|
15
|
+
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
16
|
+
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
17
|
+
gem.require_paths = ["lib"]
|
68
18
|
|
69
|
-
|
70
|
-
|
19
|
+
gem.add_dependency("rake", ">= 0.8.7")
|
20
|
+
gem.add_dependency("jsmin", "~> 1.0.1")
|
71
21
|
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
s.add_development_dependency(%q<autotest>, ["~> 4.4"])
|
80
|
-
s.add_development_dependency(%q<rcov>, [">= 0"])
|
81
|
-
s.add_development_dependency(%q<coffee-script>, [">= 2.2.0"])
|
82
|
-
s.add_development_dependency(%q<therubyracer>, [">= 0"])
|
83
|
-
else
|
84
|
-
s.add_dependency(%q<jsmin>, ["~> 1.0.1"])
|
85
|
-
s.add_dependency(%q<rake>, [">= 0.8.7"])
|
86
|
-
s.add_dependency(%q<rspec>, ["~> 2.5.0"])
|
87
|
-
s.add_dependency(%q<cucumber>, [">= 0"])
|
88
|
-
s.add_dependency(%q<jeweler>, ["~> 1.5.2"])
|
89
|
-
s.add_dependency(%q<test_notifier>, ["~> 0.3.6"])
|
90
|
-
s.add_dependency(%q<autotest>, ["~> 4.4"])
|
91
|
-
s.add_dependency(%q<rcov>, [">= 0"])
|
92
|
-
s.add_dependency(%q<coffee-script>, [">= 2.2.0"])
|
93
|
-
s.add_dependency(%q<therubyracer>, [">= 0"])
|
94
|
-
end
|
95
|
-
else
|
96
|
-
s.add_dependency(%q<jsmin>, ["~> 1.0.1"])
|
97
|
-
s.add_dependency(%q<rake>, [">= 0.8.7"])
|
98
|
-
s.add_dependency(%q<rspec>, ["~> 2.5.0"])
|
99
|
-
s.add_dependency(%q<cucumber>, [">= 0"])
|
100
|
-
s.add_dependency(%q<jeweler>, ["~> 1.5.2"])
|
101
|
-
s.add_dependency(%q<test_notifier>, ["~> 0.3.6"])
|
102
|
-
s.add_dependency(%q<autotest>, ["~> 4.4"])
|
103
|
-
s.add_dependency(%q<rcov>, [">= 0"])
|
104
|
-
s.add_dependency(%q<coffee-script>, [">= 2.2.0"])
|
105
|
-
s.add_dependency(%q<therubyracer>, [">= 0"])
|
22
|
+
gem.add_development_dependency("rspec", "~> 2.12.0")
|
23
|
+
gem.add_development_dependency("cucumber", ">= 0")
|
24
|
+
gem.add_development_dependency('test_notifier', '~> 0.3.6')
|
25
|
+
gem.add_development_dependency('autotest', '~> 4.4')
|
26
|
+
|
27
|
+
if RUBY_VERSION >= "1.9"
|
28
|
+
gem.add_development_dependency("simplecov")
|
106
29
|
end
|
107
|
-
end
|
108
30
|
|
31
|
+
gem.add_development_dependency("coffee-script", ">= 2.2.0")
|
32
|
+
gem.add_development_dependency("therubyracer")
|
33
|
+
gem.add_development_dependency("rdoc", "~> 3.12")
|
34
|
+
end
|
@@ -54,6 +54,19 @@ class Rake::Minify
|
|
54
54
|
subject.build.should == "aaaa"
|
55
55
|
end
|
56
56
|
|
57
|
+
it "should accept add inside the block passed to new" do
|
58
|
+
source = double("source", :build => "aaaa")
|
59
|
+
Source.stub!(:new).with(kind_of(Proc), :minify => false).and_return(source)
|
60
|
+
|
61
|
+
subject = Group.new(parent) do
|
62
|
+
add(:minify => false) do
|
63
|
+
# in this spec, this is not called
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
subject.build.should == "aaaa"
|
68
|
+
end
|
69
|
+
|
57
70
|
it "should expose its parent dir method" do
|
58
71
|
parent.should_receive(:dir).with("a_dir").and_yield("hello world")
|
59
72
|
(subject.dir("a_dir") { |a| a }).should == "hello world" #weird method to test this
|
@@ -13,6 +13,26 @@ class Rake::Minify
|
|
13
13
|
end
|
14
14
|
end
|
15
15
|
|
16
|
+
context "configured with a block" do
|
17
|
+
subject do
|
18
|
+
Source.new(lambda { ' var a = "b" ;' }, :minify => true)
|
19
|
+
end
|
20
|
+
|
21
|
+
it "should minify the result of the block" do
|
22
|
+
subject.build.should == "var a=\"b\";"
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
context "configured with a block and forcing the source to be some coffeescript" do
|
27
|
+
subject do
|
28
|
+
Source.new(lambda { ' a = "b" ' }, :minify => true, :coffeescript => true, :bare => true)
|
29
|
+
end
|
30
|
+
|
31
|
+
it "should minify the result of the block" do
|
32
|
+
subject.build.should == "var a;a=\"b\";"
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
16
36
|
context "configured to open 'another_source' and to not minify it" do
|
17
37
|
subject { Source.new("another_source", :minify => false) }
|
18
38
|
|
data/spec/rake/minify_spec.rb
CHANGED
@@ -174,4 +174,23 @@ describe Rake::Minify do
|
|
174
174
|
add("output", "source")
|
175
175
|
end
|
176
176
|
end
|
177
|
+
|
178
|
+
context "configured to minify the passed JS" do
|
179
|
+
subject do
|
180
|
+
Rake::Minify.new do
|
181
|
+
add("output") do
|
182
|
+
' var a = "b" ;'
|
183
|
+
end
|
184
|
+
end
|
185
|
+
end
|
186
|
+
|
187
|
+
before :each do
|
188
|
+
@output = stub_open("output","", "w")
|
189
|
+
end
|
190
|
+
|
191
|
+
it "should minify the input file when invoked" do
|
192
|
+
do_invoke
|
193
|
+
@output.string.should == "var a=\"b\";"
|
194
|
+
end
|
195
|
+
end
|
177
196
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -3,6 +3,11 @@ require 'bundler'
|
|
3
3
|
Bundler.setup
|
4
4
|
require 'rspec'
|
5
5
|
|
6
|
+
if ENV["COVERAGE"]
|
7
|
+
require 'simplecov'
|
8
|
+
SimpleCov.start
|
9
|
+
end
|
10
|
+
|
6
11
|
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
7
12
|
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
8
13
|
require 'rake-minify'
|
metadata
CHANGED
@@ -1,190 +1,139 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: rake-minify
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.4.0
|
5
5
|
prerelease:
|
6
|
-
segments:
|
7
|
-
- 0
|
8
|
-
- 3
|
9
|
-
- 3
|
10
|
-
version: 0.3.3
|
11
6
|
platform: ruby
|
12
|
-
authors:
|
7
|
+
authors:
|
13
8
|
- Matteo Collina
|
14
9
|
autorequire:
|
15
10
|
bindir: bin
|
16
11
|
cert_chain: []
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
12
|
+
date: 2012-12-26 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: rake
|
16
|
+
requirement: &70147868153080 !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: 0.8.7
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: *70147868153080
|
25
|
+
- !ruby/object:Gem::Dependency
|
22
26
|
name: jsmin
|
23
|
-
|
27
|
+
requirement: &70147868152480 !ruby/object:Gem::Requirement
|
24
28
|
none: false
|
25
|
-
requirements:
|
29
|
+
requirements:
|
26
30
|
- - ~>
|
27
|
-
- !ruby/object:Gem::Version
|
28
|
-
hash: 21
|
29
|
-
segments:
|
30
|
-
- 1
|
31
|
-
- 0
|
32
|
-
- 1
|
31
|
+
- !ruby/object:Gem::Version
|
33
32
|
version: 1.0.1
|
34
|
-
prerelease: false
|
35
33
|
type: :runtime
|
36
|
-
requirement: *id001
|
37
|
-
- !ruby/object:Gem::Dependency
|
38
|
-
name: rake
|
39
|
-
version_requirements: &id002 !ruby/object:Gem::Requirement
|
40
|
-
none: false
|
41
|
-
requirements:
|
42
|
-
- - ">="
|
43
|
-
- !ruby/object:Gem::Version
|
44
|
-
hash: 49
|
45
|
-
segments:
|
46
|
-
- 0
|
47
|
-
- 8
|
48
|
-
- 7
|
49
|
-
version: 0.8.7
|
50
34
|
prerelease: false
|
51
|
-
|
52
|
-
|
53
|
-
- !ruby/object:Gem::Dependency
|
35
|
+
version_requirements: *70147868152480
|
36
|
+
- !ruby/object:Gem::Dependency
|
54
37
|
name: rspec
|
55
|
-
|
38
|
+
requirement: &70147868151940 !ruby/object:Gem::Requirement
|
56
39
|
none: false
|
57
|
-
requirements:
|
40
|
+
requirements:
|
58
41
|
- - ~>
|
59
|
-
- !ruby/object:Gem::Version
|
60
|
-
|
61
|
-
segments:
|
62
|
-
- 2
|
63
|
-
- 5
|
64
|
-
- 0
|
65
|
-
version: 2.5.0
|
66
|
-
prerelease: false
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: 2.12.0
|
67
44
|
type: :development
|
68
|
-
|
69
|
-
|
45
|
+
prerelease: false
|
46
|
+
version_requirements: *70147868151940
|
47
|
+
- !ruby/object:Gem::Dependency
|
70
48
|
name: cucumber
|
71
|
-
|
49
|
+
requirement: &70147868151180 !ruby/object:Gem::Requirement
|
72
50
|
none: false
|
73
|
-
requirements:
|
74
|
-
- -
|
75
|
-
- !ruby/object:Gem::Version
|
76
|
-
|
77
|
-
segments:
|
78
|
-
- 0
|
79
|
-
version: "0"
|
80
|
-
prerelease: false
|
51
|
+
requirements:
|
52
|
+
- - ! '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
81
55
|
type: :development
|
82
|
-
requirement: *id004
|
83
|
-
- !ruby/object:Gem::Dependency
|
84
|
-
name: jeweler
|
85
|
-
version_requirements: &id005 !ruby/object:Gem::Requirement
|
86
|
-
none: false
|
87
|
-
requirements:
|
88
|
-
- - ~>
|
89
|
-
- !ruby/object:Gem::Version
|
90
|
-
hash: 7
|
91
|
-
segments:
|
92
|
-
- 1
|
93
|
-
- 5
|
94
|
-
- 2
|
95
|
-
version: 1.5.2
|
96
56
|
prerelease: false
|
97
|
-
|
98
|
-
|
99
|
-
- !ruby/object:Gem::Dependency
|
57
|
+
version_requirements: *70147868151180
|
58
|
+
- !ruby/object:Gem::Dependency
|
100
59
|
name: test_notifier
|
101
|
-
|
60
|
+
requirement: &70147868112740 !ruby/object:Gem::Requirement
|
102
61
|
none: false
|
103
|
-
requirements:
|
62
|
+
requirements:
|
104
63
|
- - ~>
|
105
|
-
- !ruby/object:Gem::Version
|
106
|
-
hash: 31
|
107
|
-
segments:
|
108
|
-
- 0
|
109
|
-
- 3
|
110
|
-
- 6
|
64
|
+
- !ruby/object:Gem::Version
|
111
65
|
version: 0.3.6
|
112
|
-
prerelease: false
|
113
66
|
type: :development
|
114
|
-
|
115
|
-
|
67
|
+
prerelease: false
|
68
|
+
version_requirements: *70147868112740
|
69
|
+
- !ruby/object:Gem::Dependency
|
116
70
|
name: autotest
|
117
|
-
|
71
|
+
requirement: &70147868112120 !ruby/object:Gem::Requirement
|
118
72
|
none: false
|
119
|
-
requirements:
|
73
|
+
requirements:
|
120
74
|
- - ~>
|
121
|
-
- !ruby/object:Gem::Version
|
122
|
-
|
123
|
-
segments:
|
124
|
-
- 4
|
125
|
-
- 4
|
126
|
-
version: "4.4"
|
127
|
-
prerelease: false
|
75
|
+
- !ruby/object:Gem::Version
|
76
|
+
version: '4.4'
|
128
77
|
type: :development
|
129
|
-
requirement: *id007
|
130
|
-
- !ruby/object:Gem::Dependency
|
131
|
-
name: rcov
|
132
|
-
version_requirements: &id008 !ruby/object:Gem::Requirement
|
133
|
-
none: false
|
134
|
-
requirements:
|
135
|
-
- - ">="
|
136
|
-
- !ruby/object:Gem::Version
|
137
|
-
hash: 3
|
138
|
-
segments:
|
139
|
-
- 0
|
140
|
-
version: "0"
|
141
78
|
prerelease: false
|
79
|
+
version_requirements: *70147868112120
|
80
|
+
- !ruby/object:Gem::Dependency
|
81
|
+
name: simplecov
|
82
|
+
requirement: &70147868111580 !ruby/object:Gem::Requirement
|
83
|
+
none: false
|
84
|
+
requirements:
|
85
|
+
- - ! '>='
|
86
|
+
- !ruby/object:Gem::Version
|
87
|
+
version: '0'
|
142
88
|
type: :development
|
143
|
-
|
144
|
-
|
89
|
+
prerelease: false
|
90
|
+
version_requirements: *70147868111580
|
91
|
+
- !ruby/object:Gem::Dependency
|
145
92
|
name: coffee-script
|
146
|
-
|
93
|
+
requirement: &70147868110320 !ruby/object:Gem::Requirement
|
147
94
|
none: false
|
148
|
-
requirements:
|
149
|
-
- -
|
150
|
-
- !ruby/object:Gem::Version
|
151
|
-
hash: 7
|
152
|
-
segments:
|
153
|
-
- 2
|
154
|
-
- 2
|
155
|
-
- 0
|
95
|
+
requirements:
|
96
|
+
- - ! '>='
|
97
|
+
- !ruby/object:Gem::Version
|
156
98
|
version: 2.2.0
|
157
|
-
prerelease: false
|
158
99
|
type: :development
|
159
|
-
|
160
|
-
|
100
|
+
prerelease: false
|
101
|
+
version_requirements: *70147868110320
|
102
|
+
- !ruby/object:Gem::Dependency
|
161
103
|
name: therubyracer
|
162
|
-
|
104
|
+
requirement: &70147868109880 !ruby/object:Gem::Requirement
|
163
105
|
none: false
|
164
|
-
requirements:
|
165
|
-
- -
|
166
|
-
- !ruby/object:Gem::Version
|
167
|
-
|
168
|
-
|
169
|
-
- 0
|
170
|
-
version: "0"
|
106
|
+
requirements:
|
107
|
+
- - ! '>='
|
108
|
+
- !ruby/object:Gem::Version
|
109
|
+
version: '0'
|
110
|
+
type: :development
|
171
111
|
prerelease: false
|
112
|
+
version_requirements: *70147868109880
|
113
|
+
- !ruby/object:Gem::Dependency
|
114
|
+
name: rdoc
|
115
|
+
requirement: &70147868109260 !ruby/object:Gem::Requirement
|
116
|
+
none: false
|
117
|
+
requirements:
|
118
|
+
- - ~>
|
119
|
+
- !ruby/object:Gem::Version
|
120
|
+
version: '3.12'
|
172
121
|
type: :development
|
173
|
-
|
122
|
+
prerelease: false
|
123
|
+
version_requirements: *70147868109260
|
174
124
|
description: A rake task to minify javascripts and coffeescripts
|
175
|
-
email:
|
125
|
+
email:
|
126
|
+
- hello@matteocollina.com
|
176
127
|
executables: []
|
177
|
-
|
178
128
|
extensions: []
|
179
|
-
|
180
|
-
|
181
|
-
- LICENSE.txt
|
182
|
-
- README.rdoc
|
183
|
-
files:
|
129
|
+
extra_rdoc_files: []
|
130
|
+
files:
|
184
131
|
- .autotest
|
185
132
|
- .document
|
133
|
+
- .gitignore
|
186
134
|
- .rspec
|
187
135
|
- .rvmrc
|
136
|
+
- .travis.yml
|
188
137
|
- Gemfile
|
189
138
|
- Gemfile.lock
|
190
139
|
- LICENSE.txt
|
@@ -217,41 +166,48 @@ files:
|
|
217
166
|
- spec/rake/minify/source_spec.rb
|
218
167
|
- spec/rake/minify_spec.rb
|
219
168
|
- spec/spec_helper.rb
|
220
|
-
has_rdoc: true
|
221
169
|
homepage: http://github.com/mcollina/rake-minify
|
222
|
-
licenses:
|
223
|
-
- MIT
|
170
|
+
licenses: []
|
224
171
|
post_install_message:
|
225
172
|
rdoc_options: []
|
226
|
-
|
227
|
-
require_paths:
|
173
|
+
require_paths:
|
228
174
|
- lib
|
229
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
175
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
230
176
|
none: false
|
231
|
-
requirements:
|
232
|
-
- -
|
233
|
-
- !ruby/object:Gem::Version
|
234
|
-
|
235
|
-
|
236
|
-
- 0
|
237
|
-
version: "0"
|
238
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
177
|
+
requirements:
|
178
|
+
- - ! '>='
|
179
|
+
- !ruby/object:Gem::Version
|
180
|
+
version: '0'
|
181
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
239
182
|
none: false
|
240
|
-
requirements:
|
241
|
-
- -
|
242
|
-
- !ruby/object:Gem::Version
|
243
|
-
|
244
|
-
segments:
|
245
|
-
- 0
|
246
|
-
version: "0"
|
183
|
+
requirements:
|
184
|
+
- - ! '>='
|
185
|
+
- !ruby/object:Gem::Version
|
186
|
+
version: '0'
|
247
187
|
requirements: []
|
248
|
-
|
249
188
|
rubyforge_project:
|
250
|
-
rubygems_version: 1.
|
189
|
+
rubygems_version: 1.8.15
|
251
190
|
signing_key:
|
252
191
|
specification_version: 3
|
253
192
|
summary: A rake task to minify javascripts and coffeescripts
|
254
|
-
test_files:
|
193
|
+
test_files:
|
194
|
+
- features/coffeescript.feature
|
195
|
+
- features/js-expected/a.min.js
|
196
|
+
- features/js-expected/b.min.js
|
197
|
+
- features/js-expected/c-a-bare.min.js
|
198
|
+
- features/js-expected/c-a-wrapped.min.js
|
199
|
+
- features/js-expected/c-a.min.js
|
200
|
+
- features/js-sources/a.js
|
201
|
+
- features/js-sources/b.js
|
202
|
+
- features/js-sources/c-a-bare.js
|
203
|
+
- features/js-sources/c-a-wrapped.js
|
204
|
+
- features/js-sources/c-a.coffee
|
205
|
+
- features/js-sources/c-a.js
|
206
|
+
- features/minify.feature
|
207
|
+
- features/rake-interface.feature
|
208
|
+
- features/step_definitions/rake-minify_steps.rb
|
209
|
+
- features/support/env.rb
|
210
|
+
- features/support/generate_rakefiles.rb
|
255
211
|
- spec/rake/minify/group_spec.rb
|
256
212
|
- spec/rake/minify/source_spec.rb
|
257
213
|
- spec/rake/minify_spec.rb
|