File: r2r_show

package info (click to toggle)
ruby-ruby2ruby 2.5.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 216 kB
  • sloc: ruby: 2,002; makefile: 2
file content (32 lines) | stat: -rwxr-xr-x 559 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#!/usr/bin/ruby -ws

require 'rubygems'
require 'ruby2ruby'
require 'ruby_parser'

$h ||= false
$s ||= false

if $h then
  puts "usage: #{File.basename $0} [options] [file...]"
  puts "options:"
  puts "-h     : display usage"
  puts "-s     : print the sexp before displaying the translated ruby"

  exit 1
end

ARGV.push "-" if ARGV.empty?

parser    = RubyParser.new
ruby2ruby = Ruby2Ruby.new

ARGV.each do |file|
  ruby = file == "-" ? $stdin.read : File.read(file)

  sexp = parser.process(ruby, file)

  p sexp if $s

  puts ruby2ruby.process(sexp)
end