nokogiri 1.4.7 → 1.5.0.beta.1

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of nokogiri might be problematic. Click here for more details.

Files changed (164) hide show
  1. data/CHANGELOG.ja.rdoc +8 -83
  2. data/CHANGELOG.rdoc +6 -80
  3. data/Manifest.txt +4 -74
  4. data/README.ja.rdoc +5 -1
  5. data/README.rdoc +8 -22
  6. data/Rakefile +79 -60
  7. data/bin/nokogiri +1 -6
  8. data/deps.rip +5 -0
  9. data/ext/nokogiri/extconf.rb +32 -53
  10. data/ext/nokogiri/nokogiri.c +0 -2
  11. data/ext/nokogiri/nokogiri.h +0 -9
  12. data/ext/nokogiri/xml_document.c +0 -14
  13. data/ext/nokogiri/xml_dtd.c +2 -2
  14. data/ext/nokogiri/xml_io.c +7 -32
  15. data/ext/nokogiri/xml_node.c +31 -103
  16. data/ext/nokogiri/xml_node_set.c +8 -8
  17. data/ext/nokogiri/xml_reader.c +1 -20
  18. data/ext/nokogiri/xml_sax_parser.c +3 -5
  19. data/ext/nokogiri/xml_sax_parser_context.c +0 -40
  20. data/ext/nokogiri/xml_xpath_context.c +2 -35
  21. data/ext/nokogiri/xslt_stylesheet.c +6 -124
  22. data/lib/nokogiri.rb +7 -3
  23. data/lib/nokogiri/css.rb +3 -6
  24. data/lib/nokogiri/css/generated_parser.rb +669 -0
  25. data/lib/nokogiri/css/generated_tokenizer.rb +145 -0
  26. data/lib/nokogiri/css/parser.rb +70 -665
  27. data/lib/nokogiri/css/parser.y +1 -6
  28. data/lib/nokogiri/css/tokenizer.rb +3 -148
  29. data/lib/nokogiri/css/tokenizer.rex +1 -1
  30. data/lib/nokogiri/css/xpath_visitor.rb +14 -16
  31. data/lib/nokogiri/decorators/slop.rb +3 -5
  32. data/lib/nokogiri/html.rb +3 -2
  33. data/lib/nokogiri/html/document.rb +18 -134
  34. data/lib/nokogiri/html/document_fragment.rb +21 -26
  35. data/lib/nokogiri/html/element_description_defaults.rb +671 -0
  36. data/lib/nokogiri/html/sax/parser.rb +2 -6
  37. data/lib/nokogiri/version.rb +4 -9
  38. data/lib/nokogiri/xml/attribute_decl.rb +1 -1
  39. data/lib/nokogiri/xml/builder.rb +1 -1
  40. data/lib/nokogiri/xml/document.rb +3 -27
  41. data/lib/nokogiri/xml/document_fragment.rb +2 -9
  42. data/lib/nokogiri/xml/dtd.rb +1 -12
  43. data/lib/nokogiri/xml/element_decl.rb +1 -1
  44. data/lib/nokogiri/xml/entity_decl.rb +1 -1
  45. data/lib/nokogiri/xml/node.rb +75 -172
  46. data/lib/nokogiri/xml/node/save_options.rb +0 -10
  47. data/lib/nokogiri/xml/node_set.rb +3 -28
  48. data/lib/nokogiri/xml/parse_options.rb +0 -8
  49. data/lib/nokogiri/xml/reader.rb +6 -44
  50. data/lib/nokogiri/xml/sax/document.rb +5 -9
  51. data/lib/nokogiri/xml/schema.rb +1 -7
  52. data/lib/nokogiri/xslt.rb +5 -9
  53. data/tasks/cross_compile.rb +12 -27
  54. data/tasks/test.rb +0 -0
  55. data/test/css/test_parser.rb +19 -40
  56. data/test/css/test_tokenizer.rb +0 -8
  57. data/test/helper.rb +1 -4
  58. data/test/html/sax/test_parser.rb +21 -47
  59. data/test/html/sax/test_parser_context.rb +2 -2
  60. data/test/html/test_document.rb +3 -58
  61. data/test/html/test_document_encoding.rb +0 -53
  62. data/test/html/test_document_fragment.rb +13 -82
  63. data/test/html/test_element_description.rb +4 -2
  64. data/test/html/test_node.rb +0 -9
  65. data/test/test_memory_leak.rb +2 -57
  66. data/test/test_nokogiri.rb +14 -20
  67. data/test/test_reader.rb +7 -47
  68. data/test/test_xslt_transforms.rb +5 -8
  69. data/test/xml/sax/test_parser.rb +17 -34
  70. data/test/xml/sax/test_parser_context.rb +0 -50
  71. data/test/xml/sax/test_push_parser.rb +1 -18
  72. data/test/xml/test_attr.rb +4 -31
  73. data/test/xml/test_attribute_decl.rb +7 -3
  74. data/test/xml/test_builder.rb +5 -5
  75. data/test/xml/test_cdata.rb +3 -3
  76. data/test/xml/test_document.rb +18 -15
  77. data/test/xml/test_document_fragment.rb +20 -19
  78. data/test/xml/test_dtd.rb +13 -18
  79. data/test/xml/test_element_content.rb +1 -1
  80. data/test/xml/test_element_decl.rb +1 -1
  81. data/test/xml/test_entity_decl.rb +12 -10
  82. data/test/xml/test_namespace.rb +7 -5
  83. data/test/xml/test_node.rb +15 -54
  84. data/test/xml/test_node_reparenting.rb +42 -85
  85. data/test/xml/test_node_set.rb +2 -61
  86. data/test/xml/test_schema.rb +0 -5
  87. data/test/xml/test_text.rb +2 -11
  88. data/test/xml/test_unparented_node.rb +1 -1
  89. data/test/xml/test_xpath.rb +7 -43
  90. metadata +131 -155
  91. data/.gemtest +0 -0
  92. data/ext/nokogiri/depend +0 -358
  93. data/ext/nokogiri/xml_libxml2_hacks.c +0 -112
  94. data/ext/nokogiri/xml_libxml2_hacks.h +0 -12
  95. data/lib/nokogiri/css/parser_extras.rb +0 -91
  96. data/lib/nokogiri/ffi/encoding_handler.rb +0 -42
  97. data/lib/nokogiri/ffi/html/document.rb +0 -28
  98. data/lib/nokogiri/ffi/html/element_description.rb +0 -81
  99. data/lib/nokogiri/ffi/html/entity_lookup.rb +0 -16
  100. data/lib/nokogiri/ffi/html/sax/parser_context.rb +0 -38
  101. data/lib/nokogiri/ffi/io_callbacks.rb +0 -42
  102. data/lib/nokogiri/ffi/libxml.rb +0 -420
  103. data/lib/nokogiri/ffi/structs/common_node.rb +0 -38
  104. data/lib/nokogiri/ffi/structs/html_elem_desc.rb +0 -24
  105. data/lib/nokogiri/ffi/structs/html_entity_desc.rb +0 -13
  106. data/lib/nokogiri/ffi/structs/xml_alloc.rb +0 -16
  107. data/lib/nokogiri/ffi/structs/xml_attr.rb +0 -20
  108. data/lib/nokogiri/ffi/structs/xml_attribute.rb +0 -27
  109. data/lib/nokogiri/ffi/structs/xml_buffer.rb +0 -16
  110. data/lib/nokogiri/ffi/structs/xml_char_encoding_handler.rb +0 -11
  111. data/lib/nokogiri/ffi/structs/xml_document.rb +0 -117
  112. data/lib/nokogiri/ffi/structs/xml_dtd.rb +0 -28
  113. data/lib/nokogiri/ffi/structs/xml_element.rb +0 -26
  114. data/lib/nokogiri/ffi/structs/xml_element_content.rb +0 -17
  115. data/lib/nokogiri/ffi/structs/xml_entity.rb +0 -32
  116. data/lib/nokogiri/ffi/structs/xml_enumeration.rb +0 -12
  117. data/lib/nokogiri/ffi/structs/xml_node.rb +0 -28
  118. data/lib/nokogiri/ffi/structs/xml_node_set.rb +0 -53
  119. data/lib/nokogiri/ffi/structs/xml_notation.rb +0 -11
  120. data/lib/nokogiri/ffi/structs/xml_ns.rb +0 -15
  121. data/lib/nokogiri/ffi/structs/xml_parser_context.rb +0 -20
  122. data/lib/nokogiri/ffi/structs/xml_parser_input.rb +0 -19
  123. data/lib/nokogiri/ffi/structs/xml_relax_ng.rb +0 -14
  124. data/lib/nokogiri/ffi/structs/xml_sax_handler.rb +0 -51
  125. data/lib/nokogiri/ffi/structs/xml_sax_push_parser_context.rb +0 -124
  126. data/lib/nokogiri/ffi/structs/xml_schema.rb +0 -13
  127. data/lib/nokogiri/ffi/structs/xml_syntax_error.rb +0 -31
  128. data/lib/nokogiri/ffi/structs/xml_text_reader.rb +0 -12
  129. data/lib/nokogiri/ffi/structs/xml_xpath_context.rb +0 -38
  130. data/lib/nokogiri/ffi/structs/xml_xpath_object.rb +0 -35
  131. data/lib/nokogiri/ffi/structs/xml_xpath_parser_context.rb +0 -20
  132. data/lib/nokogiri/ffi/structs/xslt_stylesheet.rb +0 -13
  133. data/lib/nokogiri/ffi/weak_bucket.rb +0 -40
  134. data/lib/nokogiri/ffi/xml/attr.rb +0 -41
  135. data/lib/nokogiri/ffi/xml/attribute_decl.rb +0 -27
  136. data/lib/nokogiri/ffi/xml/cdata.rb +0 -19
  137. data/lib/nokogiri/ffi/xml/comment.rb +0 -18
  138. data/lib/nokogiri/ffi/xml/document.rb +0 -174
  139. data/lib/nokogiri/ffi/xml/document_fragment.rb +0 -21
  140. data/lib/nokogiri/ffi/xml/dtd.rb +0 -67
  141. data/lib/nokogiri/ffi/xml/element_content.rb +0 -43
  142. data/lib/nokogiri/ffi/xml/element_decl.rb +0 -19
  143. data/lib/nokogiri/ffi/xml/entity_decl.rb +0 -36
  144. data/lib/nokogiri/ffi/xml/entity_reference.rb +0 -19
  145. data/lib/nokogiri/ffi/xml/namespace.rb +0 -44
  146. data/lib/nokogiri/ffi/xml/node.rb +0 -559
  147. data/lib/nokogiri/ffi/xml/node_set.rb +0 -150
  148. data/lib/nokogiri/ffi/xml/processing_instruction.rb +0 -20
  149. data/lib/nokogiri/ffi/xml/reader.rb +0 -236
  150. data/lib/nokogiri/ffi/xml/relax_ng.rb +0 -85
  151. data/lib/nokogiri/ffi/xml/sax/parser.rb +0 -143
  152. data/lib/nokogiri/ffi/xml/sax/parser_context.rb +0 -79
  153. data/lib/nokogiri/ffi/xml/sax/push_parser.rb +0 -51
  154. data/lib/nokogiri/ffi/xml/schema.rb +0 -109
  155. data/lib/nokogiri/ffi/xml/syntax_error.rb +0 -98
  156. data/lib/nokogiri/ffi/xml/text.rb +0 -18
  157. data/lib/nokogiri/ffi/xml/xpath.rb +0 -9
  158. data/lib/nokogiri/ffi/xml/xpath_context.rb +0 -153
  159. data/lib/nokogiri/ffi/xslt/stylesheet.rb +0 -77
  160. data/test/decorators/test_slop.rb +0 -16
  161. data/test/ffi/test_document.rb +0 -35
  162. data/test/files/encoding.html +0 -82
  163. data/test/files/encoding.xhtml +0 -84
  164. data/test/xslt/test_custom_functions.rb +0 -94
