rucola 0.0.3 → 0.5.0
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 +468 -0
- data/History.txt +25 -0
- data/License.txt +1 -1
- data/Manifest.txt +32 -0
- data/README.txt +9 -67
- data/Rakefile +39 -31
- data/TODO +10 -18
- data/app_generators/rucola/rucola_generator.rb +15 -8
- data/app_generators/rucola/templates/Rakefile.erb +35 -7
- data/app_generators/rucola/templates/config/boot.rb +0 -1
- data/app_generators/rucola/templates/config/dependencies.rb +31 -0
- data/app_generators/rucola/templates/config/environment.rb +0 -1
- data/app_generators/rucola/templates/config/environments/debug.rb +13 -1
- data/app_generators/rucola/templates/config/environments/release.rb +15 -1
- data/app_generators/rucola/templates/config/environments/test.rb +7 -1
- data/app_generators/rucola/templates/misc/rb_main.rb.erb +12 -1
- data/app_generators/rucola/templates/project.pbxproj.erb +4 -0
- data/app_generators/rucola/templates/script/console +10 -0
- data/app_generators/rucola/templates/test/controllers/test_application_controller.rb +22 -10
- data/app_generators/rucola/templates/test/test_helper.rb +1 -0
- data/bin/rucola +4 -2
- data/lib/rucola/dependencies.rb +241 -0
- data/lib/rucola/dependencies/exclusions.rb +20 -0
- data/lib/rucola/dependencies/override_require_and_gem.rb +30 -0
- data/lib/rucola/dependencies/resolver.rb +68 -0
- data/lib/rucola/fsevents.rb +108 -0
- data/lib/rucola/initializer.rb +149 -117
- data/lib/rucola/log.rb +61 -0
- data/lib/rucola/nib.rb +3 -3
- data/lib/rucola/reloader.rb +39 -0
- data/lib/rucola/ruby_debug.rb +27 -0
- data/lib/rucola/rucola_support.rb +1 -2
- data/lib/rucola/rucola_support/core_ext.rb +4 -2
- data/lib/rucola/rucola_support/core_ext/objc.rb +9 -4
- data/lib/rucola/rucola_support/core_ext/objc/nsimage.rb +22 -0
- data/lib/rucola/rucola_support/core_ext/ruby.rb +11 -4
- data/lib/rucola/rucola_support/core_ext/ruby/file.rb +11 -0
- data/lib/rucola/rucola_support/core_ext/ruby/kernel.rb +16 -0
- data/lib/rucola/rucola_support/core_ext/ruby/object.rb +47 -0
- data/lib/rucola/rucola_support/core_ext/ruby/string.rb +8 -0
- data/lib/rucola/rucola_support/notifications/notifications.rb +26 -28
- data/lib/rucola/rucola_support/rc_app.rb +18 -0
- data/lib/rucola/tasks/dependencies.rake +49 -0
- data/lib/rucola/tasks/deploy.rake +131 -0
- data/lib/rucola/tasks/main.rake +39 -6
- data/lib/rucola/tasks/xcode.rake +54 -11
- data/lib/rucola/test_case.rb +138 -0
- data/lib/rucola/test_helper.rb +11 -5
- data/lib/rucola/version.rb +2 -2
- data/lib/rucola/xcode.rb +39 -9
- data/rucola_generators/controller/templates/test_controller_template.rb.erb +19 -7
- data/rucola_generators/simple_model/USAGE +5 -0
- data/rucola_generators/simple_model/simple_model_generator.rb +54 -0
- data/rucola_generators/simple_model/templates/simple_model.rb.erb +2 -0
- data/rucola_generators/simple_model/templates/test_simple_model.rb.erb +11 -0
- data/rucola_generators/window_controller/templates/test_window_controller_template.rb.erb +24 -13
- data/test/fixtures/dependencies/foo.rb +2 -0
- data/test/fixtures/dependencies/foo/bar.rb +0 -0
- data/test/fixtures/dependencies/foo/baz.rb +0 -0
- data/test/fixtures/dependencies/requires_fileutils.rb +1 -0
- data/test/fixtures/some_reloadable_class.rb +4 -0
- data/test/test_core_ext.rb +80 -0
- data/test/test_dependencies.rb +205 -0
- data/test/test_fsevents.rb +152 -0
- data/test/test_helper.rb +30 -1
- data/test/test_initializer.rb +56 -23
- data/test/test_log.rb +44 -0
- data/test/test_objc_core_ext.rb +23 -0
- data/test/test_rc_app.rb +5 -0
- data/test/test_reloader.rb +28 -0
- data/test/test_rucola_generator.rb +7 -0
- data/test/test_simple_model_generator.rb +48 -0
- data/test/test_xcode.rb +85 -5
- data/website/index.html +17 -91
- data/website/index.txt +14 -81
- data/website/template.rhtml +1 -1
- metadata +120 -76
@@ -0,0 +1,48 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), "test_generator_helper.rb")
|
2
|
+
|
3
|
+
class TestSimpleModelGenerator < Test::Unit::TestCase
|
4
|
+
include RubiGen::GeneratorTestHelper
|
5
|
+
|
6
|
+
def setup
|
7
|
+
bare_setup
|
8
|
+
end
|
9
|
+
|
10
|
+
def teardown
|
11
|
+
bare_teardown
|
12
|
+
end
|
13
|
+
|
14
|
+
# Some generator-related assertions:
|
15
|
+
# assert_generated_file(name, &block) # block passed the file contents
|
16
|
+
# assert_directory_exists(name)
|
17
|
+
# assert_generated_class(name, &block)
|
18
|
+
# assert_generated_module(name, &block)
|
19
|
+
# assert_generated_test_for(name, &block)
|
20
|
+
# The assert_generated_(class|module|test_for) &block is passed the body of the class/module within the file
|
21
|
+
# assert_has_method(body, *methods) # check that the body has a list of methods (methods with parentheses not supported yet)
|
22
|
+
#
|
23
|
+
# Other helper methods are:
|
24
|
+
# app_root_files - put this in teardown to show files generated by the test method (e.g. p app_root_files)
|
25
|
+
# bare_setup - place this in setup method to create the APP_ROOT folder for each test
|
26
|
+
# bare_teardown - place this in teardown method to destroy the TMP_ROOT or APP_ROOT folder after each test
|
27
|
+
|
28
|
+
def test_generator_without_options
|
29
|
+
name = "foo_bar"
|
30
|
+
run_generator('simple_model', [name], sources)
|
31
|
+
|
32
|
+
assert_generated_file("app/models/foo_bar.rb") do |content|
|
33
|
+
assert(content == "class FooBar < OSX::NSObject\nend")
|
34
|
+
end
|
35
|
+
|
36
|
+
assert_generated_file("test/models/test_foo_bar.rb")
|
37
|
+
end
|
38
|
+
|
39
|
+
private
|
40
|
+
def sources
|
41
|
+
[RubiGen::PathSource.new(:test, File.join(File.dirname(__FILE__),"..", generator_path))
|
42
|
+
]
|
43
|
+
end
|
44
|
+
|
45
|
+
def generator_path
|
46
|
+
"rucola_generators"
|
47
|
+
end
|
48
|
+
end
|
data/test/test_xcode.rb
CHANGED
@@ -19,6 +19,8 @@ describe 'Xcode' do
|
|
19
19
|
OSX::NSMutableDictionary.stubs(:dictionaryWithContentsOfFile).with(@data_path).returns(@data)
|
20
20
|
|
21
21
|
@project = Xcode.new(@project_path)
|
22
|
+
# Add a stub `Linked Frameworks` group
|
23
|
+
@project.objects['1058C7A0FEA54F0111CA2CBB'] = { 'name' => 'Linked Frameworks', 'children' => [] }.to_ns
|
22
24
|
end
|
23
25
|
|
24
26
|
it "should initialize" do
|
@@ -84,15 +86,92 @@ describe 'Xcode' do
|
|
84
86
|
@project.object_for_id(id).last['files'].should == [@object_id]
|
85
87
|
end
|
86
88
|
|
89
|
+
it "should generate UUIDs" do
|
90
|
+
@project.generate_uuid.length.should.be 24
|
91
|
+
end
|
92
|
+
|
93
|
+
# This is a hack for the test if it generates a unique object id.
|
94
|
+
# I couldn't find another way to first generate a dup and the second time a good one...
|
95
|
+
def mock_generate_uuid
|
96
|
+
Xcode.class_eval do
|
97
|
+
alias_method :original_generate_uuid, :generate_uuid
|
98
|
+
def generate_uuid
|
99
|
+
generate_uuid_counter
|
100
|
+
if @never_run.nil?
|
101
|
+
@never_run = false
|
102
|
+
'519A79DB0CC8AE6B00CBE85D'
|
103
|
+
else
|
104
|
+
'519A79DB0CC8AE6B00CBE85F'
|
105
|
+
end
|
106
|
+
end
|
107
|
+
end
|
108
|
+
end
|
109
|
+
|
110
|
+
def unmock_generate_uuid
|
111
|
+
Xcode.class_eval do
|
112
|
+
alias_method :generate_uuid, :original_generate_uuid
|
113
|
+
end
|
114
|
+
end
|
115
|
+
|
116
|
+
it "should generate a non-duplicate object id" do
|
117
|
+
objects = {'519A79DB0CC8AE6B00CBE85D' => 1, '519A79DB0CC8AE6B00CBE85E' => 2}
|
118
|
+
@project.expects(:objects).returns(objects)
|
119
|
+
@project.expects(:generate_uuid_counter).times(2)
|
120
|
+
mock_generate_uuid # set the hack
|
121
|
+
@project.generate_object_id
|
122
|
+
unmock_generate_uuid # unset the hack
|
123
|
+
end
|
124
|
+
|
87
125
|
# it "should create a new framework copy build phase" do
|
88
126
|
# # FIXME: until we generate id's this is just a lame test
|
89
127
|
# Xcode::NEW_COPY_FRAMEWORKS_BUILD_PHASE = @object
|
90
128
|
# @project.new_framework_copy_build_phase.should == @object
|
91
129
|
# end
|
92
130
|
|
131
|
+
it "should add a framework" do
|
132
|
+
name = 'BlaBla.framework'
|
133
|
+
path = '/foo/BlaBla.framework'
|
134
|
+
|
135
|
+
before = @project.objects.length
|
136
|
+
framework_obj, fileref_obj = @project.add_framework(name, path)
|
137
|
+
@project.objects.length.should.be(before + 2)
|
138
|
+
|
139
|
+
framework_obj.last.should == {
|
140
|
+
'isa' => 'PBXFileReference',
|
141
|
+
'lastKnownFileType' => 'wrapper.framework',
|
142
|
+
'name' => name,
|
143
|
+
'path' => path,
|
144
|
+
'sourceTree' => '<absolute>'
|
145
|
+
}.to_ns
|
146
|
+
|
147
|
+
fileref_obj.last.should == {
|
148
|
+
'fileRef' => framework_obj.first,
|
149
|
+
'isa' => 'PBXBuildFile'
|
150
|
+
}.to_ns
|
151
|
+
|
152
|
+
linked_frameworks = @project.object_for_name('Linked Frameworks')
|
153
|
+
linked_frameworks.last['children'].should.include framework_obj.first
|
154
|
+
end
|
155
|
+
|
156
|
+
it "should add a framework as absolute" do
|
157
|
+
framework_obj, fileref_obj = @project.add_framework('BlaBla.framework', '/foo/BlaBla.framework')
|
158
|
+
framework_obj.last['sourceTree'].should == '<absolute>'
|
159
|
+
end
|
160
|
+
|
161
|
+
it "should add a framework as relative (group)" do
|
162
|
+
framework_obj, fileref_obj = @project.add_framework('BlaBla.framework', 'vendor/frameworks/BlaBla.framework')
|
163
|
+
framework_obj.last['sourceTree'].should == '<group>'
|
164
|
+
end
|
165
|
+
|
166
|
+
it "should list the frameworks that it includes" do
|
167
|
+
framework_obj, fileref_obj = @project.add_framework('BlaBla.framework', '/foo/BlaBla.framework')
|
168
|
+
@project.frameworks.should == [framework_obj]
|
169
|
+
end
|
170
|
+
|
93
171
|
it "should change the path of a framework used in the project" do
|
94
|
-
|
95
|
-
|
172
|
+
framework_obj, fileref_obj = @project.add_framework('RubyCocoa.framework', '/foo/RubyCocoa.framework')
|
173
|
+
id = framework_obj.first
|
174
|
+
|
96
175
|
framework_path = 'vendor/RubyCocoa.framework'
|
97
176
|
@project.change_framework_location('RubyCocoa.framework', framework_path)
|
98
177
|
|
@@ -107,8 +186,8 @@ describe 'Xcode' do
|
|
107
186
|
end
|
108
187
|
|
109
188
|
it "should bundle a framework with the application" do
|
110
|
-
|
111
|
-
|
189
|
+
framework_obj, fileref_obj = @project.add_framework('BlaBla.framework', '/foo/BlaBla.framework')
|
190
|
+
id = framework_obj.first
|
112
191
|
|
113
192
|
@project.bundle_framework('BlaBla.framework')
|
114
193
|
|
@@ -118,11 +197,12 @@ describe 'Xcode' do
|
|
118
197
|
|
119
198
|
build_phase_id = @project.object_for_id(build_phases.first).last['files'].first
|
120
199
|
build_phase_id, build_phase = @project.object_for_id(build_phase_id)
|
121
|
-
build_phase['fileRef'].should ==
|
200
|
+
build_phase['fileRef'].should == id
|
122
201
|
end
|
123
202
|
|
124
203
|
it "should bundle the RubyCocoa framework with the application" do
|
125
204
|
@project.expects(:bundle_framework).with('RubyCocoa.framework')
|
126
205
|
@project.bundle_rubycocoa_framework
|
127
206
|
end
|
207
|
+
|
128
208
|
end
|
data/website/index.html
CHANGED
@@ -33,7 +33,7 @@
|
|
33
33
|
<h1>rucola</h1>
|
34
34
|
<div id="version" class="clickable" onclick='document.location = "http://rubyforge.org/projects/rucola"; return false'>
|
35
35
|
<p>Get Version</p>
|
36
|
-
<a href="http://rubyforge.org/projects/rucola" class="numbers">0.0
|
36
|
+
<a href="http://rubyforge.org/projects/rucola" class="numbers">0.5.0</a>
|
37
37
|
</div>
|
38
38
|
<h1>→ ‘rucola’</h1>
|
39
39
|
|
@@ -41,12 +41,12 @@
|
|
41
41
|
<h2>What</h2>
|
42
42
|
|
43
43
|
|
44
|
-
<p>A Framework for building
|
44
|
+
<p>A Framework for rapidly building RubyCocoa applications</p>
|
45
45
|
|
46
46
|
|
47
47
|
<p>Rucola is a light weight framework that helps you write RubyCocoa apps.
|
48
48
|
It allows you to build, test, and deploy applications using rake commands,
|
49
|
-
eliminating the need to use XCode
|
49
|
+
eliminating the need to use XCode for the most common tasks.</p>
|
50
50
|
|
51
51
|
|
52
52
|
<p>Rucola provides a set of generators to help you generate controllers, window controllers,
|
@@ -58,7 +58,7 @@ ways of doing things.</p>
|
|
58
58
|
|
59
59
|
|
60
60
|
<ul>
|
61
|
-
<li><a href="http://sourceforge.net/project/showfiles.php?group_id=44114&package_id=36578">RubyCocoa 0.13</a> That’s <span class="caps">NOT</span> the one included with Leopard
|
61
|
+
<li><a href="http://sourceforge.net/project/showfiles.php?group_id=44114&package_id=36578">RubyCocoa 0.13.2</a> <em>That’s <span class="caps">NOT</span> the one currently included with Leopard</em></li>
|
62
62
|
<li>For testing it’s adviced to install the following gems: test-spec, mocha, zentest (autotest)</li>
|
63
63
|
</ul>
|
64
64
|
|
@@ -66,7 +66,7 @@ ways of doing things.</p>
|
|
66
66
|
<h2>Installing</h2>
|
67
67
|
|
68
68
|
|
69
|
-
<p><pre class='syntax'
|
69
|
+
<p><pre class='syntax'>$ sudo gem install rucola</pre></p>
|
70
70
|
|
71
71
|
|
72
72
|
<h2>Demonstration of usage</h2>
|
@@ -75,100 +75,21 @@ ways of doing things.</p>
|
|
75
75
|
<h3>Generating an application skeleton</h3>
|
76
76
|
|
77
77
|
|
78
|
-
|
79
|
-
|
78
|
+
<code>$ rucola MyApp -a "Your Name"</code>
|
80
79
|
|
81
80
|
<p>Running this command will give you a complete, working application with a single window already
|
82
81
|
bound to your application controller.</p>
|
83
82
|
|
84
83
|
|
85
|
-
<h3>
|
86
|
-
|
87
|
-
|
88
|
-
<h4>Rucola
|
89
|
-
<pre class='syntax'>
|
90
|
-
<span class="keyword">class </span><span class="class">Foo</span> <span class="punct"><</span> <span class="constant">Rucola</span><span class="punct">::</span><span class="constant">RCController</span>
|
91
|
-
<span class="ident">notify</span> <span class="symbol">:some_method</span><span class="punct">,</span> <span class="symbol">:when</span> <span class="punct">=></span> <span class="symbol">:something_happens</span>
|
92
|
-
|
93
|
-
<span class="keyword">def </span><span class="method">some_method</span><span class="punct">(</span><span class="ident">notification</span><span class="punct">)</span>
|
94
|
-
<span class="ident">puts</span> <span class="punct">"</span><span class="string">w00t!</span><span class="punct">"</span>
|
95
|
-
<span class="keyword">end</span>
|
96
|
-
<span class="keyword">end</span>
|
97
|
-
</pre></h4>
|
98
|
-
|
99
|
-
|
100
|
-
<h4>Objective C (Excluding header file)
|
101
|
-
<pre class='syntax'>
|
102
|
-
@implementation Foo
|
103
|
-
-(id)init {
|
104
|
-
if(self = [super init]) {
|
105
|
-
NSNotificationCenter *center = [NSNotificationCenter defaultCenter];
|
106
|
-
[center addObserver:self selector:(some_method:) name:@"SomethingHappensNotification" object:nil];
|
107
|
-
}
|
108
|
-
return self;
|
109
|
-
}
|
110
|
-
|
111
|
-
-(void)some_method:(NSNotification *) notification {
|
112
|
-
NSLog("w00t!");
|
113
|
-
}
|
114
|
-
@end
|
115
|
-
</pre></h4>
|
116
|
-
|
117
|
-
|
118
|
-
<h3>Alternative Way Of Using Notifications</h3>
|
119
|
-
|
120
|
-
|
121
|
-
<pre class='syntax'>
|
122
|
-
<span class="keyword">class </span><span class="class">Foo</span> <span class="punct"><</span> <span class="constant">Rucola</span><span class="punct">::</span><span class="constant">RCController</span>
|
123
|
-
<span class="ident">notify_on</span> <span class="symbol">:something_happens</span> <span class="keyword">do</span> <span class="punct">|</span><span class="ident">notification</span><span class="punct">|</span>
|
124
|
-
<span class="ident">puts</span> <span class="punct">"</span><span class="string">w0t0!</span><span class="punct">"</span>
|
125
|
-
<span class="keyword">end</span>
|
126
|
-
<span class="keyword">end</span>
|
127
|
-
</pre>
|
128
|
-
|
129
|
-
|
130
|
-
<h3>Working with Interface Builder</h3>
|
84
|
+
<h3>Running an application</h3>
|
131
85
|
|
132
86
|
|
133
|
-
|
134
|
-
An object can be a user interface element or an instance of a class.</p>
|
87
|
+
<code>$ rake</code>
|
135
88
|
|
136
|
-
|
137
|
-
<pre class='syntax'>
|
138
|
-
<span class="keyword">class </span><span class="class">ApplicationController</span> <span class="punct"><</span> <span class="constant">Rucola</span><span class="punct">::</span><span class="constant">RCController</span>
|
139
|
-
<span class="ident">ib_outlet</span> <span class="symbol">:main_window</span>
|
140
|
-
|
141
|
-
<span class="keyword">def </span><span class="method">awakeFromNib</span>
|
142
|
-
<span class="comment"># All the application delegate methods will be called on this object.</span>
|
143
|
-
<span class="constant">OSX</span><span class="punct">::</span><span class="constant">NSApp</span><span class="punct">.</span><span class="ident">delegate</span> <span class="punct">=</span> <span class="constant">self</span>
|
144
|
-
|
145
|
-
<span class="ident">puts</span> <span class="punct">"</span><span class="string">ApplicationController awoke.</span><span class="punct">"</span>
|
146
|
-
<span class="ident">puts</span> <span class="punct">"</span><span class="string">Edit: app/controllers/application_controller.rb</span><span class="punct">"</span>
|
147
|
-
<span class="ident">puts</span> <span class="punct">"</span><span class="string"><span class="escape">\n</span>It's window is: <span class="expr">#{@main_window.inspect}</span></span><span class="punct">"</span>
|
148
|
-
<span class="keyword">end</span>
|
149
|
-
|
150
|
-
<span class="comment"># NSApplication delegate methods</span>
|
151
|
-
<span class="keyword">def </span><span class="method">applicationDidFinishLaunching</span><span class="punct">(</span><span class="ident">notification</span><span class="punct">)</span>
|
152
|
-
<span class="ident">puts</span> <span class="punct">"</span><span class="string"><span class="escape">\n</span>Application finished launching.</span><span class="punct">"</span>
|
153
|
-
<span class="keyword">end</span>
|
154
|
-
|
155
|
-
<span class="keyword">def </span><span class="method">applicationWillTerminate</span><span class="punct">(</span><span class="ident">notification</span><span class="punct">)</span>
|
156
|
-
<span class="ident">puts</span> <span class="punct">"</span><span class="string"><span class="escape">\n</span>Application will terminate.</span><span class="punct">"</span>
|
157
|
-
<span class="keyword">end</span>
|
158
|
-
<span class="keyword">end</span>
|
159
|
-
</pre>
|
160
|
-
|
161
|
-
|
162
|
-
<p>The `@main_window` variable now points to the user interface window. You can invoke any methods of NSWindow.</p>
|
163
|
-
|
164
|
-
|
165
|
-
<p>There is also a `rake ib:update` that will update your nib files with the outlets you specify in your code.
|
166
|
-
For example, if we wanted to add a button to the application controller above, we could add `ib_outlet :my_button`.
|
167
|
-
After you’ve added this, you can run `rake ib:update` and your outlet will be available in interface builder that
|
168
|
-
you can now hook up to your UI button.</p>
|
89
|
+
<h2>Extras</h2>
|
169
90
|
|
170
91
|
|
171
|
-
<
|
92
|
+
<p>Documentation can be found <a href="http://rucola.rubyforge.org/rdoc/">here.</a></p>
|
172
93
|
|
173
94
|
|
174
95
|
<p>Sample apps can be found at:</p>
|
@@ -216,8 +137,13 @@ script/plugin install SACrashReporter
|
|
216
137
|
<p>Read the <a href="http://drnicwilliams.com/2007/06/01/8-steps-for-fixing-other-peoples-code/">8 steps for fixing other people’s code</a> and for section <a href="http://drnicwilliams.com/2007/06/01/8-steps-for-fixing-other-peoples-code/#8b-google-groups">8b: Submit patch to Google Groups</a>, use the Google Group above.</p>
|
217
138
|
|
218
139
|
|
219
|
-
<p>
|
140
|
+
<p>Browse the git repo online at: <code>http://github.com/alloy/rucola/tree/master</code></p>
|
141
|
+
|
142
|
+
|
143
|
+
<p>The latest version can be checked out with:</p>
|
144
|
+
|
220
145
|
|
146
|
+
<code>$ git clone git://github.com/alloy/rucola.git</code>
|
221
147
|
|
222
148
|
<h2>License</h2>
|
223
149
|
|
@@ -230,7 +156,7 @@ script/plugin install SACrashReporter
|
|
230
156
|
|
231
157
|
<p>Comments are welcome. Send an email via the <a href="http://groups.google.com/group/rucola">forum</a></p>
|
232
158
|
<p class="coda">
|
233
|
-
<a href="http://groups.google.com/group/rucola">Eloy Duran
|
159
|
+
<a href="http://groups.google.com/group/rucola">Eloy Duran</a>, 11th July 2008<br>
|
234
160
|
Theme extended from <a href="http://rb2js.rubyforge.org/">Paul Battley</a>
|
235
161
|
</p>
|
236
162
|
</div>
|
data/website/index.txt
CHANGED
@@ -4,11 +4,11 @@ h1. → 'rucola'
|
|
4
4
|
|
5
5
|
h2. What
|
6
6
|
|
7
|
-
A Framework for building
|
7
|
+
A Framework for rapidly building RubyCocoa applications
|
8
8
|
|
9
9
|
Rucola is a light weight framework that helps you write RubyCocoa apps.
|
10
10
|
It allows you to build, test, and deploy applications using rake commands,
|
11
|
-
eliminating the need to use XCode
|
11
|
+
eliminating the need to use XCode for the most common tasks.
|
12
12
|
|
13
13
|
Rucola provides a set of generators to help you generate controllers, window controllers,
|
14
14
|
and document-based applications. It also provides APIs for simplifying some of Objective-C's
|
@@ -16,101 +16,30 @@ ways of doing things.
|
|
16
16
|
|
17
17
|
h2. Requirements
|
18
18
|
|
19
|
-
* "RubyCocoa 0.13":http://sourceforge.net/project/showfiles.php?group_id=44114&package_id=36578 That's NOT the one included with Leopard
|
19
|
+
* "RubyCocoa 0.13.2":http://sourceforge.net/project/showfiles.php?group_id=44114&package_id=36578 <em>That's NOT the one currently included with Leopard</em>
|
20
20
|
* For testing it's adviced to install the following gems: test-spec, mocha, zentest (autotest)
|
21
21
|
|
22
22
|
h2. Installing
|
23
23
|
|
24
|
-
<pre syntax="sh"
|
24
|
+
<pre syntax="sh">$ sudo gem install rucola</pre>
|
25
25
|
|
26
26
|
h2. Demonstration of usage
|
27
27
|
|
28
28
|
h3. Generating an application skeleton
|
29
29
|
|
30
|
-
rucola MyApp -a "Your Name"
|
30
|
+
<code>$ rucola MyApp -a "Your Name"</code>
|
31
31
|
|
32
32
|
Running this command will give you a complete, working application with a single window already
|
33
33
|
bound to your application controller.
|
34
34
|
|
35
|
+
h3. Running an application
|
35
36
|
|
36
|
-
|
37
|
-
|
38
|
-
h4. Rucola
|
39
|
-
<pre syntax="ruby">
|
40
|
-
class Foo < Rucola::RCController
|
41
|
-
notify :some_method, :when => :something_happens
|
42
|
-
|
43
|
-
def some_method(notification)
|
44
|
-
puts "w00t!"
|
45
|
-
end
|
46
|
-
end
|
47
|
-
</pre>
|
48
|
-
|
49
|
-
h4. Objective C (Excluding header file)
|
50
|
-
<pre syntax="c">
|
51
|
-
@implementation Foo
|
52
|
-
-(id)init {
|
53
|
-
if(self = [super init]) {
|
54
|
-
NSNotificationCenter *center = [NSNotificationCenter defaultCenter];
|
55
|
-
[center addObserver:self selector:(some_method:) name:@"SomethingHappensNotification" object:nil];
|
56
|
-
}
|
57
|
-
return self;
|
58
|
-
}
|
59
|
-
|
60
|
-
-(void)some_method:(NSNotification *) notification {
|
61
|
-
NSLog("w00t!");
|
62
|
-
}
|
63
|
-
@end
|
64
|
-
</pre>
|
65
|
-
|
66
|
-
h3. Alternative Way Of Using Notifications
|
67
|
-
|
68
|
-
<pre syntax="ruby">
|
69
|
-
class Foo < Rucola::RCController
|
70
|
-
notify_on :something_happens do |notification|
|
71
|
-
puts "w0t0!"
|
72
|
-
end
|
73
|
-
end
|
74
|
-
</pre>
|
75
|
-
|
76
|
-
h3. Working with Interface Builder
|
77
|
-
|
78
|
-
A Cocoa application contains `outlets`. Outlets allow you to bind variable names to objects.
|
79
|
-
An object can be a user interface element or an instance of a class.
|
80
|
-
|
81
|
-
<pre syntax="ruby">
|
82
|
-
class ApplicationController < Rucola::RCController
|
83
|
-
ib_outlet :main_window
|
84
|
-
|
85
|
-
def awakeFromNib
|
86
|
-
# All the application delegate methods will be called on this object.
|
87
|
-
OSX::NSApp.delegate = self
|
88
|
-
|
89
|
-
puts "ApplicationController awoke."
|
90
|
-
puts "Edit: app/controllers/application_controller.rb"
|
91
|
-
puts "\nIt's window is: #{@main_window.inspect}"
|
92
|
-
end
|
93
|
-
|
94
|
-
# NSApplication delegate methods
|
95
|
-
def applicationDidFinishLaunching(notification)
|
96
|
-
puts "\nApplication finished launching."
|
97
|
-
end
|
98
|
-
|
99
|
-
def applicationWillTerminate(notification)
|
100
|
-
puts "\nApplication will terminate."
|
101
|
-
end
|
102
|
-
end
|
103
|
-
</pre>
|
104
|
-
|
105
|
-
The `@main_window` variable now points to the user interface window. You can invoke any methods of NSWindow.
|
106
|
-
|
107
|
-
There is also a `rake ib:update` that will update your nib files with the outlets you specify in your code.
|
108
|
-
For example, if we wanted to add a button to the application controller above, we could add `ib_outlet :my_button`.
|
109
|
-
After you've added this, you can run `rake ib:update` and your outlet will be available in interface builder that
|
110
|
-
you can now hook up to your UI button.
|
37
|
+
<code>$ rake</code>
|
111
38
|
|
112
39
|
h2. Extras
|
113
40
|
|
41
|
+
Documentation can be found "here.":http://rucola.rubyforge.org/rdoc/
|
42
|
+
|
114
43
|
Sample apps can be found at:
|
115
44
|
|
116
45
|
<pre syntax="sh"> svn co svn://rubyforge.org/var/svn/rucola/extras/examples/</pre>
|
@@ -144,7 +73,11 @@ h2. How to submit patches
|
|
144
73
|
|
145
74
|
Read the "8 steps for fixing other people's code":http://drnicwilliams.com/2007/06/01/8-steps-for-fixing-other-peoples-code/ and for section "8b: Submit patch to Google Groups":http://drnicwilliams.com/2007/06/01/8-steps-for-fixing-other-peoples-code/#8b-google-groups, use the Google Group above.
|
146
75
|
|
147
|
-
|
76
|
+
Browse the git repo online at: <code>http://github.com/alloy/rucola/tree/master</code>
|
77
|
+
|
78
|
+
The latest version can be checked out with:
|
79
|
+
|
80
|
+
<code>$ git clone git://github.com/alloy/rucola.git</code>
|
148
81
|
|
149
82
|
h2. License
|
150
83
|
|