Module: Rucola::RCApp
- Included in:
- RCController
- Defined in:
- lib/rucola/rucola_support/rc_app.rb
Class Method Summary collapse
-
.app_name ⇒ Object
Returns the name of the application as specified in the Info.plist file.
-
.application_support_path ⇒ Object
Returns the path to the application support directory for this application.
-
.assets_path ⇒ Object
Returns the path to the current used app/assets dir.
-
.controllers_path ⇒ Object
Returns the path to the current used app/controllers dir.
- .debug? ⇒ Boolean
-
.env ⇒ Object
Returns the current RUBYCOCOA_ENV, which normally is ‘debug’ during development, test in the tests and ‘release’ in a release.
-
.models_path ⇒ Object
Returns the path to the current used app/models dir.
-
.path_for_asset(asset) ⇒ Object
Returns the path to an
asset
file. -
.path_for_controller(controller) ⇒ Object
Returns the path to a
controller
file. -
.path_for_model(model) ⇒ Object
Returns the path to a
model
file. -
.path_for_view(view) ⇒ Object
Returns the path to a
view
file. - .release? ⇒ Boolean
-
.root_path ⇒ Object
Returns the path to the current source root of the application.
- .test? ⇒ Boolean
-
.views_path ⇒ Object
Returns the path to the current used app/views dir.
Class Method Details
.app_name ⇒ Object
115 116 117 |
# File 'lib/rucola/rucola_support/rc_app.rb', line 115 def app_name Rucola::InfoPlist.open((RUBYCOCOA_ROOT + 'config/Info.plist').to_s).app_name end |
.application_support_path ⇒ Object
123 124 125 |
# File 'lib/rucola/rucola_support/rc_app.rb', line 123 def application_support_path File.join File.('~/Library/Application Support'), app_name end |
.assets_path ⇒ Object
Returns the path to the current used app/assets dir.
So in debug & test mode this will point to your development source_root/app/assets.
In release however this will point to the equivalent of:
NSBundle.mainBundle.resourcePath + 'app/assets'
57 58 59 |
# File 'lib/rucola/rucola_support/rc_app.rb', line 57 def assets_path (RUBYCOCOA_ROOT + 'app/assets').to_s end |
.controllers_path ⇒ Object
Returns the path to the current used app/controllers dir.
So in debug & test mode this will point to your development source_root/app/controllers.
In release however this will point to the equivalent of:
NSBundle.mainBundle.resourcePath + 'app/controllers'
33 34 35 |
# File 'lib/rucola/rucola_support/rc_app.rb', line 33 def controllers_path (RUBYCOCOA_ROOT + 'app/controllers').to_s end |
.debug? ⇒ Boolean
10 |
# File 'lib/rucola/rucola_support/rc_app.rb', line 10 def debug?; env == 'debug'; end |
.env ⇒ Object
Returns the current RUBYCOCOA_ENV, which normally is ‘debug’ during development, test in the tests and ‘release’ in a release.
6 |
# File 'lib/rucola/rucola_support/rc_app.rb', line 6 def env; RUBYCOCOA_ENV; end |
.models_path ⇒ Object
Returns the path to the current used app/models dir.
So in debug & test mode this will point to your development source_root/app/models.
In release however this will point to the equivalent of:
NSBundle.mainBundle.resourcePath + 'app/models'
45 46 47 |
# File 'lib/rucola/rucola_support/rc_app.rb', line 45 def models_path (RUBYCOCOA_ROOT + 'app/models').to_s end |
.path_for_asset(asset) ⇒ Object
107 108 109 |
# File 'lib/rucola/rucola_support/rc_app.rb', line 107 def path_for_asset(asset) "#{assets_path}/#{asset}" end |
.path_for_controller(controller) ⇒ Object
77 78 79 |
# File 'lib/rucola/rucola_support/rc_app.rb', line 77 def path_for_controller(controller) "#{controllers_path}/#{controller.name.to_s.snake_case}.rb" end |
.path_for_model(model) ⇒ Object
85 86 87 |
# File 'lib/rucola/rucola_support/rc_app.rb', line 85 def path_for_model(model) "#{models_path}/#{model.name.to_s.snake_case}.rb" end |
.path_for_view(view) ⇒ Object
Returns the path to a view
file.
Rucola::RCApp.path_for_controller('preferences') #=> 'root/app/views/Preferences.nib'
Rucola::RCApp.path_for_controller('Preferences') #=> 'root/app/views/Preferences.nib'
Rucola::RCApp.path_for_controller(PreferencesController) #=> 'root/app/views/Preferences.nib'
Rucola::RCApp.path_for_controller(PreferencesController.alloc.init) #=> 'root/app/views/Preferences.nib'
97 98 99 100 101 |
# File 'lib/rucola/rucola_support/rc_app.rb', line 97 def path_for_view(view) view = view.class unless view.is_a?(String) or view.is_a?(Class) view = view.name.to_s.sub(/Controller$/, '') if view.is_a? Class "#{views_path}/#{view.camel_case}.nib" end |
.release? ⇒ Boolean
12 |
# File 'lib/rucola/rucola_support/rc_app.rb', line 12 def release?; env == 'release'; end |
.root_path ⇒ Object
Returns the path to the current source root of the application.
So in debug & test mode this will point to your development source root.
In release however this will point to the equivalent of: NSBundle.mainBundle.resourcePath
21 22 23 |
# File 'lib/rucola/rucola_support/rc_app.rb', line 21 def root_path RUBYCOCOA_ROOT.to_s end |
.test? ⇒ Boolean
8 |
# File 'lib/rucola/rucola_support/rc_app.rb', line 8 def test?; env == 'test'; end |
.views_path ⇒ Object
Returns the path to the current used app/views dir.
So in debug & test mode this will point to your development source_root/app/views.
In release however this will point to the equivalent of:
NSBundle.mainBundle.resourcePath + 'app/views'
69 70 71 |
# File 'lib/rucola/rucola_support/rc_app.rb', line 69 def views_path (RUBYCOCOA_ROOT + 'app/views').to_s end |