Slide 1

Slide 1 text

RubyJS  alpha   www.rubyjs.org   twi5er.com/hasclass      

Slide 2

Slide 2 text

50  slides  in  5  minutes  

Slide 3

Slide 3 text

No content

Slide 4

Slide 4 text

No content

Slide 5

Slide 5 text

A  port  of  Ruby  core-­‐lib  to  JS   •  String,  Regexp,  MatchData   •  Array,  Enumerable,  Enumerator   •  Numeric  (Integer/Fixnum,  Float)   •  Range   •  Time,  Hash  coming  soon  

Slide 6

Slide 6 text

JS  Methods   Array jjjjjjjjjjjjj Enumerable Fixnum Float jjjj Integer Kernel Matchdata Numeric Range Regexp jj String jjjjjjjjjjjjj

Slide 7

Slide 7 text

RubyJS  Methods   Array jjjjjjjjjjjjj................................. ............................ Enumerable .............................................. Fixnum ........................... Float jjjj.............................. Integer .................... Kernel ... Matchdata ..................... Numeric ....................... Range ...................... Regexp jj...................... String jjjjjjjjjjjjj................................ ...........................

Slide 8

Slide 8 text

Compliant  to  Ruby   No  surprises..   Rubinius  Rubyspecs  ported  to  JS  

Slide 9

Slide 9 text

str = "a"
  

Slide 10

Slide 10 text

