Sha256: 5aa813a012f6ec096242e6cabbcb83a54ffc2a2c9d2d0d2a52877914f2b17288

Contents?: true

Size: 1.14 KB

Versions: 13

Compression:

Stored size: 1.14 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_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)

puts "Your document is stored in @doc..."
IRB.start

Version data entries

13 entries across 13 versions & 7 rubygems

Version Path
radiant-1.0.0 ruby-debug/ruby/1.8/gems/nokogiri-1.5.0/bin/nokogiri
iisconfig-0.0.1.pre2 build/bundler/ruby/1.9.1/gems/nokogiri-1.5.0-x86-mingw32/bin/nokogiri
iisconfig-0.0.1.pre1 build/bundler/ruby/1.9.1/gems/nokogiri-1.5.0-x86-mingw32/bin/nokogiri
domo-0.0.5 vendor/bundle/ruby/1.9.1/gems/nokogiri-1.5.0/bin/nokogiri
horseman-0.0.4 vendor/ruby/1.9.1/gems/nokogiri-1.5.0/bin/nokogiri
horseman-0.0.3 vendor/ruby/1.9.1/gems/nokogiri-1.5.0/bin/nokogiri
horseman-0.0.2 vendor/ruby/1.9.1/gems/nokogiri-1.5.0/bin/nokogiri
nokogiri-maven-1.5.0-java bin/nokogiri
nokogiri-maglev--1.5.0.1 bin/nokogiri
nokogiri-1.5.0-java bin/nokogiri
nokogiri-1.5.0-x86-mingw32 bin/nokogiri
nokogiri-1.5.0-x86-mswin32-60 bin/nokogiri
nokogiri-1.5.0 bin/nokogiri