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
'0.4.0'.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
40 41 42 43 |
# File 'lib/hanami/assets.rb', line 40 def self.configure(&blk) configuration.instance_eval(&blk) self end |
.deploy ⇒ Object
Prepare assets for deploys
48 49 50 51 52 53 54 |
# File 'lib/hanami/assets.rb', line 48 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.
140 141 142 143 144 |
# File 'lib/hanami/assets.rb', line 140 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
122 123 124 125 126 127 |
# File 'lib/hanami/assets.rb', line 122 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
155 156 157 158 159 |
# File 'lib/hanami/assets.rb', line 155 def self.duplicates synchronize do @@duplicates ||= [] # rubocop:disable Style/ClassVars end end |
.load! ⇒ Object
Preload the framework
This MUST be used in production mode
84 85 86 |
# File 'lib/hanami/assets.rb', line 84 def self.load! configuration.load! end |
.precompile(configurations) ⇒ Object
Precompile assets
59 60 61 62 63 64 65 |
# File 'lib/hanami/assets.rb', line 59 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.
105 106 107 108 109 |
# File 'lib/hanami/assets.rb', line 105 def self.sources synchronize do @@sources ||= Config::GlobalSources.new # rubocop:disable Style/ClassVars end end |