-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
executable file
·514 lines (407 loc) · 16.2 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>RubyMotion - A Talk by Tyler Johnston @tylerjohnst</title>
<meta name="description" content="A framework for easily creating beautiful presentations using HTML">
<meta name="author" content="Hakim El Hattab">
<meta name="apple-mobile-web-app-capable" content="yes" />
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
<link rel="stylesheet" href="css/reveal.min.css">
<link rel="stylesheet" href="css/theme/beige.css" id="theme">
<!-- For syntax highlighting -->
<link rel="stylesheet" href="lib/css/zenburn.css">
<!-- If the query includes 'print-pdf', include the PDF print sheet -->
<script>
if( window.location.search.match( /print-pdf/gi ) ) {
var link = document.createElement( 'link' );
link.rel = 'stylesheet';
link.type = 'text/css';
link.href = 'css/print/pdf.css';
document.getElementsByTagName( 'head' )[0].appendChild( link );
}
</script>
<style type="text/css">
img, .unstyled {
border: 0 !important;
box-shadow: none !important;
}
code {
padding: 15px !important;
}
.table {
margin: 80px auto !important;
display: block;
width: 500px;
border: 2px solid #000 !important;
}
td, th {
padding: 15px !important;
text-align: center;
width: 100%;
}
th {
border-bottom: 3px solid #000 !important;
}
.fixed-bottom {
position: absolute !important;
bottom: 0 !important;
left: 20px !important;
}
</style>
<!--[if lt IE 9]>
<script src="lib/js/html5shiv.js"></script>
<![endif]-->
</head>
<body>
<div class="reveal">
<!-- <h2 class='fixed-bottom'>Follow along: <a>tamparuby.github.io/rubymotion-slides</a></h2> -->
<!-- Any section element inside of this container is displayed as a slide -->
<div class="slides">
<section>
<h1>RubyMotion</h1>
<p>OSX and iOS Development with Ruby</p>
<p><small>
A talk by <a>@tylerjohnst</a>
</small></p>
</section>
<section>
<h3>Hi!! I'm Tyler Johnston</h3>
<img src="imgs/ocean.jpg">
<p>Owner of Ahoy Consulting and Runner of Suncoast.js Meetup</p>
</section>
<section>
<em>Psst... you should come!</em>
</section>
<section>
<h2>What is RubyMotion?</h2>
<img src="imgs/rubymotion.png" class="unstyled">
</section>
<section>
<p>RubyMotion allows you as the developer to create and publish native Mac and iOS (and soon Android) applications using Ruby.</p>
</section>
<section>
<p>Yes, native. The RubyMotion compiler handles converting the Ruby code in to LLVM bytecode.</p>
</section>
<section>
<p>RubyMotion allows you all the power and expressiveness of the Ruby VM while letting you deploy to other platforms.</p>
</section>
<section>
<p>Ok but what is RubyMotion really like compared to Objective-C?</p>
</section>
<section>
<pre><code data-trim>
// TableViewController.h
#import <UIKit/UIKit.h>
@interface TableViewController : UITableViewController
@property NSArray *fruits;
@end
</code></pre>
<pre><code data-trim class='objective-c'>
// TableViewController.m
#import "TableViewController.h"
@interface TableViewController ()
@end
@implementation TableViewController
- (void)viewDidLoad {
[super viewDidLoad];
[self setFruits:@[@"apple", @"pear", @"banana"]];
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return [self.fruits count];
}
- (UITableViewCell *)cellForRowAtIndexPath:(NSIndexPath *)indexPath {
UITableViewCell *cell = [self.tableView dequeueReusableCellWithIdentifier:@"foobar"];
if (!cell) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"foobar"];
}
NSString *cellValue = [self.fruits objectAtIndex:indexPath.row];
cell.textLabel.text = cellValue;
return cell;
}
@end
</code></pre>
</section>
<section>
<pre><code data-trim class="ruby" style='max-height: 600px;'>
class FruitsViewController < UITableViewController
attr_reader :fruits
def viewDidLoad
super
@fruits = %w(apple pear banana)
end
def tableView(tableView, numberOfRowsInSection: section)
fruits.length
end
def tableView(tableView, cellForRowAtIndexPath: indexPath)
tableViewCell.tap do |cell|
cell.textLabel.text = fruits[indexPath.row]
end
end
private
def tableViewCell
tableView.dequeueReusableCellWithIdentifier('MyCell') ||
UITableViewCell.alloc.initWithStyle(UITableViewCellStyleValue1, reuseIdentifier: 'MyCell')
end
end
</code></pre>
</section>
<section>
<p>Ruby eliminates the need for dealing with implementing interfaces or juggling headers. Just implement the correct method and everything is good to go. Look in to code completion for your favorite editor.</p>
</section>
<section>
<p>Even though you are using Ruby you still <strong><u>need</u></strong> to know and understand the Cocoa API.</p>
<br>
<p>Well, some of it. Thats what documentation is for!</p>
</section>
<section>
<p>This is the least impressive part of the toolchain. It just looks like awkward Ruby, and it is.</p>
</section>
<section>
<p>Everything I've tried to use has been supported 100%. They seem to have about a month lag behind Apple's release shedule. The new iPhone sizes took about that long to land in RubyMotion.</p>
</section>
<section>
<h2>Ruby REPL</h2>
<p>RubyMotion binds the running iOS simulator to a Ruby REPL.</p>
<pre><code>$ rake</code></pre>
<p>Lets do the worst thing you can do in an talk and live demo!</p>
</section>
<section>
<h2>Full Cocoa API Support!</h2>
<pre><code class="ruby" data-trim>
label = UILabel.alloc.init
label.text = 'My Super Cool String'
views = { 'label' => label }
view.addConstraints(
NSLayoutConstraint.constraintsWithVisualFormat('H:|-20-[label]-20-|',
options: 0,
metrics: nil,
views: views
)
)
</code></pre>
</section>
<section>
<p>RubyMotion hides a lot of the work it's doing for you. All of the Cocoa API's accept and convert the Ruby primiatives.</p>
<table class="table">
<thead>
<tr>
<th>Cocoa</th>
<th>Ruby</th>
</tr>
</thead>
<tbody>
<tr>
<td>NSString</td>
<td>String</td>
</tr>
<tr>
<td>NSInteger</td>
<td>Integer</td>
</tr>
<tr>
<td>NSDictionary</td>
<td>Hash</td>
</tr>
<tr>
<td>NSArray</td>
<td>Array</td>
</tr>
</tbody>
</table>
<p>
<code>NSLog("Foo#{:bar}")</code>
</p>
</section>
<section>
<h2>Full support for CocoaPods!</h2>
<p>CocoaPods is the dependency manager for Objective-C projects. It has thousands of libraries and can help you scale your projects elegantly.</p>
<br>
<pre><code class="ruby" data-trim>
# Gemfile
gem 'motion-cocoapods'
</code></pre>
<pre><code class="ruby" data-trim>
# Rakefile
app.pods do
pod 'afnetworking'
end
</code></pre>
<pre><code data-trim>
$ rake pod:install
</code></pre>
</section>
<section>
<h2>Full support for Storyboards/Interface Builder!</h2>
<p>The gem handles generating a stub xcodeproj and allows you to use all of the features of Interface Builder. It handles creating stub implementation headers for the drag and drop Interface Builder features. (Outlets, Actions, Segues, etc)</p>
<br>
<pre><code class="ruby" data-trim>
# Gemfile
gem 'ib'
</code></pre>
<pre><code>
$ rake ib
</code></pre>
</section>
<section>
<p>The only problem being how much I hated interface builder. (I don't reccomend it.)</p>
</section>
<section>
<p>Now most of that stuff doesn't seem very compelling, You can do all of the same things within Xcode.</p>
<br>
<p>And while thats true, after this point you get all of the benefits of Ruby.</p>
</section>
<section>
<p>Almost all of the Ruby features are available with the exception of two things:</p>
<br>
String Eval
<pre><code class="ruby">eval("whyudodis = MyBadIdea.infect_my_system")</code></pre>
<br>
Require
<pre><code class="ruby">require 'my_other_file'</code></pre>
</section>
<section>
<p>Apple does not allow the dynamic loading of code so using require throws an exception. There is a gem called <code>motion-require</code> which allows you to use <code>require_relative</code> within your projects.</p> This solved all of my code load order problems.
</section>
<section>
<p>But everything else is available:</p>
<ul>
<li>class_eval (non string version)</li>
<li>instance_eval (non string version)</li>
<li>define_method</li>
<li>const_get/const_set</li>
<li>public_send</li>
</ul>
</section>
<section>
<p>Stand back Node.js, there is a new player in town:</p>
<h2>Code Sharing!</h2>
</section>
<section>
<p>In a project I just deployed the initial release of, the majority of the business logic is in a shared gem between the iOS application and the Rails backend.</p>
</section>
<section>
<h2>Blazing fast testing with Rspec</h2>
<br>
<pre class="unstyled">
$ bundle exec rspec
<span style='color: green'>...................................................................................................................</span>
Finished in 0.16608 seconds (files took 0.35396 seconds to load)
115 examples, 0 failures
</pre>
</section>
<section>
<p>I'd recommend asking a veteran iOS develpoer about testing and watch the look of horror in their face. If they do test, ask if their runner is done in 0.1 seconds.</p>
<img src="imgs/trollface.png">
</section>
<section>
<h1>Caveats</h1>
</section>
<section>
<p>It's not free. The license is <strong>$200</strong> but is worth every penny. If you would have bought it during early registration it was only <strong>$100</strong>.
</p>
<br>
<p>The RubyMotion team has also been slowly open sourcing parts of the framework. I believe their goal is to get almost all of it in the open. I think they are keeping secret compiler related things closed.</p>
</section>
<section>
<p>Not all of Ruby standard library is available. Where overlaps were visible between iOS and Ruby the solution was just to use those. Missing things can be patched with a CocoaPod or a Ruby gem.</p>
</section>
<section>
<p>Most Ruby gems won't work in the Runtime but they can be used before the compilation process starts. One example being I18n that I used in my project.</p>
</section>
<section>
<p>Integration testing just sucks in general on iOS. I haven't gotten it working to my liking so I've retired to just manually testing the UI. All of the business logic is tested outside of the RubyMotion app.</p>
</section>
<section>
<p>RubyMotion handles implementing automatic reference counting so you must watch your references. If you have a cyclical reference you will need to create a <code>WeakRef.new</code> to prevent memory leaks. (This is true of Objective-C as well). Best Ruby practices apply here as well.</p>
</section>
<section>
<h1>RubyMotion Gems!</h1>
<p>It's not all doom and gloom. Lets look at some awesome tools people have created!</p>
</section>
<section>
<p><code class="ruby">gem 'rmq'</code></p>
<br>
<p>RubyMotionQuery is a library built to be familiar to anyone who has used the jQuery API.</p>
<br>
<pre><code class='ruby' data-trim>
rmq.append(UILabel).on(:tap) { |sender, event| sender.hide }
rmq(my_view).find(UITextField).hide
</code></pre>
</section>
<section>
<p><code>gem 'motion_model'</code></p><br>
<p>Motion Model implements a very ActiveRecord like interface to CoreData. For anyone who has worked with CoreData before, this is a wonderful option.</p><br>
<pre><code class="ruby" data-trim>
class Task
include MotionModel::Model
include MotionModel::ArrayModelAdapter
columns :name => :string
has_many :assignees
end
class Assignee
include MotionModel::Model
include MotionModel::ArrayModelAdapter
columns :assignee_name => :string
belongs_to :task
end
a_task = Task.create(:name => "Walk the Dog")
a_task.assignees.create(:assignee_name => "Howard")
</code></pre>
</section>
<section>
<p><code>gem 'bubble-wrap'</code></p><br>
<p>This gem is wonderful for wrapping some annoying Cocoa APIs with nice interfaces.</p><br>
<pre><code data-trim class="ruby">
BW::Location.enabled? # Whether location services are enabled on the device
#=> true
BW::Location.authorized? # If your app is authorized to use location services
#=> false
File.join(App.documents_path, 'database.sqlite')
</code></pre>
</section>
<section>
<p><code>gem 'motion-support'</code></p><br>
<p>A port of useful features of ActiveSupport.</p>
<pre><code data-trim class="ruby">
1.week.ago
17.days.from_now
Date.yesterday
Time.beginning_of_week
</code></pre>
</section>
<section>
<h1>Thanks for Coming!</h1>
<h4>Questions? Comments?</h4>
</section>
</div>
</div>
<script src="lib/js/head.min.js"></script>
<script src="js/reveal.min.js"></script>
<script>
// Full list of configuration options available here:
// https://github.com/hakimel/reveal.js#configuration
Reveal.initialize({
controls: true,
progress: true,
history: true,
center: true,
theme: Reveal.getQueryHash().theme, // available themes are in /css/theme
transition: Reveal.getQueryHash().transition || 'linear', // default/cube/page/concave/zoom/linear/fade/none
// Parallax scrolling
// parallaxBackgroundImage: 'https://s3.amazonaws.com/hakim-static/reveal-js/reveal-parallax-1.jpg',
// parallaxBackgroundSize: '2100px 900px',
// Optional libraries used to extend on reveal.js
dependencies: [
{ src: 'lib/js/classList.js', condition: function() { return !document.body.classList; } },
{ src: 'plugin/markdown/marked.js', condition: function() { return !!document.querySelector( '[data-markdown]' ); } },
{ src: 'plugin/markdown/markdown.js', condition: function() { return !!document.querySelector( '[data-markdown]' ); } },
{ src: 'plugin/highlight/highlight.js', async: true, callback: function() { hljs.initHighlightingOnLoad(); } },
{ src: 'plugin/zoom-js/zoom.js', async: true, condition: function() { return !!document.body.classList; } },
{ src: 'plugin/notes/notes.js', async: true, condition: function() { return !!document.body.classList; } }
]
});
</script>
</body>
</html>