Class: Sharp::Application
- Inherits:
-
Object
- Object
- Sharp::Application
- Defined in:
- lib/sharp.rb
Constant Summary
Constants included from Rack
Instance Attribute Summary collapse
-
#root ⇒ Object
readonly
Returns the value of attribute root.
Instance Method Summary collapse
- #boot ⇒ Object
-
#command ⇒ Symbol|nil
The command represents what external command is running Sharp.
- #config ⇒ Object
-
#env ⇒ Symbol
This represents which environment is being used.
-
#initialize(root) ⇒ Application
constructor
A new instance of Application.
- #load_path ⇒ Object
Methods included from Rack
#delete, #get, #head, included, #post, #put, #route, #router
Methods included from Logging
#attach_logger, #log_file, #log_io, #log_level, #logger, #logger=, #logger_formatter, #objects_logger_is_attached_to
Constructor Details
#initialize(root) ⇒ Application
Returns a new instance of Application.
43 44 45 |
# File 'lib/sharp.rb', line 43 def initialize(root) @root = Pathname.new(root) end |
Instance Attribute Details
#root ⇒ Object (readonly)
Returns the value of attribute root.
41 42 43 |
# File 'lib/sharp.rb', line 41 def root @root end |
Instance Method Details
#boot ⇒ Object
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/sharp.rb', line 47 def boot unless booted? logger.info "Booting Sharp #{VERSION} #{env} #{command}..." ms = Benchmark.ms do pre_initialization load_i18n load_load_path load_routes post_initialization finish_boot end logger.info("Booted in %0.1fms" % ms) end self end |
#command ⇒ Symbol|nil
The command represents what external command is running Sharp. Typical values are:
-
server - A rack server like WEBrick, Thin, Unicorn, Puma, etc.
-
console - An IRB session
If Sharp is just being run in a script or something, this will be nil. You can set this to any value you like using the SHARP_COMMAND environment variable.
80 81 82 83 84 85 86 |
# File 'lib/sharp.rb', line 80 def command if defined? @command @command else @command = ENV['SHARP_COMMAND'].downcase.to_sym if ENV['SHARP_COMMAND'].present? end end |
#config ⇒ Object
88 89 90 |
# File 'lib/sharp.rb', line 88 def config @config ||= Sharp::Config.new(env, Dir[root.join("config/*.yml")]) end |
#env ⇒ Symbol
This represents which environment is being used. This is controlled via the RACK_ENV environment variable.
67 68 69 |
# File 'lib/sharp.rb', line 67 def env @env ||= ENV['RACK_ENV'].present? ? ENV['RACK_ENV'].to_sym : :development end |
#load_path ⇒ Object
92 93 94 |
# File 'lib/sharp.rb', line 92 def load_path @load_path ||= %w[app/lib app/models app/actions app/views] end |