Module: Hanami::Assets
- Includes:
- Utils::ClassAttribute
- Defined in:
- lib/hanami/assets.rb,
lib/hanami/assets/cache.rb,
lib/hanami/assets/bundler.rb,
lib/hanami/assets/helpers.rb,
lib/hanami/assets/version.rb,
lib/hanami/assets/compiler.rb,
lib/hanami/assets/precompiler.rb,
lib/hanami/assets/bundler/asset.rb,
lib/hanami/assets/configuration.rb,
lib/hanami/assets/compilers/less.rb,
lib/hanami/assets/compilers/sass.rb,
lib/hanami/assets/config/sources.rb,
lib/hanami/assets/config/manifest.rb,
lib/hanami/assets/bundler/compressor.rb,
lib/hanami/assets/compressors/abstract.rb,
lib/hanami/assets/config/global_sources.rb,
lib/hanami/assets/bundler/manifest_entry.rb,
lib/hanami/assets/compressors/javascript.rb,
lib/hanami/assets/compressors/stylesheet.rb,
lib/hanami/assets/compressors/yui_javascript.rb,
lib/hanami/assets/compressors/yui_stylesheet.rb,
lib/hanami/assets/compressors/null_compressor.rb,
lib/hanami/assets/compressors/sass_stylesheet.rb,
lib/hanami/assets/compressors/builtin_javascript.rb,
lib/hanami/assets/compressors/builtin_stylesheet.rb,
lib/hanami/assets/compressors/closure_javascript.rb,
lib/hanami/assets/compressors/uglifier_javascript.rb
Overview
Assets management for Ruby web applications
Defined Under Namespace
Modules: Compilers, Compressors, Config, Helpers Classes: Bundler, Cache, Compiler, Configuration, Error, MissingAsset, MissingManifestAssetError, MissingManifestFileError, Precompiler, UnknownAssetEngine
Constant Summary collapse
- VERSION =
Defines the version
'1.3.1'.freeze
Class Method Summary collapse
-
.configure(&blk) ⇒ Object
Configure framework.
-
.deploy ⇒ Object
Prepare assets for deploys.
-
.dupe ⇒ Module
private
Duplicate Hanami::Assets in order to create a new separated instance of the framework.
-
.duplicate(_mod, &blk) ⇒ Module
Duplicate the framework and generate modules for the target application.
-
.duplicates ⇒ Array
private
Keep track of duplicated frameworks.
-
.load! ⇒ Object
Preload the framework.
-
.precompile(configurations) ⇒ Object
Precompile assets.
-
.sources ⇒ Hanami::Assets::Config::GlobalSources
Global assets sources.
Class Method Details
.configure(&blk) ⇒ Object
Configure framework
42 43 44 45 |
# File 'lib/hanami/assets.rb', line 42 def self.configure(&blk) configuration.instance_eval(&blk) self end |
.deploy ⇒ Object
Prepare assets for deploys
50 51 52 53 54 55 56 |
# File 'lib/hanami/assets.rb', line 50 def self.deploy require 'hanami/assets/precompiler' require 'hanami/assets/bundler' Precompiler.new(configuration, duplicates).run Bundler.new(configuration, duplicates).run end |
.dupe ⇒ Module
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Duplicate Hanami::Assets in order to create a new separated instance of the framework.
The new instance of the framework will be completely decoupled from the original. It will inherit the configuration, but all the changes that happen after the duplication, won’t be reflected on the other copies.
142 143 144 145 146 |
# File 'lib/hanami/assets.rb', line 142 def self.dupe dup.tap do |duplicated| duplicated.configuration = configuration.duplicate end end |
.duplicate(_mod, &blk) ⇒ Module
Duplicate the framework and generate modules for the target application
124 125 126 127 128 129 |
# File 'lib/hanami/assets.rb', line 124 def self.duplicate(_mod, &blk) dupe.tap do |duplicated| duplicated.configure(&blk) if block_given? duplicates << duplicated end end |
.duplicates ⇒ Array
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Keep track of duplicated frameworks
157 158 159 160 161 |
# File 'lib/hanami/assets.rb', line 157 def self.duplicates synchronize do @@duplicates ||= [] # rubocop:disable Style/ClassVars end end |
.load! ⇒ Object
Preload the framework
This MUST be used in production mode
86 87 88 |
# File 'lib/hanami/assets.rb', line 86 def self.load! configuration.load! end |
.precompile(configurations) ⇒ Object
Precompile assets
61 62 63 64 65 66 67 |
# File 'lib/hanami/assets.rb', line 61 def self.precompile(configurations) require 'hanami/assets/precompiler' require 'hanami/assets/bundler' Precompiler.new(configuration, configurations).run Bundler.new(configuration, configurations).run end |
.sources ⇒ Hanami::Assets::Config::GlobalSources
Global assets sources
This is designed for third party integration gems with frontend frameworks like Bootstrap, Ember.js or React.
Developers can maintain gems that ship static assets for these frameworks and make them available to Hanami::Assets.
107 108 109 110 111 |
# File 'lib/hanami/assets.rb', line 107 def self.sources synchronize do @@sources ||= Config::GlobalSources.new # rubocop:disable Style/ClassVars end end |