/usr/bin/ruby_parse is in ruby-parser 3.6.6-1.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
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 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 | #!/usr/bin/ruby
$q ||= false
$g ||= false
require 'rubygems'
require 'ruby_parser'
require 'pp'
good = bad = 0
multi = ARGV.size != 1
total_time = 0
total_loc = 0
total_kbytes = 0
times = {}
locs = {}
kbytes = {}
class File
RUBY19 = "<3".respond_to? :encoding
class << self
alias :binread :read unless RUBY19
end
end
begin
ARGV.each do |file|
rp = RubyParser.new
loc = `wc -l #{file}`.strip.to_i
size = `wc -c #{file}`.strip.to_i / 1024.0
locs[file] = loc
kbytes[file] = size
total_loc += loc
total_kbytes += size
if $q then
$stderr.print "."
else
warn "# file = #{file} loc = #{loc}"
end
GC.start if $g
t = Time.now
begin
begin
rp.reset
r = rp.parse(File.binread(file), file)
pp r unless $q
good += 1
rescue SyntaxError => e
warn "SyntaxError for #{file}: #{e.message}"
bad += 1
end
rescue => e
warn "#{e.backtrace.first} #{e.inspect.gsub(/\n/, ' ')} for #{file}"
warn " #{e.backtrace.join("\n ")}"
bad += 1
end
t = Time.now - t
times[file] = t
total_time += t
end
rescue Interrupt
# do nothing
end
warn "done"
total = 0
times.values.each do |t|
total += t
end
puts
puts "good = #{good} bad = #{bad}" if multi
puts
format = "%5.2fs:%9.2f l/s:%8.2f Kb/s:%5d Kb:%5d loc:%s"
times.sort_by { |f, t| -t }.each do |f, t|
next if t < 0.005
loc = locs[f]
size = kbytes[f]
puts format % [t, loc / t, size / t, size, loc, f]
end
puts
puts format % [total_time,
total_loc / total_time,
total_kbytes / total_time,
total_kbytes,
total_loc,
"TOTAL"] unless total_time == 0
|