middleman-sprockets 3.3.6 → 3.3.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/features/sprockets.feature +12 -0
- data/fixtures/sprockets-svg-font-app/bower.json +8 -0
- data/fixtures/sprockets-svg-font-app/config.rb +5 -0
- data/fixtures/sprockets-svg-font-app/source/fonts/fontawesome-webfont-source.svg +504 -0
- data/fixtures/sprockets-svg-font-app/source/fonts/fontawesome-webfont-source.svg.gz +0 -0
- data/fixtures/sprockets-svg-font-app/source/images/drawing-source.svg +76 -0
- data/fixtures/sprockets-svg-font-app/vendor/assets/components/blub/images/drawing-bower.svg +76 -0
- data/fixtures/sprockets-svg-font-app/vendor/assets/components/font-awesome/fonts/fontawesome-webfont-bower.svg +504 -0
- data/fixtures/sprockets-svg-font-app/vendor/assets/components/font-awesome/fonts/fontawesome-webfont-bower.svg.gz +0 -0
- data/fixtures/sprockets-svg-font-app/vendor/assets/components/font-awesome/fonts/fontawesome-webfont-bower.ttf.gz +0 -0
- data/lib/middleman-sprockets/asset.rb +59 -42
- data/lib/middleman-sprockets/asset_list.rb +0 -4
- data/lib/middleman-sprockets/extension.rb +0 -1
- data/lib/middleman-sprockets/version.rb +1 -1
- data/spec/asset_spec.rb +5 -1
- metadata +20 -3
- data/lib/middleman-sprockets/pathname_extensions.rb +0 -10
Binary file
|
Binary file
|
@@ -3,14 +3,7 @@ module Middleman
|
|
3
3
|
module Sprockets
|
4
4
|
# Asset
|
5
5
|
class Asset
|
6
|
-
|
7
|
-
private
|
8
|
-
|
9
|
-
attr_reader :relative_source_path, :base_name, :destination_directory, :source_directory
|
10
|
-
|
11
|
-
public
|
12
|
-
|
13
|
-
attr_reader :source_path
|
6
|
+
attr_reader :source_path, :relative_source_path, :base_name, :destination_directory, :source_directory
|
14
7
|
|
15
8
|
# Create instance
|
16
9
|
#
|
@@ -24,12 +17,12 @@ module Middleman
|
|
24
17
|
|
25
18
|
fail ArgumentError, 'Missing argument source_directory' unless source_directory
|
26
19
|
|
27
|
-
@source_directory
|
20
|
+
@source_directory = source_directory
|
28
21
|
|
29
|
-
@source_path
|
22
|
+
@source_path = Pathname.new(source_path)
|
30
23
|
@relative_source_path = @source_path.relative_path_from(Pathname.new(source_directory))
|
31
|
-
@base_name
|
32
|
-
@import_it
|
24
|
+
@base_name = @source_path.basename
|
25
|
+
@import_it = false
|
33
26
|
end
|
34
27
|
|
35
28
|
# Should the asset imported?
|
@@ -58,7 +51,7 @@ module Middleman
|
|
58
51
|
def destination_path
|
59
52
|
return @destination_path if @destination_path
|
60
53
|
|
61
|
-
fail ::Sprockets::FileNotFound, "Couldn't find an appropriate output directory for '#{
|
54
|
+
fail ::Sprockets::FileNotFound, "Couldn't find an appropriate output directory for '#{source_path}'. Halting because it was explicitly requested via 'import_asset'" unless destination_directory
|
62
55
|
|
63
56
|
destination_directory + relative_source_path
|
64
57
|
end
|
@@ -105,17 +98,17 @@ module Middleman
|
|
105
98
|
end
|
106
99
|
|
107
100
|
def type
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
101
|
+
@type ||= if is_image?
|
102
|
+
:image
|
103
|
+
elsif is_script?
|
104
|
+
:script
|
105
|
+
elsif is_stylesheet?
|
106
|
+
:stylesheet
|
107
|
+
elsif is_font?
|
108
|
+
:font
|
109
|
+
else
|
110
|
+
:unknown
|
111
|
+
end
|
119
112
|
end
|
120
113
|
|
121
114
|
def file?
|
@@ -123,7 +116,7 @@ module Middleman
|
|
123
116
|
end
|
124
117
|
|
125
118
|
def partial?
|
126
|
-
base_name.start_with? '_'
|
119
|
+
base_name.to_s.start_with? '_'
|
127
120
|
end
|
128
121
|
|
129
122
|
# Is it a valid asset
|
@@ -142,42 +135,66 @@ module Middleman
|
|
142
135
|
end
|
143
136
|
|
144
137
|
def extname
|
145
|
-
source_path.
|
138
|
+
source_path.basename.to_s[/(\.[^.]+)/]
|
146
139
|
end
|
147
140
|
|
148
|
-
def
|
149
|
-
|
141
|
+
def is_image?
|
142
|
+
is_image_by_path? || (is_image_by_extension? && !is_font_by_path?)
|
150
143
|
end
|
151
144
|
|
152
|
-
def
|
153
|
-
source_directory.end_with?('images'
|
145
|
+
def is_image_by_path?
|
146
|
+
source_directory.to_s.end_with?('images') ||
|
147
|
+
source_directory.to_s.end_with?('img') ||
|
148
|
+
source_path.dirname.to_s.end_with?('images') ||
|
149
|
+
source_path.dirname.to_s.end_with?('img')
|
154
150
|
end
|
151
|
+
alias_method :is_in_images_directory?, :is_image_by_path?
|
155
152
|
|
156
|
-
def
|
157
|
-
|
153
|
+
def is_image_by_extension?
|
154
|
+
has_extname? *%w(.gif .png .jpg .jpeg .webp .svg .svgz)
|
158
155
|
end
|
159
156
|
|
160
|
-
def
|
161
|
-
|
157
|
+
def is_stylesheet?
|
158
|
+
is_stylesheet_by_path? || is_stylesheet_by_extension?
|
162
159
|
end
|
163
160
|
|
164
|
-
def
|
165
|
-
|
161
|
+
def is_stylesheet_by_extension?
|
162
|
+
has_extname? *%w(.css .sass .scss .styl .less)
|
166
163
|
end
|
167
164
|
|
168
|
-
def
|
169
|
-
|
165
|
+
def is_stylesheet_by_path?
|
166
|
+
source_directory.to_s.end_with?('stylesheets') ||
|
167
|
+
source_directory.to_s.end_with?('css') ||
|
168
|
+
source_path.dirname.to_s.end_with?('stylesheets') ||
|
169
|
+
source_path.dirname.to_s.end_with?('css')
|
170
170
|
end
|
171
171
|
|
172
|
-
def
|
173
|
-
|
172
|
+
def is_font?
|
173
|
+
is_font_by_path? || is_font_by_extension?
|
174
174
|
end
|
175
175
|
|
176
|
-
def
|
177
|
-
|
176
|
+
def is_font_by_path?
|
177
|
+
source_directory.to_s.end_with?('fonts') ||
|
178
|
+
source_path.dirname.to_s.end_with?('fonts')
|
179
|
+
end
|
180
|
+
alias_method :is_in_fonts_directory?, :is_font_by_path?
|
181
|
+
|
182
|
+
def is_font_by_extension?
|
183
|
+
has_extname? *%w(.ttf .woff .eot .otf .svg .svgz)
|
178
184
|
end
|
179
185
|
|
180
186
|
def is_script?
|
187
|
+
is_script_by_path? || is_script_by_extension?
|
188
|
+
end
|
189
|
+
|
190
|
+
def is_script_by_path?
|
191
|
+
source_directory.to_s.end_with?('javascripts') ||
|
192
|
+
source_directory.to_s.end_with?('js') ||
|
193
|
+
source_path.dirname.to_s.end_with?('javascripts') ||
|
194
|
+
source_path.dirname.to_s.end_with?('js')
|
195
|
+
end
|
196
|
+
|
197
|
+
def is_script_by_extension?
|
181
198
|
has_extname?('.js', '.coffee')
|
182
199
|
end
|
183
200
|
end
|
data/spec/asset_spec.rb
CHANGED
@@ -10,6 +10,11 @@ RSpec.describe Asset do
|
|
10
10
|
asset = Asset.new('/source/path/to/images/image.xz', source_directory: '/source/path/to/images')
|
11
11
|
expect(asset).to have_type :image
|
12
12
|
end
|
13
|
+
|
14
|
+
it 'finds type by double extension' do
|
15
|
+
asset = Asset.new('/source/path/to/image.png.xz', source_directory: '/source/path/to')
|
16
|
+
expect(asset).to have_type :image
|
17
|
+
end
|
13
18
|
end
|
14
19
|
|
15
20
|
context '#import?, #import_it' do
|
@@ -112,5 +117,4 @@ RSpec.describe Asset do
|
|
112
117
|
end
|
113
118
|
end
|
114
119
|
end
|
115
|
-
|
116
120
|
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.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Thomas Reynolds
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2014-08-
|
13
|
+
date: 2014-08-14 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: middleman-core
|
@@ -211,6 +211,15 @@ files:
|
|
211
211
|
- fixtures/sprockets-images-app/source/index.html.erb
|
212
212
|
- fixtures/sprockets-images-app/source/library/images/cat.jpg
|
213
213
|
- fixtures/sprockets-images-app/vendor/assets/images/cat-2.jpg
|
214
|
+
- fixtures/sprockets-svg-font-app/bower.json
|
215
|
+
- fixtures/sprockets-svg-font-app/config.rb
|
216
|
+
- fixtures/sprockets-svg-font-app/source/fonts/fontawesome-webfont-source.svg
|
217
|
+
- fixtures/sprockets-svg-font-app/source/fonts/fontawesome-webfont-source.svg.gz
|
218
|
+
- fixtures/sprockets-svg-font-app/source/images/drawing-source.svg
|
219
|
+
- fixtures/sprockets-svg-font-app/vendor/assets/components/blub/images/drawing-bower.svg
|
220
|
+
- fixtures/sprockets-svg-font-app/vendor/assets/components/font-awesome/fonts/fontawesome-webfont-bower.svg
|
221
|
+
- fixtures/sprockets-svg-font-app/vendor/assets/components/font-awesome/fonts/fontawesome-webfont-bower.svg.gz
|
222
|
+
- fixtures/sprockets-svg-font-app/vendor/assets/components/font-awesome/fonts/fontawesome-webfont-bower.ttf.gz
|
214
223
|
- lib/middleman-sprockets.rb
|
215
224
|
- lib/middleman-sprockets/asset.rb
|
216
225
|
- lib/middleman-sprockets/asset_list.rb
|
@@ -219,7 +228,6 @@ files:
|
|
219
228
|
- lib/middleman-sprockets/environment.rb
|
220
229
|
- lib/middleman-sprockets/extension.rb
|
221
230
|
- lib/middleman-sprockets/imported_asset.rb
|
222
|
-
- lib/middleman-sprockets/pathname_extensions.rb
|
223
231
|
- lib/middleman-sprockets/sass_function_hack.rb
|
224
232
|
- lib/middleman-sprockets/version.rb
|
225
233
|
- middleman-sprockets.gemspec
|
@@ -378,4 +386,13 @@ test_files:
|
|
378
386
|
- fixtures/sprockets-images-app/source/index.html.erb
|
379
387
|
- fixtures/sprockets-images-app/source/library/images/cat.jpg
|
380
388
|
- fixtures/sprockets-images-app/vendor/assets/images/cat-2.jpg
|
389
|
+
- fixtures/sprockets-svg-font-app/bower.json
|
390
|
+
- fixtures/sprockets-svg-font-app/config.rb
|
391
|
+
- fixtures/sprockets-svg-font-app/source/fonts/fontawesome-webfont-source.svg
|
392
|
+
- fixtures/sprockets-svg-font-app/source/fonts/fontawesome-webfont-source.svg.gz
|
393
|
+
- fixtures/sprockets-svg-font-app/source/images/drawing-source.svg
|
394
|
+
- fixtures/sprockets-svg-font-app/vendor/assets/components/blub/images/drawing-bower.svg
|
395
|
+
- fixtures/sprockets-svg-font-app/vendor/assets/components/font-awesome/fonts/fontawesome-webfont-bower.svg
|
396
|
+
- fixtures/sprockets-svg-font-app/vendor/assets/components/font-awesome/fonts/fontawesome-webfont-bower.svg.gz
|
397
|
+
- fixtures/sprockets-svg-font-app/vendor/assets/components/font-awesome/fonts/fontawesome-webfont-bower.ttf.gz
|
381
398
|
has_rdoc:
|