@@ -19,19 +19,11 @@ module Nokogiri
19
19
  # Save as HTML
20
20
  AS_HTML = 64
21
21
 
22
- # the default for XML documents
23
- DEFAULT_XML = FORMAT | AS_XML
24
- # the default for HTML document
25
- DEFAULT_HTML = FORMAT | NO_DECLARATION | NO_EMPTY_TAGS | AS_HTML
26
- # the default for XHTML document
27
- DEFAULT_XHTML = FORMAT | NO_DECLARATION | NO_EMPTY_TAGS | AS_XHTML
28
-
29
22
  # Integer representation of the SaveOptions
30
23
  attr_reader :options
31
24
 
32
25
  # Create a new SaveOptions object with +options+
33
26
  def initialize options = 0; @options = options; end
34
-
35
27
  constants.each do |constant|
36
28
  class_eval %{
37
29
  def #{constant.downcase}
@@ -44,8 +36,6 @@ module Nokogiri
44
36
  end
45
37
  }
46
38
  end
47
-
48
- alias :to_i :options
49
39
  end
50
40
  end
51
41
  end
@@ -42,7 +42,7 @@ module Nokogiri
42
42
  end
43
43
 
44
44
  ###
45
- # Returns the index of the first node in self that is == to +node+. Returns nil if no match is found.
45
+ # Returns the index of the first node in self that is == to +node+. Returns nil if no match is found.
46
46
  def index(node)
