A Clojure implementation for Ruby
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Ashe Connor 9b27b04aa0
fix names
1 year ago
bin Use Rouge::Printer for results 7 years ago
lib fix names 1 year ago
misc TODO updates. 7 years ago
spec fix names 1 year ago
.autotest This borks stuff. 7 years ago
.gitignore Ignore Vim .swp files 7 years ago
.rspec Initial commit. 7 years ago
.travis.yml Modern rubies. 4 years ago
Gemfile Gemify. 7 years ago
LICENSE fix names 1 year ago
README.md fix names 1 year ago
Rakefile Gemify. 7 years ago
rouge-lang.gemspec fix names 1 year ago

README.md

Rouge Build Status

Ruby + Clojure = Rouge.

Why?

  • Clojure is elegant and fun.
  • Quick boot time (currently around 0.1s).
  • Ruby’s gems tend to be modern with decent APIs.

Install the gem to get the local REPL:

gem install rouge-lang
rouge

You’ll see the user=> prompt. Enjoy!

example

See boot.rg, but to demonstrate salient features:

; define a macro
(defmacro defn [name args & body]
  `(def ~name (fn ~name ~args ~@body)))

; call a Ruby method on Kernel (if the ruby namespace is referred)
(defn require [lib]
  (.require Kernel lib))

; call a Ruby method on an Array with a block argument
(defn reduce [f coll]
  (.inject coll | f))

; using Ruby's AMQP gem with an inline block
(.subscribe queue {:ack true} | [metadata payload]
  (puts (str "got a message: " payload))
  (.ack metadata))

What about in Rails?

$ rails console -- -rrouge
Loading development environment (Rails 4.0.1)
irb(main):001:0> Rouge.repl
Rouge 0.0.16
user=> Entry
ruby/Entry
user=> (.where Entry {:id 1})
  Entry Load (10.5ms)  SELECT "entries".* FROM "entries" WHERE "entries"."id" = 1
#<ActiveRecord::Relation [#<Entry id: 1, user_id: 1, source: "xyz", rendered: "<p>xyz</p>", created_at: "2014-12-20 05:15:28", updated_at: "2015-07-01 10:28:27", timezone: "Australia/Sydney">]>
user=>

TODO

See TODO, but big ones include:

  • making seqs nicer
  • persistent datastructures everywhere
  • defprotocol

contributions

Yes, please!

  • Fork the project.
  • Make your feature addition or bug fix.
  • Add tests! This is so I don’t break your lovely addition in the future by accident.
  • Commit and pull request! (Bonus points for topic branches.)

Also, if there’s something in particular you want that’s missing, feel free to put your vote in by opening an Issue so I know where to direct my attention.

authorship

Original author: [Ashe Connor).

Unreserved thanks to the following people for their contributions.

The MIT license.

Copyright © 2012–2016 Ashe Connor

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.