Module: Rucola::RCApp

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

Class Method Summary collapse

Class Method Details

.app_nameObject

Returns the name of the application as specified in the Info.plist file.

Rucola::RCApp.app_name #=> 'MyApp'


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_pathObject

Returns the path to the application support directory for this application.

Rucola::RCApp.application_support_path #=> '/Users/eddy/Library/Application Support/MyApp/'


123
124
125
# File 'lib/rucola/rucola_support/rc_app.rb', line 123

def application_support_path
  File.join File.expand_path('~/Library/Application Support'), app_name
end

.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'


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

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'


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

Returns:

  • (Boolean)


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

def debug?; env == 'debug'; end

.envObject

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_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'


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

Returns the path to an asset file.

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


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

Returns the path to a controller file.

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


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

Returns the path to a model file.

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


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

Returns:

  • (Boolean)


12
# File 'lib/rucola/rucola_support/rc_app.rb', line 12

def release?; env == 'release'; 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



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

def root_path
  RUBYCOCOA_ROOT.to_s
end

.test?Boolean

Returns:

  • (Boolean)


8
# File 'lib/rucola/rucola_support/rc_app.rb', line 8

def test?; env == 'test'; 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'


69
70
71
# File 'lib/rucola/rucola_support/rc_app.rb', line 69

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