https://github.com/searls/emoruby
A little emoji language that compiles down to Ruby. "It's just ruby."
https://github.com/searls/emoruby
Last synced: 3 months ago
JSON representation
A little emoji language that compiles down to Ruby. "It's just ruby."
- Host: GitHub
- URL: https://github.com/searls/emoruby
- Owner: searls
- License: mit
- Created: 2014-11-21T19:18:16.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2021-10-14T17:07:08.000Z (over 3 years ago)
- Last Synced: 2025-02-27T07:44:43.462Z (3 months ago)
- Language: Ruby
- Size: 50.8 KB
- Stars: 66
- Watchers: 4
- Forks: 7
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
# emoruby
Use Emoji™A little language that compiles Emoji down to Ruby. It's just Ruby. Really.
## The Language
If I were a real language designer, I would have put a lot of thought into the syntax, semantics, and structure of emoruby. Instead I basically implemented an inefficient find-and-replace from a static dictionary. (🐄🎩!)
### hello world
Anyway, here is an example hello world program:
```emoruby
📋 ❤️
🔜 👋
👀 💬😃 🌏💬
🔚
🔚❤️▪️🐣▪️👋
```which is equivalent to this Ruby:
``` ruby
class Heart
def wave
puts "smiley earth_asia"
end
endHeart.new.wave
```### procs and comments
You can also define things like Procs and comments:
```emoruby
💭 Comment! 👋
👉 🔨
💬😃💬
🔚▪️📞
```which is equivalent to this Ruby:
```ruby
# Comment! 👋
-> do
"smiley"
end.call
```### enumerables and block params
You can also define Array and Hash literals, and use the `{}` block syntax:
```emoruby
◀️9️⃣➰3️⃣▶️▪️📍 ⏪ 🏂🅰🏂 🅰 ➕ 1 ⏩
```Which translates to this Ruby:
```
[9,3].map { |a| a + 1 }
```### method visibility
You can define private and protected methods:
```emoruby
📋 ❤️
🔓 🔜 👖
👀 💬👛💬
🔚🔒️ 🔜 👕
👀 💬💛💬
🔚⛔️ 🔜 👋
👀 💬😃 🌏💬
🔚
🔚❤️▪️🐣▪️👋
```which is equivalent to this Ruby:
```ruby
class Heart
public def jeans
puts "purse"
endprotected def shirt
puts "yellow_heart"
endprivate def wave
puts "smiley earth_asia"
end
endHeart.new.wave
```Which will result in an exception:
```
NoMethodError: private method `wave' called for #
```## Using the gem
### registering the ".emoruby" file extension
Emoruby uses polyglot to enable `require` to be used on `.emoruby` files just as you do with Ruby source `.rb` files. To register the file extension, simply:
```ruby
> require 'emoruby'
=> true
> Emoruby.register
=> nil
> require 'hello_world'
smiley earth_asia
=> true
```### command line
You can run emoruby from the command line by passing an emoruby file as the first argument:
```shell
$ emoruby spec/fixtures/1_hello_world.emoruby
smiley earth_asia
```### API
The API allows both evaluation of emoruby code as well as translation to Ruby.
```ruby
> source = "💬😃 🌏💬"
=> "💬😃 🌏💬"
> Emoruby.eval(source)
=> "smiley earth_asia"
Emoruby.emoji_to_ruby(source)
=> "\"smiley earth_asia\""
```## Versioning
The Emoruby team embraces and advocates the adoption of the the emerging emotional versioning standard ("emover" for short).
The initial release was 💩 (in honor of @tenderlove's 💩-lang). After that, ✊ was released. Then came 🐷. The next planned release is 📈.