Class: Hanami::Assets::Configuration
- Inherits:
-
Object
- Object
- Hanami::Assets::Configuration
- Defined in:
- gems/gems/hanami-assets-1.3.3/lib/hanami/assets/configuration.rb,
gems/gems/hanami-assets-1.3.5/lib/hanami/assets/configuration.rb
Overview
Framework configuration
Instance Attribute Summary collapse
-
#cdn(value = nil) ⇒ Object
readonly
CDN mode.
-
#compile(value = nil) ⇒ Object
readonly
Compile mode.
-
#host(value = nil) ⇒ Object
readonly
URL host for the application.
-
#javascript_compressor(value = nil) ⇒ Object
readonly
JavaScript compressor.
-
#manifest(value = nil) ⇒ Object
readonly
Manifest path from public directory.
-
#nested(value = nil) ⇒ Object
readonly
Support for nested path.
-
#port(value = nil) ⇒ Object
readonly
URL port for the application.
-
#prefix(value = nil) ⇒ Object
readonly
URL port for the application.
-
#public_directory(value = nil) ⇒ Object
readonly
Application public directory.
-
#root(value = nil) ⇒ Object
readonly
Sources root.
-
#scheme(value = nil) ⇒ Object
readonly
URL scheme for the application.
-
#stylesheet_compressor(value = nil) ⇒ Object
readonly
Stylesheet compressor.
-
#subresource_integrity(*values) ⇒ Object
readonly
Subresource integrity mode.
Instance Method Summary collapse
- #base_directories ⇒ Object
-
#fingerprint(value = nil) ⇒ Object
Fingerprint mode.
-
#subresource_integrity_algorithms ⇒ Object
An array of crypographically secure hashing algorithms to use for generating asset subresource integrity checks.
Instance Attribute Details
#cdn(value = nil) ⇒ Object
CDN mode
Determine if the helpers should always generate absolute URL. This is useful in production mode.
Source: | on GitHub
def cdn(value = nil) if value.nil? @cdn else @cdn = !!value # rubocop:disable Style/DoubleNegation end end |
#compile(value = nil) ⇒ Object
Compile mode
Determine if compile assets from sources to destination. Usually this is turned off in production mode.
Source: | on GitHub
def compile(value = nil) if value.nil? @compile else @compile = value end end |
#host(value = nil) ⇒ Object
URL host for the application
This is used to generate absolute URL from helpers.
Source: | on GitHub
def host(value = nil) if value.nil? @host else @host = value end end |
#javascript_compressor(value = nil) ⇒ Object
JavaScript compressor
Determine which compressor to use for JavaScript files during deploy.
By default it’s nil
, that means it doesn’t compress JavaScripts at deploy time.
It accepts a Symbol
or an object that respond to #compress(file)
.
The following symbols are accepted:
-
:builtin
- Ruby based implementation of jsmin. It doesn’t require any external gem. -
:yui
- YUI Compressor, it depends onyui-compressor
gem and it requires Java 1.4+ -
:uglifier
- UglifyJS, it depends onuglifier
gem and it requires Node.js -
:closure
- Google Closure Compiler, it depends onclosure-compiler
gem and it requires Java
Source: | on GitHub
def javascript_compressor(value = nil) if value.nil? @javascript_compressor else @javascript_compressor = value end end |
#manifest(value = nil) ⇒ Object
Manifest path from public directory
Source: | on GitHub
def manifest(value = nil) if value.nil? @manifest else @manifest = value.to_s end end |
#nested(value = nil) ⇒ Object
Support for nested path
Source: | on GitHub
def nested(value = nil) if value.nil? @nested else @nested = !!value # rubocop:disable Style/DoubleNegation end end |
#port(value = nil) ⇒ Object
URL port for the application
This is used to generate absolute URL from helpers.
Source: | on GitHub
def port(value = nil) if value.nil? @port else @port = value.to_s end end |
#prefix(value = nil) ⇒ Object
URL port for the application
This is used to generate absolute or relative URL from helpers.
Source: | on GitHub
def prefix(value = nil) if value.nil? @prefix else @prefix = Utils::PathPrefix.new(value) end end |
#public_directory(value = nil) ⇒ Object
Application public directory
Source: | on GitHub
def public_directory(value = nil) if value.nil? @public_directory else @public_directory = Pathname.new(::File.(value)) end end |
#root(value = nil) ⇒ Object
Sources root
#scheme(value = nil) ⇒ Object
URL scheme for the application
This is used to generate absolute URL from helpers.
Source: | on GitHub
def scheme(value = nil) if value.nil? @scheme else @scheme = value end end |
#stylesheet_compressor(value = nil) ⇒ Object
Stylesheet compressor
Determine which compressor to use for Stylesheet files during deploy.
By default it’s nil
, that means it doesn’t compress Stylesheets at deploy time.
It accepts a Symbol
or an object that respond to #compress(file)
.
The following symbols are accepted:
-
:builtin
- Ruby based compressor. It doesn’t require any external gem. It’s fast, but not an efficient compressor. -
:yui
- YUI-Compressor, it depends onyui-compressor
gem and requires Java 1.4+ -
:sass
- Sass, it depends onsassc
gem
Source: | on GitHub
def stylesheet_compressor(value = nil) if value.nil? @stylesheet_compressor else @stylesheet_compressor = value end end |
#subresource_integrity(*values) ⇒ Object
Subresource integrity mode
Determine if the helpers should generate the integrity attribute for an asset. Usually this is turned on in production mode.
Source: | on GitHub
def subresource_integrity(*values) if values.empty? @subresource_integrity elsif values.length == 1 @subresource_integrity = values.first else @subresource_integrity = values end end |
Instance Method Details
#base_directories ⇒ Object
Source: | on GitHub
def base_directories @base_directories ||= %w[ stylesheets javascripts images fonts ] end |
#fingerprint(value = nil) ⇒ Object
Fingerprint mode
Determine if the helpers should generate the fingerprinted path for an asset. Usually this is turned on in production mode.
Source: | on GitHub
def fingerprint(value = nil) if value.nil? @fingerprint else @fingerprint = value end end |
#subresource_integrity_algorithms ⇒ Object
An array of crypographically secure hashing algorithms to use for generating asset subresource integrity checks
Source: | on GitHub
def subresource_integrity_algorithms if @subresource_integrity == true [DEFAULT_SUBRESOURCE_INTEGRITY_ALGORITHM] else # Using Array() allows us to accept Array or Symbol, and '|| nil' lets # us return an empty array when @subresource_integrity is `false` Array(@subresource_integrity || nil) end end |