rabbit-slide-kou-rubykaigi-2018 2018.6.1.0

Sign up to get free protection for your applications and to get access to all the features.
Binary file
Binary file
data/interface.rab ADDED
@@ -0,0 +1,614 @@
1
+ = Interface
2
+
3
+ : author
4
+ Kouhei Sutou
5
+ : institution
6
+ ClearCode Inc.
7
+ : content-source
8
+ RubyKaigi 2018
9
+ : date
10
+ 2018-06-01
11
+ : start-time
12
+ 2018-06-01T09:40:00+09:00
13
+ : end-time
14
+ 2018-06-01T10:40:00+09:00
15
+ : theme
16
+ .
17
+
18
+ = Ad: Silver sponsor
19
+
20
+ # img
21
+ # src = images/clear-code-rubykaigi-2018-silver-sponsor.png
22
+ # relative_height = 100
23
+ # reflect_ratio = 0.1
24
+
25
+ == Slide properties
26
+
27
+ : enable-title-on-image
28
+ false
29
+
30
+ = Interface?
31
+
32
+ A | B
33
+ ^
34
+ Here
35
+
36
+ = API
37
+
38
+ Library | Program
39
+ ^
40
+ API
41
+
42
+ = Web API
43
+
44
+ Server | HTTP | Client
45
+ ^^^^^^^^
46
+ Web API
47
+
48
+ = CLI
49
+
50
+ Program | command | User
51
+ ^^^^^^^^^^^
52
+ Command Line Interface
53
+
54
+ = My activities\nas a Rubyist
55
+
56
+ * Expand "Ruby ready" areas
57
+ * Maintain libraries
58
+
59
+ = The number of developing libraries
60
+
61
+ About 130
62
+
63
+ = Ruby anywhere
64
+
65
+ There are many interfaces
66
+
67
+ = This talk's content
68
+
69
+ * Show my knowledge\n
70
+ from my activities\n
71
+ (('note:自分の活動で得られた知見を紹介'))
72
+ * Perspective:"Interface"\n
73
+ (('note:切り口:「インターフェイス」'))
74
+
75
+ = RSS Parser
76
+
77
+ Makes Ruby\n
78
+ ((*Web feed*))\n
79
+ ready
80
+
81
+ = RSS Parser - History
82
+
83
+ * 2003-05: The first release
84
+ * 2004-01: Ruby bundles this
85
+ * Became a Ruby committer
86
+
87
+ = RSS Parser - Interface
88
+
89
+ RSS Parser | Programmers
90
+ ^
91
+ API
92
+
93
+ = RSS Parser - API
94
+
95
+ * Map RSS structure to
96
+ * classes and
97
+ * methods
98
+
99
+ = Map to classes
100
+
101
+ <rss> RSS::Rss
102
+ <channel> RSS::Rss::Channel
103
+ <title>...</title> String
104
+ <item> RSS::Rss::Channel::Item
105
+ <title>...</title> String
106
+ <item>
107
+ <item> RSS::Rss::Channel::Item
108
+ <title>...</title> String
109
+ <item>
110
+ </channel>
111
+ </rss>
112
+
113
+ = Map to methods
114
+
115
+ <rss> rss
116
+ <channel> rss.channel
117
+ <title>...</title> rss.channel.title
118
+ <item> rss.channel.items[0]
119
+ <title>...</title> rss.channel.items[0].title
120
+ <item>
121
+ <item> rss.channel.items[1]
122
+ <title>...</title> rss.channel.items[1].title
123
+ <item>
124
+ </channel>
125
+ </rss>
126
+
127
+ = Pros
128
+
129
+ Users can guess API from their data
130
+
131
+ = Example
132
+
133
+ <rss> # Want /rss/channel/item/title!
134
+ <channel> rss.channel.items.each do |item|
135
+ <title>...</title>
136
+ <item>
137
+ HERE: <title>...</title> p item.title
138
+ <item>
139
+ <item>
140
+ HERE: <title>...</title>
141
+ <item>
142
+ </channel> end
143
+ </rss>
144
+
145
+ = Cons
146
+
147
+ Verbose\n
148
+ for expert
149
+
150
+ = Cons - Interface
151
+
152
+ RSS Parser | Not experts
153
+ Good
154
+
155
+ RSS Parser | Experts
156
+ Verbose
157
+
158
+ = Example
159
+
160
+ <rss> # Want item/title!
161
+ <channel> # Don't want to care
162
+ <title>...</title> # about channel.
163
+ <item> rss.items.each do |item|
164
+ HERE: <title>...</title> p item.title
165
+ <item>
166
+ <item>
167
+ HERE: <title>...</title>
168
+ <item> end
169
+ </channel>
170
+ </rss>
171
+
172
+ = Cons
173
+
174
+ Not generic
175
+
176
+ = Web feed types
177
+
178
+ * RSS 0.9*/2.0
179
+ * Really Simple Syndication
180
+ * RSS 1.0
181
+ * RDF Site Summary
182
+ * Atom
183
+ * RFC 4287
184
+
185
+ = Differences
186
+
187
+ They are ((*NOT*)) compatible
188
+
189
+ = Differences - Interface
190
+
191
+ RSS Parser | RSS 0.9*/2.0
192
+ RSS Parser | RSS 1.0
193
+ RSS Parser | Atom
194
+ ^
195
+ Different structures
196
+
197
+ = What users want
198
+
199
+ Process\n
200
+ all feed types\n
201
+ in the same way
202
+
203
+ = + High level API
204
+
205
+ # coderay ruby
206
+ # RSS 0.9*/20
207
+ rss.items # /rss/channel/item
208
+ # RSS 1.0
209
+ rdf.items # /RDF/item
210
+ # Atom
211
+ feed.items # /feed/entry
212
+
213
+ = + High level API
214
+
215
+ Users | RSS Parser | RSS 0.9*/2.0
216
+ Users | RSS Parser | RSS 1.0
217
+ Users | RSS Parser | Atom
218
+ ^ ^
219
+ Common API Different structures
220
+
221
+ = RSS Parser - Design
222
+
223
+ * Premise:(('note:前提:'))
224
+ * Users can confirm their data\n
225
+ (('note:ユーザーは自分たちのデータを確認できる'))
226
+ * Easy to use:(('note:使いやすくするために:'))
227
+ * Map data structure to Ruby\n
228
+ (('note:データの構造をそのままRubyの世界に対応させる'))
229
+ * + common feed type aware API\n
230
+ (('note:さらにフィードの種類に依存しない共通APIも用意'))
231
+
232
+ = Knowledge - RSS Parser
233
+
234
+ * Premise is important for API\n
235
+ (('note:API設計に前提は大事'))
236
+ * Different API layer for\n
237
+ different type users\n
238
+ (('note:違う種類のユーザーには違うAPIのレイヤーを'))
239
+
240
+ = RSS Parser - Omit
241
+
242
+ Validation\n
243
+ is\n
244
+ important
245
+
246
+ = Rabbit
247
+
248
+ Makes Ruby\n
249
+ ((*presentation*))\n
250
+ ready
251
+
252
+ = Rabbit - History
253
+
254
+ * 2004-07: The first release
255
+ * 2010: Matz starts using Rabbit
256
+ * Since RubyKaigi 2010?
257
+
258
+ = Rabbit - Pitch
259
+
260
+ (('tag:center'))
261
+ (('tag:large'))
262
+ A presentation tool\n
263
+ for ((*Rubyist*))
264
+
265
+ ((' '))
266
+
267
+ = Rabbit - Run
268
+
269
+ # coderay console
270
+ % rake
271
+
272
+ = Run - Interface
273
+
274
+ Rabbit | rake | Rubyist
275
+ ^^^^^^^^
276
+ CLI for Rubyist
277
+
278
+ = Rabbit - Publish
279
+
280
+ # coderay console
281
+ % rake publish:rubygems
282
+
283
+ = publish:rubygems
284
+
285
+ # coderay console
286
+ % rake gem
287
+ Generates pkg/XXX.gem
288
+ % gem push pkg/XXX.gem
289
+
290
+ = Rabbit Slide Show
291
+
292
+ # img
293
+ # src = images/rabbit-slide-show.png
294
+ # relative_height = 78
295
+
296
+ (('tag:center'))
297
+ (('tag:small'))
298
+ ((<URL:https://slide.rabbit-shocker.org/>))
299
+
300
+ == Slide properties
301
+
302
+ : enable-title-on-image
303
+ false
304
+
305
+ = Publish - Interface
306
+
307
+ Rabbit | gem push | Rubyist
308
+ ^^^^^^^^^^^^
309
+ Like a normal library
310
+ No Web browser
311
+ Your slides are versioned
312
+
313
+ = Slide as a Gem
314
+
315
+ # coderay console
316
+ % rake gem
317
+ % gem unpack pkg/*.gem
318
+ % tree rabbit-slide*
319
+
320
+ = PDF in gem
321
+
322
+ # coderay console
323
+ % tree rabbit-slide*
324
+ ├── README.rd
325
+ ...
326
+ ├── pdf
327
+ │   └── rubykaigi-2018-interface.pdf
328
+ ...
329
+
330
+ = Publish PDF in gem
331
+
332
+ (1) Receive published notifications from rubygems.org
333
+ (2) Render PDF in gems for Web browser
334
+
335
+ (('tag:center'))
336
+ (('tag:xx-small'))
337
+ ((<URL:https://github.com/rabbit-shocker/slide.rabbit-shocker.org>))
338
+
339
+ = Receive notifications
340
+
341
+ # coderay console
342
+ % curl \
343
+ -H 'Authorization:...' \
344
+ -F 'gem_name=*' \
345
+ -F 'url=https://slide.rabbit-shocker.org/web-hook-receiver/' \
346
+ https://rubygems.org/api/v1/web_hooks
347
+
348
+ (('tag:center'))
349
+ (('tag:xx-small'))
350
+ ((<URL:https://guides.rubygems.org/rubygems-org-api/#webhook-methods>))
351
+
352
+ = Notification - Interface
353
+
354
+ slide.rabbit-shocker.org | RubyGems.org
355
+ ^
356
+ Web hook
357
+
358
+ = Render PDF
359
+
360
+ Combine the following gems
361
+ * poppler - PDF parser
362
+ * cairo - 2D graphics library
363
+
364
+ = poppler & cairo
365
+
366
+ Makes Ruby\n
367
+ ((*PDF*))\n
368
+ ready
369
+
370
+ = poppler - History
371
+
372
+ * 2006-07: The first release
373
+ * 2018-05: The latest release
374
+
375
+ = poppler - Parse
376
+
377
+ # coderay ruby
378
+ pdf = Poppler::Document.new(content)
379
+ pdf.each do |page|
380
+ # Convert each page to PNG
381
+ end
382
+
383
+ = poppler - Interface
384
+
385
+ poppler | path | PDF
386
+ poppler |content| PDF
387
+ ^^^^^^^^^
388
+ Input
389
+
390
+ = cairo - History
391
+
392
+ * 2003-10: The initial commit
393
+ * 2005-09: I started developing
394
+ * Sent several patches and\n
395
+ got commit bit and more
396
+ * 2005-10: The first release
397
+ * 2018-05: The latest release
398
+
399
+ = cairo - Outputs
400
+
401
+ ((*PNG*)), PDF, SVG, X, Quarts, Win32, ...
402
+
403
+ (('tag:xx-small'))
404
+ See also: More about cairo gem in Japanese\n
405
+ ((<URL:http://magazine.rubyist.net/articles/0019/0019-cairo.html>))
406
+
407
+ = cairo - To PNG
408
+
409
+ # coderay ruby
410
+ iw, ih = image_width, image_height
411
+ Cairo::ImageSurface.new(iw, ih) do |surface|
412
+ Cairo::Context.new(surface) do |context|
413
+ width, height = page.size
414
+ x_scale = iw / width.to_f
415
+ y_scale = ih / height.to_f
416
+ context.scale(x_scale, y_scale)
417
+ context.render_poppler_page(page) # Render
418
+ surface.write_to_png("XXX.png") # Save
419
+ end
420
+ end
421
+
422
+ = cairo - Interface
423
+
424
+ cairo |Poppler::Page| PNG
425
+ ^^^^^^^^^^^^^^^
426
+ Input
427
+
428
+ = PDF on the Web - Link
429
+
430
+ # img
431
+ # src = images/pdf-clickable.png
432
+ # relative_height = 100
433
+ # reflect_ratio = 0.05
434
+
435
+ == Slide properties
436
+
437
+ : enable-title-on-image
438
+ false
439
+
440
+ = Link in image in HTML
441
+
442
+ # coderay html
443
+ <map id="XXX">
444
+ <area href="..."
445
+ shape="rect"
446
+ coords="X,Y,W,H">
447
+ </map>
448
+ <img usemap="#XXX">
449
+
450
+ = poppler - coords
451
+
452
+ # coderay ruby
453
+ pdf.each do |page|
454
+ page.link_mapping.each do |mapping|
455
+ href = mapping.action
456
+ x, y, w, h = mapping.area.to_a
457
+ coords = "#{x},#{y},#{w},#{h}"
458
+ # Generate <area>
459
+ end
460
+ end
461
+
462
+ = Link - Interface
463
+
464
+ PDF |poppler| HTML
465
+ ^^^^^^^^^
466
+ Extract information
467
+
468
+ = Rabbit - Input
469
+
470
+ * Source
471
+ * RD (Ruby Document), Markdown(('note:, PDF, image, ...'))
472
+ * Theme
473
+ * Ruby scripts
474
+
475
+ = Input - Interface
476
+
477
+ Rabbit |texts| Rubyist
478
+ ^^^^^^^
479
+ Version controllable
480
+ Like normal programs
481
+
482
+ = Knowledge - Rabbit
483
+
484
+ * Pitch is important for interface\n
485
+ (('note:インターフェイス設計にピッチは大事'))
486
+ * "for ((*Rubyist*))" for Rabbit
487
+ * Use similar way for the original
488
+
489
+ = Rabbit - Theme
490
+
491
+ Define view\n
492
+ by Ruby\n
493
+ (('note:Rubyで見た目を定義'))
494
+
495
+ = Theme - Layers
496
+
497
+ * Customize parameters
498
+ * Normal Ruby codes to\n
499
+ control render something
500
+
501
+ = Theme - Parameters
502
+
503
+ # coderay ruby
504
+ # CSS selector inspired API:
505
+ # title-slide author {
506
+ # margin_top: 2px;
507
+ # margin_bottom: 1px;
508
+ # }
509
+ match(TitleSlide, Author) do |authors|
510
+ authors.margin_top = @space * 2
511
+ authors.margin_bottom = @space
512
+ end
513
+
514
+ = Theme - Render
515
+
516
+ # coderay ruby
517
+ match(Slide) do |slides|
518
+ loader = ImageLoader.new("mini-kame-taro.png")
519
+ slides.add_post_draw_proc do
520
+ x = ... # Compute the next tortoise position
521
+ loader.draw(canvas, x, y, parameters)
522
+ end
523
+ end
524
+
525
+ = (('note:The')) Tortoise and (('note:the')) Hare\nin Rabbit\n(('note:Rabbitでうさぎとかめ'))
526
+
527
+ # img
528
+ # src = images/the-tortoise-and-the-hare.png
529
+ # relative_width = 100
530
+ # reflect_ratio = 0.05
531
+
532
+ == Slide properties
533
+
534
+ : enable-title-on-image
535
+ false
536
+
537
+ = Hare - Slide position\n(('note:うさぎはスライド位置'))
538
+
539
+ # img
540
+ # src = images/the-tortoise-and-the-hare-hare.png
541
+ # relative_width = 100
542
+ # reflect_ratio = 0.05
543
+
544
+ == Slide properties
545
+
546
+ : enable-title-on-image
547
+ false
548
+
549
+ = Tortoise - Timer\n(('note:かめはタイマー'))
550
+
551
+ # img
552
+ # src = images/the-tortoise-and-the-hare-tortoise.png
553
+ # relative_width = 100
554
+ # reflect_ratio = 0.05
555
+
556
+ == Slide properties
557
+
558
+ : enable-title-on-image
559
+ false
560
+
561
+ = Slow\n(('note:遅い'))
562
+
563
+ # img
564
+ # src = images/the-tortoise-and-the-hare-slow.png
565
+ # relative_width = 100
566
+ # reflect_ratio = 0.05
567
+
568
+ == Slide properties
569
+
570
+ : enable-title-on-image
571
+ false
572
+
573
+ = Good\n(('note:ちょうどいい'))
574
+
575
+ # img
576
+ # src = images/the-tortoise-and-the-hare-good.png
577
+ # relative_width = 100
578
+ # reflect_ratio = 0.05
579
+
580
+ == Slide properties
581
+
582
+ : enable-title-on-image
583
+ false
584
+
585
+ = Fast\n(('note:速い'))
586
+
587
+ # img
588
+ # src = images/the-tortoise-and-the-hare-fast.png
589
+ # relative_width = 100
590
+ # reflect_ratio = 0.05
591
+
592
+ == Slide properties
593
+
594
+ : enable-title-on-image
595
+ false
596
+
597
+ = Knowledge - Rabbit
598
+
599
+ * Product name is important for interface\n
600
+ (('note:インターフェイス設計にピッチは大事'))
601
+ * Rabbit isn't Hare😜
602
+ * ...
603
+
604
+ = TODO
605
+
606
+ i18n
607
+
608
+ Jekyll
609
+
610
+ rake only
611
+
612
+ https://twitter.com/darashi/status/909994900694769664
613
+
614
+ gdb b rb_raise