47
47
  each_with_index { |member, j| return j if member == node }
48
48
  nil
@@ -104,7 +104,7 @@ module Nokogiri
104
104
 
105
105
  each do |node|
106
106
  doc = node.document
107
- search_ns = ns || (doc.root ? doc.root.namespaces : {})
107
+ search_ns = ns || doc.root ? doc.root.namespaces : {}
108
108
 
109
109
  xpaths = paths.map { |rule|
110
110
  [
@@ -138,13 +138,6 @@ module Nokogiri
138
138
  sub_set
139
139
  end
140
140
 
141
- ###
142
- # Search this NodeSet's nodes' immediate children using CSS selector +selector+
143
- def > selector
144
- ns = document.root.namespaces
145
- xpath CSS.xpath_for(selector, :prefix => "./", :ns => ns).first
146
- end
147
-
148
141
  ###
149
142
  # If path is a string, search this document for +path+ returning the
150
143
  # first Node. Otherwise, index in to the array with +path+.
@@ -154,24 +147,6 @@ module Nokogiri
154
147
  end
155
148
  alias :% :at
156
149
 
157
- ##
158
- # Search this NodeSet for the first occurrence of XPath +paths+.
159
- # Equivalent to <tt>xpath(paths).first</tt>
160
- # See NodeSet#xpath for more information.
161
- #
162
- def at_xpath *paths
163
- xpath(*paths).first
164
- end
165
-
166
- ##
167
- # Search this NodeSet for the first occurrence of CSS +rules+.
168
- # Equivalent to <tt>css(rules).first</tt>
169
- # See NodeSet#css for more information.
170
- #
171
- def at_css *rules
172
- css(*rules).first
173
- end
174
-
175
150
  ###
176
151
  # Filter this list for nodes that match +expr+
177
152
  def filter expr
@@ -257,7 +232,7 @@ module Nokogiri
257
232
  # Wrap this NodeSet with +html+ or the results of the builder in +blk+
258
233
  def wrap(html, &blk)
259
234
  each do |j|
260
- new_parent = document.parse(html).first
235
+ new_parent = document.root.parse(html).first
261
236
  j.add_next_sibling(new_parent)
262
237
  new_parent.add_child(j)
263
238
  end
@@ -37,14 +37,6 @@ module Nokogiri
37
37
  NOCDATA = 1 << 14
38
38
  # do not generate XINCLUDE START/END nodes
39
39
  NOXINCNODE = 1 << 15
40
- # compact small text nodes; no modification of the tree allowed afterwards (will possibly crash if you try to modify the tree)
41
- COMPACT = 1 << 16
42
- # parse using XML-1.0 before update 5
43
- OLD10 = 1 << 17
44
- # do not fixup XINCLUDE xml:base uris
45
- NOBASEFIX = 1 << 18
46
- # relax any hardcoded limit from the parser
47
- HUGE = 1 << 19
48
40
 
49
41
  # the default options used for parsing XML documents
50
42
  DEFAULT_XML = RECOVER
@@ -30,42 +30,6 @@ module Nokogiri
30
30
  class Reader
31
31
  include Enumerable
32
32
 
33
- TYPE_NONE = 0
34
- # Element node type
35
- TYPE_ELEMENT = 1
36
- # Attribute node type
37
- TYPE_ATTRIBUTE = 2
38
- # Text node type
39
- TYPE_TEXT = 3
40
- # CDATA node type
41
- TYPE_CDATA = 4
42
- # Entity Reference node type
43
- TYPE_ENTITY_REFERENCE = 5
44
- # Entity node type
45
- TYPE_ENTITY = 6
46
- # PI node type
47
- TYPE_PROCESSING_INSTRUCTION = 7
48
- # Comment node type
49
- TYPE_COMMENT = 8
50
- # Document node type
51
- TYPE_DOCUMENT = 9
52
- # Document Type node type
53
- TYPE_DOCUMENT_TYPE = 10
54
- # Document Fragment node type
55
- TYPE_DOCUMENT_FRAGMENT = 11
56
- # Notation node type
57
- TYPE_NOTATION = 12
58
- # Whitespace node type
59
- TYPE_WHITESPACE = 13
60
- # Significant Whitespace node type
61
- TYPE_SIGNIFICANT_WHITESPACE = 14
62
- # Element end node type
63
- TYPE_END_ELEMENT = 15
64
- # Entity end node type
65
- TYPE_END_ENTITY = 16
66
- # XML Declaration node type
67
- TYPE_XML_DECLARATION = 17
68
-
69
33
  # A list of errors encountered while parsing
70
34
  attr_accessor :errors
71
35
 
@@ -75,8 +39,6 @@ module Nokogiri
75
39
  # The XML source
76
40
  attr_reader :source
77
41
 
78
- alias :self_closing? :empty_element?
79
-
80
42
  def initialize source, url = nil, encoding = nil # :nodoc:
81
43
  @source = source
82
44
  @errors = []
@@ -87,9 +49,9 @@ module Nokogiri
87
49
  ###
88
50
  # Get a list of attributes for the current node.
89
51
  def attributes
90
- Hash[*attribute_nodes.map { |node|
52
+ Hash[*(attribute_nodes.map { |node|
91
53
  [node.name, node.to_s]
92
- }.flatten].merge(namespaces || {})
54
+ }.flatten)].merge(namespaces || {})
93
55
  end
94
56
 
95
57
  ###
@@ -101,10 +63,10 @@ module Nokogiri
101
63
  end
102
64
 
103
65
  ###
104
- # Move the cursor through the document yielding the cursor to the block
105
- def each
106
- while cursor = self.read
107
- yield cursor
66
+ # Move the cursor through the document yielding each node to the block
67
+ def each(&block)
68
+ while node = self.read
69
+ block.call(node)
108
70
  end
109
71
  end
110
72
  end
@@ -8,7 +8,7 @@ module Nokogiri
8
8
  # The basic way a SAX style parser works is by creating a parser,
9
9
  # telling the parser about the events we're interested in, then giving
10
10
  # the parser some XML to process. The parser will notify you when
11
- # it encounters events you said you would like to know about.
11
+ # it encounters events your said you would like to know about.
12
12
  #
13
13
  # To register for events, you simply subclass Nokogiri::XML::SAX::Document,
14
14
  # and implement the methods for which you would like notification.
@@ -36,7 +36,7 @@ module Nokogiri
36
36
  # parser.parse(File.read(ARGV[0], 'rb'))
37
37
  #
38
38
  # Now my document handler will be called when each node starts, and when
39
- # the document ends. To see what kinds of events are available, take
39
+ # then document ends. To see what kinds of events are available, take
40
40
  # a look at Nokogiri::XML::SAX::Document.
41
41
  #
42
42
  # Two SAX parsers for XML are available, a parser that reads from a string
@@ -85,9 +85,7 @@ module Nokogiri
85
85
 
86
86
  ###
87
87
  # Called at the beginning of an element
88
- # * +name+ is the name of the tag
89
- # * +attrs+ are an assoc list of namespaces and attributes, e.g.:
90
- # [ ["xmlns:foo", "http://sample.net"], ["size", "large"] ]
88
+ # +name+ is the name of the tag with +attrs+ as attributes
91
89
  def start_element name, attrs = []
92
90
  end
93
91
 
@@ -112,7 +110,7 @@ module Nokogiri
112
110
  [['xmlns', ns_prefix].compact.join(':'), ns_uri]
113
111
  } + attrs.map { |attr|
114
112
  [[attr.prefix, attr.localname].compact.join(':'), attr.value]
115
- }
113
+ }.flatten
116
114
  start_element name, attributes
