Module: Lotus::Assets

Includes:
Utils::ClassAttribute
Defined in:
lib/lotus/assets.rb,
lib/lotus/assets/cache.rb,
lib/lotus/assets/bundler.rb,
lib/lotus/assets/helpers.rb,
lib/lotus/assets/version.rb,
lib/lotus/assets/compiler.rb,
lib/lotus/assets/precompiler.rb,
lib/lotus/assets/configuration.rb,
lib/lotus/assets/config/sources.rb,
lib/lotus/assets/config/manifest.rb,
lib/lotus/assets/compressors/abstract.rb,
lib/lotus/assets/config/global_sources.rb,
lib/lotus/assets/compressors/javascript.rb,
lib/lotus/assets/compressors/stylesheet.rb,
lib/lotus/assets/compressors/yui_javascript.rb,
lib/lotus/assets/compressors/yui_stylesheet.rb,
lib/lotus/assets/compressors/null_compressor.rb,
lib/lotus/assets/compressors/sass_stylesheet.rb,
lib/lotus/assets/compressors/builtin_javascript.rb,
lib/lotus/assets/compressors/builtin_stylesheet.rb,
lib/lotus/assets/compressors/closure_javascript.rb,
lib/lotus/assets/compressors/uglifier_javascript.rb

Overview

Assets management for Ruby web applications

Since:

  • 0.1.0

Defined Under Namespace

Modules: Compressors, Config, Helpers Classes: Bundler, Cache, Compiler, Configuration, Error, MissingAsset, MissingDigestAssetError, MissingDigestManifestError, Precompiler, UnknownAssetEngine

Constant Summary collapse

VERSION =

Defines the version

Since:

  • 0.1.0

'0.1.0'.freeze

Class Method Summary collapse

Class Method Details

.configure(&blk) ⇒ Object

Configure framework

Parameters:

  • blk (Proc)

    configuration code block

Returns:

  • self

See Also:

Since:

  • 0.1.0


40
41
42
43
# File 'lib/lotus/assets.rb', line 40

def self.configure(&blk)
  configuration.instance_eval(&blk)
  self
end

.deployObject

Prepare assets for deploys

Since:

  • 0.1.0


48
49
50
51
52
53
54
# File 'lib/lotus/assets.rb', line 48

def self.deploy
  require 'lotus/assets/precompiler'
  require 'lotus/assets/bundler'

  Precompiler.new(configuration, duplicates).run
  Bundler.new(configuration,     duplicates).run
end

.dupeModule

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 Lotus::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.

Returns:

  • (Module)

    a copy of Lotus::Assets

Since:

  • 0.1.0


129
130
131
132
133
# File 'lib/lotus/assets.rb', line 129

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

 @since 0.1.0

Parameters:

  • mod (Module)

    the Ruby namespace of the application

  • blk (Proc)

    an optional block to configure the framework

Returns:

  • (Module)

    a copy of Lotus::Assets

See Also:

Since:

  • 0.1.0


111
112
113
114
115
116
# File 'lib/lotus/assets.rb', line 111

def self.duplicate(mod, &blk)
  dupe.tap do |duplicated|
    duplicated.configure(&blk) if block_given?
    duplicates << duplicated
  end
end

.duplicatesArray

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

Returns:

  • (Array)

    a collection of duplicated frameworks

See Also:

  • #duplicate
  • #dupe

Since:

  • 0.1.0


144
145
146
147
148
# File 'lib/lotus/assets.rb', line 144

def self.duplicates
  synchronize do
    @@duplicates ||= Array.new
  end
end

.load!Object

Preload the framework

This MUST be used in production mode

Examples:

Direct Invocation

require 'lotus/assets'

Lotus::Assets.load!

Load Via Configuration Block

require 'lotus/assets'

Lotus::Assets.configure do
  # ...
end.load!

Since:

  • 0.1.0


73
74
75
# File 'lib/lotus/assets.rb', line 73

def self.load!
  configuration.load!
end

.sourcesLotus::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 Lotus::Assets.

Examples:

Ember.js Integration

# lib/lotus/emberjs.rb (third party gem)
require 'lotus/assets'

Lotus::Assets.sources << '/path/to/emberjs/assets'

Returns:

Since:

  • 0.1.0


94
95
96
97
98
# File 'lib/lotus/assets.rb', line 94

def self.sources
  synchronize do
    @@sources ||= Config::GlobalSources.new
  end
end