nokogiri 1.6.8.rc1-x86-mingw32 → 1.6.8.rc2-x86-mingw32

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 (51) hide show
  1. checksums.yaml +4 -4
  2. data/.cross_rubies +2 -0
  3. data/CHANGELOG.rdoc +16 -2
  4. data/Gemfile +2 -2
  5. data/LICENSE.txt +1 -1
  6. data/Manifest.txt +0 -1
  7. data/Rakefile +5 -3
  8. data/ext/nokogiri/extconf.rb +1 -2
  9. data/ext/nokogiri/html_document.c +6 -6
  10. data/ext/nokogiri/html_element_description.c +1 -1
  11. data/ext/nokogiri/html_entity_lookup.c +1 -1
  12. data/ext/nokogiri/html_sax_parser_context.c +4 -4
  13. data/ext/nokogiri/html_sax_push_parser.c +2 -2
  14. data/ext/nokogiri/xml_attr.c +2 -2
  15. data/ext/nokogiri/xml_comment.c +1 -1
  16. data/ext/nokogiri/xml_document.c +18 -18
  17. data/ext/nokogiri/xml_encoding_handler.c +3 -3
  18. data/ext/nokogiri/xml_entity_reference.c +1 -1
  19. data/ext/nokogiri/xml_node.c +27 -27
  20. data/ext/nokogiri/xml_node_set.c +3 -11
  21. data/ext/nokogiri/xml_processing_instruction.c +2 -2
  22. data/ext/nokogiri/xml_reader.c +6 -6
  23. data/ext/nokogiri/xml_sax_parser_context.c +1 -1
  24. data/ext/nokogiri/xml_sax_push_parser.c +1 -1
  25. data/ext/nokogiri/xml_schema.c +1 -1
  26. data/ext/nokogiri/xml_text.c +1 -1
  27. data/ext/nokogiri/xml_xpath_context.c +6 -6
  28. data/ext/nokogiri/xslt_stylesheet.c +6 -6
  29. data/lib/nokogiri/1.9/nokogiri.so +0 -0
  30. data/lib/nokogiri/2.0/nokogiri.so +0 -0
  31. data/lib/nokogiri/2.1/nokogiri.so +0 -0
  32. data/lib/nokogiri/2.2/nokogiri.so +0 -0
  33. data/lib/nokogiri/2.3/nokogiri.so +0 -0
  34. data/lib/nokogiri/version.rb +1 -1
  35. data/lib/nokogiri/xml/node.rb +5 -9
  36. data/lib/nokogiri/xml/node_set.rb +3 -3
  37. data/test/html/test_document.rb +3 -3
  38. data/test/html/test_document_encoding.rb +4 -4
  39. data/test/html/test_node_encoding.rb +60 -0
  40. data/test/test_css_cache.rb +1 -1
  41. data/test/test_reader.rb +19 -19
  42. data/test/xml/sax/test_parser.rb +3 -7
  43. data/test/xml/test_document_encoding.rb +3 -3
  44. data/test/xml/test_namespace.rb +2 -2
  45. data/test/xml/test_node.rb +4 -4
  46. data/test/xml/test_node_encoding.rb +33 -69
  47. data/test/xml/test_node_set.rb +1 -1
  48. data/test/xml/test_unparented_node.rb +1 -1
  49. data/test_all +15 -9
  50. metadata +13 -12
  51. data/CHANGELOG.ja.rdoc +0 -1075
@@ -321,25 +321,17 @@ static VALUE slice(int argc, VALUE *argv, VALUE self)
321
321
  static VALUE to_array(VALUE self, VALUE rb_node)