117
115
  end
118
116
 
@@ -128,9 +126,7 @@ module Nokogiri
128
126
  end
129
127
 
130
128
  ###
131
- # Characters read between a tag. This method might be called multiple
132
- # times given one contiguous string of characters.
133
- #
129
+ # Characters read between a tag
134
130
  # +string+ contains the character data
135
131
  def characters string
136
132
  end
@@ -43,13 +43,7 @@ module Nokogiri
43
43
  # Nokogiri::XML::SyntaxError objects found while validating the
44
44
  # +thing+ is returned.
45
45
  def validate thing
46
- if thing.is_a?(Nokogiri::XML::Document)
47
- validate_document(thing)
48
- elsif File.file?(thing)
49
- validate_file(thing)
50
- else
51
- raise ArgumentError, "Must provide Nokogiri::Xml::Document or the name of an existing file"
52
- end
46
+ thing.is_a?(Nokogiri::XML::Document) ? validate_document(thing) : validate_file(thing)
53
47
  end
54
48
 
55
49
  ###
data/lib/nokogiri/xslt.rb CHANGED
@@ -9,8 +9,8 @@ module Nokogiri
9
9
  #
10
10
  # xslt = Nokogiri::XSLT(File.read(ARGV[0]))
11
11
  #
12
- def XSLT stylesheet, modules = {}
13
- XSLT.parse(stylesheet, modules)
12
+ def XSLT stylesheet
13
+ XSLT.parse(stylesheet)
14
14
  end
