rapper 0.4.0 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.markdown +22 -0
- data/VERSION +1 -1
- data/lib/rapper/definition.rb +10 -3
- data/lib/rapper/utils.rb +1 -1
- data/rapper.gemspec +10 -3
- data/spec/fixtures/config/asset_definitions/base/javascripts.yml +1 -1
- data/spec/fixtures/config/asset_definitions/custom_destination/javascripts.yml +1 -1
- data/spec/fixtures/javascripts/{simple_2.js → subfolder/simple_2.js} +0 -0
- data/spec/fixtures/test_cases/combination/assets.yml +5 -0
- data/spec/fixtures/test_cases/combination/definitions/css.yml +16 -0
- data/spec/fixtures/test_cases/combination/definitions/js.yml +16 -0
- data/spec/fixtures/test_cases/combination/expected/javascripts/base.js +1 -0
- data/spec/fixtures/test_cases/combination/expected/javascripts/base_combined.js +1 -0
- data/spec/fixtures/test_cases/combination/expected/stylesheets/base.css +1 -0
- data/spec/fixtures/test_cases/combination/expected/stylesheets/base_combined.css +1 -0
- data/spec/fixtures/test_cases/compression/definitions/js.yml +2 -2
- data/spec/fixtures/test_cases/concatenation/definitions/js.yml +2 -2
- data/spec/rapper_spec.rb +5 -5
- metadata +12 -5
data/README.markdown
CHANGED
@@ -72,6 +72,27 @@ The above definition will create two asset files: `public/assets/base.js` and `p
|
|
72
72
|
|
73
73
|
**Note:** Definition files are YAML ordered mapping documents. This is so that version updates (which involves rapper updating the version numbers and writing out the updated definition as YAML) don't change the order of the file. This is especially useful when using git and merging branches because it prevents nasty merge conflicts.
|
74
74
|
|
75
|
+
## Combining bundles
|
76
|
+
|
77
|
+
Rapper allows you to combine bundles by referring to the other bundle with a "+"
|
78
|
+
prefix in the files list:
|
79
|
+
|
80
|
+
- assets: !omap
|
81
|
+
- base: !omap
|
82
|
+
- files:
|
83
|
+
- mootools
|
84
|
+
- version: 7b06
|
85
|
+
- extras: !omap
|
86
|
+
- files:
|
87
|
+
- mootools-more
|
88
|
+
- protovis
|
89
|
+
- version: 25c1
|
90
|
+
- full: !omap
|
91
|
+
- files:
|
92
|
+
- +base
|
93
|
+
- +extras
|
94
|
+
- version: db62
|
95
|
+
|
75
96
|
## View helpers
|
76
97
|
|
77
98
|
Rapper provides helper methods to generate HTML include tags for your assets in the `Rapper::ViewHelpers` module. Simply `include` it in the appropriate place for your web app / framework / widget / spaceship / row boat / whatever. It's automaticallly included for Merb because Merb people are notoriously lazy.
|
@@ -129,6 +150,7 @@ Rapper's got a Gemfile. You know what to do.
|
|
129
150
|
|
130
151
|
## Version history
|
131
152
|
|
153
|
+
* **0.5.0** - Added ability to nest bundles.
|
132
154
|
* **0.4.0** - Switching to YUI Compressor for JavaScript compression due to its better handling of local variable compressing in scopes with eval() usage (I'm looking at you, ExtJS). Adding `component_tag_root` and `asset_tag_root` options to allow better control over URLs.
|
133
155
|
* **0.3.0** - Remove hard Closure Compiler dependency (it will still need to be installed to compress JS), shorter view helper method names.
|
134
156
|
* **0.2.4** - Add tag_paths() to get all file paths for a given asset.
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.5.0
|
data/lib/rapper/definition.rb
CHANGED
@@ -3,6 +3,8 @@ module Rapper
|
|
3
3
|
# easier.
|
4
4
|
class Definition
|
5
5
|
|
6
|
+
COMBINATION_PREFIX = /^\+/
|
7
|
+
|
6
8
|
def initialize( path )
|
7
9
|
@path = path
|
8
10
|
@type = File.basename( path, ".yml" )
|
@@ -104,9 +106,14 @@ module Rapper
|
|
104
106
|
end
|
105
107
|
|
106
108
|
( spec["files"] || [] ).map do |file|
|
107
|
-
|
108
|
-
|
109
|
-
|
109
|
+
if file =~ COMBINATION_PREFIX
|
110
|
+
asset_name = file.sub( COMBINATION_PREFIX, "" )
|
111
|
+
self.component_paths( asset_name, root )
|
112
|
+
else
|
113
|
+
file_name = "#{file}.#{self.suffix}"
|
114
|
+
File.join( root, file_name )
|
115
|
+
end
|
116
|
+
end.flatten
|
110
117
|
end
|
111
118
|
end
|
112
119
|
end
|
data/lib/rapper/utils.rb
CHANGED
@@ -15,7 +15,7 @@ module Rapper
|
|
15
15
|
#
|
16
16
|
# @param [String] destination_file Destination for concatenated output.
|
17
17
|
def join_files( source_files, destination_file )
|
18
|
-
source_files = Array( source_files )
|
18
|
+
source_files = Array( source_files )
|
19
19
|
source_files.any? do |path|
|
20
20
|
unless File.exists?( path )
|
21
21
|
raise Rapper::Errors::MissingComponentFile, "#{path} doesn't exist."
|
data/rapper.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{rapper}
|
8
|
-
s.version = "0.
|
8
|
+
s.version = "0.5.0"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Tyson Tate"]
|
12
|
-
s.date = %q{2011-
|
12
|
+
s.date = %q{2011-09-02}
|
13
13
|
s.description = %q{Static asset packager and compressor with versioning and built-in view helpers. Compresses files only when they need compressing.}
|
14
14
|
s.email = %q{tyson@tysontate.com}
|
15
15
|
s.extra_rdoc_files = [
|
@@ -44,9 +44,16 @@ Gem::Specification.new do |s|
|
|
44
44
|
"spec/fixtures/config/asset_definitions/missing_file/stylesheets.yml",
|
45
45
|
"spec/fixtures/config/assets.yml",
|
46
46
|
"spec/fixtures/javascripts/simple_1.js",
|
47
|
-
"spec/fixtures/javascripts/simple_2.js",
|
47
|
+
"spec/fixtures/javascripts/subfolder/simple_2.js",
|
48
48
|
"spec/fixtures/stylesheets/simple_1.css",
|
49
49
|
"spec/fixtures/stylesheets/simple_2.css",
|
50
|
+
"spec/fixtures/test_cases/combination/assets.yml",
|
51
|
+
"spec/fixtures/test_cases/combination/definitions/css.yml",
|
52
|
+
"spec/fixtures/test_cases/combination/definitions/js.yml",
|
53
|
+
"spec/fixtures/test_cases/combination/expected/javascripts/base.js",
|
54
|
+
"spec/fixtures/test_cases/combination/expected/javascripts/base_combined.js",
|
55
|
+
"spec/fixtures/test_cases/combination/expected/stylesheets/base.css",
|
56
|
+
"spec/fixtures/test_cases/combination/expected/stylesheets/base_combined.css",
|
50
57
|
"spec/fixtures/test_cases/compression/assets.yml",
|
51
58
|
"spec/fixtures/test_cases/compression/definitions/css.yml",
|
52
59
|
"spec/fixtures/test_cases/compression/definitions/js.yml",
|
File without changes
|
@@ -0,0 +1,16 @@
|
|
1
|
+
--- !omap
|
2
|
+
- root: spec/fixtures/stylesheets
|
3
|
+
- asset_tag_root: /stylesheets/assets
|
4
|
+
- component_tag_root: /stylesheets
|
5
|
+
- suffix: css
|
6
|
+
- assets: !omap
|
7
|
+
- base: !omap
|
8
|
+
- files:
|
9
|
+
- simple_1
|
10
|
+
- simple_2
|
11
|
+
- version: 683e
|
12
|
+
- base_combined: !omap
|
13
|
+
- files:
|
14
|
+
- +base
|
15
|
+
- simple_1
|
16
|
+
- version: 0bb9
|
@@ -0,0 +1,16 @@
|
|
1
|
+
--- !omap
|
2
|
+
- root: spec/fixtures/javascripts
|
3
|
+
- asset_tag_root: /javascripts/assets
|
4
|
+
- component_tag_root: /javascripts
|
5
|
+
- suffix: js
|
6
|
+
- assets: !omap
|
7
|
+
- base: !omap
|
8
|
+
- files:
|
9
|
+
- simple_1
|
10
|
+
- subfolder/simple_2
|
11
|
+
- version: f3d9
|
12
|
+
- base_combined: !omap
|
13
|
+
- files:
|
14
|
+
- subfolder/simple_2
|
15
|
+
- +base
|
16
|
+
- version: ccfc
|
@@ -0,0 +1 @@
|
|
1
|
+
var x=1;var y=2;function a(){return true}a=1;b=2;function b(){return false};
|
@@ -0,0 +1 @@
|
|
1
|
+
a=1;b=2;function b(){return false}var x=1;var y=2;function a(){return true}a=1;b=2;function b(){return false};
|
@@ -0,0 +1 @@
|
|
1
|
+
body{margin:0;color:#333}*{margin:0;color:#fff}
|
@@ -0,0 +1 @@
|
|
1
|
+
body{margin:0;color:#333}*{margin:0;color:#fff}body{margin:0;color:#333}
|
data/spec/rapper_spec.rb
CHANGED
@@ -62,7 +62,7 @@ describe Rapper do
|
|
62
62
|
["version", "98bc"]]
|
63
63
|
],
|
64
64
|
["multiple_files", [
|
65
|
-
["files", ["simple_1", "simple_2"]],
|
65
|
+
["files", ["simple_1", "subfolder/simple_2"]],
|
66
66
|
["version", "f3d9"]]
|
67
67
|
]
|
68
68
|
]
|
@@ -113,7 +113,7 @@ describe Rapper do
|
|
113
113
|
["version", "98bc"]
|
114
114
|
]
|
115
115
|
rapper.definitions["javascripts"].assets["multiple_files"].should == [
|
116
|
-
["files", ["simple_1", "simple_2"]],
|
116
|
+
["files", ["simple_1", "subfolder/simple_2"]],
|
117
117
|
["version", "f3d9"]
|
118
118
|
]
|
119
119
|
end
|
@@ -155,7 +155,7 @@ describe Rapper do
|
|
155
155
|
|
156
156
|
it "doesn't use the defaut '/assets' tag root" do
|
157
157
|
@rapper.js_tag( "javascripts", "multiple_files" ).should ==
|
158
|
-
"<script src=\"/javascripts/components/simple_1.js?v=f3d9\"></script>\n<script src=\"/javascripts/components/simple_2.js?v=f3d9\"></script>"
|
158
|
+
"<script src=\"/javascripts/components/simple_1.js?v=f3d9\"></script>\n<script src=\"/javascripts/components/subfolder/simple_2.js?v=f3d9\"></script>"
|
159
159
|
end
|
160
160
|
end
|
161
161
|
|
@@ -167,7 +167,7 @@ describe Rapper do
|
|
167
167
|
|
168
168
|
rapper = Rapper::Engine.new( "spec/fixtures/config/assets.yml", "test_tag_paths_no_bundle" )
|
169
169
|
rapper.tag_paths( "javascripts", "multiple_files" ).should ==
|
170
|
-
["/javascripts/simple_1.js?v=f3d9", "/javascripts/simple_2.js?v=f3d9"]
|
170
|
+
["/javascripts/simple_1.js?v=f3d9", "/javascripts/subfolder/simple_2.js?v=f3d9"]
|
171
171
|
end
|
172
172
|
end
|
173
173
|
|
@@ -235,7 +235,7 @@ describe Rapper do
|
|
235
235
|
@controller.include_javascripts( :single_file ).should ==
|
236
236
|
"<script src=\"/javascripts/simple_1.js\"></script>"
|
237
237
|
@controller.include_javascripts( :multiple_files ).should ==
|
238
|
-
"<script src=\"/javascripts/simple_1.js\"></script>\n<script src=\"/javascripts/simple_2.js\"></script>"
|
238
|
+
"<script src=\"/javascripts/simple_1.js\"></script>\n<script src=\"/javascripts/subfolder/simple_2.js\"></script>"
|
239
239
|
end
|
240
240
|
|
241
241
|
it "returns tags for asset when bundling is on" do
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rapper
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 11
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
|
-
-
|
8
|
+
- 5
|
9
9
|
- 0
|
10
|
-
version: 0.
|
10
|
+
version: 0.5.0
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Tyson Tate
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-
|
18
|
+
date: 2011-09-02 00:00:00 -07:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
@@ -167,9 +167,16 @@ files:
|
|
167
167
|
- spec/fixtures/config/asset_definitions/missing_file/stylesheets.yml
|
168
168
|
- spec/fixtures/config/assets.yml
|
169
169
|
- spec/fixtures/javascripts/simple_1.js
|
170
|
-
- spec/fixtures/javascripts/simple_2.js
|
170
|
+
- spec/fixtures/javascripts/subfolder/simple_2.js
|
171
171
|
- spec/fixtures/stylesheets/simple_1.css
|
172
172
|
- spec/fixtures/stylesheets/simple_2.css
|
173
|
+
- spec/fixtures/test_cases/combination/assets.yml
|
174
|
+
- spec/fixtures/test_cases/combination/definitions/css.yml
|
175
|
+
- spec/fixtures/test_cases/combination/definitions/js.yml
|
176
|
+
- spec/fixtures/test_cases/combination/expected/javascripts/base.js
|
177
|
+
- spec/fixtures/test_cases/combination/expected/javascripts/base_combined.js
|
178
|
+
- spec/fixtures/test_cases/combination/expected/stylesheets/base.css
|
179
|
+
- spec/fixtures/test_cases/combination/expected/stylesheets/base_combined.css
|
173
180
|
- spec/fixtures/test_cases/compression/assets.yml
|
174
181
|
- spec/fixtures/test_cases/compression/definitions/css.yml
|
175
182
|
- spec/fixtures/test_cases/compression/definitions/js.yml
|