Class: GeneratedAssets::Manifest

Inherits:
Object
  • Object
show all
Defined in:
lib/generated-assets/manifest.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(app, prefix) ⇒ Manifest

Returns a new instance of Manifest.



21
22
23
24
25
26
27
# File 'lib/generated-assets/manifest.rb', line 21

def initialize(app, prefix)
  @app = app
  @prefix = prefix
  @entries = []
  @before_hooks = []
  @after_hooks = []
end

Instance Attribute Details

#after_hooksObject (readonly)

Returns the value of attribute after_hooks.



8
9
10
# File 'lib/generated-assets/manifest.rb', line 8

def after_hooks
  @after_hooks
end

#appObject (readonly)

Returns the value of attribute app.



7
8
9
# File 'lib/generated-assets/manifest.rb', line 7

def app
  @app
end

#before_hooksObject (readonly)

Returns the value of attribute before_hooks.



8
9
10
# File 'lib/generated-assets/manifest.rb', line 8

def before_hooks
  @before_hooks
end

#compileObject

Force generated-assets to write files and add stuff to the precompile list. It works similarly to config.assets compile, but applies only to generated assets. Under normal circumstances, generated-assets will detect when it should do these things for you, usually when 1) config.assets.compile is true, or 2) when running rake assets:precompile. If you’ve got a non-standard setup though, set this property to a truthy value when you’re compiling assets or running your app in an environment (i.e. development) that requires generated assets to be available.



19
20
21
# File 'lib/generated-assets/manifest.rb', line 19

def compile
  @compile
end

#entriesObject (readonly)

Returns the value of attribute entries.



7
8
9
# File 'lib/generated-assets/manifest.rb', line 7

def entries
  @entries
end

#prefixObject (readonly)

Returns the value of attribute prefix.



7
8
9
# File 'lib/generated-assets/manifest.rb', line 7

def prefix
  @prefix
end

Instance Method Details

#add(logical_path, options = {}, &block) ⇒ Object



29
30
31
# File 'lib/generated-assets/manifest.rb', line 29

def add(logical_path, options = {}, &block)
  entries << Entry.new(logical_path, block, options)
end

#after_apply(&block) ⇒ Object



47
48
49
# File 'lib/generated-assets/manifest.rb', line 47

def after_apply(&block)
  after_hooks << block
end

#apply!Object



33
34
35
36
37
38
39
40
41
# File 'lib/generated-assets/manifest.rb', line 33

def apply!
  return unless should_apply?
  before_hooks.each(&:call)

  write_files
  add_precompile_paths

  after_hooks.each(&:call)
end

#before_apply(&block) ⇒ Object



43
44
45
# File 'lib/generated-assets/manifest.rb', line 43

def before_apply(&block)
  before_hooks << block
end