15
15
  end
16
16
 
@@ -20,15 +20,11 @@ module Nokogiri
20
20
  module XSLT
21
21
  class << self
22
22
  ###
23
- # Parse the stylesheet in +string+, register any +modules+
24
- def parse string, modules = {}
25
- modules.each do |url, klass|
26
- XSLT.register url, klass
27
- end
28
-
23
+ # Parse the stylesheet in +string+
24
+ def parse string
29
25
  Stylesheet.parse_stylesheet_doc(XML.parse(string))
30
26
  end
31
-
27
+
32
28
  ###
33
29
  # Quote parameters in +params+ for stylesheet safety
34
30
  def quote_params params
@@ -6,7 +6,6 @@ ZLIB = 'zlib-1.2.5'
6
6
  ICONV = 'libiconv-1.13.1'
7
7
  LIBXML = 'libxml2-2.7.7'
8
8
  LIBXSLT = 'libxslt-1.1.26'
9
- RAKE_COMPILER_PKGCONFIG = File.expand_path(File.join(Dir.pwd, "tmp/cross/lib/pkgconfig/"))
10
9
 
11
10
  ### Build zlib ###
12
11
  file "tmp/cross/download/#{ZLIB}" do |t|
@@ -27,6 +26,7 @@ file "tmp/cross/download/#{ZLIB}" do |t|
27
26
  f.puts "LIBRARY_PATH = #{CROSS_DIR}/lib"
