Class: Bowline::Configuration
Overview
ships with defaults that suites most Bowline applications. But it’s possible to overwrite everything. Usually, you’ll create an Configuration file implicitly through the block running on the Initializer, but it’s also possible to create the Configuration instance in advance and pass it in like this:
config = Bowline::Configuration.new
Bowline::Initializer.run(:process, config)
Instance Attribute Summary collapse
-
#active_record ⇒ Object
A stub for setting options on ActiveRecord::Base.
-
#active_resource ⇒ Object
A stub for setting options on ActiveResource::Base.
-
#active_support ⇒ Object
A stub for setting options on ActiveSupport.
-
#app_config_file ⇒ Object
Returns the value of attribute app_config_file.
-
#binder_paths ⇒ Object
Returns the value of attribute binder_paths.
-
#bowline ⇒ Object
Returns the value of attribute bowline.
-
#cache_classes ⇒ Object
Whether or not classes should be cached (set to false if you want application classes to be reloaded on each request).
-
#copyright ⇒ Object
Returns the value of attribute copyright.
-
#database_configuration_file ⇒ Object
The path to the database configuration file to use.
-
#description ⇒ Object
Returns the value of attribute description.
-
#eager_load_paths ⇒ Object
An array of paths from which Bowline will eager load on boot if cache classes is enabled.
-
#frameworks ⇒ Object
Returns the value of attribute frameworks.
-
#gem_path ⇒ Object
Returns the value of attribute gem_path.
-
#gems ⇒ Object
An array of gems that this Bowline application depends on.
-
#helper_glob ⇒ Object
Returns the value of attribute helper_glob.
-
#icon ⇒ Object
Returns the value of attribute icon.
-
#id ⇒ Object
Returns the value of attribute id.
-
#initializer_glob ⇒ Object
Returns the value of attribute initializer_glob.
-
#load_once_paths ⇒ Object
An array of paths from which Bowline will automatically load from only once.
-
#load_paths ⇒ Object
An array of additional paths to prepend to the load path.
-
#log_level ⇒ Object
The log level to use for the default Bowline logger.
-
#log_path ⇒ Object
The path to the log file to use.
-
#logger ⇒ Object
The specific logger to use.
-
#name ⇒ Object
Returns the value of attribute name.
-
#plugin_glob ⇒ Object
Returns the value of attribute plugin_glob.
-
#publisher ⇒ Object
Returns the value of attribute publisher.
-
#reload_plugins ⇒ Object
Returns the value of attribute reload_plugins.
-
#root_path ⇒ Object
readonly
The application’s base directory.
-
#sdk ⇒ Object
Returns the value of attribute sdk.
-
#time_zone ⇒ Object
Sets the default
time_zone
. -
#titanium_version ⇒ Object
Returns the value of attribute titanium_version.
-
#url ⇒ Object
Returns the value of attribute url.
-
#version ⇒ Object
Returns the value of attribute version.
-
#whiny_nils ⇒ Object
Set to
true
if you want to be warned (noisily) when you try to invoke any method ofnil
.
Instance Method Summary collapse
-
#after_initialize(&after_initialize_block) ⇒ Object
Adds a block which will be executed after bowline has been fully initialized.
-
#after_initialize_blocks ⇒ Object
Returns the blocks added with Configuration#after_initialize.
- #app_config ⇒ Object
-
#database_configuration ⇒ Object
Loads and returns the contents of the #database_configuration_file.
-
#gem(*args) ⇒ Object
Adds a single Gem dependency to the Bowline application.
- #helpers ⇒ Object
-
#initialize ⇒ Configuration
constructor
Create a new Configuration instance, initialized with the default values.
-
#reload_plugins? ⇒ Boolean
Returns true if plugin reloading is enabled.
-
#set_root_path! ⇒ Object
Set the root_path to APP_ROOT and canonicalize it.
Constructor Details
#initialize ⇒ Configuration
Create a new Configuration instance, initialized with the default values.
433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 |
# File 'lib/bowline/initializer.rb', line 433 def initialize set_root_path! self.frameworks = default_frameworks self.load_paths = default_load_paths self.load_once_paths = default_load_once_paths self.eager_load_paths = default_eager_load_paths self.log_path = default_log_path self.log_level = default_log_level self.binder_paths = default_binder_paths self.cache_classes = default_cache_classes self.whiny_nils = default_whiny_nils self.database_configuration_file = default_database_configuration_file self.app_config_file = default_app_config_file self.gems = default_gems self.gem_path = default_gem_path self.plugin_glob = default_plugin_glob self.helper_glob = default_helper_glob self.initializer_glob = default_initalizer_glob self.publisher = default_publisher self.copyright = default_copyright self.titanium_version = default_titanium_version for framework in default_frameworks self.send("#{framework}=", Bowline::OrderedOptions.new) end end |
Instance Attribute Details
#active_record ⇒ Object
A stub for setting options on ActiveRecord::Base.
324 325 326 |
# File 'lib/bowline/initializer.rb', line 324 def active_record @active_record end |
#active_resource ⇒ Object
A stub for setting options on ActiveResource::Base.
327 328 329 |
# File 'lib/bowline/initializer.rb', line 327 def active_resource @active_resource end |
#active_support ⇒ Object
A stub for setting options on ActiveSupport.
330 331 332 |
# File 'lib/bowline/initializer.rb', line 330 def active_support @active_support end |
#app_config_file ⇒ Object
Returns the value of attribute app_config_file.
346 347 348 |
# File 'lib/bowline/initializer.rb', line 346 def app_config_file @app_config_file end |
#binder_paths ⇒ Object
Returns the value of attribute binder_paths.
340 341 342 |
# File 'lib/bowline/initializer.rb', line 340 def binder_paths @binder_paths end |
#bowline ⇒ Object
Returns the value of attribute bowline.
332 333 334 |
# File 'lib/bowline/initializer.rb', line 332 def bowline @bowline end |
#cache_classes ⇒ Object
Whether or not classes should be cached (set to false if you want application classes to be reloaded on each request)
338 339 340 |
# File 'lib/bowline/initializer.rb', line 338 def cache_classes @cache_classes end |
#copyright ⇒ Object
Returns the value of attribute copyright.
428 429 430 |
# File 'lib/bowline/initializer.rb', line 428 def copyright @copyright end |
#database_configuration_file ⇒ Object
The path to the database configuration file to use. (Defaults to config/database.yml
.)
344 345 346 |
# File 'lib/bowline/initializer.rb', line 344 def database_configuration_file @database_configuration_file end |
#description ⇒ Object
Returns the value of attribute description.
423 424 425 |
# File 'lib/bowline/initializer.rb', line 423 def description @description end |
#eager_load_paths ⇒ Object
An array of paths from which Bowline will eager load on boot if cache classes is enabled. All elements of this array must also be in load_paths
.
359 360 361 |
# File 'lib/bowline/initializer.rb', line 359 def eager_load_paths @eager_load_paths end |
#frameworks ⇒ Object
Returns the value of attribute frameworks.
334 335 336 |
# File 'lib/bowline/initializer.rb', line 334 def frameworks @frameworks end |
#gem_path ⇒ Object
Returns the value of attribute gem_path.
407 408 409 |
# File 'lib/bowline/initializer.rb', line 407 def gem_path @gem_path end |
#gems ⇒ Object
An array of gems that this Bowline application depends on. Bowline will automatically load these gems during installation, and allow you to install any missing gems with:
rake gems:sync
You can add gems with the #gem method.
390 391 392 |
# File 'lib/bowline/initializer.rb', line 390 def gems @gems end |
#helper_glob ⇒ Object
Returns the value of attribute helper_glob.
416 417 418 |
# File 'lib/bowline/initializer.rb', line 416 def helper_glob @helper_glob end |
#icon ⇒ Object
Returns the value of attribute icon.
426 427 428 |
# File 'lib/bowline/initializer.rb', line 426 def icon @icon end |
#id ⇒ Object
Returns the value of attribute id.
421 422 423 |
# File 'lib/bowline/initializer.rb', line 421 def id @id end |
#initializer_glob ⇒ Object
Returns the value of attribute initializer_glob.
418 419 420 |
# File 'lib/bowline/initializer.rb', line 418 def initializer_glob @initializer_glob end |
#load_once_paths ⇒ Object
An array of paths from which Bowline will automatically load from only once. All elements of this array must also be in load_paths
.
354 355 356 |
# File 'lib/bowline/initializer.rb', line 354 def load_once_paths @load_once_paths end |
#load_paths ⇒ Object
An array of additional paths to prepend to the load path. By default, all app
, lib
, vendor
and mock paths are included in this list.
350 351 352 |
# File 'lib/bowline/initializer.rb', line 350 def load_paths @load_paths end |
#log_level ⇒ Object
The log level to use for the default Bowline logger.
362 363 364 |
# File 'lib/bowline/initializer.rb', line 362 def log_level @log_level end |
#log_path ⇒ Object
The path to the log file to use. Defaults to log/#environment.log (e.g. log/development.log or log/production.log).
366 367 368 |
# File 'lib/bowline/initializer.rb', line 366 def log_path @log_path end |
#logger ⇒ Object
The specific logger to use. By default, a logger will be created and initialized using #log_path and #log_level, but a programmer may specifically set the logger to use via this accessor and it will be used directly.
372 373 374 |
# File 'lib/bowline/initializer.rb', line 372 def logger @logger end |
#name ⇒ Object
Returns the value of attribute name.
420 421 422 |
# File 'lib/bowline/initializer.rb', line 420 def name @name end |
#plugin_glob ⇒ Object
Returns the value of attribute plugin_glob.
414 415 416 |
# File 'lib/bowline/initializer.rb', line 414 def plugin_glob @plugin_glob end |
#publisher ⇒ Object
Returns the value of attribute publisher.
424 425 426 |
# File 'lib/bowline/initializer.rb', line 424 def publisher @publisher end |
#reload_plugins ⇒ Object
Returns the value of attribute reload_plugins.
378 379 380 |
# File 'lib/bowline/initializer.rb', line 378 def reload_plugins @reload_plugins end |
#root_path ⇒ Object (readonly)
The application’s base directory.
321 322 323 |
# File 'lib/bowline/initializer.rb', line 321 def root_path @root_path end |
#sdk ⇒ Object
Returns the value of attribute sdk.
427 428 429 |
# File 'lib/bowline/initializer.rb', line 427 def sdk @sdk end |
#time_zone ⇒ Object
Sets the default time_zone
. Setting this will enable time_zone
awareness for Active Record models and set the Active Record default timezone to :utc
.
412 413 414 |
# File 'lib/bowline/initializer.rb', line 412 def time_zone @time_zone end |
#titanium_version ⇒ Object
Returns the value of attribute titanium_version.
430 431 432 |
# File 'lib/bowline/initializer.rb', line 430 def titanium_version @titanium_version end |
#url ⇒ Object
Returns the value of attribute url.
425 426 427 |
# File 'lib/bowline/initializer.rb', line 425 def url @url end |
#version ⇒ Object
Returns the value of attribute version.
422 423 424 |
# File 'lib/bowline/initializer.rb', line 422 def version @version end |
#whiny_nils ⇒ Object
Set to true
if you want to be warned (noisily) when you try to invoke any method of nil
. Set to false
for the standard Ruby behavior.
376 377 378 |
# File 'lib/bowline/initializer.rb', line 376 def whiny_nils @whiny_nils end |
Instance Method Details
#after_initialize(&after_initialize_block) ⇒ Object
Adds a block which will be executed after bowline has been fully initialized. Useful for per-environment configuration which depends on the framework being fully initialized.
502 503 504 |
# File 'lib/bowline/initializer.rb', line 502 def after_initialize(&after_initialize_block) after_initialize_blocks << after_initialize_block if after_initialize_block end |
#after_initialize_blocks ⇒ Object
Returns the blocks added with Configuration#after_initialize
507 508 509 |
# File 'lib/bowline/initializer.rb', line 507 def after_initialize_blocks @after_initialize_blocks ||= [] end |
#app_config ⇒ Object
482 483 484 485 |
# File 'lib/bowline/initializer.rb', line 482 def app_config require 'erb' YAML::load(ERB.new(IO.read(app_config_file)).result) if File.exists?(app_config_file) end |
#database_configuration ⇒ Object
Loads and returns the contents of the #database_configuration_file. The contents of the file are processed via ERB before being sent through YAML::load.
490 491 492 493 |
# File 'lib/bowline/initializer.rb', line 490 def database_configuration require 'erb' YAML::load(ERB.new(IO.read(database_configuration_file)).result) if File.exists?(database_configuration_file) end |
#gem(*args) ⇒ Object
Adds a single Gem dependency to the Bowline application. By default, it will require the library with the same name as the gem. Use :lib to specify a different name.
# gem 'aws-s3', '>= 0.4.0'
# require 'aws/s3'
config.gem 'aws-s3', :lib => 'aws/s3', :version => '>= 0.4.0', \
:source => "http://code.whytheluckystiff.net"
To require a library be installed, but not attempt to load it, pass :lib => false
config.gem 'qrp', :version => '0.4.1', :lib => false
403 404 405 |
# File 'lib/bowline/initializer.rb', line 403 def gem(*args) @gems << Dependencies::Dependency.new(*args) end |
#helpers ⇒ Object
495 496 497 |
# File 'lib/bowline/initializer.rb', line 495 def helpers Dir[helper_glob].map {|f| File.basename(f, '.rb').classify } end |
#reload_plugins? ⇒ Boolean
Returns true if plugin reloading is enabled.
380 381 382 |
# File 'lib/bowline/initializer.rb', line 380 def reload_plugins? !!@reload_plugins end |
#set_root_path! ⇒ Object
Set the root_path to APP_ROOT and canonicalize it.
463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 |
# File 'lib/bowline/initializer.rb', line 463 def set_root_path! raise 'APP_ROOT is not set' unless defined?(::APP_ROOT) raise 'APP_ROOT is not a directory' unless File.directory?(::APP_ROOT) @root_path = # Pathname is incompatible with Windows, but Windows doesn't have # real symlinks so File.expand_path is safe. if RUBY_PLATFORM =~ /(:?mswin|mingw)/ File.(::APP_ROOT) # Otherwise use Pathname#realpath which respects symlinks. else Pathname.new(::APP_ROOT).realpath.to_s end Object.const_set(:RELATIVE_APP_ROOT, ::APP_ROOT.dup) unless defined?(::RELATIVE_APP_ROOT) ::APP_ROOT.replace @root_path end |