hanami-assets 1.1.0 → 1.1.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
- SHA1:
3
- metadata.gz: 9eb5dd67fc9b038fdc57c4901662ffc7e7e49b24
4
- data.tar.gz: a31d3212cc379ffb81457b9921238eb534f7788a
2
+ SHA256:
3
+ metadata.gz: 8d71de2dd9edf00f8046d10907f60b555b0391d3079bc81b58bd88ec68d7eaf4
4
+ data.tar.gz: 823426740462f9e3d5a5357de6d6fe15d761dec2130e4e0363fe51f8b4ffebd7
5
5
  SHA512:
6
- metadata.gz: b7bf095b5753fc4b5127d250e6cc300e8629b505b1561cab2b0ebf1108ed3c2c4f71447cf2a3a69c1891079b7a0fa713e76065e1b7e4c933ed9bd2c2edf06e17
7
- data.tar.gz: 80c5b8e66a51fdaf79bbcdc99e6e90f7fec27ef8c8a6831e4e2fed55b5701079997922c95398c3dcf15f519f01bc53688691b8dc050af590679346e42a9af657
6
+ metadata.gz: c6de7ae4f3605ea0ea0a823f14699ba8b6c4358652fb377e70af78fb5147ae33554352de2d40ba168c8039836f359c8769f44107d107cd1aa4cda7e04c6fb06b
7
+ data.tar.gz: fd1f5db6af660bfd1893495ce5059f915d8855c8b404fc648515dbadbcfc55d800f83867f9417f32a88399a86887d2a6b1da1cac07bd5b7e0af3233c697437c7
data/CHANGELOG.md CHANGED
@@ -1,6 +1,13 @@
1
1
  # Hanami::Assets
2
2
  Assets management for Ruby web applications
3
3
 
4
+ ## v1.1.1 - 2018-02-27
5
+ ### Added
6
+ - [Luca Guidi] Official support for Ruby: MRI 2.5
7
+
8
+ ### Fixed
9
+ - [Malina Sulca] Print `href` and `src` first in output HTML
10
+
4
11
  ## v1.1.0 - 2017-10-25
5
12
  ### Fixed
6
13
  - [Luca Guidi] Don't let `#javascript` and `#stylesheet` helpers to append file extension if the URL contains a query string
@@ -46,7 +46,7 @@ module Hanami
46
46
  # @api private
47
47
  def _compress(compressor)
48
48
  compressor.compress(@path)