322
322
  {
323
323
  xmlNodeSetPtr node_set ;
324
- VALUE *elts;
325
324
  VALUE list;
326
325
  int i;
327
326
 
328
327
  Data_Get_Struct(self, xmlNodeSet, node_set);
329
328
 
330
- elts = (VALUE *)calloc((size_t)(node_set->nodeNr), sizeof(VALUE));
329
+ list = rb_ary_new2(node_set->nodeNr);
331
330
  for(i = 0; i < node_set->nodeNr; i++) {
332
- elts[i] = Nokogiri_wrap_xml_node_set_node(node_set->nodeTab[i], self);
333
- rb_gc_register_address(&elts[i]);
331
+ VALUE elt = Nokogiri_wrap_xml_node_set_node(node_set->nodeTab[i], self);
332
+ rb_ary_push( list, elt );
334
333
  }
335
334
 
336
- list = rb_ary_new4((long)node_set->nodeNr, elts);
337
-
338
- for(i = 0; i < node_set->nodeNr; i++) {
339
- rb_gc_unregister_address(&elts[i]);
340
- }
341
- free(elts);
342
-
343
335
  return list;
344
336
  }
345
337
 
@@ -23,8 +23,8 @@ static VALUE new(int argc, VALUE *argv, VALUE klass)
23
23
 
24
24
  node = xmlNewDocPI(
25
25
  xml_doc,
26
- (const xmlChar *)StringValuePtr(name),
27
- (const xmlChar *)StringValuePtr(content)
26
+ (const xmlChar *)StringValueCStr(name),
27
+ (const xmlChar *)StringValueCStr(content)
28
28
  );
29
29
 
30
30
  nokogiri_root_node(node);
@@ -218,12 +218,12 @@ static VALUE reader_attribute(VALUE self, VALUE name)
218
218
  if(NIL_P(name)) return Qnil;
219
219
  name = StringValue(name) ;
220
220
 
