/usr/bin/nokogiri is in ruby-nokogiri 1.6.1+ds-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 | #!/usr/bin/env ruby
require 'optparse'
require 'open-uri'
require 'irb'
require 'uri'
require 'nokogiri'
parse_class = Nokogiri
encoding = nil
opts = OptionParser.new do |opts|
opts.banner = "Nokogiri: an HTML, XML, SAX, and Reader parser"
opts.define_head "Usage: nokogiri <uri|path> [options]"
opts.separator ""
opts.separator "Examples:"
opts.separator " nokogiri http://www.ruby-lang.org/"
opts.separator " nokogiri ./public/index.html"
opts.separator " curl -s http://nokogiri.org | nokogiri -e'p $_.css(\"h1\").length'"
opts.separator ""
opts.separator "Options:"
opts.on("--type [TYPE]", [:xml, :html]) do |v|
parse_class = {:xml => Nokogiri::XML, :html => Nokogiri::HTML}[v]
end
opts.on("-E", "--encoding encoding", "Read as encoding (default #{encoding})") do |v|
encoding = v
end
opts.on("-e command", "Specifies script from command-line.") do |v|
@script = v
end
opts.on("--rng <uri|path>", "Validate using this rng file.") do |v|
@rng = open(v) {|f| Nokogiri::XML::RelaxNG(f)}
end
opts.on_tail("-?", "--help", "Show this message") do
puts opts
exit
end
opts.on_tail("-v", "--version", "Show version") do
puts Nokogiri::VersionInfo.instance.to_markdown
exit
end
end
opts.parse!
uri = ARGV.shift
if uri.to_s.strip.empty? && $stdin.tty?
puts opts
exit 1
end
if $stdin.tty?
@doc = parse_class.parse(open(uri).read, nil, encoding)
else
@doc = parse_class.parse($stdin, nil, encoding)
end
$_ = @doc
if @rng
@rng.validate(@doc).each do |error|
puts error.message
end
else
if @script
eval @script, binding, '<main>'
else
puts "Your document is stored in @doc..."
IRB.start
end
end
|