hanami-assets 0.2.0 → 0.2.1

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a443db3ecee31792abeda3bc3c777df04b3ed8e7
4
- data.tar.gz: e8cabf2dc50f5a1a9d6c2e44403a251bddbf9873
3
+ metadata.gz: 15727c44014a8955a11e3ca6fee4f113768447b9
4
+ data.tar.gz: e9bbfc0c852365081730a441afa657ba8ef6aa45
5
5
  SHA512:
6
- metadata.gz: c837a69fa374ed5ccefedc39c202769135e8d15021a6eb11859d3d8737e0152c5add82a756a58a138ece98d258a1acb08fc0557258c225fc679ece71a5787d1c
7
- data.tar.gz: d54301922da41e242a1b5bb3e6bbf952a61007f3e3ece7c17462853dd105f42e11c0e465b46e58883d9d1a44e62b5efa8ea5b2c0ec4436c93b815957d6aa7c81
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 iπt requires Java 1.4+
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 iπt requires Java 1.4+
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
@@ -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 expecially useful in development mode, where we want to compile
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: @configuration.sources.to_a, cache_location: sass_cache_location).render }
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
@@ -59,12 +59,6 @@ module Hanami
59
59
  result
60
60
  end
61
61
 
62
- # @since 0.1.0
63
- # @api private
64
- def to_a
65
- map {|s| s }
66
- end
67
-
68
62
  private
69
63
  # @since 0.1.0
70
64
  # @api private
@@ -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 = Hanami::Assets.configuration.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
- [Hanami::Assets] : @duplicates
68
+ [@configuration] : @duplicates
64
69
  end
65
70
  end
66
71
  end
@@ -3,6 +3,6 @@ module Hanami
3
3
  # Defines the version
4
4
  #
5
5
  # @since 0.1.0
6
- VERSION = '0.2.0'.freeze
6
+ VERSION = '0.2.1'.freeze
7
7
  end
8
8
  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.0
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-01-22 00:00:00.000000000 Z
13
+ date: 2016-02-05 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: hanami-utils