
Security News
GitHub Actions Pricing Whiplash: Self-Hosted Actions Billing Change Postponed
GitHub postponed a new billing model for self-hosted Actions after developer pushback, but moved forward with hosted runner price cuts on January 1.
ruby_scribe
Advanced tools
{
}[http://travis-ci.org/rubiety/ruby_scribe]
= Ruby Scribe
Generates nicely-formatted ruby source code given a ruby abstract syntax tree (from seattlerb's ruby_parser).
== Introduction
Ruby Scribe attempts to intelligently format code (from an AST) much as a real developer would, through a series of configurable option.
== Approach
To approach creating a solid pretty-printer, I used the Rails codebase as "ideal" coding style for the emitter with default parameters. As I continued to refine ruby_scribe,
I ran it (with no AST transformations) against every ruby file in the Rails codebase. The smaller the remaining git diff after each iteration, the better the emitter was.
There are even some instances I think ruby_scribe emits more consistent code than what currently exists in the Rails codebase.
== Example
Imagine this crappily-formatted Ruby code:
module RubyScribe # My Comment class Sample < Base; def method; do_something_here; end end
Parse that with RubyParser:
sexp = RubyParser.new.parse(File.read("bad_code.rb"))
Then emit it with Ruby Scribe:
RubyScribe::Emitter.new.emit(sexp)
And out pops this, nice and clean:
module RubyScribe # My Comment class Sample < Base def method do_something_here end end end
== Usage
The entire project simply takes an incoming Sexp object (from the ruby_parser project) and emits a single string. To do this just use an Emitter:
RubyScribe::Emitter.new.emit(sexp) # => "module Something..."
== Emitter Implementation
The +Emitter+ class is nothing but a bunch of recursion. The main emit method is a big case block to offload handling of individual types to separate methods which handle and compose a big string, all through recursion.
To extend or implement your own Emitter, just subclass +RubyScribe::Emitter+ and override the necessary methods.
== Known Issues
== Future Features
FAQs
Unknown package
We found that ruby_scribe demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
GitHub postponed a new billing model for self-hosted Actions after developer pushback, but moved forward with hosted runner price cuts on January 1.

Research
Destructive malware is rising across open source registries, using delays and kill switches to wipe code, break builds, and disrupt CI/CD.

Security News
Socket CTO Ahmad Nassri shares practical AI coding techniques, tools, and team workflows, plus what still feels noisy and why shipping remains human-led.