middleman-sprockets 3.3.1 → 3.3.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/.travis.yml +9 -1
- data/CHANGELOG.md +7 -1
- data/Gemfile +12 -13
- data/Gemfile-v4 +34 -0
- data/features/sprockets_gems.feature +6 -6
- data/features/step_definitions/server_steps.rb +1 -5
- data/fixtures/bower-app/config.rb +2 -6
- data/fixtures/sprockets-app-debug-assets/source/javascripts/main.js +1 -0
- data/lib/middleman-sprockets/asset_tag_helpers.rb +2 -7
- data/lib/middleman-sprockets/config_only_environment.rb +50 -0
- data/lib/middleman-sprockets/environment.rb +38 -16
- data/lib/middleman-sprockets/extension.rb +63 -43
- data/lib/middleman-sprockets/version.rb +1 -1
- data/middleman-sprockets.gemspec +2 -2
- metadata +21 -19
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4e38b12a9c8ab12b7ae6e0be0c492c8aaba8d6bd
|
4
|
+
data.tar.gz: 6cc6c0b7ab1c046bad148904706708126b381407
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1531bc2d4691b05f64228c61d9ed35478dee6865e72e33054fb371c9f7eab179f1abdfc74f57a05e7477a9aa811c19a4117fc48df91ec102b32bc5a1a97f893b
|
7
|
+
data.tar.gz: 6290fac59b1bd578d18ca1ccadcfd6f1d7e45f03786c6097fbb1768ffee8f0d1f8fbe0c52b77e8877b48d1361fbf0eb91005b29af5768636baed661b72711235
|
data/.gitignore
CHANGED
data/.travis.yml
CHANGED
data/CHANGELOG.md
CHANGED
@@ -1,7 +1,13 @@
|
|
1
|
+
3.3.2
|
2
|
+
===
|
3
|
+
|
4
|
+
* Remove file-based cache (`.cache` folder), which did not invalidate correctly and led to a lot of problems with assets not updating.
|
5
|
+
* It is now possible to configure Sprockets via `sprockets.append_path` and `sprockets.import_asset` without having to wrap it in a `ready` block.
|
6
|
+
|
1
7
|
3.3.1
|
2
8
|
===
|
3
9
|
|
4
|
-
Fix import_asset for Bower and other import paths that don't end in /javascripts, /stylesheets, etc.
|
10
|
+
* Fix import_asset for Bower and other import paths that don't end in /javascripts, /stylesheets, etc.
|
5
11
|
|
6
12
|
3.3.0
|
7
13
|
===
|
data/Gemfile
CHANGED
@@ -5,25 +5,24 @@ gem "middleman-core", :github => "middleman/middleman", :branch => "v3-stable"
|
|
5
5
|
# Specify your gem's dependencies in middleman-sprockets.gemspec
|
6
6
|
gemspec
|
7
7
|
|
8
|
-
gem "rake",
|
9
|
-
gem "yard",
|
8
|
+
gem "rake", "~> 10.0.3", :require => false
|
9
|
+
gem "yard", "~> 0.8.0", :require => false
|
10
10
|
|
11
11
|
# Test tools
|
12
|
-
gem "cucumber"
|
13
|
-
gem "fivemat"
|
14
|
-
gem "aruba"
|
15
|
-
gem "rspec",
|
16
|
-
gem "builder",
|
12
|
+
gem "cucumber"
|
13
|
+
gem "fivemat", "~> 1.2.1"
|
14
|
+
gem "aruba"
|
15
|
+
gem "rspec", "~> 2.14"
|
16
|
+
gem "builder", "~> 3.0"
|
17
|
+
|
17
18
|
|
18
19
|
# For actual tests
|
19
20
|
# Make sure to lock down the versions of the asset gems
|
20
21
|
# so they don't cause asset hashes to change.
|
21
|
-
gem "
|
22
|
-
gem "
|
23
|
-
|
24
|
-
gem "jquery_mobile_rails", "1.
|
25
|
-
gem "sprockets", "~> 2.2.1", :require => false
|
26
|
-
gem 'rack', '1.4.5', :require => false
|
22
|
+
gem "railties", "~> 4.0.0"
|
23
|
+
gem "jquery-rails", "3.1.0", :require => false
|
24
|
+
gem "bootstrap-sass", "3.1.1.0", :require => false
|
25
|
+
gem "jquery_mobile_rails", "1.4.1", :require => false
|
27
26
|
|
28
27
|
gem "ejs", "~> 1.1.1"
|
29
28
|
gem "eco", "~> 1.0.0"
|
data/Gemfile-v4
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
source "https://rubygems.org"
|
2
|
+
|
3
|
+
gem "middleman-cli", :github => "middleman/middleman", :branch => "master"
|
4
|
+
gem "middleman-core", :github => "middleman/middleman", :branch => "master"
|
5
|
+
gem "middleman-templates", :github => "middleman/middleman", :branch => "master"
|
6
|
+
|
7
|
+
# Specify your gem's dependencies in middleman-sprockets.gemspec
|
8
|
+
gemspec
|
9
|
+
|
10
|
+
gem "rake", "~> 10.0.3", :require => false
|
11
|
+
gem "yard", "~> 0.8.0", :require => false
|
12
|
+
|
13
|
+
# Test tools
|
14
|
+
gem "cucumber"
|
15
|
+
gem "fivemat", "~> 1.2.1"
|
16
|
+
gem "aruba"
|
17
|
+
gem "rspec", "~> 2.14"
|
18
|
+
gem "builder", "~> 3.0"
|
19
|
+
|
20
|
+
# For actual tests
|
21
|
+
# Make sure to lock down the versions of the asset gems
|
22
|
+
# so they don't cause asset hashes to change.
|
23
|
+
gem "railties", "~> 4.0.0"
|
24
|
+
gem "jquery-rails", "3.1.0", :require => false
|
25
|
+
gem "bootstrap-sass", "3.1.1.0", :require => false
|
26
|
+
|
27
|
+
gem "jquery_mobile_rails", "1.4.1", :require => false
|
28
|
+
|
29
|
+
gem "ejs", "~> 1.1.1"
|
30
|
+
gem "eco", "~> 1.0.0"
|
31
|
+
gem "erubis", "~> 2.7.0"
|
32
|
+
|
33
|
+
# Code Quality
|
34
|
+
gem "cane", :platforms => [:mri_19, :mri_20], :require => false
|
@@ -7,7 +7,7 @@ Feature: Sprockets Gems
|
|
7
7
|
Scenario: Sprockets can pull CSS from gem
|
8
8
|
Given the Server is running at "sprockets-app"
|
9
9
|
When I go to "/library/css/bootstrap_include.css"
|
10
|
-
Then I should see ".btn-
|
10
|
+
Then I should see ".btn-default"
|
11
11
|
|
12
12
|
Scenario: Sprockets can pull js from vendored assets
|
13
13
|
Given the Server is running at "sprockets-app"
|
@@ -22,15 +22,15 @@ Feature: Sprockets Gems
|
|
22
22
|
Scenario: Proper reference to images from a gem, in preview
|
23
23
|
Given the Server is running at "jquery-mobile-app"
|
24
24
|
When I go to "/stylesheets/base.css"
|
25
|
-
Then I should see 'url("/images/jquery-mobile/
|
25
|
+
Then I should see 'url("/images/jquery-mobile/ajax-loader.gif")'
|
26
26
|
|
27
27
|
Scenario: Proper reference to images from a gem, in build
|
28
28
|
Given a successfully built app at "jquery-mobile-app"
|
29
29
|
When I cd to "build"
|
30
30
|
Then the following files should exist:
|
31
31
|
| stylesheets/base.css |
|
32
|
-
| images/jquery-mobile/
|
33
|
-
And the file "stylesheets/base.css" should contain 'url("/images/jquery-mobile/
|
32
|
+
| images/jquery-mobile/ajax-loader.gif |
|
33
|
+
And the file "stylesheets/base.css" should contain 'url("/images/jquery-mobile/ajax-loader.gif")'
|
34
34
|
|
35
35
|
Scenario: Same thing, but with :relative_assets on
|
36
36
|
Given a fixture app "jquery-mobile-app"
|
@@ -40,7 +40,7 @@ Feature: Sprockets Gems
|
|
40
40
|
"""
|
41
41
|
Given the Server is running at "jquery-mobile-app"
|
42
42
|
When I go to "/stylesheets/base.css"
|
43
|
-
Then I should see 'url("../images/jquery-mobile/
|
43
|
+
Then I should see 'url("../images/jquery-mobile/ajax-loader.gif")'
|
44
44
|
|
45
45
|
Scenario: JS/CSS from gems aren't aumatically in the site
|
46
46
|
Given the Server is running at "jquery-mobile-app"
|
@@ -63,5 +63,5 @@ Feature: Sprockets Gems
|
|
63
63
|
Given the Server is running at "sprockets-app-debug-assets"
|
64
64
|
And the Server is running at "sprockets-app-debug-assets"
|
65
65
|
When I go to "/index.html"
|
66
|
-
When I go to "/javascripts/bootstrap
|
66
|
+
When I go to "/javascripts/bootstrap/alert.js?body=1"
|
67
67
|
Then I should get a response with status "200"
|
@@ -1,9 +1,5 @@
|
|
1
|
-
Then /^I should see$/ do |contents|
|
2
|
-
@browser.last_response.body.should include(contents)
|
3
|
-
end
|
4
|
-
|
5
1
|
Then /^I should get a response with status "(.*?)"$/ do |status|
|
6
|
-
@browser.last_response.status.should == status.to_i
|
2
|
+
(@last_response || @browser.last_response).status.should == status.to_i
|
7
3
|
end
|
8
4
|
|
9
5
|
Given /^wait a second$/ do
|
@@ -1,7 +1,3 @@
|
|
1
|
-
|
2
|
-
sprockets.append_path File.join(root, 'bower_components')
|
1
|
+
sprockets.append_path File.join(root, 'bower_components')
|
3
2
|
|
4
|
-
|
5
|
-
# an ancient version of sprockets that doesn't understand bower.
|
6
|
-
sprockets.import_asset 'underscore/underscore'
|
7
|
-
end
|
3
|
+
sprockets.import_asset 'underscore/underscore'
|
@@ -6,7 +6,7 @@ module Middleman
|
|
6
6
|
# splits up script dependencies in individual files when
|
7
7
|
# configuration variable :debug_assets is set to true
|
8
8
|
def javascript_include_tag(*sources)
|
9
|
-
if debug_assets
|
9
|
+
if sprockets.debug_assets
|
10
10
|
options = sources.extract_options!.symbolize_keys
|
11
11
|
sources.map do |source|
|
12
12
|
super(dependencies_paths('.js', source), options)
|
@@ -20,7 +20,7 @@ module Middleman
|
|
20
20
|
# splits up stylesheets dependencies in individual files when
|
21
21
|
# configuration variable :debug_assets is set to true
|
22
22
|
def stylesheet_link_tag(*sources)
|
23
|
-
if debug_assets
|
23
|
+
if sprockets.debug_assets
|
24
24
|
options = sources.extract_options!.symbolize_keys
|
25
25
|
sources.map do |source|
|
26
26
|
super(dependencies_paths('.css', source), options)
|
@@ -32,11 +32,6 @@ module Middleman
|
|
32
32
|
|
33
33
|
private
|
34
34
|
|
35
|
-
# Should we "debug assets" by outputting each as an individual script tag instead of combining them?
|
36
|
-
def debug_assets?
|
37
|
-
!build? && (sprockets.options.debug_assets || (respond_to?(:debug_assets) && debug_assets))
|
38
|
-
end
|
39
|
-
|
40
35
|
# Find the paths for all the dependencies of a given source file.
|
41
36
|
def dependencies_paths(extension, source)
|
42
37
|
source_file_name = source.to_s
|
@@ -0,0 +1,50 @@
|
|
1
|
+
module Middleman
|
2
|
+
module Sprockets
|
3
|
+
# A fake Sprockets environment that just exposes the
|
4
|
+
# waits to create the environment until asked, but can still
|
5
|
+
# service most of the interesting configuration methods. This
|
6
|
+
# allows sprockets to be configured any time in config.rb, rather
|
7
|
+
# than having to use an after_configuration block.
|
8
|
+
class ConfigOnlyEnvironment
|
9
|
+
attr_reader :imported_assets
|
10
|
+
attr_reader :appended_paths
|
11
|
+
attr_reader :prepended_paths
|
12
|
+
|
13
|
+
def initialize(options={})
|
14
|
+
@imported_assets = []
|
15
|
+
@appended_paths = []
|
16
|
+
@prepended_paths = []
|
17
|
+
end
|
18
|
+
|
19
|
+
def method_missing?(method)
|
20
|
+
raise NoMethodError, "The Sprockets environment is not ready yet, so you can't call #{method} on it. If you need to call this method do it in a 'ready' block."
|
21
|
+
end
|
22
|
+
|
23
|
+
def apply_to_environment(environment)
|
24
|
+
@imported_assets.each do |asset|
|
25
|
+
environment.import_asset asset
|
26
|
+
end
|
27
|
+
|
28
|
+
@appended_paths.each do |path|
|
29
|
+
environment.append_path path
|
30
|
+
end
|
31
|
+
|
32
|
+
@prepended_paths.each do |path|
|
33
|
+
environment.prepend_path path
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
def import_asset(asset_logical_path)
|
38
|
+
@imported_assets << asset_logical_path
|
39
|
+
end
|
40
|
+
|
41
|
+
def append_path(path)
|
42
|
+
@appended_paths << path
|
43
|
+
end
|
44
|
+
|
45
|
+
def prepend_path(path)
|
46
|
+
@prepended_paths << path
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
@@ -2,19 +2,28 @@ module Middleman
|
|
2
2
|
module Sprockets
|
3
3
|
# Generic Middleman Sprockets env
|
4
4
|
class Environment < ::Sprockets::Environment
|
5
|
-
|
5
|
+
# Whether or not we should debug assets by splitting them all out into individual includes
|
6
|
+
attr_reader :debug_assets
|
7
|
+
|
8
|
+
# A list of Sprockets logical paths for assets that should be brought into the
|
9
|
+
# Middleman application and built.
|
10
|
+
attr_reader :imported_assets
|
11
|
+
|
12
|
+
# The current path, useful when inside helper methods
|
13
|
+
attr_reader :last_request_path
|
6
14
|
|
7
15
|
# Setup
|
8
|
-
def initialize(app)
|
16
|
+
def initialize(app, options={})
|
9
17
|
@imported_assets = []
|
10
18
|
@app = app
|
11
|
-
@
|
19
|
+
@debug_assets = options.fetch(:debug_assets, false)
|
12
20
|
|
13
21
|
super app.source_dir
|
14
22
|
|
15
|
-
# By default, sprockets has no cache! Give it
|
16
|
-
#
|
17
|
-
|
23
|
+
# By default, sprockets has no cache! Give it an in-memory one using a Hash
|
24
|
+
# There is also a Sprockets::Cache::FileStore option, but it is fraught with cache-invalidation
|
25
|
+
# peril, so we choose not to use it.
|
26
|
+
@cache = {}
|
18
27
|
|
19
28
|
enhance_context_class!
|
20
29
|
|
@@ -49,16 +58,19 @@ module Middleman
|
|
49
58
|
# Add our own customizations to the Sprockets context class
|
50
59
|
def enhance_context_class!
|
51
60
|
app = @app
|
61
|
+
env = self
|
52
62
|
|
53
63
|
# Make the app context available to Sprockets
|
54
64
|
context_class.send(:define_method, :app) { app }
|
65
|
+
context_class.send(:define_method, :env) { env }
|
55
66
|
|
56
67
|
context_class.class_eval do
|
57
68
|
def asset_path(path, options={})
|
58
69
|
# Handle people calling with the Middleman/Padrino asset path signature
|
59
70
|
if path.is_a?(::Symbol) && !options.is_a?(::Hash)
|
60
|
-
|
61
|
-
|
71
|
+
kind = path
|
72
|
+
path = options
|
73
|
+
else
|
62
74
|
|
63
75
|
kind = case options[:type]
|
64
76
|
when :image then :images
|
@@ -67,8 +79,18 @@ module Middleman
|
|
67
79
|
when :stylesheet then :css
|
68
80
|
else options[:type]
|
69
81
|
end
|
82
|
+
end
|
70
83
|
|
71
|
-
|
84
|
+
# If Middleman v4, we don't have a global for current path, so pass it in.
|
85
|
+
if self.env.last_request_path
|
86
|
+
app.asset_path(kind, path, {
|
87
|
+
:current_resource => app.sitemap.find_resource_by_destination_path(
|
88
|
+
self.env.last_request_path
|
89
|
+
)
|
90
|
+
})
|
91
|
+
else
|
92
|
+
app.asset_path(kind, path)
|
93
|
+
end
|
72
94
|
end
|
73
95
|
|
74
96
|
# These helpers are already defined in later versions of Sprockets, but we define
|
@@ -129,13 +151,15 @@ module Middleman
|
|
129
151
|
end
|
130
152
|
|
131
153
|
# Invalidate sitemap when users mess with the sprockets load paths
|
132
|
-
def append_path(
|
154
|
+
def append_path(path)
|
133
155
|
@app.sitemap.rebuild_resource_list!(:sprockets_paths)
|
156
|
+
|
134
157
|
super
|
135
158
|
end
|
136
159
|
|
137
|
-
def prepend_path(
|
160
|
+
def prepend_path(path)
|
138
161
|
@app.sitemap.rebuild_resource_list!(:sprockets_paths)
|
162
|
+
|
139
163
|
super
|
140
164
|
end
|
141
165
|
|
@@ -162,7 +186,6 @@ module Middleman
|
|
162
186
|
end
|
163
187
|
resource = @app.sitemap.find_resource_by_destination_path(request_path)
|
164
188
|
|
165
|
-
debug_assets = !@app.build? && (@options.debug_assets || (@app.respond_to?(:debug_assets) && @app.debug_assets))
|
166
189
|
if !resource && !debug_assets
|
167
190
|
response = ::Rack::Response.new
|
168
191
|
response.status = 404
|
@@ -174,6 +197,8 @@ module Middleman
|
|
174
197
|
|
175
198
|
if @app.respond_to?(:current_path=)
|
176
199
|
@app.current_path = request_path
|
200
|
+
else
|
201
|
+
@last_request_path = request_path
|
177
202
|
end
|
178
203
|
|
179
204
|
# Fix https://github.com/sstephenson/sprockets/issues/533
|
@@ -188,13 +213,10 @@ module Middleman
|
|
188
213
|
super
|
189
214
|
end
|
190
215
|
|
191
|
-
# A list of Sprockets logical paths for assets that should be brought into the
|
192
|
-
# Middleman application and built.
|
193
|
-
attr_accessor :imported_assets
|
194
|
-
|
195
216
|
# Tell Middleman to build this asset, referenced as a logical path.
|
196
217
|
def import_asset(asset_logical_path)
|
197
218
|
imported_assets << asset_logical_path
|
219
|
+
@app.sitemap.rebuild_resource_list!(:sprockets_import_asset)
|
198
220
|
end
|
199
221
|
end
|
200
222
|
end
|
@@ -1,5 +1,6 @@
|
|
1
1
|
require "sprockets"
|
2
2
|
require "sprockets-sass"
|
3
|
+
require "middleman-sprockets/config_only_environment"
|
3
4
|
require "middleman-sprockets/environment"
|
4
5
|
require "middleman-sprockets/asset_tag_helpers"
|
5
6
|
|
@@ -8,69 +9,62 @@ module Middleman
|
|
8
9
|
class SprocketsExtension < Extension
|
9
10
|
option :debug_assets, false, 'Split up each required asset into its own script/style tag instead of combining them (development only)'
|
10
11
|
|
11
|
-
|
12
|
-
require "middleman-sprockets/sass_function_hack"
|
13
|
-
|
14
|
-
super
|
15
|
-
end
|
12
|
+
attr_reader :environment
|
16
13
|
|
17
|
-
|
14
|
+
# This module gets mixed into both the Middleman instance and the Middleman class,
|
15
|
+
# so that it's available in config.rb
|
16
|
+
module SprocketsAccessor
|
18
17
|
# The sprockets environment
|
19
18
|
# @return [Middleman::MiddlemanSprocketsEnvironment]
|
20
19
|
def sprockets
|
21
20
|
extensions[:sprockets].environment
|
22
21
|
end
|
22
|
+
end
|
23
23
|
|
24
|
-
|
24
|
+
def initialize(app, options_hash={}, &block)
|
25
|
+
require "middleman-sprockets/sass_function_hack"
|
26
|
+
|
27
|
+
super
|
28
|
+
|
29
|
+
# Start out with a stub environment that can only be configured (paths and such)
|
30
|
+
@environment = ::Middleman::Sprockets::ConfigOnlyEnvironment.new
|
31
|
+
|
32
|
+
app.send :include, SprocketsAccessor
|
25
33
|
end
|
26
34
|
|
27
|
-
|
28
|
-
|
35
|
+
helpers do
|
36
|
+
include SprocketsAccessor
|
37
|
+
include ::Middleman::Sprockets::AssetTagHelpers
|
29
38
|
end
|
30
39
|
|
31
|
-
def
|
40
|
+
def before_configuration
|
32
41
|
if defined?(::Middleman::ConfigContext)
|
33
42
|
app.add_to_config_context :sprockets, &method(:environment)
|
34
43
|
end
|
35
44
|
end
|
36
45
|
|
37
46
|
def after_configuration
|
38
|
-
self.environment.options = options
|
39
|
-
|
40
47
|
::Tilt.register ::Sprockets::EjsTemplate, 'ejs'
|
41
48
|
::Tilt.register ::Sprockets::EcoTemplate, 'eco'
|
42
49
|
::Tilt.register ::Sprockets::JstProcessor, 'jst'
|
43
|
-
app.template_extensions :jst => :js, :eco => :js, :ejs => :js
|
44
|
-
|
45
|
-
app.sitemap.rebuild_resource_list!
|
46
50
|
|
47
|
-
|
48
|
-
|
49
|
-
try_paths = [
|
50
|
-
%w{ assets },
|
51
|
-
%w{ app },
|
52
|
-
%w{ app assets },
|
53
|
-
%w{ vendor },
|
54
|
-
%w{ vendor assets },
|
55
|
-
%w{ lib },
|
56
|
-
%w{ lib assets }
|
57
|
-
].inject([]) do |sum, v|
|
58
|
-
sum + [
|
59
|
-
File.join(v, 'javascripts'),
|
60
|
-
File.join(v, 'stylesheets'),
|
61
|
-
File.join(v, 'images'),
|
62
|
-
File.join(v, 'fonts')
|
63
|
-
]
|
51
|
+
if app.respond_to?(:template_extensions)
|
52
|
+
app.template_extensions :jst => :js, :eco => :js, :ejs => :js
|
64
53
|
end
|
65
54
|
|
66
|
-
|
67
|
-
|
68
|
-
select {|p| File.directory?(p) }.
|
69
|
-
each {|path| self.environment.append_path(path) }
|
55
|
+
if app.config.defines_setting?(:debug_assets) && !options.setting(:debug_assets).value_set?
|
56
|
+
options[:debug_assets] = app.config[:debug_assets]
|
70
57
|
end
|
71
58
|
|
59
|
+
config_environment = @environment
|
60
|
+
debug_assets = !app.build? && options[:debug_assets]
|
61
|
+
@environment = ::Middleman::Sprockets::Environment.new(app, :debug_assets => debug_assets)
|
62
|
+
config_environment.apply_to_environment(@environment)
|
63
|
+
|
64
|
+
add_assets_from_gems
|
65
|
+
|
72
66
|
# Setup Sprockets Sass options
|
73
|
-
if app.config.
|
67
|
+
if app.config.defines_setting?(:sass)
|
74
68
|
app.config[:sass].each { |k, v| ::Sprockets::Sass.options[k] = v }
|
75
69
|
end
|
76
70
|
|
@@ -84,12 +78,10 @@ module Middleman
|
|
84
78
|
|
85
79
|
# Add sitemap resource for every image in the sprockets load path
|
86
80
|
def manipulate_resource_list(resources)
|
87
|
-
sprockets = self.environment
|
88
|
-
|
89
81
|
imported_assets = []
|
90
|
-
|
82
|
+
environment.imported_assets.each do |asset_logical_path|
|
91
83
|
assets = []
|
92
|
-
|
84
|
+
environment.resolve(asset_logical_path) do |asset|
|
93
85
|
assets << asset
|
94
86
|
@app.logger.debug "== Importing Sprockets asset #{asset}"
|
95
87
|
end
|
@@ -98,7 +90,7 @@ module Middleman
|
|
98
90
|
end
|
99
91
|
|
100
92
|
resources_list = []
|
101
|
-
|
93
|
+
environment.paths.each do |load_path|
|
102
94
|
output_dir = nil
|
103
95
|
export_all = false
|
104
96
|
if load_path.end_with?('/images')
|
@@ -113,7 +105,7 @@ module Middleman
|
|
113
105
|
output_dir = @app.config[:js_dir]
|
114
106
|
end
|
115
107
|
|
116
|
-
|
108
|
+
environment.each_entry(load_path) do |path|
|
117
109
|
next unless path.file?
|
118
110
|
next if path.basename.to_s.start_with?('_')
|
119
111
|
|
@@ -145,5 +137,33 @@ module Middleman
|
|
145
137
|
end
|
146
138
|
resources + resources_list
|
147
139
|
end
|
140
|
+
|
141
|
+
private
|
142
|
+
|
143
|
+
# Add any directories from gems with Rails-like paths to sprockets load path
|
144
|
+
def add_assets_from_gems
|
145
|
+
try_paths = [
|
146
|
+
%w{ assets },
|
147
|
+
%w{ app },
|
148
|
+
%w{ app assets },
|
149
|
+
%w{ vendor },
|
150
|
+
%w{ vendor assets },
|
151
|
+
%w{ lib },
|
152
|
+
%w{ lib assets }
|
153
|
+
].inject([]) do |sum, v|
|
154
|
+
sum + [
|
155
|
+
File.join(v, 'javascripts'),
|
156
|
+
File.join(v, 'stylesheets'),
|
157
|
+
File.join(v, 'images'),
|
158
|
+
File.join(v, 'fonts')
|
159
|
+
]
|
160
|
+
end
|
161
|
+
|
162
|
+
([app.root] + ::Middleman.rubygems_latest_specs.map(&:full_gem_path)).each do |root_path|
|
163
|
+
try_paths.map {|p| File.join(root_path, p) }.
|
164
|
+
select {|p| File.directory?(p) }.
|
165
|
+
each {|path| self.environment.append_path(path) }
|
166
|
+
end
|
167
|
+
end
|
148
168
|
end
|
149
169
|
end
|
data/middleman-sprockets.gemspec
CHANGED
@@ -16,7 +16,7 @@ Gem::Specification.new do |s|
|
|
16
16
|
s.test_files = `git ls-files -z -- {fixtures,features}/*`.split("\0")
|
17
17
|
s.require_paths = ["lib"]
|
18
18
|
s.add_dependency("middleman-core", [">= 3.2"])
|
19
|
-
s.add_dependency("sprockets", ["~> 2.
|
19
|
+
s.add_dependency("sprockets", ["~> 2.2"])
|
20
20
|
s.add_dependency("sprockets-sass", ["~> 1.0.0"])
|
21
|
-
s.add_dependency("sprockets-helpers", ["~> 1.
|
21
|
+
s.add_dependency("sprockets-helpers", ["~> 1.1.0"])
|
22
22
|
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.3.
|
4
|
+
version: 3.3.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Thomas Reynolds
|
@@ -9,64 +9,64 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2014-
|
12
|
+
date: 2014-04-04 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: middleman-core
|
16
16
|
requirement: !ruby/object:Gem::Requirement
|
17
17
|
requirements:
|
18
|
-
- -
|
18
|
+
- - '>='
|
19
19
|
- !ruby/object:Gem::Version
|
20
20
|
version: '3.2'
|
21
21
|
type: :runtime
|
22
22
|
prerelease: false
|
23
23
|
version_requirements: !ruby/object:Gem::Requirement
|
24
24
|
requirements:
|
25
|
-
- -
|
25
|
+
- - '>='
|
26
26
|
- !ruby/object:Gem::Version
|
27
27
|
version: '3.2'
|
28
28
|
- !ruby/object:Gem::Dependency
|
29
29
|
name: sprockets
|
30
30
|
requirement: !ruby/object:Gem::Requirement
|
31
31
|
requirements:
|
32
|
-
- -
|
32
|
+
- - ~>
|
33
33
|
- !ruby/object:Gem::Version
|
34
|
-
version: '2.
|
34
|
+
version: '2.2'
|
35
35
|
type: :runtime
|
36
36
|
prerelease: false
|
37
37
|
version_requirements: !ruby/object:Gem::Requirement
|
38
38
|
requirements:
|
39
|
-
- -
|
39
|
+
- - ~>
|
40
40
|
- !ruby/object:Gem::Version
|
41
|
-
version: '2.
|
41
|
+
version: '2.2'
|
42
42
|
- !ruby/object:Gem::Dependency
|
43
43
|
name: sprockets-sass
|
44
44
|
requirement: !ruby/object:Gem::Requirement
|
45
45
|
requirements:
|
46
|
-
- -
|
46
|
+
- - ~>
|
47
47
|
- !ruby/object:Gem::Version
|
48
48
|
version: 1.0.0
|
49
49
|
type: :runtime
|
50
50
|
prerelease: false
|
51
51
|
version_requirements: !ruby/object:Gem::Requirement
|
52
52
|
requirements:
|
53
|
-
- -
|
53
|
+
- - ~>
|
54
54
|
- !ruby/object:Gem::Version
|
55
55
|
version: 1.0.0
|
56
56
|
- !ruby/object:Gem::Dependency
|
57
57
|
name: sprockets-helpers
|
58
58
|
requirement: !ruby/object:Gem::Requirement
|
59
59
|
requirements:
|
60
|
-
- -
|
60
|
+
- - ~>
|
61
61
|
- !ruby/object:Gem::Version
|
62
|
-
version: 1.
|
62
|
+
version: 1.1.0
|
63
63
|
type: :runtime
|
64
64
|
prerelease: false
|
65
65
|
version_requirements: !ruby/object:Gem::Requirement
|
66
66
|
requirements:
|
67
|
-
- -
|
67
|
+
- - ~>
|
68
68
|
- !ruby/object:Gem::Version
|
69
|
-
version: 1.
|
69
|
+
version: 1.1.0
|
70
70
|
description: Sprockets support for Middleman
|
71
71
|
email:
|
72
72
|
- me@tdreyno.com
|
@@ -75,11 +75,12 @@ executables: []
|
|
75
75
|
extensions: []
|
76
76
|
extra_rdoc_files: []
|
77
77
|
files:
|
78
|
-
-
|
79
|
-
-
|
78
|
+
- .gitignore
|
79
|
+
- .travis.yml
|
80
80
|
- CHANGELOG.md
|
81
81
|
- CONTRIBUTING.md
|
82
82
|
- Gemfile
|
83
|
+
- Gemfile-v4
|
83
84
|
- LICENSE.md
|
84
85
|
- README.md
|
85
86
|
- Rakefile
|
@@ -191,6 +192,7 @@ files:
|
|
191
192
|
- fixtures/sprockets-images-app/vendor/assets/images/cat-2.jpg
|
192
193
|
- lib/middleman-sprockets.rb
|
193
194
|
- lib/middleman-sprockets/asset_tag_helpers.rb
|
195
|
+
- lib/middleman-sprockets/config_only_environment.rb
|
194
196
|
- lib/middleman-sprockets/environment.rb
|
195
197
|
- lib/middleman-sprockets/extension.rb
|
196
198
|
- lib/middleman-sprockets/sass_function_hack.rb
|
@@ -206,17 +208,17 @@ require_paths:
|
|
206
208
|
- lib
|
207
209
|
required_ruby_version: !ruby/object:Gem::Requirement
|
208
210
|
requirements:
|
209
|
-
- -
|
211
|
+
- - '>='
|
210
212
|
- !ruby/object:Gem::Version
|
211
213
|
version: '0'
|
212
214
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
213
215
|
requirements:
|
214
|
-
- -
|
216
|
+
- - '>='
|
215
217
|
- !ruby/object:Gem::Version
|
216
218
|
version: '0'
|
217
219
|
requirements: []
|
218
220
|
rubyforge_project:
|
219
|
-
rubygems_version: 2.
|
221
|
+
rubygems_version: 2.0.2
|
220
222
|
signing_key:
|
221
223
|
specification_version: 4
|
222
224
|
summary: Sprockets support for Middleman
|