Project

elixir.rb

0.01
No commit activity in last 3 years
No release in over 3 years
An implementation of parts of the Elixir standard library in Ruby.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

>= 5.7.0, ~> 5.7
>= 10.4.2, ~> 10.4

Runtime

>= 0.3.2, ~> 0.3
>= 0.8.0, ~> 0.8
 Project Readme

Elixir.rb

Build Status

The Elixir standard library in Ruby!

So far there are partial implementations of the following Elixir modules:

  • Agent
  • Atom
  • Base
  • Dict
  • Enum
  • File
  • Float
  • Integer
  • List
  • OptionParser
  • Path
  • Range
  • Set
  • Stream
  • String
  • System
  • Task
  • Tuple
  • Version

Requirements

Ruby 2.2+

Installation

gem install elixir.rb

Examples

Stream.unfold/2

require 'elixir/stream'

include Elixir

Fib = Stream.unfold [0, 1] do |a, b|
  [a, [b, a + b]]
end

Fib.size
#=> Infinity

Fib.take 5
#=> [0, 1, 1, 2, 3]

Agent and Task

require 'elixir/agent'
require 'elixir/task'

include Elixir

status, agent = Agent.start { 0 }
#=> [:ok, #<Concurrent::Atomic:...>]

Agent.cast(agent) { |value| value + 42 }
#=> :ok

Agent.get agent, &:next
#=> 43

task = Task.async do
  sleep 0.5

  Agent.get agent, &:itself
end
#<Concurrent::IVar:...>

Task.await task
#=> 42

Development

Install Elixir.rb and its deps:

git clone https://github.com/havenwood/elixir.rb
cd elixir.rb
gem install -g --no-lock

Run the tests:

RUBYGEMS_GEMDEPS="-" rake