rack-bundle 0.2.2 → 0.2.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/VERSION +1 -1
- data/lib/rack/bundle/bundles/base.rb +1 -1
- data/lib/rack/bundle/bundles/js.rb +19 -0
- data/rack-bundle.gemspec +2 -2
- data/spec/bundles/base_spec.rb +2 -2
- data/spec/bundles/js_spec.rb +8 -3
- data/spec/store/file_system_store_spec.rb +4 -4
- metadata +4 -4
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.2.
|
1
|
+
0.2.3
|
@@ -2,4 +2,23 @@ require File.dirname(__FILE__) + '/base'
|
|
2
2
|
|
3
3
|
class Rack::Bundle::JSBundle < Rack::Bundle::Base
|
4
4
|
@extension, @joiner, @mime_type = "js", ";", "text/javascript"
|
5
|
+
|
6
|
+
def contents
|
7
|
+
@contents ||= @files.map { |file| file.contents }.join(joiner)
|
8
|
+
end
|
9
|
+
|
10
|
+
# Leaving this comment here for the sake of documenting my intention.
|
11
|
+
# For some reason, opening the pipe below makes Rack hang indefinitely,
|
12
|
+
# even though specs pass.
|
13
|
+
#
|
14
|
+
# def compress javascript
|
15
|
+
# compressed = ""
|
16
|
+
# open(%Q{| #{Rack::Bundle.vendor_path}/jsmin.rb}, 'w+') do |process|
|
17
|
+
# process.write javascript
|
18
|
+
# process.close_write
|
19
|
+
# compressed = process.read
|
20
|
+
# end
|
21
|
+
# puts compressed
|
22
|
+
# compressed
|
23
|
+
# end
|
5
24
|
end
|
data/rack-bundle.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{rack-bundle}
|
8
|
-
s.version = "0.2.
|
8
|
+
s.version = "0.2.3"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Julio Cesar Ody"]
|
12
|
-
s.date = %q{2010-07-
|
12
|
+
s.date = %q{2010-07-15}
|
13
13
|
s.description = %q{Javascript and CSS bundling at the Rack level}
|
14
14
|
s.email = %q{julio.ody@gmail.com}
|
15
15
|
s.extra_rdoc_files = [
|
data/spec/bundles/base_spec.rb
CHANGED
@@ -16,8 +16,8 @@ describe Rack::Bundle::Base do
|
|
16
16
|
@bundle.contents.should == [$jquery.contents, $mylib.contents].join(';')
|
17
17
|
end
|
18
18
|
|
19
|
-
it 'creates a MD5 hash out of the file names in the bundle' do
|
20
|
-
@bundle.hash.should == MD5.new([filename($jquery), filename($mylib)].join).to_s
|
19
|
+
it 'creates a MD5 hash out of the file names and mtimes in the bundle' do
|
20
|
+
@bundle.hash.should == MD5.new([filename($jquery) + File.mtime($jquery.path).to_s, filename($mylib) + File.mtime($mylib.path).to_s].join).to_s
|
21
21
|
end
|
22
22
|
|
23
23
|
it 'returns the path through which the bundle can be retrieved on #path' do
|
data/spec/bundles/js_spec.rb
CHANGED
@@ -4,12 +4,17 @@ describe Rack::Bundle::JSBundle do
|
|
4
4
|
before do
|
5
5
|
@bundle = make_js_bundle
|
6
6
|
end
|
7
|
-
|
7
|
+
|
8
8
|
it "should return 'js' as #extension" do
|
9
9
|
subject.extension.should == "js"
|
10
10
|
end
|
11
|
-
|
11
|
+
|
12
12
|
it "should return 'text/javascript' as #mime_type" do
|
13
13
|
subject.mime_type.should == "text/javascript"
|
14
|
-
end
|
14
|
+
end
|
15
|
+
|
16
|
+
it 'compresses Javascript when you try to access the #contents' do
|
17
|
+
pending
|
18
|
+
@bundle.contents.length.should < [$jquery.contents, $mylib.contents].join(";").length
|
19
|
+
end
|
15
20
|
end
|
@@ -25,12 +25,12 @@ describe Rack::Bundle::FileSystemStore do
|
|
25
25
|
Rack::Bundle::FileSystemStore.new FIXTURES_PATH
|
26
26
|
File.exists?(FIXTURES_PATH + '/rack-bundle-1234567890.js').should be_false
|
27
27
|
end
|
28
|
+
|
29
|
+
it "checks if a bundle exists with #has_bundle?" do
|
30
|
+
@storage.has_bundle?(@jsbundle).should be_true
|
31
|
+
end
|
28
32
|
|
29
33
|
context 'storing bundles in the file system' do
|
30
|
-
it "checks if a bundle exists with #has_bundle?" do
|
31
|
-
@storage.has_bundle?(@jsbundle).should be_true
|
32
|
-
end
|
33
|
-
|
34
34
|
it 'skips saving a bundle if one with a matching hash already exists' do
|
35
35
|
File.should_not_receive(:open)
|
36
36
|
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rack-bundle
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 17
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 2
|
9
|
-
-
|
10
|
-
version: 0.2.
|
9
|
+
- 3
|
10
|
+
version: 0.2.3
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Julio Cesar Ody
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2010-07-
|
18
|
+
date: 2010-07-15 00:00:00 +10:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|