49
- rescue => e # rubocop:disable Lint/RescueWithoutErrorClass
49
+ rescue => e # rubocop:disable Style/RescueStandardError
50
50
  warn(
51
51
  [
52
52
  "Skipping compression of: `#{@path}'",
@@ -1,4 +1,3 @@
1
- require 'thread'
2
1
  require 'pathname'
3
2
 
4
3
  module Hanami
@@ -1,6 +1,5 @@
1
1
  require 'uri'
2
2
  require 'set'
3
- require 'thread'
4
3
  require 'hanami/helpers/html_helper'
5
4
  require 'hanami/utils/escape'
6
5
 
@@ -166,18 +165,22 @@ module Hanami
166
165
  # <%= javascript 'application' %>
167
166
  #
168
167
  # # <script src="https://assets.bookshelf.org/assets/application-28a6b886de2372ee3922fcaf3f78f2d8.js" type="text/javascript"></script>
169
- def javascript(*sources, **options)
170
- _safe_tags(*sources) do |source|
171
- tag_options = options.dup
172
- tag_options[:src] ||= _typed_asset_path(source, JAVASCRIPT_EXT)
173
- tag_options[:type] ||= JAVASCRIPT_MIME_TYPE
168
+ def javascript(*sources, **options) # rubocop:disable Metrics/MethodLength
169
+ options = options.reject { |k, _| k.to_sym == :src }
174
170
 
175
- if _subresource_integrity? || tag_options.include?(:integrity)
176
- tag_options[:integrity] ||= _subresource_integrity_value(source, JAVASCRIPT_EXT)
177
- tag_options[:crossorigin] ||= CROSSORIGIN_ANONYMOUS
171
+ _safe_tags(*sources) do |source|
172
+ attributes = {
173
+ src: _typed_asset_path(source, JAVASCRIPT_EXT),
174
+ type: JAVASCRIPT_MIME_TYPE
175
+ }
176
+ attributes.merge!(options)
177
+
178
+ if _subresource_integrity? || attributes.include?(:integrity)
179
+ attributes[:integrity] ||= _subresource_integrity_value(source, JAVASCRIPT_EXT)
180
+ attributes[:crossorigin] ||= CROSSORIGIN_ANONYMOUS
178
181
  end
179
182
 
180
- html.script(**tag_options).to_s
183
+ html.script(**attributes).to_s
181
184
  end
182
185
  end
183
186
 
@@ -253,19 +256,23 @@ module Hanami
253
256
  # <%= stylesheet 'application' %>
254
257
  #
255
258
  # # <link href="https://assets.bookshelf.org/assets/application-28a6b886de2372ee3922fcaf3f78f2d8.css" type="text/css" rel="stylesheet">
256
- def stylesheet(*sources, **options) # rubocop:disable Metrics/AbcSize, Metrics/MethodLength
259
+ def stylesheet(*sources, **options) # rubocop:disable Metrics/MethodLength
260
+ options = options.reject { |k, _| k.to_sym == :href }
261
+
257
262
  _safe_tags(*sources) do |source|
258
- tag_options = options.dup
259
- tag_options[:href] ||= _typed_asset_path(source, STYLESHEET_EXT)
260
- tag_options[:type] ||= STYLESHEET_MIME_TYPE
261
- tag_options[:rel] ||= STYLESHEET_REL
262
-
263
- if _subresource_integrity? || tag_options.include?(:integrity)
264
- tag_options[:integrity] ||= _subresource_integrity_value(source, STYLESHEET_EXT)
265
- tag_options[:crossorigin] ||= CROSSORIGIN_ANONYMOUS
263
+ attributes = {
264
+ href: _typed_asset_path(source, STYLESHEET_EXT),
265
+ type: STYLESHEET_MIME_TYPE,
266
+ rel: STYLESHEET_REL
267
+ }
268
+ attributes.merge!(options)
269
+
270
+ if _subresource_integrity? || attributes.include?(:integrity)
271
+ attributes[:integrity] ||= _subresource_integrity_value(source, STYLESHEET_EXT)
272
+ attributes[:crossorigin] ||= CROSSORIGIN_ANONYMOUS
266
273
  end
267
274
 
268
- html.link(**tag_options).to_s
275
+ html.link(**attributes).to_s
269
276
  end
270
277
  end
271
278
 
@@ -335,10 +342,15 @@ module Hanami
335
342
  #
336
343
  # # <img src="https://assets.bookshelf.org/assets/logo-28a6b886de2372ee3922fcaf3f78f2d8.png" alt="Logo">
337
344
  def image(source, options = {})
338
- options[:src] = asset_path(source)
339
- options[:alt] ||= Utils::String.titleize(::File.basename(source, WILDCARD_EXT))
345
+ options = options.reject { |k, _| k.to_sym == :src }
340
346
 
341
- html.img(options)
347
+ attributes = {
348
+ src: asset_path(source),
349
+ alt: Utils::String.titleize(::File.basename(source, WILDCARD_EXT))
350
+ }
351
+ attributes.merge!(options)
352
+
353
+ html.img(attributes)
342
354
  end
343
355
 
344
356
  # Generate <tt>link</tt> tag application favicon.
@@ -397,11 +409,16 @@ module Hanami
397
409
  #
398
410
  # # <link href="https://assets.bookshelf.org/assets/favicon-28a6b886de2372ee3922fcaf3f78f2d8.ico" rel="shortcut icon" type="image/x-icon">
399
411
  def favicon(source = DEFAULT_FAVICON, options = {})
400
- options[:href] = asset_path(source)
401
- options[:rel] ||= FAVICON_REL
402
- options[:type] ||= FAVICON_MIME_TYPE
412
+ options = options.reject { |k, _| k.to_sym == :href }
413
+
414
+ attributes = {
415
+ href: asset_path(source),
416
+ rel: FAVICON_REL,
417
+ type: FAVICON_MIME_TYPE
418
+ }
419
+ attributes.merge!(options)
403
420
 
404
- html.link(options)
421
+ html.link(attributes)
405
422
  end
406
423
 
407
424
  # Generate <tt>video</tt> tag for given source
@@ -52,7 +52,7 @@ module Hanami
52
52
  asset_file_name.unlink if asset_file_name.exist?
53
53
  end
54
54
  rescue JSON::ParserError
55
- $stderr.puts 'Non JSON manifest found and unlinked.'
55
+ warn 'Non JSON manifest found and unlinked.'
56
56
  ensure
57
57
  manifest.unlink
58
58
  end
@@ -3,6 +3,6 @@ module Hanami
3
3
  # Defines the version
4
4
  #
5
5
  # @since 0.1.0
6
- VERSION = '1.1.0'.freeze
6
+ VERSION = '1.1.1'.freeze
7
7
  end
8
8
  end
data/lib/hanami/assets.rb CHANGED
@@ -1,4 +1,3 @@
1
- require 'thread'
2
1
  require 'hanami/utils/class_attribute'
3
2
 
4
3
  # Hanami
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hanami-assets
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Luca Guidi
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-10-25 00:00:00.000000000 Z
11
+ date: 2018-02-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: hanami-utils
@@ -245,7 +245,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
245
245
  version: '0'
246
246
  requirements: []
247
247
  rubyforge_project:
248
- rubygems_version: 2.6.13
248
+ rubygems_version: 2.7.5
249
249
  signing_key:
250
250
  specification_version: 4
251
251
  summary: Assets management