rucola 0.0.1 → 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/ChangeLog +301 -0
- data/History.txt +51 -0
- data/Manifest.txt +12 -0
- data/README.txt +6 -7
- data/TODO +13 -8
- data/app_generators/rucola/rucola_generator.rb +1 -1
- data/app_generators/rucola/templates/app/controllers/application_controller.rb +2 -2
- data/app_generators/rucola/templates/test/controllers/test_application_controller.rb +22 -5
- data/app_generators/rucola/templates/test/test_helper.rb +3 -2
- data/config/hoe.rb +2 -2
- data/lib/autotest/discover.rb +9 -0
- data/lib/autotest/fail.png +0 -0
- data/lib/autotest/growl_images.rb +39 -0
- data/lib/autotest/pass.png +0 -0
- data/lib/autotest/rucola.rb +36 -0
- data/lib/autotest/sound.rb +52 -0
- data/lib/rucola/info_plist.rb +5 -0
- data/lib/rucola/initializer.rb +65 -113
- data/lib/rucola/nib.rb +2 -2
- data/lib/rucola/plugin.rb +57 -0
- data/lib/rucola/rucola_support/initialize_hooks.rb +7 -0
- data/lib/rucola/rucola_support/notifications/notifications.rb +67 -27
- data/lib/rucola/rucola_support/rc_app.rb +9 -0
- data/lib/rucola/tasks/main.rake +8 -4
- data/lib/rucola/tasks/xcode.rake +10 -6
- data/lib/rucola/test_helper.rb +14 -0
- data/lib/rucola/version.rb +1 -1
- data/lib/rucola/xcode.rb +11 -6
- data/rucola_generators/controller/controller_generator.rb +1 -1
- data/rucola_generators/controller/templates/test_controller_template.rb.erb +14 -5
- data/rucola_generators/document_model/document_model_generator.rb +3 -3
- data/rucola_generators/document_model/templates/test_document_model_template.rb.erb +18 -5
- data/rucola_generators/rucola_plugin/USAGE +6 -0
- data/rucola_generators/rucola_plugin/rucola_plugin_generator.rb +63 -0
- data/rucola_generators/rucola_plugin/templates/init.rb.erb +25 -0
- data/rucola_generators/window_controller/templates/test_window_controller_template.rb.erb +21 -5
- data/rucola_generators/window_controller/window_controller_generator.rb +1 -1
- data/test/test_document_model_generator.rb +8 -2
- data/test/test_info_plist.rb +4 -0
- data/test/test_initializer.rb +80 -0
- data/test/test_nib.rb +9 -0
- data/test/test_notifications.rb +38 -19
- data/test/test_plugin.rb +48 -0
- data/test/test_rc_app.rb +5 -0
- data/test/test_rucola_plugin_generator.rb +65 -0
- data/test/test_xcode.rb +3 -3
- data/website/index.html +49 -7
- data/website/index.txt +34 -4
- metadata +37 -2
@@ -12,11 +12,11 @@ class ApplicationController < Rucola::RCController
|
|
12
12
|
|
13
13
|
# NSApplication delegate methods
|
14
14
|
def applicationDidFinishLaunching(notification)
|
15
|
-
puts "\nApplication finished launching."
|
15
|
+
Kernel.puts "\nApplication finished launching."
|
16
16
|
end
|
17
17
|
|
18
18
|
def applicationWillTerminate(notification)
|
19
|
-
puts "\nApplication will terminate."
|
19
|
+
Kernel.puts "\nApplication will terminate."
|
20
20
|
end
|
21
21
|
|
22
22
|
end
|
@@ -1,10 +1,27 @@
|
|
1
1
|
require File.expand_path('../../test_helper', __FILE__)
|
2
2
|
|
3
|
-
|
3
|
+
describe 'ApplicationController' do
|
4
|
+
before do
|
5
|
+
@controller = ApplicationController.alloc.init
|
6
|
+
end
|
7
|
+
|
8
|
+
it "should initialize" do
|
9
|
+
@controller.should.be.an.instance_of ApplicationController
|
10
|
+
end
|
4
11
|
|
5
|
-
|
6
|
-
|
7
|
-
|
12
|
+
it "should set itself as the application delegate" do
|
13
|
+
OSX::NSApp.expects(:delegate=).with(@controller)
|
14
|
+
@controller.ib_outlet(:main_window).expects(:inspect)
|
15
|
+
@controller.awakeFromNib
|
8
16
|
end
|
9
17
|
|
10
|
-
|
18
|
+
it "should do some stuff when the application has finished launching" do
|
19
|
+
Kernel.expects(:puts)
|
20
|
+
@controller.applicationDidFinishLaunching(nil)
|
21
|
+
end
|
22
|
+
|
23
|
+
it "should do some stuff when the application will terminate" do
|
24
|
+
Kernel.expects(:puts)
|
25
|
+
@controller.applicationWillTerminate(nil)
|
26
|
+
end
|
27
|
+
end
|
@@ -2,8 +2,9 @@ ENV['RUBYCOCOA_ENV'] = 'test'
|
|
2
2
|
ENV['RUBYCOCOA_ROOT'] = File.expand_path('../../', __FILE__)
|
3
3
|
|
4
4
|
require 'rubygems'
|
5
|
-
require
|
6
|
-
require
|
5
|
+
require 'test/unit'
|
6
|
+
require 'test/spec'
|
7
|
+
require 'mocha'
|
7
8
|
require 'rucola'
|
8
9
|
require 'rucola/test_helper'
|
9
10
|
|
data/config/hoe.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
require 'rucola/version'
|
2
2
|
|
3
|
-
AUTHOR = ['Eloy Duran', 'Justin Palmer'] # can also be an array of Authors
|
3
|
+
AUTHOR = ['Eloy Duran', 'Justin Palmer', 'Chris McGrath', 'Satoshi Nagakawa'] # can also be an array of Authors
|
4
4
|
EMAIL = "e.duran@superalloy.nl"
|
5
5
|
DESCRIPTION = "Rucola is an extension for RubyCocoa. It has a application skeleton generator and builds an \"opinionated\" application layout, like the one known from rails. And comes with RubyCocoa specific rake tasks."
|
6
6
|
GEM_NAME = 'rucola' # what ppl will type to install your gem
|
@@ -59,7 +59,7 @@ hoe = Hoe.new(GEM_NAME, VERS) do |p|
|
|
59
59
|
|
60
60
|
# == Optional
|
61
61
|
p.changes = p.paragraphs_of("History.txt", 0..1).join("\\n\\n")
|
62
|
-
p.extra_deps = ['rubigen', 'rubynode'] # An array of rubygem dependencies [name, version], e.g. [ ['active_support', '>= 1.3.1'] ]
|
62
|
+
p.extra_deps = ['rubigen', 'rubynode', 'test-spec', 'mocha'] # An array of rubygem dependencies [name, version], e.g. [ ['active_support', '>= 1.3.1'] ]
|
63
63
|
|
64
64
|
#p.spec_extras = {} # A hash of extra values to set in the gemspec.
|
65
65
|
|
Binary file
|
@@ -0,0 +1,39 @@
|
|
1
|
+
# Copyright John Nunemaker
|
2
|
+
# See: http://railstips.org/2007/7/23/autotest-growl-pass-fail-notifications
|
3
|
+
|
4
|
+
require 'autotest'
|
5
|
+
require 'autotest/redgreen'
|
6
|
+
require 'autotest/timestamp'
|
7
|
+
|
8
|
+
# To use this autotest plugin add the following to your autotest config file (~/.autotest):
|
9
|
+
#
|
10
|
+
# require 'autotest/growl_images'
|
11
|
+
#
|
12
|
+
# At this moment growlnotify still has a few issues on Leopard.
|
13
|
+
# This means that sometimes the notification will show up and sometimes not.
|
14
|
+
module Autotest::Growl
|
15
|
+
# Override this to specify an alternative path to your pass/fail images.
|
16
|
+
#
|
17
|
+
# def self.images_path
|
18
|
+
# File.expand_path('..', __FILE__)
|
19
|
+
# end
|
20
|
+
def self.images_path
|
21
|
+
File.expand_path('..', __FILE__)
|
22
|
+
end
|
23
|
+
|
24
|
+
def self.growl(title, msg, img, pri=0, sticky="")
|
25
|
+
system "growlnotify -n autotest --image #{img} -p #{pri} -m #{msg.inspect} #{title} #{sticky}"
|
26
|
+
end
|
27
|
+
|
28
|
+
Autotest.add_hook :ran_command do |at|
|
29
|
+
results = [at.results].flatten.join("\n")
|
30
|
+
output = results.slice(/(\d+)\stests,\s(\d+)\sassertions,\s(\d+)\sfailures,\s(\d+)\serrors/)
|
31
|
+
if output
|
32
|
+
if $~[3].to_i > 0 || $~[4].to_i > 0
|
33
|
+
growl "FAIL", "#{output}", "#{images_path}/fail.png", 2
|
34
|
+
else
|
35
|
+
growl "Pass", "#{output}", "#{images_path}/pass.png"
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
Binary file
|
@@ -0,0 +1,36 @@
|
|
1
|
+
require 'autotest'
|
2
|
+
|
3
|
+
class Autotest::Rucola < Autotest
|
4
|
+
|
5
|
+
def initialize # :nodoc:
|
6
|
+
super
|
7
|
+
@exceptions = /^\.\/(?:script|vendor\/rubycocoa)/
|
8
|
+
|
9
|
+
@test_mappings = {
|
10
|
+
%r%^app/models/(.*)\.rb$% => proc { |_, m|
|
11
|
+
["test/models/test_#{m[1]}.rb"]
|
12
|
+
},
|
13
|
+
%r%^app/controllers/(.*)\.rb$% => proc { |_, m|
|
14
|
+
["test/controllers/test_#{m[1]}.rb"]
|
15
|
+
},
|
16
|
+
%r%^test/.*\.rb$% => proc { |filename, _|
|
17
|
+
filename
|
18
|
+
}
|
19
|
+
}
|
20
|
+
end
|
21
|
+
|
22
|
+
# Given the string filename as the path, determine
|
23
|
+
# the corresponding tests for it, in an array.
|
24
|
+
def tests_for_file(filename)
|
25
|
+
super.select { |f| @files.has_key? f }
|
26
|
+
end
|
27
|
+
|
28
|
+
# Convert the pathname s to the name of class.
|
29
|
+
def path_to_classname(s)
|
30
|
+
sep = File::SEPARATOR
|
31
|
+
f = s.sub(/^test#{sep}((models|controllers)#{sep})?/, '').sub(/\.rb$/, '').split(sep)
|
32
|
+
f = f.map { |path| path.split(/_/).map { |seg| seg.capitalize }.join }
|
33
|
+
f = f.map { |path| path.sub(/^Test/, '') }
|
34
|
+
f.join('::')
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,52 @@
|
|
1
|
+
# Original idea by Jeremy Seitz.
|
2
|
+
# See: http://fozworks.com/2007/7/28/autotest-sound-effects
|
3
|
+
|
4
|
+
require 'osx/cocoa'
|
5
|
+
require 'autotest'
|
6
|
+
|
7
|
+
# To use this autotest plugin add the following to your autotest config file (~/.autotest):
|
8
|
+
#
|
9
|
+
# require 'autotest/sound'
|
10
|
+
module Autotest::Sound
|
11
|
+
# Override this to specify an alternative path to your hook sounds.
|
12
|
+
#
|
13
|
+
# def self.sound_path
|
14
|
+
# '/System/Library/Sounds'
|
15
|
+
# end
|
16
|
+
def self.sound_path
|
17
|
+
'/System/Library/Sounds'
|
18
|
+
end
|
19
|
+
|
20
|
+
# Override this to specify the sounds for the hooks.
|
21
|
+
#
|
22
|
+
# def self.hook_sounds
|
23
|
+
# {
|
24
|
+
# #:run => 'Purr',
|
25
|
+
# :red => 'Basso.aiff',
|
26
|
+
# :green => 'Blow.aiff',
|
27
|
+
# :quit => 'Submarine.aiff',
|
28
|
+
# :run_command => 'Purr.aiff',
|
29
|
+
# #:ran_command => 'Morse.aiff'
|
30
|
+
# }
|
31
|
+
# end
|
32
|
+
def self.hook_sounds
|
33
|
+
{
|
34
|
+
#:run => sound('Purr'),
|
35
|
+
:red => 'Basso.aiff',
|
36
|
+
:green => 'Blow.aiff',
|
37
|
+
:quit => 'Submarine.aiff',
|
38
|
+
:run_command => 'Purr.aiff',
|
39
|
+
#:ran_command => 'Morse.aiff'
|
40
|
+
}
|
41
|
+
end
|
42
|
+
|
43
|
+
hook_sounds.each_key do |hook|
|
44
|
+
Autotest.add_hook(hook) do |at|
|
45
|
+
if hook_sounds.has_key?(hook)
|
46
|
+
snd = OSX::NSSound.alloc.initWithContentsOfFile_byReference( File.join(File.expand_path(sound_path), hook_sounds[hook]), true )
|
47
|
+
snd.play
|
48
|
+
sleep 0.25 while snd.playing?
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
data/lib/rucola/info_plist.rb
CHANGED
@@ -15,6 +15,7 @@ module Rucola
|
|
15
15
|
|
16
16
|
def document_types
|
17
17
|
@data['CFBundleDocumentTypes'] ||= []
|
18
|
+
@data['CFBundleDocumentTypes'] = @data['CFBundleDocumentTypes'].to_ns
|
18
19
|
@data['CFBundleDocumentTypes']
|
19
20
|
end
|
20
21
|
|
@@ -33,5 +34,9 @@ module Rucola
|
|
33
34
|
@data.writeToFile_atomically(@path, true)
|
34
35
|
end
|
35
36
|
|
37
|
+
# Returns the name of the application (CFBundleExecutable).
|
38
|
+
def app_name
|
39
|
+
@data['CFBundleExecutable']
|
40
|
+
end
|
36
41
|
end
|
37
42
|
end
|
data/lib/rucola/initializer.rb
CHANGED
@@ -1,12 +1,15 @@
|
|
1
1
|
require 'osx/cocoa'
|
2
2
|
require 'pathname'
|
3
3
|
|
4
|
+
require 'rucola/rucola_support/rc_app'
|
5
|
+
require 'rucola/plugin'
|
6
|
+
|
4
7
|
unless ENV['RUBYCOCOA_ENV'].nil?
|
5
8
|
RUBYCOCOA_ENV = ENV['RUBYCOCOA_ENV']
|
6
9
|
else
|
7
10
|
unless ENV['DYLD_LIBRARY_PATH'].nil?
|
8
11
|
env = ENV['DYLD_LIBRARY_PATH'].split('/').last.downcase
|
9
|
-
if %(debug release).include?(env)
|
12
|
+
if %(debug release test).include?(env)
|
10
13
|
RUBYCOCOA_ENV = env
|
11
14
|
else
|
12
15
|
RUBYCOCOA_ENV = 'debug'
|
@@ -16,11 +19,6 @@ else
|
|
16
19
|
end
|
17
20
|
end
|
18
21
|
|
19
|
-
# ActiveRecord uses RAILS_ENV internally to figure out which environment key to parse in
|
20
|
-
# database.yml. Since we use the non-standard release and debug environments, we need to
|
21
|
-
# set this here
|
22
|
-
RAILS_ENV = RUBYCOCOA_ENV
|
23
|
-
|
24
22
|
unless ENV['RUBYCOCOA_ROOT'].nil?
|
25
23
|
# rake will set the RUBYCOCOA_ROOT for debugging purpose
|
26
24
|
RUBYCOCOA_ROOT = Pathname.new(ENV['RUBYCOCOA_ROOT'])
|
@@ -28,10 +26,10 @@ else
|
|
28
26
|
# We are running in debug from xcode, which doesn't set RUBYCOCOA_ROOT.
|
29
27
|
# Or we are simply running in release.
|
30
28
|
RUBYCOCOA_ROOT =
|
31
|
-
if RUBYCOCOA_ENV == '
|
32
|
-
Pathname.new(ENV['DYLD_LIBRARY_PATH'] + "../../../").cleanpath
|
33
|
-
else
|
29
|
+
if RUBYCOCOA_ENV == 'release'
|
34
30
|
Pathname.new(OSX::NSBundle.mainBundle.resourcePath.fileSystemRepresentation)
|
31
|
+
else
|
32
|
+
Pathname.new(ENV['DYLD_LIBRARY_PATH'] + "../../../").cleanpath
|
35
33
|
end
|
36
34
|
end
|
37
35
|
|
@@ -54,27 +52,54 @@ module Rucola
|
|
54
52
|
# The Configuration instance used by this Initializer instance.
|
55
53
|
attr_reader :configuration
|
56
54
|
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
55
|
+
class << self
|
56
|
+
# Load the config/boot.rb file.
|
57
|
+
def boot
|
58
|
+
Rucola::Plugin.before_boot
|
59
|
+
do_boot
|
60
|
+
Rucola::Plugin.after_boot
|
61
|
+
end
|
62
|
+
|
63
|
+
# Override this method from your Plugin.before_boot method if you need
|
64
|
+
# to alter behaviour before any of the application's files are required
|
65
|
+
# and the app is started.
|
66
|
+
def do_boot
|
67
|
+
require RUBYCOCOA_ROOT + 'config/boot'
|
68
|
+
end
|
69
|
+
|
70
|
+
# Returns the path to the plugins root directory. Eg /MyApp/vendor/plugins.
|
71
|
+
def plugins_root
|
72
|
+
RUBYCOCOA_ROOT + 'vendor/plugins'
|
73
|
+
end
|
74
|
+
|
75
|
+
# Loads all the plugins that are found in +plugins_root+.
|
76
|
+
def load_plugins
|
77
|
+
root = plugins_root
|
78
|
+
if root.exist?
|
79
|
+
root.children.each do |plugin|
|
80
|
+
next unless plugin.directory?
|
81
|
+
Kernel.require plugin + 'init.rb'
|
82
|
+
end
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
# Run the initializer and start the application. The #process method is run by default which
|
87
|
+
# runs all the initialization routines. You can alternatively specify
|
88
|
+
# a command to run.
|
89
|
+
#
|
90
|
+
# OSX::Initializer.run(:set_load_path)
|
91
|
+
#
|
92
|
+
def run(command = :process, configuration = Configuration.new)
|
93
|
+
yield configuration if block_given?
|
94
|
+
initializer = new configuration
|
95
|
+
initializer.send(command)
|
96
|
+
start_app
|
97
|
+
end
|
98
|
+
|
99
|
+
# Starts the application's run loop.
|
100
|
+
def start_app
|
101
|
+
OSX.NSApplicationMain(0, nil) unless RUBYCOCOA_ENV == 'test' || ENV['DONT_START_RUBYCOCOA_APP']
|
102
|
+
end
|
78
103
|
end
|
79
104
|
|
80
105
|
# Create an initializer instance that references the given
|
@@ -86,6 +111,7 @@ module Rucola
|
|
86
111
|
# Step through the initialization routines, skipping the active_record
|
87
112
|
# routines if active_record isnt' being used.
|
88
113
|
def process
|
114
|
+
Rucola::Plugin.before_process(self)
|
89
115
|
unless ENV['DYLD_LIBRARY_PATH'].nil?
|
90
116
|
set_load_path
|
91
117
|
copy_load_paths_for_release
|
@@ -95,12 +121,7 @@ module Rucola
|
|
95
121
|
require_frameworks
|
96
122
|
require_ruby_source_files
|
97
123
|
load_environment
|
98
|
-
|
99
|
-
if configuration.use_active_record?
|
100
|
-
initialize_database_directories
|
101
|
-
initialize_database
|
102
|
-
initialize_active_record_settings
|
103
|
-
end
|
124
|
+
Rucola::Plugin.after_process(self)
|
104
125
|
end
|
105
126
|
|
106
127
|
# Requires all frameworks specified by the Configuration#objc_frameworks
|
@@ -108,12 +129,6 @@ module Rucola
|
|
108
129
|
# use_active_record? is true
|
109
130
|
def require_frameworks
|
110
131
|
configuration.objc_frameworks.each { |framework| OSX.require_framework(framework) }
|
111
|
-
if configuration.use_active_record?
|
112
|
-
require 'active_support'
|
113
|
-
configuration.active_record = OrderedOptions.new
|
114
|
-
require 'active_record'
|
115
|
-
require 'osx/active_record_proxy'
|
116
|
-
end
|
117
132
|
end
|
118
133
|
|
119
134
|
# Loads the Rucola support library
|
@@ -144,27 +159,6 @@ module Rucola
|
|
144
159
|
end
|
145
160
|
end
|
146
161
|
|
147
|
-
def initialize_database_directories
|
148
|
-
return if configuration.environment == 'debug'
|
149
|
-
`mkdir -p '#{configuration.application_support_path}'` unless File.exists?(configuration.application_support_path)
|
150
|
-
end
|
151
|
-
|
152
|
-
def initialize_database
|
153
|
-
ActiveRecord::Base.configurations = configuration.database_configuration
|
154
|
-
ActiveRecord::Base.logger = Logger.new($stderr)
|
155
|
-
ActiveRecord::Base.colorize_logging = false
|
156
|
-
ActiveRecord::Base.establish_connection
|
157
|
-
ActiveRecord::Base.connection.initialize_schema_information
|
158
|
-
end
|
159
|
-
|
160
|
-
# Initializes active_record settings. The available settings map to the accessors
|
161
|
-
# of the ActiveRecord::Base class.
|
162
|
-
def initialize_active_record_settings
|
163
|
-
configuration.send('active_record').each do |setting, value|
|
164
|
-
ActiveRecord::Base.send("#{setting}=", value)
|
165
|
-
end
|
166
|
-
end
|
167
|
-
|
168
162
|
def load_application_initializers
|
169
163
|
Dir["#{configuration.root_path}/config/initializers/**/*.rb"].sort.each do |initializer|
|
170
164
|
load(initializer)
|
@@ -194,29 +188,16 @@ module Rucola
|
|
194
188
|
end
|
195
189
|
|
196
190
|
# Copy the default load paths to the resource directory for the application if
|
197
|
-
# we are building a release, otherwise we do nothing. When in debug mode,
|
198
|
-
# files are loaded directly from your working directory.
|
191
|
+
# we are building a release, otherwise we do nothing. When in debug or test mode,
|
192
|
+
# the files are loaded directly from your working directory.
|
199
193
|
#
|
200
194
|
# TODO: Remove debug database from released app if it exists.
|
201
195
|
def copy_load_paths_for_release
|
202
|
-
return
|
196
|
+
return unless configuration.environment == 'release'
|
203
197
|
configuration.load_paths.each do |path|
|
204
198
|
`cp -R #{path} #{RUBYCOCOA_ROOT}/#{File.basename(path)}` if File.directory?(path)
|
205
199
|
end
|
206
200
|
end
|
207
|
-
|
208
|
-
# Now is a good time to load the plugins, because
|
209
|
-
# this will give them the chance to alter the
|
210
|
-
# behaviour of Rucola before it starts.
|
211
|
-
RUBYCOCOA_PLUGINS_ROOT = RUBYCOCOA_ROOT + 'vendor/plugins'
|
212
|
-
@@required_plugins = [] # TODO: isn't used yet
|
213
|
-
if RUBYCOCOA_PLUGINS_ROOT.exist?
|
214
|
-
RUBYCOCOA_PLUGINS_ROOT.children.each do |plugin|
|
215
|
-
next unless plugin.directory?
|
216
|
-
@@required_plugins.push plugin
|
217
|
-
require plugin + 'init.rb'
|
218
|
-
end
|
219
|
-
end
|
220
201
|
end
|
221
202
|
|
222
203
|
class Configuration
|
@@ -230,28 +211,16 @@ module Rucola
|
|
230
211
|
# List of Objective-C frameworks that should be required
|
231
212
|
attr_accessor :objc_frameworks
|
232
213
|
|
233
|
-
#Stub for setting options on ActiveRecord::Base
|
234
|
-
attr_accessor :active_record
|
235
|
-
|
236
|
-
# Should the active_record framework be loaded.
|
237
|
-
attr_accessor :use_active_record
|
238
|
-
|
239
214
|
# An array of additional paths to prepend to the load path. By default,
|
240
215
|
# all +models+, +config+, +controllers+ and +db+ paths are included in this list.
|
241
216
|
attr_accessor :load_paths
|
242
217
|
|
243
|
-
# The path to the database configuration file to use. (Defaults to
|
244
|
-
# <tt>config/database.yml</tt>.)
|
245
|
-
attr_accessor :database_configuration_file
|
246
|
-
|
247
|
-
|
248
218
|
def initialize
|
249
219
|
set_root_path!
|
250
220
|
set_application_support_path!
|
251
221
|
|
252
222
|
self.objc_frameworks = []
|
253
223
|
self.load_paths = default_load_paths
|
254
|
-
self.database_configuration_file = default_database_configuration_file
|
255
224
|
end
|
256
225
|
|
257
226
|
def set_root_path!
|
@@ -262,14 +231,8 @@ module Rucola
|
|
262
231
|
# TODO: we might want to set this to something in test mode.
|
263
232
|
return if RUBYCOCOA_ENV == 'test'
|
264
233
|
|
265
|
-
app_name = OSX::NSBundle.mainBundle.bundleIdentifier.to_s.scan(/\w+$/).first
|
266
234
|
user_app_support_path = File.join(OSX::NSSearchPathForDirectoriesInDomains(OSX::NSLibraryDirectory, OSX::NSUserDomainMask, true)[0].to_s, "Application Support")
|
267
|
-
@application_support_path = File.join(user_app_support_path, app_name)
|
268
|
-
end
|
269
|
-
|
270
|
-
# Returns the value of @use_active_record
|
271
|
-
def use_active_record?
|
272
|
-
@use_active_record
|
235
|
+
@application_support_path = File.join(user_app_support_path, Rucola::RCApp.app_name)
|
273
236
|
end
|
274
237
|
|
275
238
|
# Returns the value of RUBYCOCOA_ENV
|
@@ -282,17 +245,7 @@ module Rucola
|
|
282
245
|
def environment_path
|
283
246
|
"#{root_path}/config/environments/#{environment}.rb"
|
284
247
|
end
|
285
|
-
|
286
|
-
# Loads and returns the contents of the #database_configuration_file. The
|
287
|
-
# contents of the file are processed via ERB before being sent through
|
288
|
-
# YAML::load.
|
289
|
-
def database_configuration
|
290
|
-
db_config = YAML::load(ERB.new(IO.read(database_configuration_file)).result)
|
291
|
-
db = db_config[environment]['database']
|
292
|
-
db_config[environment]['database'] = environment == 'release' ? "#{application_support_path}/#{db.split('/').last}" : "#{RUBYCOCOA_ROOT}/db/#{db.split('/').last}"
|
293
|
-
db_config
|
294
|
-
end
|
295
|
-
|
248
|
+
|
296
249
|
private
|
297
250
|
# Set the load paths, which specifies what directories should be copied over on release.
|
298
251
|
# We can't use RUBYCOCOA_ROOT here because when building for release the .app file is the
|
@@ -305,9 +258,8 @@ module Rucola
|
|
305
258
|
db
|
306
259
|
).map {|dir| "#{Pathname.new(ENV['DYLD_LIBRARY_PATH'] + "../../../").cleanpath}/#{dir}" }.select { |dir| File.directory?(dir) }
|
307
260
|
end
|
308
|
-
|
309
|
-
def default_database_configuration_file
|
310
|
-
File.join(root_path, 'config', 'database.yml')
|
311
|
-
end
|
312
261
|
end
|
313
262
|
end
|
263
|
+
|
264
|
+
# Directly load plugins, so the Rucola Initializer & Configuration classes can be overriden.
|
265
|
+
Rucola::Initializer.load_plugins
|