hanami-assets 0.2.0 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +8 -0
- data/README.md +2 -2
- data/lib/hanami/assets/cache.rb +1 -1
- data/lib/hanami/assets/compiler.rb +19 -3
- data/lib/hanami/assets/config/sources.rb +0 -6
- data/lib/hanami/assets/precompiler.rb +8 -3
- data/lib/hanami/assets/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 15727c44014a8955a11e3ca6fee4f113768447b9
|
4
|
+
data.tar.gz: e9bbfc0c852365081730a441afa657ba8ef6aa45
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: dcae9c85fa64d98e67da40d615c7e1c50df244ed7317a4968e4b35fa0e97f5709700e9ecf9e70c16db4c7966a4cd4852b6a6df48d30b0cc9efdd712ef5af9b8b
|
7
|
+
data.tar.gz: bbd26c301fe64b96173607b0311abc479e594b9b8e51c1745bc10c9d65b04d517d6d73ac22c22174885ca0b12b4a1695e14094b63e3091445c53f773d3e22cde
|
data/CHANGELOG.md
CHANGED
@@ -1,6 +1,14 @@
|
|
1
1
|
# Hanami::Assets
|
2
2
|
Assets management for Ruby web applications
|
3
3
|
|
4
|
+
## v0.2.1 - 2016-02-05
|
5
|
+
### Changed
|
6
|
+
- [Derk-Jan Karrenbeld] Don't precompile `.map` files
|
7
|
+
|
8
|
+
### Fixed
|
9
|
+
- [Luca Guidi] Fix recursive Sass imports
|
10
|
+
- [Luca Guidi] Ensure to truncate assets in public before to precompile/copy them
|
11
|
+
|
4
12
|
## v0.2.0 - 2016-01-22
|
5
13
|
### Changed
|
6
14
|
- [Luca Guidi] Renamed the project
|
data/README.md
CHANGED
@@ -335,7 +335,7 @@ To do so we need to specify which gem we want to use and add it to our `Gemfile`
|
|
335
335
|
Hanami can use the following compressors (aka minifiers) for JavaScript.
|
336
336
|
|
337
337
|
* `:builtin` - Ruby based implementation of jsmin. It doesn't require any external gem.
|
338
|
-
* `:yui` - [YUI Compressor](http://yui.github.io/yuicompressor), it depends on [`yui-compressor`](https://rubygems.org/gems/yui-compressor) gem and
|
338
|
+
* `:yui` - [YUI Compressor](http://yui.github.io/yuicompressor), it depends on [`yui-compressor`](https://rubygems.org/gems/yui-compressor) gem and it requires Java 1.4+
|
339
339
|
* `:uglifier` - [UglifyJS](http://lisperator.net/uglifyjs), it depends on [`uglifier`](https://rubygems.org/gems/uglifier) gem and it requires Node.js
|
340
340
|
* `:closure` - [Google Closure Compiler](https://developers.google.com/closure/compiler), it depends on [`closure-compiler`](https://rubygems.org/gems/closure-compiler) gem and it requires Java
|
341
341
|
|
@@ -350,7 +350,7 @@ end
|
|
350
350
|
Hanami can use the following compressors (aka minifiers) for Stylesheet.
|
351
351
|
|
352
352
|
* `:builtin` - Ruby based compressor. It doesn't require any external gem. It's fast, but not an efficient compressor.
|
353
|
-
* `:yui` - [YUI Compressor](http://yui.github.io/yuicompressor), it depends on [`yui-compressor`](https://rubygems.org/gems/yui-compressor) gem and
|
353
|
+
* `:yui` - [YUI Compressor](http://yui.github.io/yuicompressor), it depends on [`yui-compressor`](https://rubygems.org/gems/yui-compressor) gem and it requires Java 1.4+
|
354
354
|
* `:sass` - [Sass](http://sass-lang.com/), it depends on [`sass`](https://rubygems.org/gems/sass) gem
|
355
355
|
|
356
356
|
```ruby
|
data/lib/hanami/assets/cache.rb
CHANGED
@@ -4,7 +4,7 @@ module Hanami
|
|
4
4
|
module Assets
|
5
5
|
# Store assets references when compile mode is on.
|
6
6
|
#
|
7
|
-
# This is
|
7
|
+
# This is especially useful in development mode, where we want to compile
|
8
8
|
# only the assets that were changed from last browser refresh.
|
9
9
|
#
|
10
10
|
# @since 0.1.0
|
@@ -1,3 +1,5 @@
|
|
1
|
+
require 'find'
|
2
|
+
|
1
3
|
module Hanami
|
2
4
|
module Assets
|
3
5
|
class MissingAsset < Error
|
@@ -33,7 +35,7 @@ module Hanami
|
|
33
35
|
|
34
36
|
# @since 0.1.0
|
35
37
|
# @api private
|
36
|
-
EXTENSIONS = {'.js' => true, '.css' => true}.freeze
|
38
|
+
EXTENSIONS = {'.js' => true, '.css' => true, '.map' => true}.freeze
|
37
39
|
|
38
40
|
# @since 0.1.0
|
39
41
|
# @api private
|
@@ -170,7 +172,7 @@ module Hanami
|
|
170
172
|
#
|
171
173
|
# This is needed to don't create a `.sass-cache' directory at the root of the project,
|
172
174
|
# but to have it under `tmp/sass-cache'.
|
173
|
-
write { Tilt.new(source, nil, load_paths:
|
175
|
+
write { Tilt.new(source, nil, load_paths: sass_load_paths, cache_location: sass_cache_location).render }
|
174
176
|
rescue RuntimeError
|
175
177
|
raise UnknownAssetEngine.new(source)
|
176
178
|
end
|
@@ -191,7 +193,7 @@ module Hanami
|
|
191
193
|
# @api private
|
192
194
|
def write
|
193
195
|
destination.dirname.mkpath
|
194
|
-
destination.open(File::WRONLY|File::CREAT, DEFAULT_PERMISSIONS) do |file|
|
196
|
+
destination.open(File::WRONLY|File::TRUNC|File::CREAT, DEFAULT_PERMISSIONS) do |file|
|
195
197
|
file.write(yield)
|
196
198
|
end
|
197
199
|
end
|
@@ -202,6 +204,20 @@ module Hanami
|
|
202
204
|
self.class.cache
|
203
205
|
end
|
204
206
|
|
207
|
+
# @since x.x.x
|
208
|
+
# @api private
|
209
|
+
def sass_load_paths
|
210
|
+
result = []
|
211
|
+
|
212
|
+
@configuration.sources.each do |source|
|
213
|
+
Find.find(source) do |path|
|
214
|
+
result << path if File.directory?(path)
|
215
|
+
end
|
216
|
+
end
|
217
|
+
|
218
|
+
result
|
219
|
+
end
|
220
|
+
|
205
221
|
# @since 0.1.0
|
206
222
|
# @api private
|
207
223
|
def sass_cache_location
|
@@ -39,7 +39,7 @@ module Hanami
|
|
39
39
|
# @since 0.1.0
|
40
40
|
# @api private
|
41
41
|
def clear_public_directory
|
42
|
-
public_directory =
|
42
|
+
public_directory = @configuration.public_directory
|
43
43
|
public_directory.rmtree if public_directory.exist?
|
44
44
|
end
|
45
45
|
|
@@ -47,7 +47,12 @@ module Hanami
|
|
47
47
|
# @api private
|
48
48
|
def precompile
|
49
49
|
applications.each do |duplicate|
|
50
|
-
config = duplicate.configuration
|
50
|
+
config = if duplicate.respond_to?(:configuration)
|
51
|
+
duplicate.configuration
|
52
|
+
else
|
53
|
+
duplicate
|
54
|
+
end
|
55
|
+
|
51
56
|
config.compile true
|
52
57
|
|
53
58
|
config.files.each do |file|
|
@@ -60,7 +65,7 @@ module Hanami
|
|
60
65
|
# @api private
|
61
66
|
def applications
|
62
67
|
@duplicates.empty? ?
|
63
|
-
[
|
68
|
+
[@configuration] : @duplicates
|
64
69
|
end
|
65
70
|
end
|
66
71
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hanami-assets
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Luca Guidi
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2016-
|
13
|
+
date: 2016-02-05 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: hanami-utils
|