Class: Kirei::App
Overview
This is the entrypoint into the application; it implements the Rack interface.
Constant Summary
Routing::Base::NOT_FOUND
Instance Attribute Summary
#params
Class Method Summary
collapse
#add_cors_headers, #call, #default_headers, #initialize, #render
Class Method Details
.default_db_name ⇒ Object
55
56
57
|
# File 'lib/kirei/app.rb', line 55
def default_db_name
@default_db_name ||= T.let("#{config.app_name}_#{environment}".freeze, T.nilable(String))
end
|
.default_db_url ⇒ Object
64
65
66
67
68
69
|
# File 'lib/kirei/app.rb', line 64
def default_db_url
@default_db_url ||= T.let(
ENV.fetch("DATABASE_URL", "postgresql://localhost:5432/#{default_db_name}"),
T.nilable(String),
)
end
|
.environment ⇒ Object
46
47
48
|
# File 'lib/kirei/app.rb', line 46
def environment
ENV.fetch("RACK_ENV", "development")
end
|
.raw_db_connection ⇒ Object
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
|
# File 'lib/kirei/app.rb', line 72
def raw_db_connection
@raw_db_connection = T.let(@raw_db_connection, T.nilable(Sequel::Database))
return @raw_db_connection unless @raw_db_connection.nil?
@raw_db_connection = Sequel.connect(App.config.db_url || default_db_url)
config.db_extensions.each do |ext|
T.cast(@raw_db_connection, Sequel::Database).extension(ext)
end
if config.db_extensions.include?(:pg_json)
@raw_db_connection.wrap_json_primitives = true
end
@raw_db_connection
end
|
.root ⇒ Object
22
23
24
|
# File 'lib/kirei/app.rb', line 22
def root
defined?(::APP_ROOT) ? Pathname.new(::APP_ROOT) : Pathname.new(Dir.pwd)
end
|
.version ⇒ Object
33
34
35
36
37
38
39
40
|
# File 'lib/kirei/app.rb', line 33
def version
@version = T.let(@version, T.nilable(String))
@version ||= ENV.fetch("APP_VERSION", nil)
@version ||= ENV.fetch("GIT_SHA", nil)
@version ||= T.must(
`command -v git && git rev-parse --short HEAD`.to_s.split("\n").last,
).freeze end
|