28
27
  f.puts "INCLUDE_PATH = #{CROSS_DIR}/include"
29
28
 
29
+ # FIXME: need to make the cross compiler dynamic
30
30
  f.puts mk.sub(/^PREFIX\s*=\s*$/, "PREFIX = #{HOST}-") #.
31
31
  #sub(/^SHARED_MODE=0$/, 'SHARED_MODE=1').
32
32
  #sub(/^IMPLIB\s*=.*$/, 'IMPLIB=libz.dll.a')
@@ -55,6 +55,7 @@ file "tmp/cross/download/#{ICONV}" do |t|
55
55
  end
56
56
 
57
57
  Dir.chdir t.name do
58
+ # FIXME: need to make the host dynamic
58
59
  sh "./configure --disable-shared --enable-static --host=#{HOST} --target=#{TARGET} --prefix=#{CROSS_DIR} CPPFLAGS='-mno-cygwin -Wall' CFLAGS='-mno-cygwin -O2 -g' CXXFLAGS='-mno-cygwin -O2 -g' LDFLAGS=-mno-cygwin"
59
60
  end
60
61
  end
@@ -80,6 +81,7 @@ file "tmp/cross/download/#{LIBXML}" do |t|
80
81
  end
81
82
 
82
83
  Dir.chdir t.name do
84
+ # FIXME: need to make the host dynamic
83
85
  sh "CFLAGS='-DIN_LIBXML' ./configure --host=#{HOST} --target=#{TARGET} --enable-static --disable-shared --prefix=#{CROSS_DIR} --with-zlib=#{CROSS_DIR} --with-iconv=#{CROSS_DIR} --without-python --without-readline"
84
86
  end
85
87
  end
@@ -105,7 +107,8 @@ file "tmp/cross/download/#{LIBXSLT}" do |t|
105
107
  end
106
108
 
107
109
  Dir.chdir t.name do
108
- sh "CFLAGS='-DIN_LIBXML' ./configure --host=#{HOST} --target=#{TARGET} --enable-static --disable-shared --prefix=#{CROSS_DIR} --with-libxml-prefix=#{CROSS_DIR} --without-python --without-crypto"
110
+ # FIXME: need to make the host dynamic
111
+ sh "CFLAGS='-DIN_LIBXML' ./configure --host=#{HOST} --target=#{TARGET} --enable-static --disable-shared --prefix=#{CROSS_DIR} --with-libxml-prefix=#{CROSS_DIR} --without-python"
109
112
  end
110
113
  end
111
114
 
@@ -117,7 +120,7 @@ file 'tmp/cross/bin/xslt-config' => "tmp/cross/download/#{LIBXSLT}" do |t|
117
120
  end
118
121
  ### End build libxslt ###
119
122
 
120
- file 'lib/nokogiri/nokogiri.rb' => 'cross:check' do
123
+ file 'lib/nokogiri/nokogiri.rb' => 'cross:libxslt' do
121
124
  File.open("lib/#{HOE.name}/#{HOE.name}.rb", 'wb') do |f|
122
125
  f.write <<-eoruby
123
126
  require "#{HOE.name}/\#{RUBY_VERSION.sub(/\\.\\d+$/, '')}/#{HOE.name}"
@@ -131,43 +134,25 @@ namespace :cross do
131
134
  task :libxml2 => ['cross:zlib', 'cross:iconv', 'tmp/cross/bin/xml2-config']
132
135
  task :libxslt => ['cross:libxml2', 'tmp/cross/bin/xslt-config']
133
136
 
134
- task :check => ["cross:libxslt"] do
135
- unless File.directory?(RAKE_COMPILER_PKGCONFIG)
136
- raise RuntimeError.new("looks like rake-compiler changed where pkgconfig info is kept. (#{RAKE_COMPILER_PKGCONFIG})")
137
+ task :copy_dlls do
138
+ Dir['tmp/cross/bin/*.dll'].each do |file|
139
+ cp file, "ext/nokogiri"
137
140
  end
138
141
  end
139
142
 
140
- task :file_list do
143
+ task :file_list => 'cross:copy_dlls' do
141
144
  HOE.spec.extensions = []
142
145
  HOE.spec.files += Dir["lib/#{HOE.name}/#{HOE.name}.rb"]
143
146
  HOE.spec.files += Dir["lib/#{HOE.name}/1.{8,9}/#{HOE.name}.so"]
147
+ HOE.spec.files += Dir["ext/nokogiri/*.dll"]
144
148
  end
145
149
  end
