nokogiri 1.1.1 → 1.2.0

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 (88) hide show
  1. data/History.ja.txt +34 -0
  2. data/History.txt +36 -0
  3. data/Manifest.txt +21 -0
  4. data/README.ja.txt +1 -1
  5. data/README.txt +1 -1
  6. data/Rakefile +27 -89
  7. data/ext/nokogiri/extconf.rb +48 -63
  8. data/ext/nokogiri/html_document.c +90 -29
  9. data/ext/nokogiri/html_sax_parser.c +23 -2
  10. data/ext/nokogiri/native.c +18 -8
  11. data/ext/nokogiri/native.h +22 -0
  12. data/ext/nokogiri/xml_attr.c +83 -0
  13. data/ext/nokogiri/xml_attr.h +9 -0
  14. data/ext/nokogiri/xml_cdata.c +1 -1
  15. data/ext/nokogiri/xml_document.c +84 -18
  16. data/ext/nokogiri/xml_document_fragment.c +38 -0
  17. data/ext/nokogiri/xml_document_fragment.h +10 -0
  18. data/ext/nokogiri/xml_dtd.c +2 -22
  19. data/ext/nokogiri/xml_entity_reference.c +41 -0
  20. data/ext/nokogiri/xml_entity_reference.h +9 -0
  21. data/ext/nokogiri/xml_io.c +10 -3
  22. data/ext/nokogiri/xml_io.h +1 -0
  23. data/ext/nokogiri/xml_node.c +116 -66
  24. data/ext/nokogiri/xml_node_set.c +5 -1
  25. data/ext/nokogiri/xml_processing_instruction.c +44 -0
  26. data/ext/nokogiri/xml_processing_instruction.h +9 -0
  27. data/ext/nokogiri/xml_reader.c +20 -4
  28. data/ext/nokogiri/xml_sax_parser.c +51 -15
  29. data/ext/nokogiri/xml_sax_push_parser.c +85 -0
  30. data/ext/nokogiri/xml_sax_push_parser.h +9 -0
  31. data/ext/nokogiri/xml_syntax_error.c +12 -8
  32. data/ext/nokogiri/xml_syntax_error.h +2 -1
  33. data/ext/nokogiri/xml_xpath_context.c +11 -2
  34. data/ext/nokogiri/xslt_stylesheet.c +1 -6
  35. data/lib/nokogiri.rb +10 -13
  36. data/lib/nokogiri/css.rb +1 -1
  37. data/lib/nokogiri/css/generated_parser.rb +287 -295
  38. data/lib/nokogiri/css/generated_tokenizer.rb +36 -51
  39. data/lib/nokogiri/css/node.rb +1 -3
  40. data/lib/nokogiri/css/parser.rb +21 -12
  41. data/lib/nokogiri/css/parser.y +55 -44
  42. data/lib/nokogiri/css/syntax_error.rb +2 -1
  43. data/lib/nokogiri/css/tokenizer.rex +23 -32
  44. data/lib/nokogiri/decorators/hpricot/node_set.rb +1 -1
  45. data/lib/nokogiri/html.rb +10 -4
  46. data/lib/nokogiri/html/document.rb +6 -2
  47. data/lib/nokogiri/syntax_error.rb +4 -0
  48. data/lib/nokogiri/version.rb +2 -1
  49. data/lib/nokogiri/xml.rb +3 -1
  50. data/lib/nokogiri/xml/attr.rb +3 -4
  51. data/lib/nokogiri/xml/cdata.rb +1 -1
  52. data/lib/nokogiri/xml/document.rb +4 -7
  53. data/lib/nokogiri/xml/document_fragment.rb +9 -0
  54. data/lib/nokogiri/xml/dtd.rb +3 -0
  55. data/lib/nokogiri/xml/node.rb +144 -40
  56. data/lib/nokogiri/xml/node/save_options.rb +32 -0
  57. data/lib/nokogiri/xml/node_set.rb +11 -20
  58. data/lib/nokogiri/xml/processing_instruction.rb +6 -0
  59. data/lib/nokogiri/xml/reader.rb +5 -0
  60. data/lib/nokogiri/xml/sax.rb +1 -0
  61. data/lib/nokogiri/xml/sax/push_parser.rb +47 -0
  62. data/lib/nokogiri/xml/syntax_error.rb +3 -1
  63. data/lib/nokogiri/xml/xpath/syntax_error.rb +1 -1
  64. data/tasks/test.rb +136 -0
  65. data/test/css/test_parser.rb +4 -0
  66. data/test/css/test_tokenizer.rb +30 -17
  67. data/test/css/test_xpath_visitor.rb +11 -0
  68. data/test/helper.rb +11 -0
  69. data/test/hpricot/test_builder.rb +2 -9
  70. data/test/hpricot/test_parser.rb +4 -4
  71. data/test/html/test_builder.rb +7 -7
  72. data/test/html/test_document.rb +90 -4
  73. data/test/html/test_node.rb +1 -0
  74. data/test/test_css_cache.rb +1 -3
  75. data/test/test_reader.rb +19 -1
  76. data/test/test_xslt_transforms.rb +1 -1
  77. data/test/xml/node/test_save_options.rb +20 -0
  78. data/test/xml/sax/test_parser.rb +17 -0
  79. data/test/xml/sax/test_push_parser.rb +67 -0
  80. data/test/xml/test_attr.rb +16 -0
  81. data/test/xml/test_cdata.rb +1 -1
  82. data/test/xml/test_document.rb +45 -0
  83. data/test/xml/test_document_fragment.rb +18 -0
  84. data/test/xml/test_dtd.rb +2 -4
  85. data/test/xml/test_entity_reference.rb +16 -0
  86. data/test/xml/test_node.rb +149 -80
  87. data/test/xml/test_processing_instruction.rb +24 -0
  88. metadata +28 -2
