Skip to content

Latest commit

 

History

History
65 lines (42 loc) · 1.1 KB

File metadata and controls

65 lines (42 loc) · 1.1 KB

Ruby 2 JavaScript

CoffeeScript

CoffeeScript is a programming language that transcompiles to JavaScript. It adds syntactic sugar inspired by Ruby, Python and Haskell in an effort to enhance JavaScript's brevity and readability.

Quick CoffeeScript Review

Here a quick how to if CoffeeScript in general

  • To install CoffeScript
npm install -g coffee-script
  • For live conversion
coffee --watch --compile script.coffee 

Ruby CoffeScript gem

Ruby CoffeeScript gem is a bridge to the official CoffeeScript compiler.

  • To install CoffeeScript gem
gem install coffee-script
  • Convert CoffeeScript file to Javascript
#!/usr/bin/env ruby
require 'coffee-script'
if ARGF
  file = File.open("#{ARGV[0]}.js", 'a')
  file.write CoffeeScript.compile(ARGF.read)
end

Run it

ruby cofee2js.rb exploit.coffee 

Opal

Opal is a Ruby to JavaScript source-to-source compiler. It also has an implementation of the Ruby corelib.

  • To install Opal
gem install opal opal-jquery