146
150
 
147
151
  CLOBBER.include("lib/nokogiri/nokogiri.{so,dylib,rb,bundle}")
148
152
  CLOBBER.include("lib/nokogiri/1.{8,9}")
153
+ CLOBBER.include("ext/nokogiri/*.dll")
149
154
 
150
155
  if Rake::Task.task_defined?(:cross)
151
156
  Rake::Task[:cross].prerequisites << "lib/nokogiri/nokogiri.rb"
152
157
  Rake::Task[:cross].prerequisites << "cross:file_list"
153
158
  end
154
-
155
- desc "build a windows gem without all the ceremony."
156
- task "gem:windows" do
157
- rake_compiler_config = YAML.load_file("#{ENV['HOME']}/.rake-compiler/config.yml")
158
-
159
- # check that rake-compiler config contains the right patchlevels of 1.8.6 and 1.9.1. see #279.
160
- ["1.8.6-p383", "1.9.1-p243"].each do |version|
161
- majmin, patchlevel = version.split("-")
162
- rbconfig = "rbconfig-#{majmin}"
163
- unless rake_compiler_config.key?(rbconfig) && rake_compiler_config[rbconfig] =~ /-#{patchlevel}/
164
- raise "rake-compiler '#{rbconfig}' not #{patchlevel}. try running 'env --unset=HOST rake-compiler cross-ruby VERSION=#{version}'"
165
- end
166
- end
167
-
168
- # verify that --export-all is in the 1.9.1 rbconfig. see #279,#374,#375.
169
- rbconfig_191 = rake_compiler_config["rbconfig-1.9.1"]
170
- raise "rbconfig #{rbconfig_191} needs --export-all in its DLDFLAGS value" if File.read(rbconfig_191).grep(/CONFIG\["DLDFLAGS"\].*--export-all/).empty?
171
-
172
- system("env PKG_CONFIG_PATH=#{RAKE_COMPILER_PKGCONFIG} RUBY_CC_VERSION=1.8.6:1.9.1 rake cross native gem") || raise("build failed!")
173
- end
data/tasks/test.rb CHANGED
File without changes
@@ -16,10 +16,6 @@ module Nokogiri
16
16
  assert_raises(CSS::SyntaxError) { @parser.parse("a[x=]") }
17
17
  end
18
18
 
19
- def test_function_and_pseudo
20
- assert_xpath '//child::text()[position() = 99]', @parser.parse('text():nth-of-type(99)')
21
- end
22
-
23
19
  def test_find_by_type
24
20
  ast = @parser.parse("a:nth-child(2)").first