@@ -1,3 +1,37 @@
1
+ === 1.2.0 / 2008年2月22日
2
+
3
+ * 新しい機能
4
+ * CSSサーチが CSS3 名前空間クエリをサポートするようになった
5
+ * ルート要素での名前空間が自動的に登録されるようになった
6
+ * CSS クエリが初期設定の名前空間を使うようになった
7
+ * Nokogiri::XML::Document#encoding で文書にエンコードを使用、受け取る
8
+ * Nokogiri::XML::Document#url で文書のURLを受け取る
9
+ * Nokogiri::XML::Node#each はname属性、値を一組にし反復適用する
10
+ * Nokogiri::XML::Node#keys はすべてのname属性を受け取る
11
+ * Nokogiri::XML::Node#line は行番号をノード用に受け取る (Dirkjan Bussinkさんに感謝感激)
12
+ * Nokogiri::XML::Node#serialize は任意されたencodingパラメーターを受け入れる
13
+ * Nokogiri::XML::Node#to_html, to_xml, と to_xhtml は任意されたencodingパラメーターを受け入れる
14
+ * Nokogiri::XML::Node#to_str
15
+ * Nokogiri::XML::Node#to_xhtml でXHTML文書を生成する
16
+ * Nokogiri::XML::Node#values が全ての属性値を受け入れる
17
+ * Nokogiri::XML::Node#write_to は任意されたencodingで要素をIOオブジェクトへ書く
18
+ * Nokogiri::XML::ProcessingInstrunction.new
19
+ * Nokogiri::XML::SAX::PushParser は全てのプッシュパースに必要な解析をする
20
+
21
+ * バグの修正
22
+
23
+ * Nokogiri::XML::Document#dup を修正
24
+ * ヘッダ検知を修正. 謝々るびきちさん!
25
+ * 無効なCSS内にて解析機能を動かなくさせる原因を修正
26
+
27
+ * 廃棄予定
28
+
29
+ * Nokogiri::XML::Node.new_from_str は1.3.0にて廃棄予定
30
+
31
+ * APIの変更
32
+
33
+ * Nokogiri::HTML.fragment は XML::DocumentFragment (LH #32)で返す
34
+
1
35
  === 1.1.1
2
36
 
3
37
  * 新しい機能
@@ -1,3 +1,39 @@
1
+ === 1.2.0 / 2008-02-22
2
+
3
+ * New features
4
+
5
+ * CSS search now supports CSS3 namespace queries
6
+ * Namespaces on the root node are automatically registered
7
+ * CSS queries use the default namespace
8
+ * Nokogiri::XML::Document#encoding get encoding used for this document
9
+ * Nokogiri::XML::Document#url get the document url
10
+ * Nokogiri::XML::Node#add_namespace add a namespace to the node LH#38
11
+ * Nokogiri::XML::Node#each iterate over attribute name, value pairs
12
+ * Nokogiri::XML::Node#keys get all attribute names
13
+ * Nokogiri::XML::Node#line get the line number for a node (Thanks Dirkjan Bussink!)
14
+ * Nokogiri::XML::Node#serialize now takes an optional encoding parameter
15
+ * Nokogiri::XML::Node#to_html, to_xml, and to_xhtml take an optional encoding
16
+ * Nokogiri::XML::Node#to_str
17
+ * Nokogiri::XML::Node#to_xhtml to produce XHTML documents
18
+ * Nokogiri::XML::Node#values get all attribute values
19
+ * Nokogiri::XML::Node#write_to writes the node to an IO object with optional encoding
20
+ * Nokogiri::XML::ProcessingInstrunction.new
21
+ * Nokogiri::XML::SAX::PushParser for all your push parsing needs.
22
+
23
+ * Bugfixes
24
+
25
+ * Fixed Nokogiri::XML::Document#dup
26
+ * Fixed header detection. Thanks rubikitch!
27
+ * Fixed a problem where invalid CSS would cause the parser to hang
28
+
29
+ * Deprecations
30
+
31
+ * Nokogiri::XML::Node.new_from_str will be deprecated in 1.3.0
32
+
33
+ * API Changes
34
+
35
+ * Nokogiri::HTML.fragment now returns an XML::DocumentFragment (LH #32)
36
+
1
37
  === 1.1.1
2
38
 
3
39
  * New features
@@ -11,24 +11,34 @@ ext/nokogiri/html_sax_parser.c
11
11
  ext/nokogiri/html_sax_parser.h
12
12
  ext/nokogiri/native.c
13
13
  ext/nokogiri/native.h
14
+ ext/nokogiri/xml_attr.c
15
+ ext/nokogiri/xml_attr.h
14
16
  ext/nokogiri/xml_cdata.c
15
17
  ext/nokogiri/xml_cdata.h
16
18
  ext/nokogiri/xml_comment.c
17
19
  ext/nokogiri/xml_comment.h
18
20
  ext/nokogiri/xml_document.c
19
21
  ext/nokogiri/xml_document.h
22
+ ext/nokogiri/xml_document_fragment.c
23
+ ext/nokogiri/xml_document_fragment.h
20
24
  ext/nokogiri/xml_dtd.c
21
25
  ext/nokogiri/xml_dtd.h
26
+ ext/nokogiri/xml_entity_reference.c
27
+ ext/nokogiri/xml_entity_reference.h
22
28
  ext/nokogiri/xml_io.c
23
29
  ext/nokogiri/xml_io.h
24
30
  ext/nokogiri/xml_node.c
25
31
  ext/nokogiri/xml_node.h
26
32
  ext/nokogiri/xml_node_set.c
27
33
  ext/nokogiri/xml_node_set.h
34
+ ext/nokogiri/xml_processing_instruction.c
35
+ ext/nokogiri/xml_processing_instruction.h
28
36
  ext/nokogiri/xml_reader.c
29
37
  ext/nokogiri/xml_reader.h
30
38
  ext/nokogiri/xml_sax_parser.c
31
39
  ext/nokogiri/xml_sax_parser.h
40
+ ext/nokogiri/xml_sax_push_parser.c
41
+ ext/nokogiri/xml_sax_push_parser.h
32
42
  ext/nokogiri/xml_syntax_error.c
33
43
  ext/nokogiri/xml_syntax_error.h
34
44
  ext/nokogiri/xml_text.c
@@ -62,6 +72,7 @@ lib/nokogiri/html.rb
62
72
  lib/nokogiri/html/builder.rb
63
73
  lib/nokogiri/html/document.rb
64
74
  lib/nokogiri/html/sax/parser.rb
75
+ lib/nokogiri/syntax_error.rb
65
76
  lib/nokogiri/version.rb
66
77
  lib/nokogiri/xml.rb
67
78
  lib/nokogiri/xml/after_handler.rb
@@ -71,16 +82,20 @@ lib/nokogiri/xml/builder.rb
71
82
  lib/nokogiri/xml/cdata.rb
72
83
  lib/nokogiri/xml/comment.rb
73
84
  lib/nokogiri/xml/document.rb
85
+ lib/nokogiri/xml/document_fragment.rb
74
86
  lib/nokogiri/xml/dtd.rb
75
87
  lib/nokogiri/xml/element.rb
76
88
  lib/nokogiri/xml/entity_declaration.rb
77
89
  lib/nokogiri/xml/node.rb
90
+ lib/nokogiri/xml/node/save_options.rb
78
91
  lib/nokogiri/xml/node_set.rb
79
92
  lib/nokogiri/xml/notation.rb
93
+ lib/nokogiri/xml/processing_instruction.rb
80
94
  lib/nokogiri/xml/reader.rb
81
95
  lib/nokogiri/xml/sax.rb
82
96
  lib/nokogiri/xml/sax/document.rb
83
97
  lib/nokogiri/xml/sax/parser.rb
98
+ lib/nokogiri/xml/sax/push_parser.rb
84
99
  lib/nokogiri/xml/syntax_error.rb
85
100
  lib/nokogiri/xml/text.rb
86
101
  lib/nokogiri/xml/xpath.rb
@@ -88,6 +103,7 @@ lib/nokogiri/xml/xpath/syntax_error.rb
88
103
  lib/nokogiri/xml/xpath_context.rb
89
104
  lib/nokogiri/xslt.rb
90
105
  lib/nokogiri/xslt/stylesheet.rb
106
+ tasks/test.rb
91
107
  test/css/test_nthiness.rb
92
108
  test/css/test_parser.rb
93
109
  test/css/test_tokenizer.rb
@@ -127,15 +143,20 @@ test/test_memory_leak.rb
127
143
  test/test_nokogiri.rb
128
144
  test/test_reader.rb
129
145
  test/test_xslt_transforms.rb
146
+ test/xml/node/test_save_options.rb
130
147
  test/xml/sax/test_parser.rb
148
+ test/xml/sax/test_push_parser.rb
131
149
  test/xml/test_attr.rb
132
150
  test/xml/test_builder.rb
133
151
  test/xml/test_cdata.rb
134
152
  test/xml/test_comment.rb
135
153
  test/xml/test_document.rb
154
+ test/xml/test_document_fragment.rb
136
155
  test/xml/test_dtd.rb
156
+ test/xml/test_entity_reference.rb
137
157
  test/xml/test_node.rb
138
158
  test/xml/test_node_set.rb
159
+ test/xml/test_processing_instruction.rb
139
160
  test/xml/test_text.rb
140
161
  test/xml/test_xpath.rb
141
162
  vendor/hoe.rb
@@ -75,7 +75,7 @@ NokogiriはHpricotの代わりに使用出来る。
75
75
 
76
76
  (The MIT License)
77
77
 
78
- Copyright (c) 2008:
78
+ Copyright (c) 2008 - 2009:
79
79
 
80
80
  * {Aaron Patterson}[http://tenderlovemaking.com]
81
81
  * {Mike Dalessio}[http://mike.daless.io]
data/README.txt CHANGED
@@ -84,7 +84,7 @@ Developing Nokogiri requires racc and frex.
84
84
 
85
85
  (The MIT License)
86
86
 
87
- Copyright (c) 2008:
87
+ Copyright (c) 2008 - 2009:
88
88
 
89
89
  * {Aaron Patterson}[http://tenderlovemaking.com]
90
90
  * {Mike Dalessio}[http://mike.daless.io]
data/Rakefile CHANGED
@@ -33,6 +33,13 @@ HOE = Hoe.new('nokogiri', Nokogiri::VERSION) do |p|
33
33
  p.spec_extras = { :extensions => ["ext/nokogiri/extconf.rb"] }
34
34
  end
35
35
 
36
+ namespace :libxml do
37
+ desc "What version of LibXML are we building against?"
38
+ task :version => :build do
39
+ sh "#{RUBY} -Ilib:ext -rnokogiri -e 'puts Nokogiri::LIBXML_VERSION'"
40
+ end
41
+ end
42
+
36
43
  namespace :gem do
37
44
  namespace :dev do
38
45
  task :spec do
@@ -61,7 +68,7 @@ namespace :gem do
61
68
  namespace :jruby do
62
69
  task :spec => ['build'] do
63
70
  File.open("#{HOE.name}.gemspec", 'w') do |f|
64
- HOE.spec.platform = 'jruby'
71
+ HOE.spec.platform = 'java'
65
72
  HOE.spec.files << GENERATED_PARSER
66
73
  HOE.spec.files << GENERATED_TOKENIZER
67
74
  HOE.spec.extensions = []
@@ -81,12 +88,6 @@ namespace :gem do
81
88
  task :spec => ['gem:dev:spec']
82
89
  end
83
90
 
84
- desc "Run code-coverage analysis"
85
- task :coverage do
86
- rm_rf "coverage"
87
- sh "rcov -x Library -I lib:test #{Dir[*HOE.test_globs].join(' ')}"
88
- end
89
-
90
91
  file GENERATED_PARSER => "lib/nokogiri/css/parser.y" do |t|
91
92
  begin
92
93
  racc = `which racc`.strip
@@ -99,7 +100,7 @@ end
99
100
 
100
101
  file GENERATED_TOKENIZER => "lib/nokogiri/css/tokenizer.rex" do |t|
101
102
  begin
102
- sh "frex -i --independent -o #{t.name} #{t.prerequisites.first}"
103
+ sh "frex --independent -o #{t.name} #{t.prerequisites.first}"
103
104
  rescue
104
105
  abort "need frex, sudo gem install aaronp-frex -s http://gems.github.com"
105
106
  end
@@ -107,7 +108,7 @@ end
107
108
 
108
109
  task 'ext/nokogiri/Makefile' do
109
110
  Dir.chdir('ext/nokogiri') do
110
- ruby "extconf.rb"
111
+ ruby "extconf.rb #{ENV['EXTOPTS']}"
111
112
  end
112
113
  end
113
114
 
@@ -168,8 +169,19 @@ namespace :build do
168
169
  dash_i = File.expand_path(
169
170
  File.join(File.dirname(__FILE__), 'cross/lib/ruby/1.8/i386-mingw32/')
170
171
  )
172
+
173
+ xml2_lib =
174
+ File.join(File.dirname(__FILE__), 'cross/libxml2-2.7.3.win32/bin')
175
+ xml2_inc =
176
+ File.join(File.dirname(__FILE__), 'cross/libxml2-2.7.3.win32/include')
177
+
178
+ xslt_lib =
179
+ File.join(File.dirname(__FILE__), 'cross/libxslt-1.1.24.win32/bin')
180
+ xslt_inc =
181
+ File.join(File.dirname(__FILE__), 'cross/libxslt-1.1.24.win32/include')
182
+
171
183
  Dir.chdir('ext/nokogiri') do
172
- ruby " -I #{dash_i} extconf.rb"
184
+ ruby " -I #{dash_i} extconf.rb --with-xml2-lib=#{xml2_lib} --with-xml2-include=#{xml2_inc} --with-xslt-lib=#{xslt_lib} --with-xslt-include=#{xslt_inc}"
173
185
  sh 'make'
174
186
  end
175
187
  dlls = Dir[File.join(File.dirname(__FILE__), 'cross', '**/*.dll')]
@@ -182,7 +194,7 @@ namespace :build do
182
194
  libs = %w{
183
195
  iconv-1.9.2.win32
184
196
  zlib-1.2.3.win32
185
- libxml2-2.7.2.win32
197
+ libxml2-2.7.3.win32
186
198
  libxslt-1.1.24.win32
187
199
  }
188
200
 
@@ -231,86 +243,12 @@ task :debug do
231
243
  ENV['CFLAGS'] += " -DDEBUG"
232
244
  end
233
245
 
234
- def test_suite_cmdline
235
- require 'find'
236
- match = ENV['MATCH'] ? /#{ENV['MATCH']}/ : /./
246
+ require 'tasks/test'
237
247
 
238
- files = []
239
- Find.find("test") do |f|
240
- basename = File.basename(f)
241
-
242
- files << f if basename =~ /.*test.*\.rb$/ && basename =~ match
243
- end
244
- cmdline = "ruby -w -I.:lib:ext:test -rtest/unit -e '%w[#{files.join(' ')}].each {|f| require f}'"
245
- end
246
-
247
- class ValgrindTestTask < Rake::TestTask
248
- def initialize *args
249
- super
250
- %w[ ext lib bin test ].each do |dir|
251
- self.libs << dir
252
- end
253
- self.test_files = FileList['test/**/test_*.rb'] +
254
- FileList['test/**/*_test.rb']
255
- self.verbose = true
256
- self.warning = true
257
- end
258
- end
259
-
260
- VALGRIND_BASIC_OPTS = "--num-callers=50 --error-limit=no --partial-loads-ok=yes --undef-value-errors=no"
261
-
262
- desc "run test suite under valgrind with basic ruby options"
263
- ValgrindTestTask.new('test:valgrind').extend(Module.new {
264
- def ruby *args
265
- cmd = "valgrind #{VALGRIND_BASIC_OPTS} #{RUBY} #{args.join(' ')}"
266
- puts cmd
267
- system cmd
268
- end
269
- })
270
248
  Rake::Task['test:valgrind'].prerequisites << :build
271
-
272
- namespace :test do
273
- # partial-loads-ok and undef-value-errors necessary to ignore
274
- # spurious (and eminently ignorable) warnings from the ruby
275
- # interpreter
276
-
277
- desc "run test suite under valgrind with memory-fill ruby options"
278
- task :valgrind_mem => :build do
279
- # fill malloced memory with "m" and freed memory with "f"
280
- cmdline = "valgrind #{VALGRIND_BASIC_OPTS} --freelist-vol=100000000 --malloc-fill=6D --free-fill=66 #{test_suite_cmdline}"
281
- puts cmdline
282
- system cmdline
283
- end
284
-
285
- desc "run test suite under valgrind with memory-zero ruby options"
286
- task :valgrind_mem0 => :build do
287
- # fill malloced and freed memory with 0
288
- cmdline = "valgrind #{VALGRIND_BASIC_OPTS} --freelist-vol=100000000 --malloc-fill=00 --free-fill=00 #{test_suite_cmdline}"
289
- puts cmdline
290
- system cmdline
291
- end
292
-
293
- desc "run test suite under gdb"
294
- task :gdb => :build do
295
- cmdline = "gdb --args #{test_suite_cmdline}"
296
- puts cmdline
297
- system cmdline
298
- end
299
-
300
- desc "run test suite with aggressive GC"
301
- task :gc => :build do
302
- ENV['NOKOGIRI_GC'] = "true"
303
- Rake::Task["test"].invoke
304
- end
305
-
306
- desc "find call-seq in the rdoc"
307
- task :rdoc => 'docs' do
308
- Dir['doc/**/*.html'].each { |docfile|
309
- next if docfile =~ /\.src/
310
- puts "FAIL: #{docfile}" if File.read(docfile) =~ /call-seq/
311
- }
312
- end
313
- end
249
+ Rake::Task['test:valgrind_mem'].prerequisites << :build
250
+ Rake::Task['test:valgrind_mem0'].prerequisites << :build
251
+ Rake::Task['test:coverage'].prerequisites << :build
314
252
 
315
253
  namespace :install do
316
254
  desc "Install frex and racc for development"
@@ -6,7 +6,9 @@ ROOT = File.expand_path(File.join(File.dirname(__FILE__), '..', '..'))
6
6
  LIBDIR = Config::CONFIG['libdir']
7
7
  INCLUDEDIR = Config::CONFIG['includedir']
8
8
 
9
- use_macports = !(defined?(RUBY_ENGINE) && RUBY_ENGINE != 'ruby')
9
+ if defined?(RUBY_ENGINE) && RUBY_ENGINE == 'macruby'
10
+ $LIBRUBYARG_STATIC.gsub!(/-static/, '')
11
+ end
10
12
 
11
13
  $CFLAGS << " #{ENV["CFLAGS"]}"
12
14
  if Config::CONFIG['target_os'] == 'mingw32'
@@ -15,79 +17,62 @@ else
15
17
  $CFLAGS << " -g -DXP_UNIX"
16
18
  end
17
19
 
18
- $LIBPATH << "/opt/local/lib" if use_macports
19
-
20
20
  $CFLAGS << " -O3 -Wall -Wcast-qual -Wwrite-strings -Wconversion -Wmissing-noreturn -Winline"
21
21
 
22
- if Config::CONFIG['target_os'] == 'mingw32'
23
- header = File.join(ROOT, 'cross', 'libxml2-2.7.2.win32', 'include')
24
- unless find_header('libxml/xmlversion.h', header)
25
- abort "need libxml"
26
- end
22
+ HEADER_DIRS = [
23
+ File.join(INCLUDEDIR, "libxml2"),
24
+ INCLUDEDIR,
25
+ '/usr/local/include/libxml2',
26
+ '/usr/include/libxml2',
27
+ ]
27
28
 
28
- header = File.join(ROOT, 'cross', 'libxslt-1.1.24.win32', 'include')
29
- unless find_header('libxslt/libxslt.h', header)
30
- abort "need libxslt"
31
- end
32
- unless find_header('libexslt/libexslt.h', header)
33
- abort "need libexslt"
34
- end
29
+ LIB_DIRS = [
30
+ LIBDIR,
31
+ '/opt/local/lib',
32
+ '/usr/local/lib',
33
+ '/usr/lib'
34
+ ]
35
35
 
36
+ if Config::CONFIG['target_os'] == 'mingw32'
36
37
  header = File.join(ROOT, 'cross', 'iconv-1.9.2.win32', 'include')
37
38
  unless find_header('iconv.h', header)
38
39
  abort "need iconv"
39
40
  end
40
- else
41
- HEADER_DIRS = [
42
- File.join(INCLUDEDIR, "libxml2"),
43
- INCLUDEDIR,
44
- '/usr/include/libxml2',
45
- '/usr/local/include/libxml2'
46
- ]
47
-
48
- [
49
- '/opt/local/include/libxml2',
50
- '/opt/local/include',
51
- ].each { |x| HEADER_DIRS.unshift(x) } if use_macports
52
-
53
- unless find_header('libxml/xmlversion.h', *HEADER_DIRS)
54
- abort "need libxml"
55
- end
41
+ end
56
42
 
57
- unless find_header('libxslt/xslt.h', *HEADER_DIRS)
58
- abort "need libxslt"
59
- end
60
- unless find_header('libexslt/exslt.h', *HEADER_DIRS)
61
- abort "need libxslt"
62
- end
43
+ xml2_dirs = dir_config('xml2', '/opt/local/include/libxml2', '/opt/local/lib')
44
+ unless [nil, nil] == xml2_dirs
45
+ HEADER_DIRS.unshift xml2_dirs.first
46
+ LIB_DIRS.unshift xml2_dirs[1]
63
47
  end
64
48
 
65
- if Config::CONFIG['target_os'] == 'mingw32'
66
- find_library('xml2', 'xmlParseDoc',
67
- File.join(ROOT, 'cross', 'libxml2-2.7.2.win32', 'bin'))
68
- find_library('xslt', 'xsltParseStylesheetDoc',
69
- File.join(ROOT, 'cross', 'libxslt-1.1.24.win32', 'bin'))
70
- find_library('exslt', 'exsltFuncRegister',
71
- File.join(ROOT, 'cross', 'libxslt-1.1.24.win32', 'bin'))
72
- else
73
- find_library('xml2', 'xmlParseDoc',
74
- LIBDIR,
75
- '/opt/local/lib',
76
- '/usr/local/lib',
77
- '/usr/lib'
78
- )
79
- find_library('xslt', 'xsltParseStylesheetDoc',
80
- LIBDIR,
81
- '/opt/local/lib',
82
- '/usr/local/lib',
83
- '/usr/lib'
84
- )
85
- find_library('exslt', 'exsltFuncRegister',
86
- LIBDIR,
87
- '/opt/local/lib',
88
- '/usr/local/lib',
89
- '/usr/lib'
90
- )
49
+ xslt_dirs = dir_config('xslt', '/opt/local/include/', '/opt/local/lib')
50
+ unless [nil, nil] == xslt_dirs
51
+ HEADER_DIRS.unshift xslt_dirs.first
52
+ LIB_DIRS.unshift xslt_dirs[1]
53
+ end
54
+
55
+ unless find_header('libxml/parser.h', *HEADER_DIRS)
56
+ abort "libxml2 is missing. try 'port install libxml2' or 'yum install libxml2'"
57
+ end
58
+
59
+ unless find_header('libxslt/xslt.h', *HEADER_DIRS)
60
+ abort "libxslt is missing. try 'port install libxslt' or 'yum install libxslt'"
61
+ end
62
+ unless find_header('libexslt/exslt.h', *HEADER_DIRS)
63
+ abort "libxslt is missing. try 'port install libxslt' or 'yum install libxslt'"
64
+ end
65
+
66
+ unless find_library('xml2', 'xmlParseDoc', *LIB_DIRS)
67
+ abort "libxml2 is missing. try 'port install libxml2' or 'yum install libxml2'"
68
+ end
69
+
70
+ unless find_library('xslt', 'xsltParseStylesheetDoc', *LIB_DIRS)
71
+ abort "libxslt is missing. try 'port install libxslt' or 'yum install libxslt'"
72
+ end
73
+
74
+ unless find_library('exslt', 'exsltFuncRegister', *LIB_DIRS)
75
+ abort "libxslt is missing. try 'port install libxslt' or 'yum install libxslt'"
91
76
  end
92
77
 
93
78
  create_makefile('nokogiri/native')