sith

sith is a macro preprocessor for Ruby

Build Status

Still a prototype.

Example:

a macro definitions file:

macro_mapper attr_reader(label, delimiter: "\n")
  def ~{label}
    @~{label}
  end
end

macro_mapper attr_writer(label, delimiter: "\n")
  def ~{label}=(value)
    @~{label} = value
  end
end

macro attr_accessor(*labels)
  attr_reader ~{labels}
  attr_writer ~{labels}
end

a ruby file

class A
  attr_accessor a
end
sith ruby_file.rb macro_definitions.rb > output.rb`

output.rb

class A
  def a
    @a
  end
  def a=(value)
    @a = value
  end
end

install

gem install sith

thanks

built on top of parser and unparser gems.

similar to

rubymacros

however, the macros in sith are defined using a ruby-like template notation, not a lisp-like ast notation.

built by

Alexander Ivanov