|
a913af57
»
|
flavorjones |
2009-04-23 |
added Nokogiri::VERSION_INF... |
1 |
# -*- coding: utf-8 -*- |
|
7f2ae51a
»
|
tenderlove |
2009-02-13 |
loading the native portions... |
2 |
# Modify the PATH on windows so that the external DLLs will get loaded. |
| |
3 |
ENV['PATH'] = [File.expand_path( |
| |
4 |
File.join(File.dirname(__FILE__), "..", "ext", "nokogiri") |
|
454c543f
»
|
tenderlove |
2009-05-07 |
adding fat binary codes |
5 |
), ENV['PATH']].compact.join(';') if RUBY_PLATFORM =~ /(mswin|mingw)/i |
|
7f2ae51a
»
|
tenderlove |
2009-02-13 |
loading the native portions... |
6 |
|
|
836e526a
»
|
flavorjones |
2009-04-30 |
FFI branch squash-merged in... |
7 |
if ENV['NOKOGIRI_FFI'] || RUBY_PLATFORM =~ /java/ |
|
b2975514
»
|
flavorjones |
2009-05-11 |
requiring ruby-ffi gem 0.4.... |
8 |
gem 'ffi', '>=0.4.0' unless RUBY_PLATFORM =~ /java/ |
|
836e526a
»
|
flavorjones |
2009-04-30 |
FFI branch squash-merged in... |
9 |
require 'ffi' |
| |
10 |
require 'nokogiri/ffi/libxml' |
| |
11 |
else |
|
454c543f
»
|
tenderlove |
2009-05-07 |
adding fat binary codes |
12 |
if RUBY_PLATFORM =~/(mswin|mingw)/i |
| |
13 |
# Fat binary gems, you make the Rockin' world go round |
| |
14 |
require "nokogiri/#{RUBY_VERSION.sub(/\.\d+$/, '')}/nokogiri" |
| |
15 |
else |
| |
16 |
require 'nokogiri/nokogiri' |
| |
17 |
end |
|
836e526a
»
|
flavorjones |
2009-04-30 |
FFI branch squash-merged in... |
18 |
end |
|
7f2ae51a
»
|
tenderlove |
2009-02-13 |
loading the native portions... |
19 |
|
|
08450f39
»
|
tenderlove |
2008-08-19 |
auto generating the IDL int... |
20 |
require 'nokogiri/version' |
|
597861f0
»
|
jmhodges |
2009-02-03 |
providing a central Nokogir... |
21 |
require 'nokogiri/syntax_error' |
|
34102644
»
|
tenderlove |
2008-07-18 |
adding the html and xml parser |
22 |
require 'nokogiri/xml' |
|
5ff03ff3
»
|
tenderlove |
2008-08-24 |
adding xslt support |
23 |
require 'nokogiri/xslt' |
|
34102644
»
|
tenderlove |
2008-07-18 |
adding the html and xml parser |
24 |
require 'nokogiri/html' |
|
221a44e7
»
|
tenderlove |
2008-09-15 |
adding decoration to nokogi... |
25 |
require 'nokogiri/decorators' |
|
38d3bfbd
»
|
tenderlove |
2008-09-17 |
starting the css selector ast |
26 |
require 'nokogiri/css' |
|
221a44e7
»
|
tenderlove |
2008-09-15 |
adding decoration to nokogi... |
27 |
require 'nokogiri/html/builder' |
|
8a45571f
»
|
flavorjones |
2008-09-15 |
added Nokogiri(), Nokogiri.... |
28 |
require 'nokogiri/hpricot' |
|
35cace6b
»
|
tenderlove |
2008-10-29 |
fixing up win32 build, addi... |
29 |
|
|
9d4a78eb
»
|
tenderlove |
2009-03-13 |
adding some documentation, ... |
30 |
# Nokogiri parses and searches XML/HTML very quickly, and also has |
| |
31 |
# correctly implemented CSS3 selector support as well as XPath support. |
| |
32 |
# |
| |
33 |
# Parsing a document returns either a Nokogiri::XML::Document, or a |
| |
34 |
# Nokogiri::HTML::Document depending on the kind of document you parse. |
| |
35 |
# |
| |
36 |
# Here is an example: |
| |
37 |
# |
| |
38 |
# require 'nokogiri' |
| |
39 |
# require 'open-uri' |
| |
40 |
# |
| |
41 |
# # Get a Nokogiri::HTML:Document for the page we’re interested in... |
| |
42 |
# |
| |
43 |
# doc = Nokogiri::HTML(open('http://www.google.com/search?q=tenderlove')) |
| |
44 |
# |
| |
45 |
# # Do funky things with it using Nokogiri::XML::Node methods... |
| |
46 |
# |
| |
47 |
# #### |
| |
48 |
# # Search for nodes by css |
| |
49 |
# doc.css('h3.r a.l').each do |link| |
| |
50 |
# puts link.content |
| |
51 |
# end |
| |
52 |
# |
| |
53 |
# See Nokogiri::XML::Node#css for more information about CSS searching. |
| |
54 |
# See Nokogiri::XML::Node#xpath for more information about XPath searching. |
|
9eebaa08
»
|
tenderlove |
2008-07-14 |
breaking up nokogiri |
55 |
module Nokogiri |
|
e7f98b6c
»
|
tenderlove |
2008-07-14 |
initial checkin |
56 |
class << self |
|
8b9daefb
»
|
tenderlove |
2008-11-30 |
making sure that sloppy css... |
57 |
### |
| |
58 |
# Parse an HTML or XML document. +string+ contains the document. |
|
93761f99
»
|
tenderlove |
2008-10-15 |
adding parser constants and... |
59 |
def parse string, url = nil, encoding = nil, options = nil |
|
449e7c5a
»
|
tenderlove |
2008-07-18 |
working on new api |
60 |
doc = |
| |
61 |
if string =~ /^\s*<[^Hh>]*html/i # Probably html |
|
93761f99
»
|
tenderlove |
2008-10-15 |
adding parser constants and... |
62 |
Nokogiri::HTML.parse(string, url, encoding, options || 2145) |
|
449e7c5a
»
|
tenderlove |
2008-07-18 |
working on new api |
63 |
else |
|
93761f99
»
|
tenderlove |
2008-10-15 |
adding parser constants and... |
64 |
Nokogiri::XML.parse(string, url, encoding, options || 2159) |
|
449e7c5a
»
|
tenderlove |
2008-07-18 |
working on new api |
65 |
end |
| |
66 |
yield doc if block_given? |
| |
67 |
doc |
|
e7f98b6c
»
|
tenderlove |
2008-07-14 |
initial checkin |
68 |
end |
|
8a45571f
»
|
flavorjones |
2008-09-15 |
added Nokogiri(), Nokogiri.... |
69 |
|
|
acddc4a8
»
|
tenderlove |
2009-04-25 |
adding an rdoc test and add... |
70 |
### |
| |
71 |
# Create a new Nokogiri::XML::DocumentFragment |
|
93761f99
»
|
tenderlove |
2008-10-15 |
adding parser constants and... |
72 |
def make input = nil, opts = {}, &blk |
|
1c4e553b
»
|
flavorjones |
2008-09-16 |
implemented NodeSet.wrap() ... |
73 |
if input |
|
0dfe0255
»
|
tenderlove |
2009-02-05 |
HTML.fragment now returns a... |
74 |
Nokogiri::HTML.fragment(input).children.first |
|
1c4e553b
»
|
flavorjones |
2008-09-16 |
implemented NodeSet.wrap() ... |
75 |
else |
|
903a28d3
»
|
tenderlove |
2008-09-25 |
fixing warning |
76 |
Nokogiri(&blk) |
|
1c4e553b
»
|
flavorjones |
2008-09-16 |
implemented NodeSet.wrap() ... |
77 |
end |
| |
78 |
end |
|
acddc4a8
»
|
tenderlove |
2009-04-25 |
adding an rdoc test and add... |
79 |
|
|
8b9daefb
»
|
tenderlove |
2008-11-30 |
making sure that sloppy css... |
80 |
### |
| |
81 |
# Parse a document and add the Slop decorator. The Slop decorator |
| |
82 |
# implements method_missing such that methods may be used instead of CSS |
| |
83 |
# or XPath. For example: |
| |
84 |
# |
| |
85 |
# doc = Nokogiri::Slop(<<-eohtml) |
| |
86 |
# <html> |
| |
87 |
# <body> |
| |
88 |
# <p>first</p> |
| |
89 |
# <p>second</p> |
| |
90 |
# </body> |
| |
91 |
# </html> |
| |
92 |
# eohtml |
| |
93 |
# assert_equal('second', doc.html.body.p[1].text) |
| |
94 |
# |
|
46be2582
»
|
jbarnette |
2008-11-26 |
Nokogiri::Slop(xml) provide... |
95 |
def Slop(*args, &block) |
| |
96 |
Nokogiri(*args, &block).slop! |
| |
97 |
end |
|
8a45571f
»
|
flavorjones |
2008-09-15 |
added Nokogiri(), Nokogiri.... |
98 |
end |
| |
99 |
end |
| |
100 |
|
|
acddc4a8
»
|
tenderlove |
2009-04-25 |
adding an rdoc test and add... |
101 |
### |
| |
102 |
# Parser a document contained in +args+. Nokogiri will try to guess what |
| |
103 |
# type of document you are attempting to parse. For more information, see |
| |
104 |
# Nokogiri.parse |
| |
105 |
# |
| |
106 |
# To specify the type of document, use Nokogiri.XML or Nokogiri.HTML. |
|
8a45571f
»
|
flavorjones |
2008-09-15 |
added Nokogiri(), Nokogiri.... |
107 |
def Nokogiri(*args, &block) |
| |
108 |
if block_given? |
|
1c4e553b
»
|
flavorjones |
2008-09-16 |
implemented NodeSet.wrap() ... |
109 |
builder = Nokogiri::HTML::Builder.new(&block) |
|
a02964e4
»
|
tenderlove |
2009-02-13 |
adding to_xhtml using xmlsa... |
110 |
return builder.doc.root |
|
8a45571f
»
|
flavorjones |
2008-09-15 |
added Nokogiri(), Nokogiri.... |
111 |
else |
|
33ab946e
»
|
tenderlove |
2008-11-22 |
delegating Nokogiri() to th... |
112 |
Nokogiri.parse(*args) |
|
e7f98b6c
»
|
tenderlove |
2008-07-14 |
initial checkin |
113 |
end |
| |
114 |
end |