middleman-sprockets 3.0.1 → 3.0.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/features/asset_hash.feature +28 -28
- data/features/sprockets.feature +21 -0
- data/features/sprockets_gems.feature +5 -0
- data/features/step_definitions/server_steps.rb +3 -0
- data/fixtures/asset-paths-app/config.rb +1 -0
- data/fixtures/asset-paths-app/derp/javascripts/vendored_js.js +1 -0
- data/fixtures/asset-paths-app/source/javascripts/vendored_include.js +1 -0
- data/fixtures/sprockets-app-debug-assets/config.rb +1 -0
- data/fixtures/sprockets-app-debug-assets/source/index.html.erb +1 -0
- data/fixtures/sprockets-app-debug-assets/source/javascripts/dependency1.js +3 -0
- data/fixtures/sprockets-app-debug-assets/source/javascripts/dependency2.js +1 -0
- data/fixtures/sprockets-app-debug-assets/source/javascripts/main.js +3 -0
- data/fixtures/sprockets-app2/source/javascripts/asset_path.js.erb +3 -0
- data/lib/middleman-sprockets/extension.rb +35 -3
- data/lib/middleman-sprockets/version.rb +1 -1
- metadata +25 -5
data/features/asset_hash.feature
CHANGED
@@ -7,8 +7,8 @@ Feature: Assets get a file hash appended to their and references to them are upd
|
|
7
7
|
| images/100px-1242c368.png |
|
8
8
|
| images/100px-5fd6fb90.jpg |
|
9
9
|
| images/100px-5fd6fb90.gif |
|
10
|
-
| javascripts/application-
|
11
|
-
| stylesheets/site-
|
10
|
+
| javascripts/application-1d8d5276.js |
|
11
|
+
| stylesheets/site-50eaa978.css |
|
12
12
|
| index.html |
|
13
13
|
| subdir/index.html |
|
14
14
|
| other/index.html |
|
@@ -19,50 +19,50 @@ Feature: Assets get a file hash appended to their and references to them are upd
|
|
19
19
|
| javascripts/application.js |
|
20
20
|
| stylesheets/site.css |
|
21
21
|
|
22
|
-
And the file "javascripts/application-
|
23
|
-
And the file "stylesheets/site-
|
24
|
-
And the file "index.html" should contain 'href="stylesheets/site-
|
25
|
-
And the file "index.html" should contain 'src="javascripts/application-
|
22
|
+
And the file "javascripts/application-1d8d5276.js" should contain "img.src = '/images/100px-5fd6fb90.jpg'"
|
23
|
+
And the file "stylesheets/site-50eaa978.css" should contain "background-image: url('../images/100px-5fd6fb90.jpg')"
|
24
|
+
And the file "index.html" should contain 'href="stylesheets/site-50eaa978.css"'
|
25
|
+
And the file "index.html" should contain 'src="javascripts/application-1d8d5276.js"'
|
26
26
|
And the file "index.html" should contain 'src="images/100px-5fd6fb90.jpg"'
|
27
|
-
And the file "subdir/index.html" should contain 'href="../stylesheets/site-
|
28
|
-
And the file "subdir/index.html" should contain 'src="../javascripts/application-
|
27
|
+
And the file "subdir/index.html" should contain 'href="../stylesheets/site-50eaa978.css"'
|
28
|
+
And the file "subdir/index.html" should contain 'src="../javascripts/application-1d8d5276.js"'
|
29
29
|
And the file "subdir/index.html" should contain 'src="../images/100px-5fd6fb90.jpg"'
|
30
|
-
And the file "other/index.html" should contain 'href="../stylesheets/site-
|
31
|
-
And the file "other/index.html" should contain 'src="../javascripts/application-
|
30
|
+
And the file "other/index.html" should contain 'href="../stylesheets/site-50eaa978.css"'
|
31
|
+
And the file "other/index.html" should contain 'src="../javascripts/application-1d8d5276.js"'
|
32
32
|
And the file "other/index.html" should contain 'src="../images/100px-5fd6fb90.jpg"'
|
33
33
|
|
34
34
|
Scenario: Hashed assets work in preview server
|
35
35
|
Given the Server is running at "asset-hash-app"
|
36
36
|
When I go to "/"
|
37
|
-
Then I should see 'href="stylesheets/site-
|
38
|
-
And I should see 'src="javascripts/application-
|
37
|
+
Then I should see 'href="stylesheets/site-50eaa978.css"'
|
38
|
+
And I should see 'src="javascripts/application-1d8d5276.js"'
|
39
39
|
And I should see 'src="images/100px-5fd6fb90.jpg"'
|
40
40
|
When I go to "/subdir/"
|
41
|
-
Then I should see 'href="../stylesheets/site-
|
42
|
-
And I should see 'src="../javascripts/application-
|
41
|
+
Then I should see 'href="../stylesheets/site-50eaa978.css"'
|
42
|
+
And I should see 'src="../javascripts/application-1d8d5276.js"'
|
43
43
|
And I should see 'src="../images/100px-5fd6fb90.jpg"'
|
44
44
|
When I go to "/other/"
|
45
|
-
Then I should see 'href="../stylesheets/site-
|
46
|
-
And I should see 'src="../javascripts/application-
|
45
|
+
Then I should see 'href="../stylesheets/site-50eaa978.css"'
|
46
|
+
And I should see 'src="../javascripts/application-1d8d5276.js"'
|
47
47
|
And I should see 'src="../images/100px-5fd6fb90.jpg"'
|
48
|
-
When I go to "/javascripts/application-
|
48
|
+
When I go to "/javascripts/application-1d8d5276.js"
|
49
49
|
Then I should see "img.src = '/images/100px-5fd6fb90.jpg'"
|
50
|
-
When I go to "/stylesheets/site-
|
50
|
+
When I go to "/stylesheets/site-50eaa978.css"
|
51
51
|
Then I should see "background-image: url('../images/100px-5fd6fb90.jpg')"
|
52
52
|
|
53
53
|
Scenario: Enabling an asset host still produces hashed files and references
|
54
54
|
Given the Server is running at "asset-hash-host-app"
|
55
55
|
When I go to "/"
|
56
|
-
Then I should see 'href="http://middlemanapp.com/stylesheets/site-
|
56
|
+
Then I should see 'href="http://middlemanapp.com/stylesheets/site-171eb3c0.css"'
|
57
57
|
And I should see 'src="http://middlemanapp.com/images/100px-5fd6fb90.jpg"'
|
58
58
|
When I go to "/subdir/"
|
59
|
-
Then I should see 'href="http://middlemanapp.com/stylesheets/site-
|
59
|
+
Then I should see 'href="http://middlemanapp.com/stylesheets/site-171eb3c0.css"'
|
60
60
|
And I should see 'src="http://middlemanapp.com/images/100px-5fd6fb90.jpg"'
|
61
61
|
When I go to "/other/"
|
62
|
-
Then I should see 'href="http://middlemanapp.com/stylesheets/site-
|
62
|
+
Then I should see 'href="http://middlemanapp.com/stylesheets/site-171eb3c0.css"'
|
63
63
|
And I should see 'src="http://middlemanapp.com/images/100px-5fd6fb90.jpg"'
|
64
64
|
# Asset helpers don't appear to work from Compass right now
|
65
|
-
# When I go to "/stylesheets/site-
|
65
|
+
# When I go to "/stylesheets/site-171eb3c0.css"
|
66
66
|
# Then I should see "background-image: url('http://middlemanapp.com/images/100px-5fd6fb90.jpg')"
|
67
67
|
|
68
68
|
Scenario: The asset hash should change when a SASS partial changes
|
@@ -73,14 +73,14 @@ Feature: Assets get a file hash appended to their and references to them are upd
|
|
73
73
|
font-size: 14px
|
74
74
|
"""
|
75
75
|
When I go to "/partials/"
|
76
|
-
Then I should see 'href="../stylesheets/uses_partials-
|
76
|
+
Then I should see 'href="../stylesheets/uses_partials-423a00f7.css'
|
77
77
|
And the file "source/stylesheets/_partial.sass" has the contents
|
78
78
|
"""
|
79
79
|
body
|
80
80
|
font-size: 18px !important
|
81
81
|
"""
|
82
82
|
When I go to "/partials/"
|
83
|
-
Then I should see 'href="../stylesheets/uses_partials-
|
83
|
+
Then I should see 'href="../stylesheets/uses_partials-e8c3d4eb.css'
|
84
84
|
|
85
85
|
Scenario: The asset hash should change when a Javascript partial changes
|
86
86
|
Given the Server is running at "asset-hash-app"
|
@@ -89,14 +89,14 @@ Feature: Assets get a file hash appended to their and references to them are upd
|
|
89
89
|
function sprockets_sub_function() { }
|
90
90
|
"""
|
91
91
|
When I go to "/partials/"
|
92
|
-
Then I should see 'src="../javascripts/sprockets_base-
|
93
|
-
When I go to "/javascripts/sprockets_base-
|
92
|
+
Then I should see 'src="../javascripts/sprockets_base-095c3f3f.js'
|
93
|
+
When I go to "/javascripts/sprockets_base-095c3f3f.js"
|
94
94
|
Then I should see "sprockets_sub_function"
|
95
95
|
And the file "source/javascripts/sprockets_sub.js" has the contents
|
96
96
|
"""
|
97
97
|
function sprockets_sub2_function() { }
|
98
98
|
"""
|
99
99
|
When I go to "/partials/"
|
100
|
-
Then I should see 'src="../javascripts/sprockets_base-
|
101
|
-
When I go to "/javascripts/sprockets_base-
|
100
|
+
Then I should see 'src="../javascripts/sprockets_base-095c3f3f.js'
|
101
|
+
When I go to "/javascripts/sprockets_base-095c3f3f.js"
|
102
102
|
Then I should see "sprockets_sub2_function"
|
data/features/sprockets.feature
CHANGED
@@ -4,6 +4,11 @@ Feature: Sprockets
|
|
4
4
|
Given the Server is running at "sprockets-app2"
|
5
5
|
When I go to "/javascripts/sprockets_base.js"
|
6
6
|
Then I should see "sprockets_sub_function"
|
7
|
+
|
8
|
+
Scenario: asset_path helper
|
9
|
+
Given the Server is running at "sprockets-app2"
|
10
|
+
When I go to "/javascripts/asset_path.js"
|
11
|
+
Then I should see "templates.js"
|
7
12
|
|
8
13
|
Scenario: Sprockets JS require with custom :js_dir
|
9
14
|
Given the Server is running at "sprockets-app"
|
@@ -20,6 +25,22 @@ Feature: Sprockets
|
|
20
25
|
When I go to "/javascripts/multiple_engines.js"
|
21
26
|
Then I should see "Hello One"
|
22
27
|
|
28
|
+
Scenario: Sprockets JS should only contain body when requested
|
29
|
+
Given the Server is running at "sprockets-app2"
|
30
|
+
When I go to "/javascripts/sprockets_base.js?body=1"
|
31
|
+
Then I should see "base"
|
32
|
+
And I should not see "sprockets_sub_function"
|
33
|
+
|
34
|
+
Scenario: Script tags should be provided individually while debugging assets
|
35
|
+
Given the Server is running at "sprockets-app-debug-assets"
|
36
|
+
When I go to "/index.html"
|
37
|
+
Then I should see
|
38
|
+
"""
|
39
|
+
<script src="/javascripts/dependency2.js?body=1" type="text/javascript"></script>
|
40
|
+
<script src="/javascripts/dependency1.js?body=1" type="text/javascript"></script>
|
41
|
+
<script src="/javascripts/main.js?body=1" type="text/javascript"></script>
|
42
|
+
"""
|
43
|
+
|
23
44
|
Scenario: Multiple engine files should build correctly
|
24
45
|
Given a successfully built app at "sprockets-app2"
|
25
46
|
When I cd to "build"
|
@@ -12,4 +12,9 @@ Feature: Sprockets Gems
|
|
12
12
|
Scenario: Sprockets can pull js from vendored assets
|
13
13
|
Given the Server is running at "sprockets-app"
|
14
14
|
When I go to "/library/js/vendored_include.js"
|
15
|
+
Then I should see "var vendored_js_included = true;"
|
16
|
+
|
17
|
+
Scenario: Sprockets can pull js from custom vendor dir
|
18
|
+
Given the Server is running at "asset-paths-app"
|
19
|
+
When I go to "/javascripts/vendored_include.js"
|
15
20
|
Then I should see "var vendored_js_included = true;"
|
@@ -0,0 +1 @@
|
|
1
|
+
set :js_assets_paths, ["#{root}/derp/javascripts/"]
|
@@ -0,0 +1 @@
|
|
1
|
+
var vendored_js_included = true;
|
@@ -0,0 +1 @@
|
|
1
|
+
//= require "vendored_js"
|
@@ -0,0 +1 @@
|
|
1
|
+
set :debug_assets, true
|
@@ -0,0 +1 @@
|
|
1
|
+
<%= javascript_include_tag "main" %>
|
@@ -0,0 +1 @@
|
|
1
|
+
function dependency2() {}
|
@@ -11,7 +11,6 @@ module Middleman::Sprockets
|
|
11
11
|
# Location of javascripts external to source directory.
|
12
12
|
# @return [Array]
|
13
13
|
# set :js_assets_paths, ["#{root}/assets/javascripts/", "/path/2/external/js/repository/"]
|
14
|
-
app.set :js_assets_paths, []
|
15
14
|
|
16
15
|
# Add class methods to context
|
17
16
|
app.send :include, InstanceMethods
|
@@ -19,8 +18,12 @@ module Middleman::Sprockets
|
|
19
18
|
require "middleman-sprockets/sass"
|
20
19
|
app.register Middleman::Sprockets::Sass
|
21
20
|
|
21
|
+
app.after_configuration do
|
22
|
+
helpers JavascriptTagHelper
|
23
|
+
end
|
24
|
+
|
22
25
|
# Once Middleman is setup
|
23
|
-
app.
|
26
|
+
app.after_configuration do
|
24
27
|
::Tilt.register ::Sprockets::EjsTemplate, 'ejs'
|
25
28
|
::Tilt.register ::Sprockets::EcoTemplate, 'eco'
|
26
29
|
|
@@ -93,9 +96,10 @@ module Middleman::Sprockets
|
|
93
96
|
append_path app.css_dir
|
94
97
|
|
95
98
|
# add custom assets paths to the scope
|
99
|
+
|
96
100
|
app.js_assets_paths.each do |p|
|
97
101
|
append_path p
|
98
|
-
end
|
102
|
+
end if app.respond_to?(:js_assets_paths)
|
99
103
|
end
|
100
104
|
|
101
105
|
# Override Sprockets' default digest function to *not*
|
@@ -123,4 +127,32 @@ module Middleman::Sprockets
|
|
123
127
|
# Clear cache on error
|
124
128
|
alias :css_exception_response :javascript_exception_response
|
125
129
|
end
|
130
|
+
|
131
|
+
module JavascriptTagHelper
|
132
|
+
|
133
|
+
# extend padrinos javascript_include_tag with debug functionality
|
134
|
+
# splits up script dependencies in individual files when
|
135
|
+
# configuration variable :debug_assets is set to true
|
136
|
+
def javascript_include_tag(*sources)
|
137
|
+
options = sources.extract_options!.symbolize_keys
|
138
|
+
|
139
|
+
if respond_to?(:debug_assets) && debug_assets
|
140
|
+
|
141
|
+
# loop through all sources and the dependencies and
|
142
|
+
# output each as script tag in the correct order
|
143
|
+
sources.map do |source|
|
144
|
+
dependencies_paths = sprockets[source].to_a.map do |dependency|
|
145
|
+
# if sprockets sees "?body=1" it only gives back the body
|
146
|
+
# of the script without the dependencies included
|
147
|
+
dependency.logical_path << "?body=1"
|
148
|
+
end
|
149
|
+
|
150
|
+
super(dependencies_paths)
|
151
|
+
end.join("")
|
152
|
+
|
153
|
+
else
|
154
|
+
super
|
155
|
+
end
|
156
|
+
end
|
157
|
+
end
|
126
158
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: middleman-sprockets
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.0.
|
4
|
+
version: 3.0.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-09-
|
12
|
+
date: 2012-09-23 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: middleman-more
|
@@ -77,6 +77,7 @@ files:
|
|
77
77
|
- features/sass_partials.feature
|
78
78
|
- features/sprockets.feature
|
79
79
|
- features/sprockets_gems.feature
|
80
|
+
- features/step_definitions/server_steps.rb
|
80
81
|
- features/support/env.rb
|
81
82
|
- fixtures/asset-hash-app/config.rb
|
82
83
|
- fixtures/asset-hash-app/source/images/100px.gif
|
@@ -102,6 +103,9 @@ files:
|
|
102
103
|
- fixtures/asset-hash-host-app/source/other.html.erb
|
103
104
|
- fixtures/asset-hash-host-app/source/stylesheets/site.css.scss
|
104
105
|
- fixtures/asset-hash-host-app/source/subdir/index.html.erb
|
106
|
+
- fixtures/asset-paths-app/config.rb
|
107
|
+
- fixtures/asset-paths-app/derp/javascripts/vendored_js.js
|
108
|
+
- fixtures/asset-paths-app/source/javascripts/vendored_include.js
|
105
109
|
- fixtures/preview-app/config.rb
|
106
110
|
- fixtures/preview-app/source/content.html.erb
|
107
111
|
- fixtures/preview-app/source/layout.erb
|
@@ -110,6 +114,11 @@ files:
|
|
110
114
|
- fixtures/preview-app/source/stylesheets/main.css.sass
|
111
115
|
- fixtures/preview-app/source/stylesheets/main2.css.sass
|
112
116
|
- fixtures/preview-app/source/stylesheets/plain.css.sass
|
117
|
+
- fixtures/sprockets-app-debug-assets/config.rb
|
118
|
+
- fixtures/sprockets-app-debug-assets/source/index.html.erb
|
119
|
+
- fixtures/sprockets-app-debug-assets/source/javascripts/dependency1.js
|
120
|
+
- fixtures/sprockets-app-debug-assets/source/javascripts/dependency2.js
|
121
|
+
- fixtures/sprockets-app-debug-assets/source/javascripts/main.js
|
113
122
|
- fixtures/sprockets-app/.sass-cache/be37f3d65d619a3996ff80c3e286084336419f31/bootstrap_include.css.scssc
|
114
123
|
- fixtures/sprockets-app/.sass-cache/be37f3d65d619a3996ff80c3e286084336419f31/sprockets_base1.css.scssc
|
115
124
|
- fixtures/sprockets-app/.sass-cache/be37f3d65d619a3996ff80c3e286084336419f31/sprockets_base2.css.scssc
|
@@ -130,6 +139,7 @@ files:
|
|
130
139
|
- fixtures/sprockets-app2/data/test2.json
|
131
140
|
- fixtures/sprockets-app2/source/javascripts/_templates/test.jst.ejs
|
132
141
|
- fixtures/sprockets-app2/source/javascripts/_templates/test2.jst.eco
|
142
|
+
- fixtures/sprockets-app2/source/javascripts/asset_path.js.erb
|
133
143
|
- fixtures/sprockets-app2/source/javascripts/multiple_engines.js.coffee.erb
|
134
144
|
- fixtures/sprockets-app2/source/javascripts/sprockets_base.js
|
135
145
|
- fixtures/sprockets-app2/source/javascripts/sprockets_sub.js
|
@@ -157,7 +167,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
157
167
|
version: '0'
|
158
168
|
segments:
|
159
169
|
- 0
|
160
|
-
hash:
|
170
|
+
hash: 905335292850793182
|
161
171
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
162
172
|
none: false
|
163
173
|
requirements:
|
@@ -166,10 +176,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
166
176
|
version: '0'
|
167
177
|
segments:
|
168
178
|
- 0
|
169
|
-
hash:
|
179
|
+
hash: 905335292850793182
|
170
180
|
requirements: []
|
171
181
|
rubyforge_project: middleman-sprockets
|
172
|
-
rubygems_version: 1.8.
|
182
|
+
rubygems_version: 1.8.24
|
173
183
|
signing_key:
|
174
184
|
specification_version: 3
|
175
185
|
summary: Sprockets support for Middleman
|
@@ -179,6 +189,7 @@ test_files:
|
|
179
189
|
- features/sass_partials.feature
|
180
190
|
- features/sprockets.feature
|
181
191
|
- features/sprockets_gems.feature
|
192
|
+
- features/step_definitions/server_steps.rb
|
182
193
|
- features/support/env.rb
|
183
194
|
- fixtures/asset-hash-app/config.rb
|
184
195
|
- fixtures/asset-hash-app/source/images/100px.gif
|
@@ -204,6 +215,9 @@ test_files:
|
|
204
215
|
- fixtures/asset-hash-host-app/source/other.html.erb
|
205
216
|
- fixtures/asset-hash-host-app/source/stylesheets/site.css.scss
|
206
217
|
- fixtures/asset-hash-host-app/source/subdir/index.html.erb
|
218
|
+
- fixtures/asset-paths-app/config.rb
|
219
|
+
- fixtures/asset-paths-app/derp/javascripts/vendored_js.js
|
220
|
+
- fixtures/asset-paths-app/source/javascripts/vendored_include.js
|
207
221
|
- fixtures/preview-app/config.rb
|
208
222
|
- fixtures/preview-app/source/content.html.erb
|
209
223
|
- fixtures/preview-app/source/layout.erb
|
@@ -212,6 +226,11 @@ test_files:
|
|
212
226
|
- fixtures/preview-app/source/stylesheets/main.css.sass
|
213
227
|
- fixtures/preview-app/source/stylesheets/main2.css.sass
|
214
228
|
- fixtures/preview-app/source/stylesheets/plain.css.sass
|
229
|
+
- fixtures/sprockets-app-debug-assets/config.rb
|
230
|
+
- fixtures/sprockets-app-debug-assets/source/index.html.erb
|
231
|
+
- fixtures/sprockets-app-debug-assets/source/javascripts/dependency1.js
|
232
|
+
- fixtures/sprockets-app-debug-assets/source/javascripts/dependency2.js
|
233
|
+
- fixtures/sprockets-app-debug-assets/source/javascripts/main.js
|
215
234
|
- fixtures/sprockets-app/.sass-cache/be37f3d65d619a3996ff80c3e286084336419f31/bootstrap_include.css.scssc
|
216
235
|
- fixtures/sprockets-app/.sass-cache/be37f3d65d619a3996ff80c3e286084336419f31/sprockets_base1.css.scssc
|
217
236
|
- fixtures/sprockets-app/.sass-cache/be37f3d65d619a3996ff80c3e286084336419f31/sprockets_base2.css.scssc
|
@@ -232,6 +251,7 @@ test_files:
|
|
232
251
|
- fixtures/sprockets-app2/data/test2.json
|
233
252
|
- fixtures/sprockets-app2/source/javascripts/_templates/test.jst.ejs
|
234
253
|
- fixtures/sprockets-app2/source/javascripts/_templates/test2.jst.eco
|
254
|
+
- fixtures/sprockets-app2/source/javascripts/asset_path.js.erb
|
235
255
|
- fixtures/sprockets-app2/source/javascripts/multiple_engines.js.coffee.erb
|
236
256
|
- fixtures/sprockets-app2/source/javascripts/sprockets_base.js
|
237
257
|
- fixtures/sprockets-app2/source/javascripts/sprockets_sub.js
|