/usr/lib/ruby/1.9.1/gettext/tools/parser/erb.rb is in libgettext-ruby1.9.1 2.1.0-2.1ubuntu1.
This file is owned by root:root, with mode 0o644.
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 | =begin
parser/erb.rb - parser for ERB
Copyright (C) 2005-2009 Masao Mutoh
You may redistribute it and/or modify it under the same
license terms as Ruby or LGPL.
=end
require 'erb'
require 'gettext/tools/parser/ruby'
module GetText
module ErbParser
extend self
@config = {
:extnames => ['.rhtml', '.erb']
}
# Sets some preferences to parse ERB files.
# * config: a Hash of the config. It can takes some values below:
# * :extnames: An Array of target files extension. Default is [".rhtml"].
def init(config)
config.each{|k, v|
@config[k] = v
}
end
def parse(file, targets = []) # :nodoc:
src = ERB.new(IO.readlines(file).join).src
# Remove magic comment prepended by erb in Ruby 1.9.
src.sub!(/\A#.*?coding[:=].*?\n/, '') if src.respond_to?(:encode)
erb = src.split(/$/)
RubyParser.parse_lines(file, erb, targets)
end
def target?(file) # :nodoc:
@config[:extnames].each do |v|
return true if File.extname(file) == v
end
false
end
end
end
if __FILE__ == $0
# ex) ruby glade.rhtml foo.rhtml bar.rhtml
ARGV.each do |file|
p GetText::ErbParser.parse(file)
end
end
|