Class: Rucola::Configuration
- Inherits:
-
Object
- Object
- Rucola::Configuration
- Defined in:
- lib/rucola/initializer.rb
Instance Attribute Summary collapse
-
#active_record ⇒ Object
Stub for setting options on ActiveRecord::Base.
-
#application_support_path ⇒ Object
The path to the applications support directory
~/Library/Application Support/AppName
. -
#database_configuration_file ⇒ Object
The path to the database configuration file to use.
-
#load_paths ⇒ Object
An array of additional paths to prepend to the load path.
-
#objc_frameworks ⇒ Object
List of Objective-C frameworks that should be required.
-
#root_path ⇒ Object
readonly
The applications base directory.
-
#use_active_record ⇒ Object
Should the active_record framework be loaded.
Instance Method Summary collapse
-
#database_configuration ⇒ Object
Loads and returns the contents of the #database_configuration_file.
-
#environment ⇒ Object
Returns the value of RUBYCOCOA_ENV.
-
#environment_path ⇒ Object
The path to the current environment’s file (development.rb, etc.).
-
#initialize ⇒ Configuration
constructor
A new instance of Configuration.
- #set_application_support_path! ⇒ Object
- #set_root_path! ⇒ Object
-
#use_active_record? ⇒ Boolean
Returns the value of @use_active_record.
Constructor Details
#initialize ⇒ Configuration
Returns a new instance of Configuration.
248 249 250 251 252 253 254 255 |
# File 'lib/rucola/initializer.rb', line 248 def initialize set_root_path! set_application_support_path! self.objc_frameworks = [] self.load_paths = default_load_paths self.database_configuration_file = default_database_configuration_file end |
Instance Attribute Details
#active_record ⇒ Object
Stub for setting options on ActiveRecord::Base
234 235 236 |
# File 'lib/rucola/initializer.rb', line 234 def active_record @active_record end |
#application_support_path ⇒ Object
The path to the applications support directory ~/Library/Application Support/AppName
228 229 230 |
# File 'lib/rucola/initializer.rb', line 228 def application_support_path @application_support_path end |
#database_configuration_file ⇒ Object
The path to the database configuration file to use. (Defaults to config/database.yml
.)
245 246 247 |
# File 'lib/rucola/initializer.rb', line 245 def database_configuration_file @database_configuration_file end |
#load_paths ⇒ Object
An array of additional paths to prepend to the load path. By default, all models
, config
, controllers
and db
paths are included in this list.
241 242 243 |
# File 'lib/rucola/initializer.rb', line 241 def load_paths @load_paths end |
#objc_frameworks ⇒ Object
List of Objective-C frameworks that should be required
231 232 233 |
# File 'lib/rucola/initializer.rb', line 231 def objc_frameworks @objc_frameworks end |
#root_path ⇒ Object (readonly)
The applications base directory
224 225 226 |
# File 'lib/rucola/initializer.rb', line 224 def root_path @root_path end |
#use_active_record ⇒ Object
Should the active_record framework be loaded.
237 238 239 |
# File 'lib/rucola/initializer.rb', line 237 def use_active_record @use_active_record end |
Instance Method Details
#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.
289 290 291 292 293 294 |
# File 'lib/rucola/initializer.rb', line 289 def database_configuration db_config = YAML::load(ERB.new(IO.read(database_configuration_file)).result) db = db_config[environment]['database'] db_config[environment]['database'] = environment == 'release' ? "#{application_support_path}/#{db.split('/').last}" : "#{RUBYCOCOA_ROOT}/db/#{db.split('/').last}" db_config end |
#environment ⇒ Object
Returns the value of RUBYCOCOA_ENV
276 277 278 |
# File 'lib/rucola/initializer.rb', line 276 def environment ::RUBYCOCOA_ENV end |
#environment_path ⇒ Object
The path to the current environment’s file (development.rb, etc.). By default the file is at config/environments/#{environment}.rb
.
282 283 284 |
# File 'lib/rucola/initializer.rb', line 282 def environment_path "#{root_path}/config/environments/#{environment}.rb" end |
#set_application_support_path! ⇒ Object
261 262 263 264 265 266 267 268 |
# File 'lib/rucola/initializer.rb', line 261 def set_application_support_path! # TODO: we might want to set this to something in test mode. return if RUBYCOCOA_ENV == 'test' app_name = OSX::NSBundle.mainBundle.bundleIdentifier.to_s.scan(/\w+$/).first user_app_support_path = File.join(OSX::NSSearchPathForDirectoriesInDomains(OSX::NSLibraryDirectory, OSX::NSUserDomainMask, true)[0].to_s, "Application Support") @application_support_path = File.join(user_app_support_path, app_name) end |
#set_root_path! ⇒ Object
257 258 259 |
# File 'lib/rucola/initializer.rb', line 257 def set_root_path! @root_path = Pathname.new(::RUBYCOCOA_ROOT).realpath.to_s end |
#use_active_record? ⇒ Boolean
Returns the value of @use_active_record
271 272 273 |
# File 'lib/rucola/initializer.rb', line 271 def use_active_record? @use_active_record end |