Skip to content

Commit

Permalink
Remove deprecated apis.
Browse files Browse the repository at this point in the history
  • Loading branch information
Charlie Savage committed Feb 9, 2017
1 parent 7a5e8a9 commit 6ec2582
Show file tree
Hide file tree
Showing 20 changed files with 172 additions and 759 deletions.
2 changes: 2 additions & 0 deletions HISTORY
Expand Up @@ -19,6 +19,8 @@

* Update Visual Studio project for Visual Studio 15 - requires ruby 2.4+ (Charlie Savage)

* Remove APIs that have been deprecated for several years (Charlie Savage)

== 2.9.0 / 2016-06-13 Charlie Savage

* Revamp libxml-ruby's memory management to not cause crashes when used with Nokogiri (James Laird-Wah)
Expand Down
3 changes: 1 addition & 2 deletions ext/libxml/ruby_xml_html_parser.c
Expand Up @@ -42,8 +42,7 @@ static VALUE rxml_html_parser_initialize(int argc, VALUE *argv, VALUE self)

if (context == Qnil)
{
rb_warn("Passing no parameters to XML::HTMLParser.new is deprecated. Pass an instance of XML::Parser::Context instead.");
context = rb_class_new_instance(0, NULL, cXMLParserContext);
rb_raise(rb_eArgError, "An instance of a XML::Parser::Context must be passed to XML::HTMLParser.new");
}

rb_ivar_set(self, CONTEXT_ATTR, context);
Expand Down
30 changes: 0 additions & 30 deletions ext/libxml/ruby_xml_node.c
Expand Up @@ -421,35 +421,6 @@ static VALUE rxml_node_content_set(VALUE self, VALUE content)
return (Qtrue);
}

/*
* call-seq:
* node.content_stripped -> "string"
*
* Obtain this node's stripped content.
*
* *Deprecated*: Stripped content can be obtained via the
* +content+ method.
*/
static VALUE rxml_node_content_stripped_get(VALUE self)
{
xmlNodePtr xnode;
xmlChar* content;
VALUE result = Qnil;

xnode = rxml_get_xnode(self);

if (!xnode->content)
return result;

content = xmlNodeGetContent(xnode);
if (content)
{
result = rxml_new_cstr( content, NULL);
xmlFree(content);
}
return (result);
}

/*
* call-seq:
* node.debug -> true|false
Expand Down Expand Up @@ -1406,7 +1377,6 @@ void rxml_init_node(void)
rb_define_method(cXMLNode, "copy", rxml_node_copy, 1);
rb_define_method(cXMLNode, "content", rxml_node_content_get, 0);
rb_define_method(cXMLNode, "content=", rxml_node_content_set, 1);
rb_define_method(cXMLNode, "content_stripped", rxml_node_content_stripped_get, 0);
rb_define_method(cXMLNode, "debug", rxml_node_debug, 0);
rb_define_method(cXMLNode, "doc", rxml_node_doc, 0);
rb_define_method(cXMLNode, "empty?", rxml_node_empty_q, 0);
Expand Down
3 changes: 1 addition & 2 deletions ext/libxml/ruby_xml_parser.c
Expand Up @@ -44,8 +44,7 @@ static VALUE rxml_parser_initialize(int argc, VALUE *argv, VALUE self)

if (context == Qnil)
{
rb_warn("Passing no parameters to XML::Parser.new is deprecated. Pass an instance of XML::Parser::Context instead.");
context = rb_class_new_instance(0, NULL, cXMLParserContext);
rb_raise(rb_eArgError, "An instance of a XML::Parser::Context must be passed to XML::Parser.new");
}

rb_ivar_set(self, CONTEXT_ATTR, context);
Expand Down
22 changes: 6 additions & 16 deletions ext/libxml/ruby_xml_reader.c
Expand Up @@ -311,24 +311,14 @@ static VALUE rxml_reader_move_to_attr_no(VALUE self, VALUE index)
*/
static VALUE rxml_reader_move_to_attr(VALUE self, VALUE val)
{
if (TYPE(val) == T_FIXNUM)
{
rb_warn("%s::move_to_attribute with a Fixnum argument is deprecated. "
"Please, consider move_to_attribute_no method instead.",
rb_class2name(cXMLReader));
return rxml_reader_move_to_attr_no(self, val);
}
else
{
int ret;
xmlTextReaderPtr xreader;
int ret;
xmlTextReaderPtr xreader;

xreader = rxml_text_reader_get(self);
ret = xmlTextReaderMoveToAttribute(xreader,
(const xmlChar *) StringValueCStr(val));
xreader = rxml_text_reader_get(self);
ret = xmlTextReaderMoveToAttribute(xreader,
(const xmlChar *) StringValueCStr(val));

return INT2FIX(ret);
}
return INT2FIX(ret);
}

