Class: Teaspoon::Engine

Inherits:
Rails::Engine
  • Object
show all
Defined in:
lib/teaspoon/engine.rb

Defined Under Namespace

Modules: ExceptionHandling

Class Method Summary collapse

Class Method Details

.add_precompiled_assets(assets) ⇒ Object



48
49
50
# File 'lib/teaspoon/engine.rb', line 48

def self.add_precompiled_assets(assets)
  assets.precompile += Teaspoon.configuration.asset_manifest
end

.append_asset_paths(assets) ⇒ Object



37
38
39
40
41
42
43
44
45
46
# File 'lib/teaspoon/engine.rb', line 37

def self.append_asset_paths(assets)
  Teaspoon.configuration.asset_paths.each do |path|
    assets.paths << Teaspoon.configuration.root.join(path).to_s
  end

  # TODO: This breaks lazy loading of frameworks. Another way to avoid this?
  Teaspoon::Framework.available.keys.each do |framework|
    assets.paths += Teaspoon::Framework.fetch(framework).asset_paths
  end
end

.default_root_path(root) ⇒ Object



33
34
35
# File 'lib/teaspoon/engine.rb', line 33

def self.default_root_path(root)
  Teaspoon.configuration.root ||= root
end

.inject_instrumentationObject



52
53
54
55
56
57
58
# File 'lib/teaspoon/engine.rb', line 52

def self.inject_instrumentation
  Sprockets::Environment.send(:include, Teaspoon::SprocketsInstrumentation)
  Sprockets::CachedEnvironment.send(:include, Teaspoon::SprocketsInstrumentation)
rescue NameError
  # Handle cached environment in Sprockets 2.x
  Sprockets::Index.send(:include, Teaspoon::SprocketsInstrumentation)
end

.prepend_routes(app) ⇒ Object



60
61
62
63
64
65
66
67
68
69
# File 'lib/teaspoon/engine.rb', line 60

def self.prepend_routes(app)
  mount_at = Teaspoon.configuration.mount_at

  return if app.routes.recognize_path(mount_at)[:action] != "routing_error" rescue nil
  ActiveSupport.on_load(:action_controller) do
    require Teaspoon::Engine.root.join("app/controllers/teaspoon/suite_controller")
  end

  app.routes.prepend { mount Teaspoon::Engine => mount_at, as: "teaspoon" }
end