Sha256: b9b13f71a3f8f13193beef489eccaa5dd638d8cd37a1824930b4ba546838aa44

Contents?: true

Size: 1.31 KB

Versions: 50

Compression:

Stored size: 1.31 KB

Contents

#!/usr/bin/env ruby
require 'optparse'
require 'open-uri'
require 'irb'
require 'uri'
require 'rubygems'
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 ""
  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("--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?
  puts opts
  exit 1
end

@doc = parse_class.parse(open(uri).read, nil, encoding)

if @rng
  puts @rng.validate(@doc)
else
  puts "Your document is stored in @doc..."
  IRB.start
end

Version data entries

50 entries across 50 versions & 6 rubygems

Version Path
nokogiri-maglev--1.5.2 bin/nokogiri
nokogiri-maglev--1.5.3 bin/nokogiri
sunrise-cms-0.3.3 vendor/bundle/ruby/1.9.1/gems/nokogiri-1.5.2/bin/nokogiri
sunrise-cms-0.3.2 vendor/bundle/ruby/1.9.1/gems/nokogiri-1.5.2/bin/nokogiri
sunrise-cms-0.3.1 vendor/bundle/ruby/1.9.1/gems/nokogiri-1.5.2/bin/nokogiri
sunrise-cms-0.3.0 vendor/bundle/ruby/1.9.1/gems/nokogiri-1.5.2/bin/nokogiri
nokogiri-1.5.3-java bin/nokogiri
nokogiri-1.5.3-x86-mingw32 bin/nokogiri
nokogiri-1.5.3-x86-mswin32-60 bin/nokogiri
nokogiri-1.5.3 bin/nokogiri
nokogiri-1.5.3.rc6-java bin/nokogiri
nokogiri-1.5.3.rc6-x86-mingw32 bin/nokogiri
nokogiri-1.5.3.rc6-x86-mswin32-60 bin/nokogiri
nokogiri-1.5.3.rc6 bin/nokogiri
sunrise-cms-0.3.0.rc vendor/bundle/ruby/1.9.1/gems/nokogiri-1.5.2/bin/nokogiri
ftl-0.2.0 vendor/bundle/gems/nokogiri-1.5.2/bin/nokogiri
nokogiri-1.5.3.rc5 bin/nokogiri
nokogiri-1.5.3.rc5-x86-mswin32-60 bin/nokogiri
nokogiri-1.5.3.rc5-x86-mingw32 bin/nokogiri
nokogiri-1.5.3.rc5-java bin/nokogiri