rapper 0.2.0 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- data/README.markdown +13 -3
- data/VERSION +1 -1
- data/lib/rapper/html_tags.rb +21 -9
- data/rapper.gemspec +1 -1
- data/spec/rapper_spec.rb +8 -0
- metadata +3 -3
data/README.markdown
CHANGED
@@ -71,7 +71,14 @@ The above definition will create two asset files: `public/assets/base.js` and `p
|
|
71
71
|
|
72
72
|
## View helpers
|
73
73
|
|
74
|
-
Rapper provides helper methods to generate HTML include tags for your assets in the `Rapper::ViewHelpers
|
74
|
+
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.
|
75
|
+
|
76
|
+
Rapper's view helpers respect your `bundle` setting. If it is `true`, a singe include tag for the joined asset will be returned. If bundling is `false`, it will return include tags for every component file of the asset (as a single string).
|
77
|
+
|
78
|
+
Rapper provides helper methods for each definition type. For instance, if you have "javascripts.yml" and "stylesheets.yml" definition files, Rapper will provide `rapper_javascripts_tag` and `rapper_stylesheets_tag` helper methods. Just pass the name of the asset to the helper method as a symbol and the correct HTML will be returned:
|
79
|
+
|
80
|
+
rapper_stylesheets_tag :mootools
|
81
|
+
# <script src="/javascripts/assets/mootools.js"></script>
|
75
82
|
|
76
83
|
## Versioning
|
77
84
|
|
@@ -114,11 +121,14 @@ Rapper's got a Gemfile. You know what to do.
|
|
114
121
|
* Watch for CoffeeScript changes and automatically compile
|
115
122
|
* Watch for Sass changes and automatically compile
|
116
123
|
* Per-asset configuration overrides
|
117
|
-
* Sinatra helpers
|
118
|
-
* Rails helpers
|
124
|
+
* Auto-setup Sinatra helpers (?)
|
125
|
+
* Auto-setup Rails helpers (?)
|
119
126
|
|
120
127
|
## Version history
|
121
128
|
|
129
|
+
* **0.2.1** - Add tag_files() to get all file paths for a given asset.
|
130
|
+
* **0.2.0** - Custom asset destination roots, fix Rake task.
|
131
|
+
* **0.1.1** - Rake tasks.
|
122
132
|
* **0.1.0** - View helpers.
|
123
133
|
* **0.0.3** - New `Definition` object to make working with definitions significantly easier, don't re-package assets that don't need re-packaging.
|
124
134
|
* **0.0.2** - Compression now works and is specced.
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.2.
|
1
|
+
0.2.1
|
data/lib/rapper/html_tags.rb
CHANGED
@@ -30,7 +30,7 @@ module Rapper
|
|
30
30
|
|
31
31
|
# Build a CSS tag for an asset.
|
32
32
|
#
|
33
|
-
# @param [Symbol]
|
33
|
+
# @param [Symbol] type Definition type.
|
34
34
|
#
|
35
35
|
# @param [Symbol] name Name of the asset to build a `<link>` tag for.
|
36
36
|
#
|
@@ -40,6 +40,24 @@ module Rapper
|
|
40
40
|
self.get_tag( CssTag, type, name )
|
41
41
|
end
|
42
42
|
|
43
|
+
# Get all paths for a given asset. If bundling is turned on, a one-item
|
44
|
+
# array is returned containing the path to the asset file. Otherwise, an
|
45
|
+
# array of all component paths for the asset are returned.
|
46
|
+
#
|
47
|
+
# @param [Symbol] type Definition type.
|
48
|
+
#
|
49
|
+
# @param [Symbol] name Name of the asset to get paths for.
|
50
|
+
#
|
51
|
+
# @return [String<Array>] All files that comprise the given asset.
|
52
|
+
def tag_files( type, name )
|
53
|
+
definition = @definitions[type]
|
54
|
+
if self.get_config( "bundle" )
|
55
|
+
Array( definition.asset_path( name, definition.asset_tag_root ) )
|
56
|
+
else
|
57
|
+
definition.component_paths( name, definition.component_tag_root )
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
43
61
|
protected
|
44
62
|
|
45
63
|
def get_tag( klass, type, name )
|
@@ -50,15 +68,9 @@ module Rapper
|
|
50
68
|
version = definition.get_version( name )
|
51
69
|
end
|
52
70
|
|
53
|
-
|
54
|
-
path = definition.asset_path( name, definition.asset_tag_root )
|
71
|
+
tag_files( type, name ).map do |path|
|
55
72
|
klass.send( :for, path, version, style )
|
56
|
-
|
57
|
-
paths = definition.component_paths( name, definition.component_tag_root )
|
58
|
-
paths.map do |path|
|
59
|
-
klass.send( :for, path, version, style )
|
60
|
-
end.join( "\n" )
|
61
|
-
end
|
73
|
+
end.join( "\n" )
|
62
74
|
end
|
63
75
|
|
64
76
|
# Represents an HTML tag.
|
data/rapper.gemspec
CHANGED
data/spec/rapper_spec.rb
CHANGED
@@ -67,6 +67,14 @@ describe Rapper do
|
|
67
67
|
]
|
68
68
|
]
|
69
69
|
end
|
70
|
+
|
71
|
+
it "provides tag files" do
|
72
|
+
rapper = Rapper::Engine.new( "spec/fixtures/config/assets.yml", "test" )
|
73
|
+
rapper.tag_files( "javascripts", "multiple_files" ).should == ["/javascripts/assets/multiple_files.js"]
|
74
|
+
|
75
|
+
rapper = Rapper::Engine.new( "spec/fixtures/config/assets.yml", "test_no_bundle" )
|
76
|
+
rapper.tag_files( "javascripts", "multiple_files" ).should == ["/javascripts/simple_1.js", "/javascripts/simple_2.js"]
|
77
|
+
end
|
70
78
|
end
|
71
79
|
|
72
80
|
describe "logging" do
|
metadata
CHANGED