hanami-assets 1.3.4 → 1.3.5

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
  SHA256:
3
- metadata.gz: dec13ddd703f41b58845cc0dbbcb07c702e15dbb501d06930d6b4c2a968bedf4
4
- data.tar.gz: 7c68a5fdeaf40a07a829222092a70fe12d1b91636e32e0b20b648a0a78b9cbbe
3
+ metadata.gz: 5176826ee1e6f1cdf7930ec50f52e9e2c3ddaad08c29081f50c3b523edf39910
4
+ data.tar.gz: 5cdb9005b3f3c818d0ede825faa6e022ea61bf0d11d5d48c290b96797f28b0e4
5
5
  SHA512:
6
- metadata.gz: c46de5c621ef1725c288d7299a8a91eeb059cb8b9b88ac4e23a78961bd687176aa18eeaacfa8f2777002f32429f0248e12e923495bad5df3085fd3dddab37f9a
7
- data.tar.gz: f71eb9164a3ccc95446d0798b4c0284542840558838432f1b38ce1aaddedd79549b8d59d3c13adfd93ec054def0c9066590273c5d43d840e2cd412d466c9806a
6
+ metadata.gz: 249d3393b9b7936b601b680273da8f3ca07e5eca1dd684b0906d6132a476741a80729d7f0ac596de525b4e48a7a97cc5ca67bfc38806e9209ac1c6cf031d68c1
7
+ data.tar.gz: 66588d6713351e17e2777fcf08f2eb65aa06c9d67dc6329dcacd119dfa3d41c8a57b7fe0875863a9e2a1c4a792f0b4142f61c849ec26add1f6951250d6c3e685
@@ -1,6 +1,11 @@
1
1
  # Hanami::Assets
2
2
  Assets management for Ruby web applications
3
3
 
4
+ ## v1.3.5 - 2021-01-14
5
+ ### Added
6
+ - [Luca Guidi] Official support for Ruby: MRI 3.0
7
+ - [Luca Guidi] Official support for Ruby: MRI 2.7
8
+
4
9
  ## v1.3.4 - 2019-10-11
5
10
  ### Fixed
6
11
  - [unleashy] Precompile assets using binary mode to ensure compatibility with Windows
data/LICENSE.md CHANGED
@@ -1,4 +1,4 @@
1
- Copyright © 2014-2017 Luca Guidi
1
+ Copyright © 2014-2021 Luca Guidi
2
2
 
3
3
  MIT License
4
4
 
data/README.md CHANGED
@@ -5,8 +5,7 @@ Assets management for Ruby web projects
5
5
  ## Status
6
6
 