25
21
  matches = ast.find_by_type(
@@ -142,31 +138,30 @@ module Nokogiri
142
138
 
143
139
  def test_nonstandard_nth_selectors
144
140
  ## These are non standard CSS
145
- assert_xpath '//a[position() = 1]', @parser.parse('a:first()')
146
- assert_xpath '//a[position() = 1]', @parser.parse('a:first') # no parens
147
- assert_xpath '//a[position() = 99]', @parser.parse('a:eq(99)')
148
- assert_xpath '//a[position() = 99]', @parser.parse('a:nth(99)')
149
- assert_xpath '//a[position() = last()]', @parser.parse('a:last()')
150
- assert_xpath '//a[position() = last()]', @parser.parse('a:last') # no parens
151
- assert_xpath '//a[node()]', @parser.parse('a:parent')
141
+ assert_xpath '//a[position() = 99]', @parser.parse('a:eq(99)')
142
+ assert_xpath '//a[position() = 1]', @parser.parse('a:first') # no parens
143
+ assert_xpath '//a[position() = last()]', @parser.parse('a:last') # no parens
144
+ assert_xpath '//a[position() = 99]', @parser.parse('a:nth(99)')
145
+ assert_xpath '//a[position() = 1]', @parser.parse('a:first()')
146
+ assert_xpath '//a[position() = last()]', @parser.parse('a:last()')
147
+ assert_xpath '//a[node()]', @parser.parse('a:parent')
152
148
  end
153
149
 
154
150
  def test_standard_nth_selectors
155
- assert_xpath '//a[position() = 1]', @parser.parse('a:first-of-type()')
156
- assert_xpath '//a[position() = 1]', @parser.parse('a:first-of-type') # no parens
157
- assert_xpath '//a[position() = 99]', @parser.parse('a:nth-of-type(99)')
158
- assert_xpath '//a[position() = last()]', @parser.parse('a:last-of-type()')
159
- assert_xpath '//a[position() = last()]', @parser.parse('a:last-of-type') # no parens
160
- assert_xpath '//a[position() = last()]', @parser.parse('a:nth-last-of-type(1)')
161
- assert_xpath '//a[position() = last() - 98]', @parser.parse('a:nth-last-of-type(99)')
151
+ assert_xpath '//a[position() = 99]', @parser.parse('a:nth-of-type(99)')
152
+ assert_xpath '//a[position() = 1]', @parser.parse('a:first-of-type()')
153
+ assert_xpath '//a[position() = last()]', @parser.parse('a:last-of-type()')
154
+ assert_xpath '//a[position() = 1]', @parser.parse('a:first-of-type') # no parens
155
+ assert_xpath '//a[position() = last()]', @parser.parse('a:last-of-type') # no parens
156
+ assert_xpath '//a[position() = last() - 99]', @parser.parse('a:nth-last-of-type(99)')
157
+ assert_xpath '//a[position() = last() - 99]', @parser.parse('a:nth-last-of-type(99)')
162
158
  end
163
159
 
164
160
  def test_nth_child_selectors
165
- assert_xpath '//*[position() = 1 and self::a]', @parser.parse('a:first-child')
166
- assert_xpath '//*[position() = 99 and self::a]', @parser.parse('a:nth-child(99)')
167
- assert_xpath '//*[position() = last() and self::a]', @parser.parse('a:last-child')
168
- assert_xpath '//*[position() = last() and self::a]', @parser.parse('a:nth-last-child(1)')
169
- assert_xpath '//*[position() = last() - 98 and self::a]', @parser.parse('a:nth-last-child(99)')
161
+ assert_xpath '//*[position() = 1 and self::a]', @parser.parse('a:first-child')
162
+ assert_xpath '//*[position() = last() and self::a]', @parser.parse('a:last-child')
163
+ assert_xpath '//*[position() = 99 and self::a]', @parser.parse('a:nth-child(99)')
164
+ assert_xpath '//*[position() = last() - 99 and self::a]', @parser.parse('a:nth-last-child(99)')
170
165
  end
171
166
 
172
167
  def test_miscellaneous_selectors
@@ -186,32 +181,16 @@ module Nokogiri
186
181
  assert_xpath '//a[(position() <= 3) and (((position()-3) mod 1) = 0)]', @parser.parse('a:nth-of-type(-n+3)')
187
182
  assert_xpath '//a[(position() >= 3) and (((position()-3) mod 1) = 0)]', @parser.parse('a:nth-of-type(1n+3)')
188
183
  assert_xpath '//a[(position() >= 3) and (((position()-3) mod 1) = 0)]', @parser.parse('a:nth-of-type(n+3)')
189
-
190
- assert_xpath '//a[((last()-position()+1) mod 2) = 0]', @parser.parse('a:nth-last-of-type(2n)')
191
- assert_xpath '//a[((last()-position()+1) >= 1) and ((((last()-position()+1)-1) mod 2) = 0)]', @parser.parse('a:nth-last-of-type(2n+1)')
192
- assert_xpath '//a[((last()-position()+1) mod 2) = 0]', @parser.parse('a:nth-last-of-type(even)')
193
- assert_xpath '//a[((last()-position()+1) >= 1) and ((((last()-position()+1)-1) mod 2) = 0)]', @parser.parse('a:nth-last-of-type(odd)')
194
- assert_xpath '//a[((last()-position()+1) >= 3) and ((((last()-position()+1)-3) mod 4) = 0)]', @parser.parse('a:nth-last-of-type(4n+3)')
195
- assert_xpath '//a[((last()-position()+1) <= 3) and ((((last()-position()+1)-3) mod 1) = 0)]', @parser.parse('a:nth-last-of-type(-1n+3)')
196
- assert_xpath '//a[((last()-position()+1) <= 3) and ((((last()-position()+1)-3) mod 1) = 0)]', @parser.parse('a:nth-last-of-type(-n+3)')
197
- assert_xpath '//a[((last()-position()+1) >= 3) and ((((last()-position()+1)-3) mod 1) = 0)]', @parser.parse('a:nth-last-of-type(1n+3)')
198
- assert_xpath '//a[((last()-position()+1) >= 3) and ((((last()-position()+1)-3) mod 1) = 0)]', @parser.parse('a:nth-last-of-type(n+3)')
199
184
  end
200
185
 
201
186
  def test_preceding_selector
202
- assert_xpath "//E/following-sibling::F",
187
+ assert_xpath "//F[preceding-sibling::E]",
203
188
  @parser.parse("E ~ F")
204
-
205
- assert_xpath "//E/following-sibling::F//G",
206
- @parser.parse("E ~ F G")
207
189
  end
208
190
 
209
191
  def test_direct_preceding_selector
210
192
  assert_xpath "//E/following-sibling::*[1]/self::F",
211
193
  @parser.parse("E + F")
212
-
213
- assert_xpath "//E/following-sibling::*[1]/self::F//G",
214
- @parser.parse("E + F G")
215
194
  end
216
195
 
217
196
  def test_attribute