Module: Rucola::RCApp

Included in:
RCController
Defined in:
lib/rucola/rucola_support/rc_app.rb

Class Method Summary collapse

Class Method Details

.assets_pathObject

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'


45
46
47
# File 'lib/rucola/rucola_support/rc_app.rb', line 45

def assets_path
  (RUBYCOCOA_ROOT + 'app/assets').to_s
end

.controllers_pathObject

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'


21
22
23
# File 'lib/rucola/rucola_support/rc_app.rb', line 21

def controllers_path
  (RUBYCOCOA_ROOT + 'app/controllers').to_s
end

.models_pathObject

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'


33
34
35
# File 'lib/rucola/rucola_support/rc_app.rb', line 33

def models_path
  (RUBYCOCOA_ROOT + 'app/models').to_s
end

.path_for_asset(asset) ⇒ Object

Returns the path to an asset file.

Rucola::RCApp.path_for_asset('somefile.png') #=> 'root/app/assets/somefile.png'


95
96
97
# File 'lib/rucola/rucola_support/rc_app.rb', line 95

def path_for_asset(asset)
  "#{assets_path}/#{asset}"
end

.path_for_controller(controller) ⇒ Object

Returns the path to a controller file.

Rucola::RCApp.path_for_controller(ApplicationController) #=> 'root/app/controllers/application_controller.rb'


65
66
67
# File 'lib/rucola/rucola_support/rc_app.rb', line 65

def path_for_controller(controller)
  "#{controllers_path}/#{controller.name.to_s.snake_case}.rb"
end

.path_for_model(model) ⇒ Object

Returns the path to a model file.

Rucola::RCApp.path_for_model(Person) #=> 'root/app/models/person.rb'


73
74
75
# File 'lib/rucola/rucola_support/rc_app.rb', line 73

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'


85
86
87
88
89
# File 'lib/rucola/rucola_support/rc_app.rb', line 85

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

.root_pathObject

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



9
10
11
# File 'lib/rucola/rucola_support/rc_app.rb', line 9

def root_path
  RUBYCOCOA_ROOT.to_s
end

.views_pathObject

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'


57
58
59
# File 'lib/rucola/rucola_support/rc_app.rb', line 57

def views_path
  (RUBYCOCOA_ROOT + 'app/views').to_s
end