7
7
  [![Gem Version](https://badge.fury.io/rb/hanami-assets.svg)](https://badge.fury.io/rb/hanami-assets)
8
- [![TravisCI](https://travis-ci.org/hanami/assets.svg?branch=master)](https://travis-ci.org/hanami/assets)
9
- [![CircleCI](https://circleci.com/gh/hanami/assets/tree/master.svg?style=svg)](https://circleci.com/gh/hanami/assets/tree/master)
8
+ [![CI](https://github.com/hanami/assets/workflows/ci/badge.svg?branch=master)](https://github.com/hanami/assets/actions?query=workflow%3Aci+branch%3Amaster)
10
9
  [![Test Coverage](https://codecov.io/gh/hanami/assets/branch/master/graph/badge.svg)](https://codecov.io/gh/hanami/assets)
11
10
  [![Depfu](https://badges.depfu.com/badges/4b37347bd74042ff96477495cc16531d/overview.svg)](https://depfu.com/github/hanami/assets?project=Bundler)
12
11
  [![Inline Docs](http://inch-ci.org/github/hanami/assets.svg)](http://inch-ci.org/github/hanami/assets)
@@ -494,6 +493,6 @@ __Hanami::Assets__ uses [Semantic Versioning 2.0.0](http://semver.org)
494
493
 
495
494
  ## Copyright
496
495
 
497
- Copyright © 2014-2017 Luca Guidi – Released under MIT License
496
+ Copyright © 2014-2021 Luca Guidi – Released under MIT License
498
497
 
499
498
  This project was formerly known as Lotus (`lotus-assets`).
@@ -1,22 +1,23 @@
1
1
  #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
2
3
 
3
- require 'optparse'
4
- require 'pathname'
4
+ require "optparse"
5
+ require "pathname"
5
6
 
6
7
  options = {}
7
8
  OptionParser.new do |opts|
8
- opts.banner = 'Usage: hanami-assets --config=path/to/config.rb'
9
+ opts.banner = "Usage: hanami-assets --config=path/to/config.rb"
9
10
 
10
- opts.on('-c', '--config FILE', 'Path to config') do |c|
11
+ opts.on("-c", "--config FILE", "Path to config") do |c|
11
12
  options[:config] = c
12
13
  end
13
14
  end.parse!
14
15
 
15
- config = options.fetch(:config) { raise ArgumentError.new('You must specify a configuration file') }
16
+ config = options.fetch(:config) { raise ArgumentError.new("You must specify a configuration file") }
16
17
  config = Pathname.new(config)
17
18
  config.exist? or raise ArgumentError.new("Cannot find configuration file: #{config}")
18
19
 
19
- require 'hanami/assets'
20
+ require "hanami/assets"
20
21
  load config
21
22
 
22
23
  Hanami::Assets.deploy
@@ -35,4 +35,6 @@ Gem::Specification.new do |spec|
35
35
 
36
36
  spec.add_development_dependency 'coffee-script', '~> 2.3'
37
37
  spec.add_development_dependency 'babel-transpiler', '~> 0.7'
38
+
39
+ spec.add_development_dependency 'rubocop', '0.81'
38
40
  end
@@ -1,4 +1,6 @@
1
- require 'hanami/utils/class_attribute'
1
+ # frozen_string_literal: true
2
+
3
+ require "hanami/utils/class_attribute"
2
4
 
3
5
  # Hanami
4
6
  #
@@ -16,10 +18,10 @@ module Hanami
16
18
  class Error < ::StandardError
17
19
  end
18
20
 
19
- require 'hanami/assets/version'
20
- require 'hanami/assets/configuration'
21
- require 'hanami/assets/config/global_sources'
22
- require 'hanami/assets/helpers'
21
+ require "hanami/assets/version"
22
+ require "hanami/assets/configuration"
23
+ require "hanami/assets/config/global_sources"
24
+ require "hanami/assets/helpers"
23
25
 
24
26
  include Utils::ClassAttribute
25
27
 
@@ -48,8 +50,8 @@ module Hanami
48
50
  #
49
51
  # @since 0.1.0
50
52
  def self.deploy
51
- require 'hanami/assets/precompiler'
52
- require 'hanami/assets/bundler'
53
+ require "hanami/assets/precompiler"
54
+ require "hanami/assets/bundler"
53
55
 
54
56
  Precompiler.new(configuration, duplicates).run
55
57
  Bundler.new(configuration, duplicates).run
@@ -59,8 +61,8 @@ module Hanami
59
61
  #
60
62
  # @since 0.4.0
61
63
  def self.precompile(configurations)
62
- require 'hanami/assets/precompiler'
63
- require 'hanami/assets/bundler'
64
+ require "hanami/assets/precompiler"
65
+ require "hanami/assets/bundler"
64
66
 
65
67
  Precompiler.new(configuration, configurations).run
66
68
  Bundler.new(configuration, configurations).run
@@ -1,9 +1,11 @@
1
- require 'fileutils'
2
- require 'json'
1
+ # frozen_string_literal: true
3
2
 
4
- require 'hanami/assets/bundler/compressor'
5
- require 'hanami/assets/bundler/asset'
6
- require 'hanami/assets/bundler/manifest_entry'
3
+ require "fileutils"
4
+ require "json"
5
+
6
+ require "hanami/assets/bundler/compressor"
7
+ require "hanami/assets/bundler/asset"
8
+ require "hanami/assets/bundler/manifest_entry"
7
9
 
8
10
  module Hanami
9
11
  module Assets
@@ -18,11 +20,11 @@ module Hanami
18
20
 
19
21
  # @since 0.1.0
20
22
  # @api private
21
- URL_SEPARATOR = '/'.freeze
23
+ URL_SEPARATOR = "/"
22
24
 
23
25
  # @since 0.1.0
24
26
  # @api private
25
- URL_REPLACEMENT = ''.freeze
27
+ URL_REPLACEMENT = ""
26
28
 
27
29
  # Return a new instance
28
30
  #
@@ -105,7 +107,7 @@ module Hanami
105
107
  # @api private
106
108
  def _convert_to_url(path)
107
109
  path.sub(public_directory.to_s, URL_REPLACEMENT)
108
- .gsub(File::SEPARATOR, URL_SEPARATOR)
110
+ .gsub(File::SEPARATOR, URL_SEPARATOR)
109
111
  end
110
112
 
111
113
  # @since 0.1.0
@@ -1,4 +1,6 @@
1
- require 'openssl'
1
+ # frozen_string_literal: true
2
+
3
+ require "openssl"
2
4
 
3
5
  module Hanami
4
6
  module Assets
@@ -20,7 +22,7 @@ module Hanami
20
22
 
21
23
  # @since 0.3.0
22
24
  # @api private
23
- WILDCARD_EXT = '.*'.freeze
25
+ WILDCARD_EXT = ".*"
24
26
 
25
27
  # Return a new instance
26
28
  #
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Hanami
2
4
  module Assets
3
5
  class Bundler
@@ -8,11 +10,11 @@ module Hanami
8
10
  class Compressor
9
11
  # @since 0.3.0
10
12
  # @api private
11
- JAVASCRIPT_EXT = '.js'.freeze
13
+ JAVASCRIPT_EXT = ".js"
12
14
 
13
15
  # @since 0.3.0
14
16
  # @api private
15
- STYLESHEET_EXT = '.css'.freeze
17
+ STYLESHEET_EXT = ".css"
16
18
 
17
19
  # Return a new instance
18
20
  #
@@ -39,7 +41,7 @@ module Hanami
39
41
  # @since 0.3.0
40
42
  # @api private
41
43
  def compressor(type)
42
- @configuration.__send__(:"#{ type }_compressor")
44
+ @configuration.__send__(:"#{type}_compressor")
43
45
  end
44
46
 
45
47
  # @since 0.3.0
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Hanami
2
4
  module Assets
3
5
  class Bundler
@@ -8,7 +10,7 @@ module Hanami
8
10
  class ManifestEntry
9
11
  # @since 0.3.0
10
12
  # @api private
11
- SUBRESOURCE_INTEGRITY_SEPARATOR = '-'.freeze
13
+ SUBRESOURCE_INTEGRITY_SEPARATOR = "-"
12
14
 
13
15
  # Return a new instance
14
16
  #
@@ -22,7 +24,7 @@ module Hanami
22
24
  # @since 0.3.0
23
25
  # @api private
24
26
  def entry
25
- { name => values }
27
+ {name => values}
26
28
  end
27
29
 
28
30
  private
@@ -54,7 +56,7 @@ module Hanami
54
56
  # @api private
55
57
  def _convert_to_url(path)
56
58
  path.sub(@asset.configuration.public_directory.to_s, URL_REPLACEMENT)
57
- .gsub(File::SEPARATOR, URL_SEPARATOR)
59
+ .gsub(File::SEPARATOR, URL_SEPARATOR)
58
60
  end
59
61
  end
60
62
  end
@@ -1,4 +1,6 @@
1
- require 'pathname'
1
+ # frozen_string_literal: true
2
+
3
+ require "pathname"
2
4
 
3
5
  module Hanami
4
6
  module Assets
@@ -1,13 +1,15 @@
1
- require 'set'
2
- require 'find'
3
- require 'hanami/utils/class_attribute'
1
+ # frozen_string_literal: true
2
+
3
+ require "set"
4
+ require "find"
5
+ require "hanami/utils/class_attribute"
4
6
 
5
7
  module Hanami
6
8
  module Assets
7
9
  # Missing Asset error
8
10
  class MissingAsset < Error
9
11
  def initialize(name, sources)
10
- sources = sources.map(&:to_s).join(', ')
12
+ sources = sources.map(&:to_s).join(", ")
11
13
  super("Missing asset: `#{name}' (sources: #{sources})")
12
14
  end
13
15
  end
@@ -28,18 +30,18 @@ module Hanami
28
30
  #
29
31
  # @since 0.1.0
30
32
  # @api private
31
- class Compiler # rubocop:disable Metrics/ClassLength
33
+ class Compiler
32
34
  # @since 0.1.0
33
35
  # @api private
34
36
  DEFAULT_PERMISSIONS = 0o644
35
37
 
36
38
  # @since 0.1.0
37
39
  # @api private
38
- COMPILE_PATTERN = '*.*.*'.freeze # Example hello.js.es6
40
+ COMPILE_PATTERN = "*.*.*" # Example hello.js.es6
39
41
 
40
42
  # @since 0.1.0
41
43
  # @api private
42
- EXTENSIONS = { '.js' => true, '.css' => true, '.map' => true }.freeze
44
+ EXTENSIONS = {".js" => true, ".css" => true, ".map" => true}.freeze
43
45
 
44
46
  include Utils::ClassAttribute
45
47
 
@@ -67,10 +69,10 @@ module Hanami
67
69
  def self.compile(configuration, name)
68
70
  return unless configuration.compile
69
71
 
70
- require 'tilt'
71
- require 'hanami/assets/cache'
72
- require 'hanami/assets/compilers/sass'
73
- require 'hanami/assets/compilers/less'
72
+ require "tilt"
73
+ require "hanami/assets/cache"
74
+ require "hanami/assets/compilers/sass"
75
+ require "hanami/assets/compilers/less"
74
76
  fabricate(configuration, name).compile
75
77
  end
76
78
 
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Hanami
2
4
  module Assets
3
5
  module Compilers
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Hanami
2
4
  module Assets
3
5
  module Compilers
@@ -20,7 +22,7 @@ module Hanami
20
22
  # @api private
21
23
  def initialize(*)
22
24
  super
23
- require 'sassc'
25
+ require "sassc"
24
26
  end
25
27
 
26
28
  private
@@ -1,4 +1,6 @@
1
- require 'hanami/utils/load_paths'
1
+ # frozen_string_literal: true
2
+
3
+ require "hanami/utils/load_paths"
2
4
 
3
5
  module Hanami
4
6
  module Assets
@@ -27,7 +29,7 @@ module Hanami
27
29
 
28
30
  # @since 0.1.0
29
31
  # @api private
30
- alias << push
32
+ alias_method :<<, :push
31
33
 
32
34
  private
33
35
 
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Hanami
2
4
  module Assets
3
5
  # This error is raised when the application starts but can't be load the
@@ -83,11 +85,11 @@ module Hanami
83
85
  class Manifest
84
86
  # @since 0.4.0
85
87
  # @api private
86
- TARGET = 'target'.freeze
88
+ TARGET = "target"
87
89
 
88
90
  # @since 0.3.0
89
91
  # @api private
90
- SUBRESOURCE_INTEGRITY = 'sri'.freeze
92
+ SUBRESOURCE_INTEGRITY = "sri"
91
93
 
92
94
  # Return a new instance
93
95
  #
@@ -1,5 +1,7 @@
1
- require 'hanami/utils/load_paths'
2
- require 'hanami/utils/file_list'
1
+ # frozen_string_literal: true
2
+
3
+ require "hanami/utils/load_paths"
4
+ require "hanami/utils/file_list"
3
5
 
4
6
  module Hanami
5
7
  module Assets
@@ -20,7 +22,7 @@ module Hanami
20
22
  class Sources < Utils::LoadPaths
21
23
  # @since 0.3.0
22
24
  # @api private
23
- SKIPPED_FILE_PREFIX = '_'.freeze
25
+ SKIPPED_FILE_PREFIX = "_"
24
26
 
25
27
  # @since 0.1.0
26
28
  # @api private
@@ -1,61 +1,63 @@
1
- require 'pathname'
2
- require 'json'
3
- require 'hanami/utils/string'
4
- require 'hanami/utils/class'
5
- require 'hanami/utils/path_prefix'
6
- require 'hanami/utils/basic_object'
7
- require 'hanami/assets/config/manifest'
8
- require 'hanami/assets/config/sources'
1
+ # frozen_string_literal: true
2
+
3
+ require "pathname"
4
+ require "json"
5
+ require "hanami/utils/string"
6
+ require "hanami/utils/class"
7
+ require "hanami/utils/path_prefix"
8
+ require "hanami/utils/basic_object"
9
+ require "hanami/assets/config/manifest"
10
+ require "hanami/assets/config/sources"
9
11
 
10
12
  module Hanami
11
13
  module Assets
12
14
  # Framework configuration
13
15
  #
14
16
  # @since 0.1.0
15
- class Configuration # rubocop:disable Metrics/ClassLength
17
+ class Configuration
16
18
  # @since 0.1.0
17
19
  # @api private
18
- DEFAULT_SCHEME = 'http'.freeze
20
+ DEFAULT_SCHEME = "http"
19
21
 
20
22
  # @since 0.1.0
21
23
  # @api private
22
- DEFAULT_HOST = 'localhost'.freeze
24
+ DEFAULT_HOST = "localhost"
23
25
 
24
26
  # @since 0.1.0
25
27
  # @api private
26
- DEFAULT_PORT = '2300'.freeze
28
+ DEFAULT_PORT = "2300"
27
29
 
28
30
  # @since 0.1.0
29
31
  # @api private
30
- DEFAULT_PUBLIC_DIRECTORY = 'public'.freeze
32
+ DEFAULT_PUBLIC_DIRECTORY = "public"
31
33
 
32
34
  # @since 0.1.0
33
35
  # @api private
34
- DEFAULT_MANIFEST = 'assets.json'.freeze
36
+ DEFAULT_MANIFEST = "assets.json"
35
37
 
36
38
  # @since 0.1.0
37
39
  # @api private
38
- DEFAULT_PREFIX = '/assets'.freeze
40
+ DEFAULT_PREFIX = "/assets"
39
41
 
40
42
  # @since 0.1.0
41
43
  # @api private
42
- URL_SEPARATOR = '/'.freeze
44
+ URL_SEPARATOR = "/"
43
45
 
44
46
  # @since 0.1.0
45
47
  # @api private
46
- HTTP_SCHEME = 'http'.freeze
48
+ HTTP_SCHEME = "http"
47
49
 
48
50
  # @since 0.1.0
49
51
  # @api private
50
- HTTP_PORT = '80'.freeze
52
+ HTTP_PORT = "80"
51
53
 
52
54
  # @since 0.1.0
53
55
  # @api private
54
- HTTPS_SCHEME = 'https'.freeze
56
+ HTTPS_SCHEME = "https"
55
57
 
56
58
  # @since 0.1.0
57
59
  # @api private
58
- HTTPS_PORT = '443'.freeze
60
+ HTTPS_PORT = "443"
59
61
 
60
62
  # @since 0.3.0
61
63
  # @api private
@@ -63,7 +65,7 @@ module Hanami
63
65
 
64
66
  # @since 0.3.0
65
67
  # @api private
66
- SUBRESOURCE_INTEGRITY_SEPARATOR = ' '.freeze
68
+ SUBRESOURCE_INTEGRITY_SEPARATOR = " "
67
69
 
68
70
  # Return a copy of the configuration of the framework instance associated
69
71
  # with the given class.
@@ -80,9 +82,10 @@ module Hanami
80
82
  # @since 0.1.0
81
83
  # @api private
82
84
  def self.for(base)
83
- # TODO: this implementation is similar to Hanami::Controller::Configuration consider to extract it into Hanami::Utils
85
+ # TODO: this implementation is similar to Hanami::Controller::Configuration
86
+ # consider to extract it into Hanami::Utils
84
87
  namespace = Utils::String.namespace(base)
85
- framework = Utils::Class.load("#{namespace}::Assets") || Utils::Class.load!('Hanami::Assets')
88
+ framework = Utils::Class.load("#{namespace}::Assets") || Utils::Class.load!("Hanami::Assets")
86
89
  framework.configuration
87
90
  end
88
91
 
@@ -136,7 +139,7 @@ module Hanami
136
139
  if value.nil?
137
140
  @nested
138
141
  else
139
- @nested = !!value # rubocop:disable Style/DoubleNegation
142
+ @nested = !!value
140
143
  end
141
144
  end
142
145
 
@@ -166,7 +169,7 @@ module Hanami
166
169
  if value.nil?
167
170
  @cdn
168
171
  else
169
- @cdn = !!value # rubocop:disable Style/DoubleNegation
172
+ @cdn = !!value
170
173
  end
171
174
  end
172
175
 
@@ -183,7 +186,8 @@ module Hanami
183
186
  # * <tt>:builtin</tt> - Ruby based implementation of jsmin. It doesn't require any external gem.
184
187
  # * <tt>:yui</tt> - YUI Compressor, it depends on <tt>yui-compressor</tt> gem and it requires Java 1.4+
185
188
  # * <tt>:uglifier</tt> - UglifyJS, it depends on <tt>uglifier</tt> gem and it requires Node.js
186
- # * <tt>:closure</tt> - Google Closure Compiler, it depends on <tt>closure-compiler</tt> gem and it requires Java
189
+ # * <tt>:closure</tt> - Google Closure Compiler, it depends on <tt>closure-compiler</tt> gem
190
+ # and it requires Java
187
191
  #
188
192
  # @param value [Symbol,#compress] the compressor
189
193
  #
@@ -231,7 +235,8 @@ module Hanami
231
235
  #
232
236
  # The following symbols are accepted:
233
237
  #
234
- # * <tt>:builtin</tt> - Ruby based compressor. It doesn't require any external gem. It's fast, but not an efficient compressor.
238
+ # * <tt>:builtin</tt> - Ruby based compressor. It doesn't require any external gem.
239
+ # It's fast, but not an efficient compressor.
235
240
  # * <tt>:yui</tt> - YUI-Compressor, it depends on <tt>yui-compressor</tt> gem and requires Java 1.4+
236
241
  # * <tt>:sass</tt> - Sass, it depends on <tt>sassc</tt> gem
237
242
  #
@@ -484,7 +489,7 @@ module Hanami
484
489
  # @see Hanami::Assets::Configuration#javascript_compressor
485
490
  # @see Hanami::Assets::Compressors::Javascript#for
486
491
  def js_compressor
487
- require 'hanami/assets/compressors/javascript'
492
+ require "hanami/assets/compressors/javascript"
488
493
  Hanami::Assets::Compressors::Javascript.for(javascript_compressor)
489
494
  end
490
495
 
@@ -501,13 +506,13 @@ module Hanami
501
506
  # @see Hanami::Assets::Configuration#stylesheet_compressor
502
507
  # @see Hanami::Assets::Compressors::Stylesheet#for
503
508
  def css_compressor
504
- require 'hanami/assets/compressors/stylesheet'
509
+ require "hanami/assets/compressors/stylesheet"
505
510
  Hanami::Assets::Compressors::Stylesheet.for(stylesheet_compressor)
506
511
  end
507
512
 
508
513
  # @since 0.1.0
509
514
  # @api private
510
- def duplicate # rubocop:disable Metrics/AbcSize, Metrics/MethodLength
515
+ def duplicate
511
516
  Configuration.new.tap do |c|
512
517
  c.root = root
513
518
  c.scheme = scheme
@@ -528,7 +533,7 @@ module Hanami
528
533
 
529
534
  # @since 0.1.0
530
535
  # @api private
531
- def reset! # rubocop:disable Metrics/AbcSize, Metrics/MethodLength
536
+ def reset!
532
537
  @scheme = DEFAULT_SCHEME
533
538
  @host = DEFAULT_HOST
534
539
  @port = DEFAULT_PORT
@@ -1,6 +1,8 @@
1
- require 'uri'
2
- require 'hanami/helpers/html_helper'
3
- require 'hanami/utils/escape'
1
+ # frozen_string_literal: true
2
+
3
+ require "uri"
4
+ require "hanami/helpers/html_helper"
5
+ require "hanami/utils/escape"
4
6
 
5
7
  module Hanami
6
8
  module Assets
@@ -13,51 +15,50 @@ module Hanami
13
15
  # @see http://www.rubydoc.info/gems/hanami-helpers/Hanami/Helpers/HtmlHelper
14
16
  #
15
17
  # rubocop:disable Metrics/ModuleLength
16
- # rubocop:disable Naming/UncommunicativeMethodParamName
17
18
  module Helpers
18
19
  # @since 0.1.0
19
20
  # @api private
20
- NEW_LINE_SEPARATOR = "\n".freeze
21
+ NEW_LINE_SEPARATOR = "\n"
21
22
 
22
23
  # @since 0.1.0
23
24
  # @api private
24
- WILDCARD_EXT = '.*'.freeze
25
+ WILDCARD_EXT = ".*"
25
26
 
26
27
  # @since 0.1.0
27
28
  # @api private
28
- JAVASCRIPT_EXT = '.js'.freeze
29
+ JAVASCRIPT_EXT = ".js"
29
30
 
30
31
  # @since 0.1.0
31
32
  # @api private
32
- STYLESHEET_EXT = '.css'.freeze
33
+ STYLESHEET_EXT = ".css"
33
34
 
34
35
  # @since 0.1.0
35
36
  # @api private
36
- JAVASCRIPT_MIME_TYPE = 'text/javascript'.freeze
37
+ JAVASCRIPT_MIME_TYPE = "text/javascript"
37
38
 
38
39
  # @since 0.1.0
39
40
  # @api private
40
- STYLESHEET_MIME_TYPE = 'text/css'.freeze
41
+ STYLESHEET_MIME_TYPE = "text/css"
41
42
 
42
43
  # @since 0.1.0
43
44
  # @api private
44
- FAVICON_MIME_TYPE = 'image/x-icon'.freeze
45
+ FAVICON_MIME_TYPE = "image/x-icon"
45
46
 
46
47
  # @since 0.1.0
47
48
  # @api private
48
- STYLESHEET_REL = 'stylesheet'.freeze
49
+ STYLESHEET_REL = "stylesheet"
49
50
 
50
51
  # @since 0.1.0
51
52
  # @api private
52
- FAVICON_REL = 'shortcut icon'.freeze
53
+ FAVICON_REL = "shortcut icon"
53
54
 
54
55
  # @since 0.1.0
55
56
  # @api private
56
- DEFAULT_FAVICON = 'favicon.ico'.freeze
57
+ DEFAULT_FAVICON = "favicon.ico"
57
58
 
58
59
  # @since 0.3.0
59
60
  # @api private
60
- CROSSORIGIN_ANONYMOUS = 'anonymous'.freeze
61
+ CROSSORIGIN_ANONYMOUS = "anonymous"
61
62
 
62
63
  # @since 0.3.0
63
64
  # @api private
@@ -140,13 +141,15 @@ module Hanami
140
141
  #
141
142
  # <%= javascript 'application' %>
142
143
  #
143
- # # <script src="/assets/application-28a6b886de2372ee3922fcaf3f78f2d8.js" type="text/javascript" integrity="sha384-oqVu...Y8wC" crossorigin="anonymous"></script>
144
+ # # <script src="/assets/application-28a6b886de2372ee3922fcaf3f78f2d8.js"
145
+ # # type="text/javascript" integrity="sha384-oqVu...Y8wC" crossorigin="anonymous"></script>
144
146
  #
145
147
  # @example Subresource Integrity for 3rd Party Scripts
146
148
  #
147
149
  # <%= javascript 'https://example.com/assets/example.js', integrity: 'sha384-oqVu...Y8wC' %>
148
150
  #
149
- # # <script src="https://example.com/assets/example.js" type="text/javascript" integrity="sha384-oqVu...Y8wC" crossorigin="anonymous"></script>
151
+ # # <script src="https://example.com/assets/example.js" type="text/javascript"
152
+ # # integrity="sha384-oqVu...Y8wC" crossorigin="anonymous"></script>
150
153
  #
151
154
  # @example Deferred Execution
152
155
  #
@@ -170,13 +173,14 @@ module Hanami
170
173
  #
171
174
  # <%= javascript 'application' %>
172
175
  #
173
- # # <script src="https://assets.bookshelf.org/assets/application-28a6b886de2372ee3922fcaf3f78f2d8.js" type="text/javascript"></script>
176
+ # # <script src="https://assets.bookshelf.org/assets/application-28a6b886de2372ee3922fcaf3f78f2d8.js"
177
+ # # type="text/javascript"></script>
174
178
  #
175
179
  # @example Disable Push Promise/Early Hints
176
180
  #
177
181
  # <%= javascript 'application', push: false %>
178
182
  # <%= javascript 'http://cdn.example.test/jquery.js', 'dashboard', push: false %>
179
- def javascript(*sources, push: true, **options) # rubocop:disable Metrics/MethodLength
183
+ def javascript(*sources, push: true, **options)
180
184
  options = options.reject { |k, _| k.to_sym == :src }
181
185
 
182
186
  _safe_tags(*sources) do |source|
@@ -247,19 +251,22 @@ module Hanami
247
251
  #
248
252
  # <%= stylesheet 'application' %>
249
253
  #
250
- # # <link href="/assets/application-28a6b886de2372ee3922fcaf3f78f2d8.css" type="text/css" integrity="sha384-oqVu...Y8wC" crossorigin="anonymous"></script>
254
+ # # <link href="/assets/application-28a6b886de2372ee3922fcaf3f78f2d8.css"
255
+ # # type="text/css" integrity="sha384-oqVu...Y8wC" crossorigin="anonymous"></script>
251
256
  #
252
257
  # @example Subresource Integrity for 3rd Party Assets
253
258
  #
254
259
  # <%= stylesheet 'https://example.com/assets/example.css', integrity: 'sha384-oqVu...Y8wC' %>
255
260
  #
256
- # # <link href="https://example.com/assets/example.css" type="text/css" rel="stylesheet" integrity="sha384-oqVu...Y8wC" crossorigin="anonymous"></script>
261
+ # # <link href="https://example.com/assets/example.css"
262
+ # # type="text/css" rel="stylesheet" integrity="sha384-oqVu...Y8wC" crossorigin="anonymous"></script>
257
263
  #
258
264
  # @example Absolute URL
259
265
  #
260
266
  # <%= stylesheet 'https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css' %>
261
267
  #
262
- # # <link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" type="text/css" rel="stylesheet">
268
+ # # <link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css"
269
+ # # type="text/css" rel="stylesheet">
263
270
  #
264
271
  # @example Fingerprint Mode
265
272
  #
@@ -271,13 +278,14 @@ module Hanami
271
278
  #
272
279
  # <%= stylesheet 'application' %>
273
280
  #
274
- # # <link href="https://assets.bookshelf.org/assets/application-28a6b886de2372ee3922fcaf3f78f2d8.css" type="text/css" rel="stylesheet">
281
+ # # <link href="https://assets.bookshelf.org/assets/application-28a6b886de2372ee3922fcaf3f78f2d8.css"
282
+ # # type="text/css" rel="stylesheet">
275
283
  #
276
284
  # @example Disable Push Promise/Early Hints
277
285
  #
278
286
  # <%= stylesheet 'application', push: false %>
279
287
  # <%= stylesheet 'http://cdn.example.test/bootstrap.css', 'dashboard', push: false %>
280
- def stylesheet(*sources, push: true, **options) # rubocop:disable Metrics/MethodLength
288
+ def stylesheet(*sources, push: true, **options)
281
289
  options = options.reject { |k, _| k.to_sym == :href }
282
290
 
283
291
  _safe_tags(*sources) do |source|
@@ -435,7 +443,8 @@ module Hanami
435
443
  #
436
444
  # <%= favicon %>
437
445
  #
438
- # # <link href="https://assets.bookshelf.org/assets/favicon-28a6b886de2372ee3922fcaf3f78f2d8.ico" rel="shortcut icon" type="image/x-icon">
446
+ # # <link href="https://assets.bookshelf.org/assets/favicon-28a6b886de2372ee3922fcaf3f78f2d8.ico"
447
+ # rel="shortcut icon" type="image/x-icon">
439
448
  #
440
449
  # @example Enable Push Promise/Early Hints
441
450
  #
@@ -863,7 +872,7 @@ module Hanami
863
872
 
864
873
  # @api private
865
874
  def _subresource_integrity?
866
- !!self.class.assets_configuration.subresource_integrity # rubocop:disable Style/DoubleNegation
875
+ !!self.class.assets_configuration.subresource_integrity
867
876
  end
868
877
 
869
878
  # @api private
@@ -909,7 +918,9 @@ module Hanami
909
918
  options[:src] = asset_path(src, push: options.delete(:push) || false, as: as)
910
919
  end
911
920
 
912
- raise ArgumentError.new('You should provide a source via `src` option or with a `source` HTML tag') if !options[:src] && !block_given?
921
+ if !options[:src] && !block_given?
922
+ raise ArgumentError.new("You should provide a source via `src` option or with a `source` HTML tag")
923
+ end
913
924
 
914
925
  options
915
926
  end
@@ -918,7 +929,7 @@ module Hanami
918
929
  # @api private
919
930
  def _push_promise(url, as: nil)
920
931
  Thread.current[:__hanami_assets] ||= {}
921
- Thread.current[:__hanami_assets][url.to_s] = { as: as, crossorigin: _crossorigin?(url) }
932
+ Thread.current[:__hanami_assets][url.to_s] = {as: as, crossorigin: _crossorigin?(url)}
922
933
 
923
934
  url
924
935
  end
@@ -929,7 +940,6 @@ module Hanami
929
940
  source !~ QUERY_STRING_MATCHER && source !~ /#{Regexp.escape(ext)}\z/
930
941
  end
931
942
  end
932
- # rubocop:enable Naming/UncommunicativeMethodParamName
933
943
  # rubocop:enable Metrics/ModuleLength
934
944
  end
935
945
  end
@@ -1,5 +1,7 @@
1
- require 'fileutils'
2
- require 'hanami/assets/compiler'
1
+ # frozen_string_literal: true
2
+
3
+ require "fileutils"
4
+ require "hanami/assets/compiler"
3
5
 
4
6
  module Hanami
5
7
  module Assets
@@ -48,18 +50,18 @@ module Hanami
48
50
  # @api private
49
51
  def clear_manifest(manifest)
50
52
  JSON.parse(manifest).each_value do |asset_hash|
51
- asset_file_name = @configuration.public_directory.join(asset_hash['target'])
53
+ asset_file_name = @configuration.public_directory.join(asset_hash["target"])
52
54
  asset_file_name.unlink if asset_file_name.exist?
53
55
  end
54
56
  rescue JSON::ParserError
55
- warn 'Non JSON manifest found and unlinked.'
57
+ warn "Non JSON manifest found and unlinked."
56
58
  ensure
57
59
  manifest.unlink
58
60
  end
59
61
 
60
62
  # @since 0.1.0
61
63
  # @api private
62
- def precompile # rubocop:disable Metrics/MethodLength
64
+ def precompile
63
65
  applications.each do |duplicate|
64
66
  config = if duplicate.respond_to?(:configuration)
65
67
  duplicate.configuration
@@ -1,8 +1,10 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Hanami
2
4
  module Assets
3
5
  # Defines the version
4
6
  #
5
7
  # @since 0.1.0
6
- VERSION = '1.3.4'.freeze
8
+ VERSION = "1.3.5"
7
9
  end
8
10
  end
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.3.4
4
+ version: 1.3.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Luca Guidi
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-10-11 00:00:00.000000000 Z
11
+ date: 2021-01-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: hanami-utils
@@ -190,6 +190,20 @@ dependencies:
190
190
  - - "~>"
191
191
  - !ruby/object:Gem::Version
192
192
  version: '0.7'
193
+ - !ruby/object:Gem::Dependency
194
+ name: rubocop
195
+ requirement: !ruby/object:Gem::Requirement
196
+ requirements:
197
+ - - '='
198
+ - !ruby/object:Gem::Version
199
+ version: '0.81'
200
+ type: :development
201
+ prerelease: false
202
+ version_requirements: !ruby/object:Gem::Requirement
203
+ requirements:
204
+ - - '='
205
+ - !ruby/object:Gem::Version
206
+ version: '0.81'
193
207
  description: Assets management for Ruby web applications
194
208
  email:
195
209
  - me@lucaguidi.com
@@ -235,7 +249,7 @@ homepage: http://hanamirb.org
235
249
  licenses:
236
250
  - MIT
237
251
  metadata: {}
238
- post_install_message:
252
+ post_install_message:
239
253
  rdoc_options: []
240
254
  require_paths:
241
255
  - lib
@@ -250,8 +264,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
250
264
  - !ruby/object:Gem::Version
251
265
  version: '0'
252
266
  requirements: []
253
- rubygems_version: 3.0.6
254
- signing_key:
267
+ rubygems_version: 3.2.4
268
+ signing_key:
255
269
  specification_version: 4
256
270
  summary: Assets management
257
271
  test_files: []