rack-bundle 0.2.1 → 0.2.2
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.rb +21 -19
- data/lib/rack/bundle/bundles/base.rb +44 -0
- data/lib/rack/bundle/bundles/css.rb +5 -0
- data/lib/rack/bundle/bundles/js.rb +5 -0
- data/lib/rack/bundle/database_store.rb +3 -3
- data/lib/rack/bundle/file_system_store.rb +8 -2
- data/rack-bundle.gemspec +11 -8
- data/spec/bundles/base_spec.rb +55 -0
- data/spec/bundles/css_spec.rb +15 -0
- data/spec/bundles/js_spec.rb +15 -0
- data/spec/rack-bundle_spec.rb +6 -12
- data/spec/spec_helper.rb +11 -8
- data/spec/store/database_store_spec.rb +1 -1
- data/spec/store/file_system_store_spec.rb +7 -1
- metadata +13 -10
- data/lib/rack/bundle/css_bundle.rb +0 -17
- data/lib/rack/bundle/js_bundle.rb +0 -17
- data/spec/bundles/css_bundle_spec.rb +0 -15
- data/spec/bundles/js_bundle_spec.rb +0 -15
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.2.
|
1
|
+
0.2.2
|
data/lib/rack/bundle.rb
CHANGED
@@ -1,6 +1,14 @@
|
|
1
1
|
require 'rack'
|
2
2
|
require 'nokogiri'
|
3
3
|
|
4
|
+
class File
|
5
|
+
def contents
|
6
|
+
_contents = read
|
7
|
+
rewind
|
8
|
+
_contents
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
4
12
|
module Rack
|
5
13
|
class Bundle
|
6
14
|
SELECTORS = Struct.new('Selector', :js, :css).new(
|
@@ -10,8 +18,8 @@ module Rack
|
|
10
18
|
attr_accessor :storage, :document, :public_dir
|
11
19
|
autoload :FileSystemStore, 'rack/bundle/file_system_store'
|
12
20
|
autoload :DatabaseStore, 'rack/bundle/database_store'
|
13
|
-
autoload :JSBundle, 'rack/bundle/
|
14
|
-
autoload :CSSBundle, 'rack/bundle/
|
21
|
+
autoload :JSBundle, 'rack/bundle/bundles/js'
|
22
|
+
autoload :CSSBundle, 'rack/bundle/bundles/css'
|
15
23
|
|
16
24
|
def initialize app, options = {}
|
17
25
|
@app, @public_dir = app, options[:public_dir]
|
@@ -37,7 +45,6 @@ module Rack
|
|
37
45
|
end
|
38
46
|
|
39
47
|
def parse!
|
40
|
-
# http://github.com/logicaltext/rack-bundle/commit/8e7d0282b05b01a0cbfa59b519242046437605f6
|
41
48
|
body = ""
|
42
49
|
@response.each do |part| body << part end
|
43
50
|
@document = Nokogiri::HTML(body)
|
@@ -49,7 +56,7 @@ module Rack
|
|
49
56
|
@storage.add bundle unless @storage.has_bundle? bundle
|
50
57
|
bundle_node = @document.create_element 'script',
|
51
58
|
:type => 'text/javascript',
|
52
|
-
:src =>
|
59
|
+
:src => bundle.path,
|
53
60
|
:charset => 'utf-8'
|
54
61
|
@document.css(SELECTORS.js).first.before(bundle_node)
|
55
62
|
@document.css(SELECTORS.js).slice(1..-1).remove
|
@@ -61,13 +68,13 @@ module Rack
|
|
61
68
|
styles = local_css_nodes.group_by { |node| node.attribute('media').value rescue nil }
|
62
69
|
styles.each do |media, nodes|
|
63
70
|
next unless nodes.count > 1
|
64
|
-
stylesheets =
|
71
|
+
stylesheets = stylesheets_for nodes
|
65
72
|
bundle = CSSBundle.new *stylesheets
|
66
73
|
@storage.add bundle unless @storage.has_bundle? bundle
|
67
74
|
node = @document.create_element 'link',
|
68
75
|
:rel => 'stylesheet',
|
69
76
|
:type => 'text/css',
|
70
|
-
:href =>
|
77
|
+
:href => bundle.path,
|
71
78
|
:media => media
|
72
79
|
nodes.first.before(node)
|
73
80
|
nodes.map { |node| node.remove }
|
@@ -85,32 +92,27 @@ module Rack
|
|
85
92
|
end
|
86
93
|
|
87
94
|
def scripts
|
88
|
-
local_javascript_nodes.inject([]) do |
|
95
|
+
local_javascript_nodes.inject([]) do |files, node|
|
89
96
|
path = ::File.join(@public_dir, node.attribute('src').value)
|
90
|
-
|
91
|
-
|
97
|
+
files << ::File.open(path) if ::File.exists?(path)
|
98
|
+
files
|
92
99
|
end
|
93
100
|
end
|
94
101
|
|
95
|
-
def
|
96
|
-
nodes.inject([]) do |
|
102
|
+
def stylesheets_for nodes
|
103
|
+
nodes.inject([]) do |files, node|
|
97
104
|
path = ::File.join(@public_dir, node.attribute('href').value)
|
98
|
-
|
99
|
-
|
105
|
+
files << ::File.open(path) if ::File.exists?(path)
|
106
|
+
files
|
100
107
|
end
|
101
108
|
end
|
102
109
|
|
103
|
-
def bundle_path bundle
|
104
|
-
"/rack-bundle-#{bundle.hash}.#{bundle.extension}"
|
105
|
-
end
|
106
|
-
|
107
110
|
def not_found
|
108
111
|
[404, {'Content-Type' => 'text/plain'}, ['Not Found']]
|
109
112
|
end
|
110
113
|
|
111
114
|
def respond_with bundle
|
112
|
-
|
113
|
-
[200, {'Content-Type' => content_type}, [bundle.contents]]
|
115
|
+
[200, {'Content-Type' => bundle.mime_type}, [bundle.contents]]
|
114
116
|
end
|
115
117
|
end
|
116
118
|
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
require 'md5'
|
2
|
+
|
3
|
+
class Rack::Bundle::Base
|
4
|
+
class << self; attr_accessor :extension, :joiner, :mime_type; end
|
5
|
+
attr_accessor :contents, :files
|
6
|
+
|
7
|
+
def self.new_from_contents contents
|
8
|
+
instance = new
|
9
|
+
instance.contents = contents
|
10
|
+
instance
|
11
|
+
end
|
12
|
+
|
13
|
+
def initialize *files
|
14
|
+
@files = files
|
15
|
+
end
|
16
|
+
|
17
|
+
def contents
|
18
|
+
@contents ||= @files.map { |file| file.contents }.join(joiner)
|
19
|
+
end
|
20
|
+
|
21
|
+
def hash
|
22
|
+
@hash ||= MD5.new(@files.map { |file| File.basename(file.path) }.join).to_s
|
23
|
+
end
|
24
|
+
|
25
|
+
def path
|
26
|
+
"/rack-bundle-#{hash}.#{extension}"
|
27
|
+
end
|
28
|
+
|
29
|
+
def extension
|
30
|
+
self.class.extension
|
31
|
+
end
|
32
|
+
|
33
|
+
def joiner
|
34
|
+
self.class.joiner
|
35
|
+
end
|
36
|
+
|
37
|
+
def mime_type
|
38
|
+
self.class.mime_type
|
39
|
+
end
|
40
|
+
|
41
|
+
def == bundle
|
42
|
+
self.class == bundle.class && hash == bundle.hash
|
43
|
+
end
|
44
|
+
end
|
@@ -11,8 +11,8 @@ class Rack::Bundle::DatabaseStore
|
|
11
11
|
def find_bundle_by_hash hash
|
12
12
|
return nil unless result = @db[:rack_bundle].where(:hash => hash).first
|
13
13
|
result[:type] == 'js' ?
|
14
|
-
Rack::Bundle::JSBundle.
|
15
|
-
Rack::Bundle::CSSBundle.
|
14
|
+
Rack::Bundle::JSBundle.new_from_contents(result[:contents]) :
|
15
|
+
Rack::Bundle::CSSBundle.new_from_contents(result[:contents])
|
16
16
|
end
|
17
17
|
|
18
18
|
def add bundle
|
@@ -26,7 +26,7 @@ class Rack::Bundle::DatabaseStore
|
|
26
26
|
not find_bundle_by_hash(bundle.hash).nil?
|
27
27
|
end
|
28
28
|
|
29
|
-
private
|
29
|
+
private
|
30
30
|
def create_table!
|
31
31
|
@db.create_table! 'rack_bundle' do
|
32
32
|
String :hash
|
@@ -5,13 +5,14 @@ class Rack::Bundle::FileSystemStore
|
|
5
5
|
|
6
6
|
def initialize dir = Dir.tmpdir
|
7
7
|
@dir = dir
|
8
|
+
clear_existing_bundles
|
8
9
|
end
|
9
10
|
|
10
11
|
def find_bundle_by_hash hash
|
11
12
|
found = Dir["#{dir}/rack-bundle-#{hash}.*"]
|
12
13
|
return nil unless found.any?
|
13
14
|
type, contents = File.extname(found.first).sub(/^./, ''), File.read(File.join(dir, File.basename(found.first)))
|
14
|
-
type == 'js' ? Rack::Bundle::JSBundle.
|
15
|
+
type == 'js' ? Rack::Bundle::JSBundle.new_from_contents(contents) : Rack::Bundle::CSSBundle.new_from_contents(contents)
|
15
16
|
end
|
16
17
|
|
17
18
|
def has_bundle? bundle
|
@@ -22,5 +23,10 @@ class Rack::Bundle::FileSystemStore
|
|
22
23
|
File.open("#{dir}/rack-bundle-#{bundle.hash}.#{bundle.extension}", 'w') do |file|
|
23
24
|
file << bundle.contents
|
24
25
|
end
|
25
|
-
end
|
26
|
+
end
|
27
|
+
|
28
|
+
private
|
29
|
+
def clear_existing_bundles
|
30
|
+
Dir["#{dir}/rack-bundle-*"].each do |file| FileUtils.rm_f(file) end
|
31
|
+
end
|
26
32
|
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.2"
|
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-14}
|
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 = [
|
@@ -23,13 +23,15 @@ Gem::Specification.new do |s|
|
|
23
23
|
"VERSION",
|
24
24
|
"lib/rack-bundle.rb",
|
25
25
|
"lib/rack/bundle.rb",
|
26
|
-
"lib/rack/bundle/
|
26
|
+
"lib/rack/bundle/bundles/base.rb",
|
27
|
+
"lib/rack/bundle/bundles/css.rb",
|
28
|
+
"lib/rack/bundle/bundles/js.rb",
|
27
29
|
"lib/rack/bundle/database_store.rb",
|
28
30
|
"lib/rack/bundle/file_system_store.rb",
|
29
|
-
"lib/rack/bundle/js_bundle.rb",
|
30
31
|
"rack-bundle.gemspec",
|
31
|
-
"spec/bundles/
|
32
|
-
"spec/bundles/
|
32
|
+
"spec/bundles/base_spec.rb",
|
33
|
+
"spec/bundles/css_spec.rb",
|
34
|
+
"spec/bundles/js_spec.rb",
|
33
35
|
"spec/fixtures/hh-reset.css",
|
34
36
|
"spec/fixtures/index.html",
|
35
37
|
"spec/fixtures/iphone.css",
|
@@ -52,8 +54,9 @@ Gem::Specification.new do |s|
|
|
52
54
|
s.rubygems_version = %q{1.3.7}
|
53
55
|
s.summary = %q{Javascript and CSS bundling at the Rack level}
|
54
56
|
s.test_files = [
|
55
|
-
"spec/bundles/
|
56
|
-
"spec/bundles/
|
57
|
+
"spec/bundles/base_spec.rb",
|
58
|
+
"spec/bundles/css_spec.rb",
|
59
|
+
"spec/bundles/js_spec.rb",
|
57
60
|
"spec/rack-bundle_spec.rb",
|
58
61
|
"spec/spec_helper.rb",
|
59
62
|
"spec/store/database_store_spec.rb",
|
@@ -0,0 +1,55 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), '..', 'spec_helper')
|
2
|
+
|
3
|
+
describe Rack::Bundle::Base do
|
4
|
+
before do
|
5
|
+
@bundle = Rack::Bundle::Base.new $jquery, $mylib
|
6
|
+
Rack::Bundle::Base.stub(:joiner).and_return(";")
|
7
|
+
Rack::Bundle::Base.stub(:extension).and_return("js")
|
8
|
+
end
|
9
|
+
|
10
|
+
it { should respond_to :files }
|
11
|
+
it { should respond_to :contents }
|
12
|
+
it { should respond_to :hash }
|
13
|
+
it { should respond_to :extension }
|
14
|
+
|
15
|
+
it 'makes the contents of one or more file(s) accessible via #contents' do
|
16
|
+
@bundle.contents.should == [$jquery.contents, $mylib.contents].join(';')
|
17
|
+
end
|
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
|
21
|
+
end
|
22
|
+
|
23
|
+
it 'returns the path through which the bundle can be retrieved on #path' do
|
24
|
+
@bundle.path.should == "/rack-bundle-#{@bundle.hash}.#{@bundle.extension}"
|
25
|
+
end
|
26
|
+
|
27
|
+
context "bundled instances" do
|
28
|
+
before do
|
29
|
+
@bundled = Rack::Bundle::Base.new_from_contents "moo foo"
|
30
|
+
end
|
31
|
+
|
32
|
+
it "are instances created from an existing bundle in storage" do
|
33
|
+
end
|
34
|
+
|
35
|
+
it "are initialized through #new_from_contents, with the contents as argument" do
|
36
|
+
@bundled.is_a? Rack::Bundle::Base
|
37
|
+
end
|
38
|
+
|
39
|
+
it "have #contents" do
|
40
|
+
@bundled.contents.should == "moo foo"
|
41
|
+
end
|
42
|
+
|
43
|
+
it "doesn't have #files" do
|
44
|
+
@bundled.files.should be_empty
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
|
49
|
+
it "should be equal to another bundle of the same hash and class" do
|
50
|
+
another = Rack::Bundle::Base.new
|
51
|
+
subject.should_receive(:hash).and_return('moo')
|
52
|
+
another.should_receive(:hash).and_return('moo')
|
53
|
+
subject.should == another
|
54
|
+
end
|
55
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), '..', 'spec_helper')
|
2
|
+
|
3
|
+
describe Rack::Bundle::CSSBundle do
|
4
|
+
before do
|
5
|
+
@bundle = make_css_bundle
|
6
|
+
end
|
7
|
+
|
8
|
+
it "should return 'css' as #extension" do
|
9
|
+
subject.extension.should == "css"
|
10
|
+
end
|
11
|
+
|
12
|
+
it "should return 'text/css' as #mime_type" do
|
13
|
+
subject.mime_type.should == "text/css"
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), '..', 'spec_helper')
|
2
|
+
|
3
|
+
describe Rack::Bundle::JSBundle do
|
4
|
+
before do
|
5
|
+
@bundle = make_js_bundle
|
6
|
+
end
|
7
|
+
|
8
|
+
it "should return 'js' as #extension" do
|
9
|
+
subject.extension.should == "js"
|
10
|
+
end
|
11
|
+
|
12
|
+
it "should return 'text/javascript' as #mime_type" do
|
13
|
+
subject.mime_type.should == "text/javascript"
|
14
|
+
end
|
15
|
+
end
|
data/spec/rack-bundle_spec.rb
CHANGED
@@ -11,16 +11,16 @@ describe Rack::Bundle do
|
|
11
11
|
end
|
12
12
|
|
13
13
|
it 'defaults to FileSystemStore for storage' do
|
14
|
-
Rack::Bundle.new(index_page, :public_dir =>
|
14
|
+
Rack::Bundle.new(index_page, :public_dir => FIXTURES_PATH).storage.is_a? Rack::Bundle::FileSystemStore
|
15
15
|
end
|
16
16
|
|
17
17
|
context 'serving bundles' do
|
18
18
|
before do
|
19
19
|
@jsbundle, @cssbundle = make_js_bundle, make_css_bundle
|
20
|
-
@bundle.storage.add
|
20
|
+
@bundle.storage.add @jsbundle
|
21
21
|
@bundle.storage.add @cssbundle
|
22
|
-
@js_request = Rack::MockRequest.env_for @
|
23
|
-
@css_request = Rack::MockRequest.env_for @
|
22
|
+
@js_request = Rack::MockRequest.env_for @jsbundle.path
|
23
|
+
@css_request = Rack::MockRequest.env_for @cssbundle.path
|
24
24
|
end
|
25
25
|
|
26
26
|
it "fetches a bundle from storage and serves if the request URL matches" do
|
@@ -59,6 +59,7 @@ describe Rack::Bundle do
|
|
59
59
|
before do
|
60
60
|
status, headers, @response = @bundle.call(@env)
|
61
61
|
end
|
62
|
+
|
62
63
|
it "doesn't happen unless the response is HTML" do
|
63
64
|
bundle = Rack::Bundle.new plain_text, :public_dir => FIXTURES_PATH
|
64
65
|
bundle.should_not_receive :parse!
|
@@ -75,7 +76,7 @@ describe Rack::Bundle do
|
|
75
76
|
@simple = Rack::Bundle.new simple_page, :public_dir => FIXTURES_PATH
|
76
77
|
end
|
77
78
|
|
78
|
-
it "leaves
|
79
|
+
it "leaves Javascripts that are not locally hosted alone" do
|
79
80
|
@bundle.call @env
|
80
81
|
@bundle.document.css
|
81
82
|
end
|
@@ -103,11 +104,4 @@ describe Rack::Bundle do
|
|
103
104
|
end
|
104
105
|
end
|
105
106
|
end
|
106
|
-
|
107
|
-
context 'private methods' do
|
108
|
-
it 'returns a URL to a bundle on #bundle_path' do
|
109
|
-
@jsbundle = Rack::Bundle::JSBundle.new 'omg'
|
110
|
-
@bundle.send(:bundle_path, @jsbundle).should == "/rack-bundle-#{@jsbundle.hash}.js"
|
111
|
-
end
|
112
|
-
end
|
113
107
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -2,45 +2,48 @@ $:.unshift File.join(File.dirname(__FILE__), '..', 'lib')
|
|
2
2
|
require 'spec'
|
3
3
|
require 'fileutils'
|
4
4
|
require 'rack/bundle'
|
5
|
+
require 'rack/bundle/bundles/base'
|
5
6
|
require 'tmpdir'
|
7
|
+
|
6
8
|
include Rack::Utils
|
7
9
|
alias :h :escape_html
|
8
10
|
|
9
11
|
FIXTURES_PATH = File.join(File.dirname(__FILE__), 'fixtures')
|
10
12
|
|
11
13
|
def fixture name
|
12
|
-
File.
|
14
|
+
File.open(File.join(FIXTURES_PATH, name))
|
13
15
|
end
|
14
16
|
|
15
17
|
def make_js_bundle
|
16
|
-
Rack::Bundle::JSBundle.new
|
18
|
+
Rack::Bundle::JSBundle.new $jquery, $mylib
|
17
19
|
end
|
18
20
|
|
19
21
|
def make_css_bundle
|
20
|
-
Rack::Bundle::CSSBundle.new
|
22
|
+
Rack::Bundle::CSSBundle.new $reset, $screen
|
23
|
+
end
|
24
|
+
|
25
|
+
def filename file
|
26
|
+
File.basename file.path
|
21
27
|
end
|
22
28
|
|
23
29
|
def index_page
|
24
|
-
lambda { |env| [200, { 'Content-Type' => 'text/html' }, [fixture('index.html')]] }
|
30
|
+
lambda { |env| [200, { 'Content-Type' => 'text/html' }, [fixture('index.html').contents]] }
|
25
31
|
end
|
26
32
|
|
27
33
|
def simple_page
|
28
|
-
lambda { |env| [200, { 'Content-Type' => 'text/html' }, [fixture('simple.html')]] }
|
34
|
+
lambda { |env| [200, { 'Content-Type' => 'text/html' }, [fixture('simple.html').contents]] }
|
29
35
|
end
|
30
36
|
|
31
37
|
def plain_text
|
32
38
|
lambda { |env| [200, { 'Content-Type' => 'text/plain' }, ['plain texto']] }
|
33
39
|
end
|
34
40
|
|
35
|
-
|
36
41
|
Spec::Runner.configure do |config|
|
37
42
|
$jquery, $mylib = fixture('jquery-1.4.1.min.js'), fixture('mylib.js')
|
38
43
|
$reset, $screen = fixture('reset.css'), fixture('screen.css')
|
39
44
|
$index = fixture('index.html')
|
40
45
|
$doc = Nokogiri::HTML($index)
|
41
|
-
|
42
46
|
config.after(:all) do
|
43
47
|
`rm -f #{FIXTURES_PATH}/rack-bundle*`
|
44
48
|
end
|
45
|
-
|
46
49
|
end
|
@@ -23,7 +23,7 @@ describe Rack::Bundle::DatabaseStore do
|
|
23
23
|
it 'takes a bundle hash as argument and returns a matching bundle' do
|
24
24
|
jsbundle = Rack::Bundle::JSBundle.new fixture('jquery-1.4.1.min.js'), fixture('mylib.js')
|
25
25
|
@db_store.db[:rack_bundle].insert(:hash => jsbundle.hash, :contents => jsbundle.contents, :type => 'js')
|
26
|
-
@db_store.find_bundle_by_hash(jsbundle.hash).should
|
26
|
+
@db_store.find_bundle_by_hash(jsbundle.hash).should be_an_instance_of Rack::Bundle::JSBundle
|
27
27
|
end
|
28
28
|
it "returns nil when a bundle can't be found with a matching hash" do
|
29
29
|
@db_store.find_bundle_by_hash('non existant').should be_nil
|
@@ -17,7 +17,13 @@ describe Rack::Bundle::FileSystemStore do
|
|
17
17
|
end
|
18
18
|
|
19
19
|
it "finds a bundle by it's hash on #find_bundle_by_hash" do
|
20
|
-
@storage.find_bundle_by_hash(@jsbundle.hash).should
|
20
|
+
@storage.find_bundle_by_hash(@jsbundle.hash).should be_an_instance_of Rack::Bundle::JSBundle
|
21
|
+
end
|
22
|
+
|
23
|
+
it "clears existing bundles when initializing" do
|
24
|
+
FileUtils.touch FIXTURES_PATH + '/rack-bundle-1234567890.js'
|
25
|
+
Rack::Bundle::FileSystemStore.new FIXTURES_PATH
|
26
|
+
File.exists?(FIXTURES_PATH + '/rack-bundle-1234567890.js').should be_false
|
21
27
|
end
|
22
28
|
|
23
29
|
context 'storing bundles in the file system' do
|
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: 19
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 2
|
9
|
-
-
|
10
|
-
version: 0.2.
|
9
|
+
- 2
|
10
|
+
version: 0.2.2
|
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-14 00:00:00 +10:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
@@ -98,13 +98,15 @@ files:
|
|
98
98
|
- VERSION
|
99
99
|
- lib/rack-bundle.rb
|
100
100
|
- lib/rack/bundle.rb
|
101
|
-
- lib/rack/bundle/
|
101
|
+
- lib/rack/bundle/bundles/base.rb
|
102
|
+
- lib/rack/bundle/bundles/css.rb
|
103
|
+
- lib/rack/bundle/bundles/js.rb
|
102
104
|
- lib/rack/bundle/database_store.rb
|
103
105
|
- lib/rack/bundle/file_system_store.rb
|
104
|
-
- lib/rack/bundle/js_bundle.rb
|
105
106
|
- rack-bundle.gemspec
|
106
|
-
- spec/bundles/
|
107
|
-
- spec/bundles/
|
107
|
+
- spec/bundles/base_spec.rb
|
108
|
+
- spec/bundles/css_spec.rb
|
109
|
+
- spec/bundles/js_spec.rb
|
108
110
|
- spec/fixtures/hh-reset.css
|
109
111
|
- spec/fixtures/index.html
|
110
112
|
- spec/fixtures/iphone.css
|
@@ -155,8 +157,9 @@ signing_key:
|
|
155
157
|
specification_version: 3
|
156
158
|
summary: Javascript and CSS bundling at the Rack level
|
157
159
|
test_files:
|
158
|
-
- spec/bundles/
|
159
|
-
- spec/bundles/
|
160
|
+
- spec/bundles/base_spec.rb
|
161
|
+
- spec/bundles/css_spec.rb
|
162
|
+
- spec/bundles/js_spec.rb
|
160
163
|
- spec/rack-bundle_spec.rb
|
161
164
|
- spec/spec_helper.rb
|
162
165
|
- spec/store/database_store_spec.rb
|
@@ -1,17 +0,0 @@
|
|
1
|
-
require 'md5'
|
2
|
-
|
3
|
-
class Rack::Bundle::CSSBundle
|
4
|
-
attr_accessor :contents, :hash
|
5
|
-
def initialize *files
|
6
|
-
@contents = files.join "\n"
|
7
|
-
@hash = MD5.new(@contents).to_s
|
8
|
-
end
|
9
|
-
|
10
|
-
def extension
|
11
|
-
'css'
|
12
|
-
end
|
13
|
-
|
14
|
-
def == bundle
|
15
|
-
self.class == bundle.class && hash == bundle.hash
|
16
|
-
end
|
17
|
-
end
|
@@ -1,17 +0,0 @@
|
|
1
|
-
require 'md5'
|
2
|
-
|
3
|
-
class Rack::Bundle::JSBundle
|
4
|
-
attr_accessor :contents, :hash
|
5
|
-
def initialize *files
|
6
|
-
@contents = files.join ';'
|
7
|
-
@hash = MD5.new(@contents).to_s
|
8
|
-
end
|
9
|
-
|
10
|
-
def extension
|
11
|
-
'js'
|
12
|
-
end
|
13
|
-
|
14
|
-
def == bundle
|
15
|
-
self.class == bundle.class && hash == bundle.hash
|
16
|
-
end
|
17
|
-
end
|
@@ -1,15 +0,0 @@
|
|
1
|
-
require File.join(File.dirname(__FILE__), '..', 'spec_helper')
|
2
|
-
|
3
|
-
describe Rack::Bundle::CSSBundle do
|
4
|
-
before do
|
5
|
-
@bundle = Rack::Bundle::CSSBundle.new $reset, $screen
|
6
|
-
end
|
7
|
-
|
8
|
-
it 'makes the contents of one or more stylesheets accessible via #contents' do
|
9
|
-
@bundle.contents.should == [$reset, $screen].join("\n")
|
10
|
-
end
|
11
|
-
|
12
|
-
it 'creates a MD5 hash out of the contents of the bundle' do
|
13
|
-
@bundle.hash.should == MD5.new(@bundle.contents).to_s
|
14
|
-
end
|
15
|
-
end
|
@@ -1,15 +0,0 @@
|
|
1
|
-
require File.join(File.dirname(__FILE__), '..', 'spec_helper')
|
2
|
-
|
3
|
-
describe Rack::Bundle::JSBundle do
|
4
|
-
before do
|
5
|
-
@bundle = Rack::Bundle::JSBundle.new $jquery, $mylib
|
6
|
-
end
|
7
|
-
|
8
|
-
it 'makes the contents of one or more Javascript file(s) accessible via #contents' do
|
9
|
-
@bundle.contents.should == [$jquery, $mylib].join(';')
|
10
|
-
end
|
11
|
-
|
12
|
-
it 'creates a MD5 hash out of the contents of the bundle' do
|
13
|
-
@bundle.hash.should == MD5.new(@bundle.contents).to_s
|
14
|
-
end
|
15
|
-
end
|