/*
Expand Down
3 changes: 1 addition & 2 deletions ext/libxml/ruby_xml_sax_parser.c
Expand Up @@ -58,8 +58,7 @@ static VALUE rxml_sax_parser_initialize(int argc, VALUE *argv, VALUE self)

if (context == Qnil)
{
rb_warn("Passing no parameters to XML::SaxParser.new is deprecated. Pass an instance of XML::Parser::Context instead.");
context = rb_class_new_instance(0, NULL, cXMLParserContext);
rb_raise(rb_eArgError, "An instance of a XML::Parser::Context must be passed to XML::SaxParser.new");
}

rb_ivar_set(self, CONTEXT_ATTR, context);
Expand Down
2 changes: 2 additions & 0 deletions ext/libxml/ruby_xml_xpath_object.c
Expand Up @@ -333,4 +333,6 @@ void rxml_init_xpath_object(void)
rb_define_method(cXMLXPathObject, "[]", rxml_xpath_object_aref, 1);
rb_define_method(cXMLXPathObject, "string", rxml_xpath_object_string, 0);
rb_define_method(cXMLXPathObject, "debug", rxml_xpath_object_debug, 0);
rb_define_alias(cXMLXPathObject, "size", "length");

}
2 changes: 1 addition & 1 deletion ext/vc/libxml_ruby/libxml_ruby.vcxproj
Expand Up @@ -128,7 +128,7 @@
<Link>
<AdditionalDependencies>x64-vcruntime140-ruby240.lib;libxml2.lib;%(AdditionalDependencies)</AdditionalDependencies>
<OutputFile>$(OutDir)\$(TargetName)$(TargetExt)</OutputFile>
<AdditionalLibraryDirectories>C:\msys64\local\vc\lib;C:\msys64\local\ruby\lib;C:\msys64\mingw64\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<AdditionalLibraryDirectories>C:\msys64\local\ruby\lib;C:\msys64\mingw64\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<GenerateDebugInformation>true</GenerateDebugInformation>
<SubSystem>Console</SubSystem>
<RandomizedBaseAddress>false</RandomizedBaseAddress>
Expand Down
7 changes: 1 addition & 6 deletions lib/libxml.rb
Expand Up @@ -7,29 +7,24 @@
rescue LoadError
require "libxml_ruby"
end

# Load Ruby supporting code.
require 'libxml/error'
require 'libxml/parser'
require 'libxml/document'
require 'libxml/namespaces'
require 'libxml/namespace'
require 'libxml/node'
require 'libxml/ns'
require 'libxml/attributes'
require 'libxml/attr'
require 'libxml/attr_decl'
require 'libxml/tree'
require 'libxml/reader'
require 'libxml/html_parser'
require 'libxml/sax_parser'
require 'libxml/sax_callbacks'
require 'libxml/xpath_object'

#Schema Interface
require 'libxml/schema'
require 'libxml/schema/type'
require 'libxml/schema/element'
require 'libxml/schema/attribute'

# Deprecated
require 'libxml/properties'
76 changes: 0 additions & 76 deletions lib/libxml/node.rb
Expand Up @@ -309,82 +309,6 @@ def xinclude_start?
alias :child :first
alias :each_child :each

# --- Deprecated Output ---
# :stopdoc:
def dump
warn('Node#dump is deprecated. Use Node#to_s instead.')
self.to_s
end

# --- Deprecated DOM Manipulation ---
def child_add(node)
warn('Node#child_add is deprecated. Use Node#<< instead.')
self << node
end

def child=(node)
warn('Node#child= is deprecated. Use Node#<< instead.')
self << node
end

# --- Deprecated Namespaces ---
def namespace
warn('Node#namespace is deprecated. Use Node#namespaces instead.')
self.namespaces.entries
end

def namespace=(value)
warn('Node#namespace= is deprecated. Use Node#namespaces.namespace= instead.')
self.namespaces.namespace = value
end

def namespace_node
warn('Node#namespace_node is deprecated. Use Node#namespaces.namespace instead.')
self.namespaces.namespace
end

def ns
warn('Node#ns is deprecated. Use Node#namespaces.namespace instead.')
self.namespaces.namespace
end

def ns?
warn('Node#ns? is deprecated. Use !Node#namespaces.namespace.nil? instead.')
!self.namespaces.namespace.nil?
end

def ns_def
warn('Node#ns_def is deprecated. Use Node#namespaces.definitions instead.')
self.namespaces.definitions
end

def ns_def?
warn('Node#ns_def? is deprecated. Use !Node#namespaces.definitions.nil? instead.')
!self.namespaces.definitions.nil?
end

def base
warn('Node#base is deprecated. Use Node#base_uri.')
self.base_uri
end

def base=(value)
warn('Node#base= is deprecated. Use Node#base_uri=.')
self.base_uri = value
end

def search_ns(prefix)
warn('Node#search_ns is deprecated. Use Node#namespaces.find_by_prefix instead.')
self.namespaces.find_by_prefix(prefix)
end

def search_href(href)
warn('Node#search_href is deprecated. Use Node#namespaces.find_by_href instead.')
self.namespaces.find_by_href(href)
end

# :startdoc:

private

def create_string_io(xml)
Expand Down
22 changes: 0 additions & 22 deletions lib/libxml/ns.rb

This file was deleted.

0 comments on commit 6ec2582

Please sign in to comment.