Class: Jets::Shim::Config

Inherits:
Object
  • Object
show all
Extended by:
Memoist
Includes:
Singleton
Defined in:
lib/jets/shim/config.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#adapterObject

Returns the value of attribute adapter.



9
10
11
# File 'lib/jets/shim/config.rb', line 9

def adapter
  @adapter
end

#boot_pathObject

Returns the value of attribute boot_path.



8
9
10
# File 'lib/jets/shim/config.rb', line 8

def boot_path
  @boot_path
end

#fallback_handlerObject

Returns the value of attribute fallback_handler.



9
10
11
# File 'lib/jets/shim/config.rb', line 9

def fallback_handler
  @fallback_handler
end

#rack_appObject Also known as: app



18
19
20
21
22
23
24
25
26
# File 'lib/jets/shim/config.rb', line 18

def rack_app
  if Maintenance.enabled?
    Maintenance.app
  elsif @rack_app
    @rack_app
  else
    framework_app
  end
end

Instance Method Details

#frameworkObject



62
63
64
# File 'lib/jets/shim/config.rb', line 62

def framework
  Jets::Framework.name
end

#framework_appObject



30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# File 'lib/jets/shim/config.rb', line 30

def framework_app
  # Explicitly set boot_path takes precedence
  # IE: my_app.rb => MyApp
  if @boot_path && File.exist?(@boot_path)
    app_class = @boot_path.sub(/\.rb$/, "").camelize.constantize
    return app_class
  end

  # Infer app.rb boot_path
  # IE: app.rb => App
  if File.exist?("app.rb")
    require_boot_path("app")
    return App
  end

  # Infer rack app from config.ru
  case framework
  when "rails"
    require_boot_path "config/environment"
    Rails.application
  when "hanami"
    require "hanami/boot"
    Hanami.app
  end
end

#require_boot_path(path) ⇒ Object



56
57
58
59
60
# File 'lib/jets/shim/config.rb', line 56

def require_boot_path(path)
  path = path.starts_with?(".") ? path : "./#{path}"
  path = path.ends_with?(".rb") ? path : "#{path}.rb"
  require path # IE: config/environment.rb (Rails) or app.rb (generic rack app)
end