str = R("a”) #=> R.String
  

Slide 11

Slide 11 text

str = R("a")
 str.capitalize() #=> R.String
 #=> A

Slide 12

Slide 12 text

str = R("a")
 str.capitalize() 
 .upto('C') #=> R.Enumerator

Slide 13

Slide 13 text

str = R("a")
 str.capitalize() 
 .upto('C’)
 .each_cons(2, function (a,b) {
 R.puts("#{a} to the #{b}") })
 # A to the B
 # B to the C  

Slide 14

Slide 14 text

str = R("a")
 str.capitalize() 
 .upto('C’)
 .to_a() #=> R.Array
 #=> [A, B, C]

Slide 15

Slide 15 text

str = R("a")
 str.capitalize() 
 .upto('C’) .to_a() .join(', ') #=> R.String #=> ’A, B, C'

Slide 16

Slide 16 text

str = R("a")
 str.capitalize() 
 .upto('C’) .to_a() .join(', ') .ljust(10, ‘-’) #=> R.String #=> ’A, B, C---'

Slide 17

Slide 17 text

str = R("a")
 str.capitalize() 
 .upto('C’) .to_a() .join(', ') .ljust(10, ‘-’)
 .to_native(); #=> string
 #=> ’A, B, C---'

Slide 18

Slide 18 text

RubyJS  objects  are  wrappers   Around  naMve  JS  objects  

Slide 19

Slide 19 text

Wrapper   class RubyJS.Fixnum @include RubyJS.Comparable
 
 constructor: (__native__) -> @__native__ = __native__; 
 
 #=> new R.Fixnum(2)  

Slide 20

Slide 20 text

Wrapper   class RubyJS.Fixnum @include RubyJS.Comparable
 
 constructor: (@__native__) -> odd: ->
 @__native__ % 2 != 0
  

Slide 21

Slide 21 text

Wrapper   class RubyJS.Fixnum @include RubyJS.Comparable
 
 constructor: (@__native__) -> odd: ->
 @__native__ % 2 != 0
 
 next: ->
 new R.Fixnum(@__native__ + 1)  

Slide 22

Slide 22 text

PorMng  Ruby  Code  to  JS  

Slide 23

Slide 23 text

Ruby   arr = %w(looks feels acts) 
 arr.map {|w| w.capitalize }
 .join(", ") 
 .concat(" like Ruby")
 .center(35, '-') '---Looks, Feels, Acts like Ruby---’  

Slide 24

Slide 24 text

RubyJS   arr = R.w('looks feels acts') 
 
  

Slide 25

Slide 25 text

RubyJS   arr = R.w('looks feels acts') 
 
 arr.map {|w| w.capitalize }
  

Slide 26

Slide 26 text

RubyJS   arr = R.w('looks feels acts') 
 
 arr.map((w) -> w.capitalize() )
 
 
 


Slide 27

Slide 27 text

RubyJS   arr = R.w('looks feels acts') 
 
 arr.map((w) -> w.capitalize() )
 .join(", ") 
 .concat(" like Ruby")
 .center(35, '-')
 '---Looks, Feels, Acts like Ruby---’  

Slide 28

Slide 28 text

Ruby   arr = %w(looks feels acts) 
 
 arr.map {|w| w.capitalize }
 .join(", ") 
 .concat(" like Ruby")
 .center(35, '-’) 
 '---Looks, Feels, Acts like Ruby---’  

Slide 29

Slide 29 text

RubyJS   arr = R.w('looks feels acts') 
 
 arr.map((w) -> w.capitalize() )
 .join(", ") 
 .concat(" like Ruby")
 .center(35, '-')
 '---Looks, Feels, Acts like Ruby---’  

Slide 30

Slide 30 text

Symbol#to_proc   arr = R.w('looks feels acts') 
 
 arr.map( R.proc('capitalize’) ) .join(", ") 
 .concat(" like Ruby")
 .center(35, '-')    

Slide 31

Slide 31 text

Symbol#to_proc   arr = R.w('looks feels acts') 
 
 arr.map( R.proc(’ljust’, 35) ) .join(", ") 
 .concat(" like Ruby")
 .center(35, '-')    

Slide 32

Slide 32 text

But  I  can  do  with  library  x,  y  ,z  

Slide 33

Slide 33 text

arr = ['looks', 'feels', 'acts'];
 
 str = _.map(arr, (w) ->
 S(w).capitalize().s;
 ).join(', ')
 
 str += ' like Ruby’;
 S(str).pad(15, '-');
  

Slide 34

Slide 34 text

RubyJS   arr = R.w('looks feels acts') 
 
 arr.map((w) -> w.capitalize() )
 .join(", ") 
 .concat(" like Ruby")
 .center(35, '-')
 '---Looks, Feels, Acts like Ruby---’  

Slide 35

Slide 35 text

Benefits  

Slide 36

Slide 36 text

One  dependency   
 <script src="/underscore-1.3.min.js"/>
 <script src="/stringjs-0.9.9.js"/>
 <script src="/momentjs-1.5.1.js"/>
 <script src="/custom_functions.js"/>  

Slide 37

Slide 37 text

One  dependency   
 <script src="/underscore-1.3.min.js"/>
 <script src="/stringjs-0.9.9.js"/>
 <script src="/momentjs-1.5.1.js"/>
 <script src="/custom_functions.js"/> <script src="/ruby.js">    

Slide 38

Slide 38 text

One  API   _.map([], (w) -> ) 
 _.chain(arr).(...).value()
 S("foo").capitalize().s
 moment().format('L')
  

Slide 39

Slide 39 text

One  API   R( [1] ).map().to_native() 
 R( [2] ).map().reject().to_native() 
 R("foo").capitalize().to_native() 
 R(new Date(…)).strftime(“%y-%m-%d”)  

Slide 40

Slide 40 text

One  chain   arr = ['looks', 'feels', 'acts']
 str = _.map(arr, (w) -> S(w).capitalize().s ).join(', ’)
 str += " not like Ruby”
 S(str).pad(str, 35, '-').s  

Slide 41

Slide 41 text

One  chain   arr = R.w('looks feels acts') 
 arr.map((w) -> w.capitalize() )
 .join(", ") 
 .concat(" like Ruby")
 .center(35, '-')
  

Slide 42

Slide 42 text

One  documentaMon  

Slide 43

Slide 43 text

One  documentaMon  

Slide 44

Slide 44 text

20  kbytes   minified  and  gzipped  

Slide 45

Slide 45 text

It  scales  

Slide 46

Slide 46 text

Dual-­‐license   •  AGPL     •  Commercial  license    

Slide 47

Slide 47 text

Booh  

Slide 48

Slide 48 text

Booh  

Slide 49

Slide 49 text

Should  I  open  source  it?  

Slide 50

Slide 50 text

No content

Slide 51

Slide 51 text

DO  IT  

Slide 52

Slide 52 text

RubyJS  is  now  MIT  License  

Slide 53

Slide 53 text

Happy  hacking  

Slide 54

Slide 54 text

Roadmap   •  Move  from  CoffeeScript  to  JavaScript   •  RubyJS  corelib   – Time,  Hash,  Date   •  RubyJS  corelib-­‐lite   – remove  some  rubyisms   – simplify  

Slide 55

Slide 55 text

RubyJS.org   twi5er.com/hasclass