221
- value = xmlTextReaderGetAttribute(reader, (xmlChar*)StringValuePtr(name));
221
+ value = xmlTextReaderGetAttribute(reader, (xmlChar*)StringValueCStr(name));
222
222
  if(value == NULL) {
223
223
  /* this section is an attempt to workaround older versions of libxml that
224
224
  don't handle namespaces properly in all attribute-and-friends functions */
225
225
  xmlChar *prefix = NULL ;
226
- xmlChar *localname = xmlSplitQName2((xmlChar*)StringValuePtr(name), &prefix);
226
+ xmlChar *localname = xmlSplitQName2((xmlChar*)StringValueCStr(name), &prefix);
227
227
  if (localname != NULL) {
228
228
  value = xmlTextReaderLookupNamespace(reader, localname);
229
229
  xmlFree(localname) ;
@@ -546,8 +546,8 @@ static VALUE from_memory(int argc, VALUE *argv, VALUE klass)
546
546
  rb_scan_args(argc, argv, "13", &rb_buffer, &rb_url, &encoding, &rb_options);
547
547
 
548
548
  if (!RTEST(rb_buffer)) rb_raise(rb_eArgError, "string cannot be nil");
549
- if (RTEST(rb_url)) c_url = StringValuePtr(rb_url);
550
- if (RTEST(encoding)) c_encoding = StringValuePtr(encoding);
549
+ if (RTEST(rb_url)) c_url = StringValueCStr(rb_url);
550
+ if (RTEST(encoding)) c_encoding = StringValueCStr(encoding);
551
551
  if (RTEST(rb_options)) c_options = (int)NUM2INT(rb_options);
552
552
 
553
553
  reader = xmlReaderForMemory(
@@ -590,8 +590,8 @@ static VALUE from_io(int argc, VALUE *argv, VALUE klass)
590
590
  rb_scan_args(argc, argv, "13", &rb_io, &rb_url, &encoding, &rb_options);
591
591
 
592
592
  if (!RTEST(rb_io)) rb_raise(rb_eArgError, "io cannot be nil");
593
- if (RTEST(rb_url)) c_url = StringValuePtr(rb_url);
594
- if (RTEST(encoding)) c_encoding = StringValuePtr(encoding);
593
+ if (RTEST(rb_url)) c_url = StringValueCStr(rb_url);
594
+ if (RTEST(encoding)) c_encoding = StringValueCStr(encoding);
595
595
  if (RTEST(rb_options)) c_options = (int)NUM2INT(rb_options);
596
596
 
597
597
  reader = xmlReaderForIO(
@@ -45,7 +45,7 @@ parse_io(VALUE klass, VALUE io, VALUE encoding)
45
45
  */
46
46
  static VALUE parse_file(VALUE klass, VALUE filename)
47
47
  {
48
- xmlParserCtxtPtr ctxt = xmlCreateFileParserCtxt(StringValuePtr(filename));
48
+ xmlParserCtxtPtr ctxt = xmlCreateFileParserCtxt(StringValueCStr(filename));
49
49
  return Data_Wrap_Struct(klass, NULL, deallocate, ctxt);
50
50
  }
51
51
 
@@ -59,7 +59,7 @@ static VALUE initialize_native(VALUE self, VALUE _xml_sax, VALUE _filename)
59
59
 
60
60
  Data_Get_Struct(_xml_sax, xmlSAXHandler, sax);
61
61
 
62
- if(_filename != Qnil) filename = StringValuePtr(_filename);
62
+ if(_filename != Qnil) filename = StringValueCStr(_filename);
63
63
 
64
64
  ctx = xmlCreatePushParserCtxt(
65
65
  sax,
@@ -61,7 +61,7 @@ static VALUE validate_file(VALUE self, VALUE rb_filename)
61
61
  VALUE errors;
62
62
 
63
63
  Data_Get_Struct(self, xmlSchema, schema);
64
- filename = (const char*)StringValuePtr(rb_filename) ;
64
+ filename = (const char*)StringValueCStr(rb_filename) ;
65
65
 
66
66
  errors = rb_ary_new();
67
67
 
@@ -19,7 +19,7 @@ static VALUE new(int argc, VALUE *argv, VALUE klass)
19
19
 
20
20
  Data_Get_Struct(document, xmlDoc, doc);
21
21
 
22
- node = xmlNewText((xmlChar *)StringValuePtr(string));
22
+ node = xmlNewText((xmlChar *)StringValueCStr(string));
23
23
  node->doc = doc->doc;
24
24
 
25
25
  nokogiri_root_node(node);
@@ -21,8 +21,8 @@ static VALUE register_ns(VALUE self, VALUE prefix, VALUE uri)
21
21
  Data_Get_Struct(self, xmlXPathContext, ctx);
22
22
 
23
23
  xmlXPathRegisterNs( ctx,
24
- (const xmlChar *)StringValuePtr(prefix),
25
- (const xmlChar *)StringValuePtr(uri)
24
+ (const xmlChar *)StringValueCStr(prefix),
25
+ (const xmlChar *)StringValueCStr(uri)
26
26
  );
27
27
  return self;
28
28
  }
@@ -39,10 +39,10 @@ static VALUE register_variable(VALUE self, VALUE name, VALUE value)
39
39
  xmlXPathObjectPtr xmlValue;
40
40
  Data_Get_Struct(self, xmlXPathContext, ctx);
41
41
 
42
- xmlValue = xmlXPathNewCString(StringValuePtr(value));
42
+ xmlValue = xmlXPathNewCString(StringValueCStr(value));
43
43
 
44
44
  xmlXPathRegisterVariable( ctx,
45
- (const xmlChar *)StringValuePtr(name),
45
+ (const xmlChar *)StringValueCStr(name),
46
46
  xmlValue
47
47
  );
48
48
 
@@ -108,7 +108,7 @@ void Nokogiri_marshal_xpath_funcall_and_return_values(xmlXPathParserContextPtr c
108
108
  case T_STRING:
109
109
  xmlXPathReturnString(
110
110
  ctx,
111
- xmlCharStrdup(StringValuePtr(result))
111
+ xmlCharStrdup(StringValueCStr(result))
112
112
  );
113
113
  break;
114
114
  case T_TRUE:
@@ -200,7 +200,7 @@ static VALUE evaluate(int argc, VALUE *argv, VALUE self)
200
200
  if(rb_scan_args(argc, argv, "11", &search_path, &xpath_handler) == 1)
201
201
  xpath_handler = Qnil;
202
202
 
203
- query = (xmlChar *)StringValuePtr(search_path);
203
+ query = (xmlChar *)StringValueCStr(search_path);
204
204
 
205
205
  if(Qnil != xpath_handler) {
206
206
  /* FIXME: not sure if this is the correct place to shove private data. */
@@ -22,7 +22,7 @@ static void dealloc(nokogiriXsltStylesheetTuple *wrapper)
22
22
  NOKOGIRI_DEBUG_START(doc);
23
23
  xsltFreeStylesheet(doc); /* commented out for now. */
24
24
  NOKOGIRI_DEBUG_END(doc);
25
-
25
+
26
26
  free(wrapper);
27
27
  }
28
28
 
@@ -47,7 +47,7 @@ VALUE Nokogiri_wrap_xslt_stylesheet(xsltStylesheetPtr ss)
47
47
 
48
48
  self = Data_Make_Struct(cNokogiriXsltStylesheet, nokogiriXsltStylesheetTuple,
49
49
  mark, dealloc, wrapper);
50
-
50
+
51
51
  ss->_private = (void *)self;
52
52
  wrapper->ss = ss;
53
53
  wrapper->func_instances = rb_ary_new();
@@ -122,7 +122,7 @@ static void swallow_superfluous_xml_errors(void * userdata, xmlErrorPtr error, .
122
122
  * returns Nokogiri::XML::Document
123
123
  *
124
124
  * Example:
125
- *
125
+ *
126
126
  * doc = Nokogiri::XML(File.read(ARGV[0]))
127
127
  * xslt = Nokogiri::XSLT(File.read(ARGV[1]))
128
128
  * puts xslt.transform(doc, ['key', 'value'])
@@ -158,7 +158,7 @@ static VALUE transform(int argc, VALUE* argv, VALUE self)
158
158
  params = calloc((size_t)param_len+1, sizeof(char*));
159
159
  for (j = 0 ; j < param_len ; j++) {
160
160
  VALUE entry = rb_ary_entry(paramobj, j);
161
- const char * ptr = StringValuePtr(entry);
161
+ const char * ptr = StringValueCStr(entry);
162
162
  params[j] = ptr;
163
163
  }
164
164
  params[param_len] = 0 ;
@@ -211,7 +211,7 @@ static void * initFunc(xsltTransformContextPtr ctxt, const xmlChar *uri)
211
211
  for(i = 0; i < RARRAY_LEN(methods); i++) {
212
212
  VALUE method_name = rb_obj_as_string(rb_ary_entry(methods, i));
213
213
  xsltRegisterExtFunction(ctxt,
214
- (unsigned char *)StringValuePtr(method_name), uri, method_caller);
214
+ (unsigned char *)StringValueCStr(method_name), uri, method_caller);
215
215
  }
216
216
 
217
217
  Data_Get_Struct(ctxt->style->_private, nokogiriXsltStylesheetTuple,
@@ -245,7 +245,7 @@ static VALUE registr(VALUE self, VALUE uri, VALUE obj)
245
245
  if(NIL_P(modules)) rb_raise(rb_eRuntimeError, "wtf! @modules isn't set");
246
246
 
247
247
  rb_hash_aset(modules, uri, obj);
248
- xsltRegisterExtModule((unsigned char *)StringValuePtr(uri), initFunc, shutdownFunc);
248
+ xsltRegisterExtModule((unsigned char *)StringValueCStr(uri), initFunc, shutdownFunc);
249
249
  return self;
250
250
  }
251
251
 
Binary file
Binary file
Binary file
Binary file
Binary file
@@ -1,6 +1,6 @@
1
1
  module Nokogiri
2
2
  # The version of Nokogiri you are using
3
- VERSION = '1.6.8.rc1'
3
+ VERSION = '1.6.8.rc2'
4
4
 
5
5
  class VersionInfo # :nodoc:
6
6
  def jruby?
@@ -1,3 +1,4 @@
1
+ # encoding: UTF-8
1
2
  require 'stringio'
2
3
  require 'nokogiri/xml/node/save_options'
3
4
 
@@ -331,13 +332,13 @@ module Nokogiri
331
332
  ###
332
333
  # Get the attribute values for this Node.
333
334
  def values
334
- attribute_nodes.map { |node| node.value }
335
+ attribute_nodes.map(&:value)
335
336
  end
336
337
 
337
338
  ###
338
339
  # Get the attribute names for this Node.
339
340
  def keys
340
- attribute_nodes.map { |node| node.node_name }
341
+ attribute_nodes.map(&:node_name)
341
342
  end
342
343
 
343
344
  ###
@@ -439,12 +440,6 @@ module Nokogiri
439
440
  def namespaces
440
441
  Hash[namespace_scopes.map { |nd|
441
442
  key = ['xmlns', nd.prefix].compact.join(':')
442
- if document.encoding
443
- begin
444
- key.force_encoding document.encoding
445
- rescue ArgumentError
446
- end
447
- end
448
443
  [key, nd.href]
449
444
  }]
450
445
  end
@@ -546,9 +541,10 @@ module Nokogiri
546
541
  return NodeSet.new(document, parents) unless selector
547
542
 
548
543
  root = parents.last
544
+ search_results = root.search(selector)
549
545
 
550
546
  NodeSet.new(document, parents.find_all { |parent|
551
- root.search(selector).include?(parent)
547
+ search_results.include?(parent)
552
548
  })
553
549
  end
554
550
 
@@ -191,7 +191,7 @@ module Nokogiri
191
191
  ###
192
192
  # Get the inner text of all contained Node objects
193
193
  def inner_text
194
- collect{|j| j.inner_text}.join('')
194
+ collect(&:inner_text).join('')
195
195
  end
196
196
  alias :text :inner_text
197
197
 
@@ -215,7 +215,7 @@ module Nokogiri
215
215
  ###
216
216
  # Convert this NodeSet to a string.
217
217
  def to_s
218
- map { |x| x.to_s }.join
218
+ map(&:to_s).join
219
219
  end
220
220
 
221
221
  ###
@@ -296,7 +296,7 @@ module Nokogiri
296
296
  ###
297
297
  # Return a nicely formated string representation
298
298
  def inspect
299
- "[#{map { |c| c.inspect }.join ', '}]"
299
+ "[#{map(&:inspect).join ', '}]"
300
300
  end
301
301
 
302
302
  alias :+ :|
@@ -97,7 +97,7 @@ module Nokogiri
97
97
  rescue Exception => e
98
98
  skip("This test needs the internet. Skips if no internet available. (#{e})")
99
99
  end
100
- doc = Nokogiri::HTML html ,"http:/foobar.foobar/"
100
+ doc = Nokogiri::HTML html ,"http:/foobar.foobar/", 'UTF-8'
101
101
  refute_empty doc.to_s, "Document should not be empty"
102
102
  end
103
103
 
@@ -422,7 +422,7 @@ eohtml
422
422
  eohtml
423
423
  set = html.css('p, a')
424
424
  assert_equal(2, set.length)
425
- assert_equal ['a tag', 'p tag'].sort, set.map { |x| x.content }.sort
425
+ assert_equal ['a tag', 'p tag'].sort, set.map(&:content).sort
426
426
  end
427
427
 
428
428
  def test_inner_text
@@ -600,7 +600,7 @@ eohtml
600
600
  eohtml
601
601
  list = doc.css('.red')
602
602
  assert_equal 2, list.length
603
- assert_equal %w{ RED RED }, list.map { |x| x.text }
603
+ assert_equal %w{ RED RED }, list.map(&:text)
604
604
  end
605
605
 
606
606
  def test_parse_can_take_io
@@ -107,16 +107,16 @@ module Nokogiri
107
107
  def test_document_xhtml_enc
108
108
  [ENCODING_XHTML_FILE, ENCODING_HTML_FILE].each { |file|
109
109
  doc_from_string_enc = Nokogiri::HTML(binread(file), nil, 'Shift_JIS')
110
- ary_from_string_enc = doc_from_string_enc.xpath('//p/text()').map { |text| text.text }
110
+ ary_from_string_enc = doc_from_string_enc.xpath('//p/text()').map(&:text)
111
111
 
112
112
  doc_from_string = Nokogiri::HTML(binread(file))
113
- ary_from_string = doc_from_string.xpath('//p/text()').map { |text| text.text }
113
+ ary_from_string = doc_from_string.xpath('//p/text()').map(&:text)
114
114
 
115
115
  doc_from_file_enc = Nokogiri::HTML(binopen(file), nil, 'Shift_JIS')
116
- ary_from_file_enc = doc_from_file_enc.xpath('//p/text()').map { |text| text.text }
116
+ ary_from_file_enc = doc_from_file_enc.xpath('//p/text()').map(&:text)
117
117
 
118
118
  doc_from_file = Nokogiri::HTML(binopen(file))
119
- ary_from_file = doc_from_file.xpath('//p/text()').map { |text| text.text }
119
+ ary_from_file = doc_from_file.xpath('//p/text()').map(&:text)
120
120
 
121
121
  title = 'たこ焼き仮面'
122
122
 
@@ -4,6 +4,48 @@ require "helper"
4
4
  module Nokogiri
5
5
  module HTML
6
6
  class TestNodeEncoding < Nokogiri::TestCase
7
+ def setup
8
+ super
9
+ @html = Nokogiri::HTML(File.open(NICH_FILE, "rb"))
10
+ end
11
+
12
+ def test_get_attribute
13
+ node = @html.css('a').first
14
+ assert_equal 'UTF-8', node['href'].encoding.name
15
+ end
16
+
17
+ def test_text_encoding_is_utf_8
18
+ assert_equal 'UTF-8', @html.text.encoding.name
19
+ end
20
+
21
+ def test_serialize_encoding_html
22
+ assert_equal @html.encoding.downcase,
23
+ @html.serialize.encoding.name.downcase
24
+
25
+ @doc = Nokogiri::HTML(@html.serialize)
26
+ assert_equal @html.serialize, @doc.serialize
27
+ end
28
+
29
+ def test_encode_special_chars
30
+ foo = @html.css('a').first.encode_special_chars('foo')
31
+ assert_equal 'UTF-8', foo.encoding.name
32
+ end
33
+
34
+ def test_content
35
+ node = @html.css('a').first
36
+ assert_equal 'UTF-8', node.content.encoding.name
37
+ end
38
+
39
+ def test_name
40
+ node = @html.css('a').first
41
+ assert_equal 'UTF-8', node.name.encoding.name
42
+ end
43
+
44
+ def test_path
45
+ node = @html.css('a').first
46
+ assert_equal 'UTF-8', node.path.encoding.name
47
+ end
48
+
7
49
  def test_inner_html
8
50
  doc = Nokogiri::HTML File.open(SHIFT_JIS_HTML, 'rb')
9
51
 
@@ -20,6 +62,24 @@ module Nokogiri
20
62
  contents = doc.at('h2').inner_html
21
63
  assert_match hello, contents
22
64
  end
65
+
66
+ def test_encoding_GH_1113
67
+ doc = Nokogiri::HTML::Document.new
68
+ hex = '<p>&#x1f340;</p>'
69
+ decimal = '<p>&#127808;</p>'
70
+ encoded = '<p>🍀</p>'
71
+
72
+ doc.encoding = 'UTF-8'
73
+ [hex, decimal, encoded].each do |document|
74
+ assert_equal encoded, doc.fragment(document).to_s
75
+ end
76
+
77
+ doc.encoding = 'US-ASCII'
78
+ expected = Nokogiri.jruby? ? hex : decimal
79
+ [hex, decimal].each do |document|
80
+ assert_equal expected, doc.fragment(document).to_s
81
+ end
82
+ end
23
83
  end
24
84
  end
25
85
  end
@@ -6,7 +6,7 @@ class TestCssCache < Nokogiri::TestCase
6
6
  super
7
7
  @css = "a1 > b2 > c3"
8
8
  @parse_result = Nokogiri::CSS.parse(@css)
9
- @to_xpath_result = @parse_result.map {|ast| ast.to_xpath}
9
+ @to_xpath_result = @parse_result.map(&:to_xpath)
10
10
  Nokogiri::CSS::Parser.class_eval do
11
11
  class << @cache
12
12
  alias :old_bracket :[]
data/test/test_reader.rb CHANGED
@@ -85,7 +85,7 @@ class TestReader < Nokogiri::TestCase
85
85
  reader = Nokogiri::XML::Reader.from_io(io)
86
86
  assert_equal false, reader.default?
87
87
  assert_equal [false, false, false, false, false, false, false],
88
- reader.map { |x| x.default? }
88
+ reader.map(&:default?)
89
89
  end
90
90
 
91
91
  def test_io
@@ -93,7 +93,7 @@ class TestReader < Nokogiri::TestCase
93
93
  reader = Nokogiri::XML::Reader(io)
94
94
  assert_equal false, reader.default?
95
95
  assert_equal [false, false, false, false, false, false, false],
96
- reader.map { |x| x.default? }
96
+ reader.map(&:default?)
97
97
  end
98
98
 
99
99
  def test_string_io
@@ -105,7 +105,7 @@ class TestReader < Nokogiri::TestCase
105
105
  reader = Nokogiri::XML::Reader(io)
106
106
  assert_equal false, reader.default?
107
107
  assert_equal [false, false, false, false, false, false, false],
108
- reader.map { |x| x.default? }
108
+ reader.map(&:default?)
109
109
  end
110
110
 
111
111
  class ReallyBadIO
@@ -156,7 +156,7 @@ class TestReader < Nokogiri::TestCase
156
156
  eoxml
157
157
  assert_equal false, reader.default?
158
158
  assert_equal [false, false, false, false, false, false, false],
159
- reader.map { |x| x.default? }
159
+ reader.map(&:default?)
160
160
  end
161
161
 
162
162
  def test_value?
@@ -167,7 +167,7 @@ class TestReader < Nokogiri::TestCase
167
167
  eoxml
168
168
  assert_equal false, reader.value?
169
169
  assert_equal [false, true, false, true, false, true, false],
170
- reader.map { |x| x.value? }
170
+ reader.map(&:value?)
171
171
  end
172
172
 
173
173
  def test_read_error_document
@@ -191,7 +191,7 @@ class TestReader < Nokogiri::TestCase
191
191
  eoxml
192
192
  assert_equal false, reader.attributes?
193
193
  assert_equal [true, false, true, false, true, false, true],
194
- reader.map { |x| x.attributes? }
194
+ reader.map(&:attributes?)
195
195
  end
196
196
 
197
197
  def test_attributes
@@ -208,7 +208,7 @@ class TestReader < Nokogiri::TestCase
208
208
  {}, {"awesome"=>"true"}, {}, {"awesome"=>"true"}, {},
209
209
  {'xmlns:tenderlove'=>'http://tenderlovemaking.com/',
210
210
  'xmlns'=>'http://mothership.connection.com/'}],
211
- reader.map { |x| x.attributes }
211
+ reader.map(&:attributes)
212
212
  end
213
213
 
214
214
  def test_attribute_roundtrip
@@ -257,7 +257,7 @@ class TestReader < Nokogiri::TestCase
257
257
  </x>
258
258
  eoxml
259
259
  assert_equal 0, reader.attribute_count
260
- assert_equal [1, 0, 1, 0, 0, 0, 0], reader.map { |x| x.attribute_count }
260
+ assert_equal [1, 0, 1, 0, 0, 0, 0], reader.map(&:attribute_count)
261
261
  end
262
262
 
263
263
  def test_depth
@@ -267,7 +267,7 @@ class TestReader < Nokogiri::TestCase
267
267
  </x>
268
268
  eoxml
269
269
  assert_equal 0, reader.depth
270
- assert_equal [0, 1, 1, 2, 1, 1, 0], reader.map { |x| x.depth }
270
+ assert_equal [0, 1, 1, 2, 1, 1, 0], reader.map(&:depth)
271
271
  end
272
272
 
273
273
  def test_encoding
@@ -278,7 +278,7 @@ class TestReader < Nokogiri::TestCase
278
278
  </awesome>
279
279
  eoxml
280
280
  reader = Nokogiri::XML::Reader.from_memory(string, nil, 'UTF-8')
281
- assert_equal ['UTF-8'], reader.map { |x| x.encoding }.uniq
281
+ assert_equal ['UTF-8'], reader.map(&:encoding).uniq
282
282
  end
283
283
 
284
284
  def test_xml_version
@@ -288,7 +288,7 @@ class TestReader < Nokogiri::TestCase
288
288
  </x>
289
289
  eoxml
290
290
  assert_nil reader.xml_version
291
- assert_equal ['1.0'], reader.map { |x| x.xml_version }.uniq
291
+ assert_equal ['1.0'], reader.map(&:xml_version).uniq
292
292
  end
293
293
 
294
294
  def test_lang
@@ -300,7 +300,7 @@ class TestReader < Nokogiri::TestCase
300
300
  eoxml
301
301
  assert_nil reader.lang
302
302
  assert_equal [nil, nil, "en", "en", "en", nil, "ja", "ja", "ja", nil, nil],
303
- reader.map { |x| x.lang }
303
+ reader.map(&:lang)
304
304
  end
305
305
 
306
306
  def test_value
@@ -311,7 +311,7 @@ class TestReader < Nokogiri::TestCase
311
311
  eoxml
312
312
  assert_nil reader.value
313
313
  assert_equal [nil, "\n ", nil, "snuggles!", nil, "\n ", nil],
314
- reader.map { |x| x.value }
314
+ reader.map(&:value)
315
315
  end
316
316
 
317
317
  def test_prefix
@@ -322,7 +322,7 @@ class TestReader < Nokogiri::TestCase
322
322
  eoxml
323
323
  assert_nil reader.prefix
324
324
  assert_equal [nil, nil, "edi", nil, "edi", nil, nil],
325
- reader.map { |n| n.prefix }
325
+ reader.map(&:prefix)
326
326
  end
327
327
 
328
328
  def test_node_type
@@ -332,7 +332,7 @@ class TestReader < Nokogiri::TestCase
332
332
  </x>
333
333
  eoxml
334
334
  assert_equal 0, reader.node_type
335
- assert_equal [1, 14, 1, 3, 15, 14, 15], reader.map { |n| n.node_type }
335
+ assert_equal [1, 14, 1, 3, 15, 14, 15], reader.map(&:node_type)
336
336
  end
337
337
 
338
338
  def test_inner_xml
@@ -383,7 +383,7 @@ class TestReader < Nokogiri::TestCase
383
383
  "http://ecommerce.example.org/schema",
384
384
  nil,
385
385
  nil],
386
- reader.map { |n| n.namespace_uri })
386
+ reader.map(&:namespace_uri))
387
387
  end
388
388
 
389
389
  def test_namespaced_attributes
@@ -413,7 +413,7 @@ class TestReader < Nokogiri::TestCase
413
413
  eoxml
414
414
  assert_nil reader.local_name
415
415
  assert_equal(["x", "#text", "foo", "#text", "foo", "#text", "x"],
416
- reader.map { |n| n.local_name })
416
+ reader.map(&:local_name))
417
417
  end
418
418
 
419
419
  def test_name
@@ -424,7 +424,7 @@ class TestReader < Nokogiri::TestCase
424
424
  eoxml
425
425
  assert_nil reader.name
426
426
  assert_equal(["x", "#text", "edi:foo", "#text", "edi:foo", "#text", "x"],
427
- reader.map { |n| n.name })
427
+ reader.map(&:name))
428
428
  end
429
429
 
430
430
  def test_base_uri
@@ -452,7 +452,7 @@ class TestReader < Nokogiri::TestCase
452
452
  "http://base.example.org/base/relative",
453
453
  "http://base.example.org/base/",
454
454
  "http://base.example.org/base/"],
455
- reader.map {|n| n.base_uri })
455
+ reader.map(&:base_uri))
456
456
  end
457
457
 
458
458
  def test_xlink_href_without_base_uri