replace usage of Class::Tiny::Chained
Dan Book [Mon, 9 Nov 2015 04:59:07 +0000 (23:59 -0500)]
Build.PL
META.json
cpanfile
lib/DOM/Tiny/CSS.pm
lib/DOM/Tiny/HTML.pm

index 8291946..f594773 100644 (file)
--- a/Build.PL
+++ b/Build.PL
@@ -83,7 +83,6 @@ EOW
       "recursive_test_files" => 1,
       "requires" => {
         "Carp" => 0,
-        "Class::Tiny::Chained" => 0,
         "Exporter" => 0,
         "List::Util" => 0,
         "Scalar::Util" => 0,
index 2ddf603..d523916 100644 (file)
--- a/META.json
+++ b/META.json
@@ -39,7 +39,6 @@
       "runtime" : {
          "requires" : {
             "Carp" : "0",
-            "Class::Tiny::Chained" : "0",
             "Exporter" : "0",
             "List::Util" : "0",
             "Scalar::Util" : "0",
index f5d9461..e1ffa35 100644 (file)
--- a/cpanfile
+++ b/cpanfile
@@ -1,6 +1,5 @@
 requires 'perl' => '5.010001';
 requires 'Carp';
-requires 'Class::Tiny::Chained';
 requires 'Exporter';
 requires 'List::Util';
 requires 'Scalar::Util';
index becedc6..3970dfd 100644 (file)
@@ -2,7 +2,6 @@ package DOM::Tiny::CSS;
 
 use strict;
 use warnings;
-use Class::Tiny::Chained 'tree';
 
 our $VERSION = '0.001';
 
@@ -18,6 +17,18 @@ my $ATTR_RE   = qr/
   \]
 /x;
 
+sub new {
+  my $class = shift;
+  bless @_ ? @_ > 1 ? {@_} : {%{$_[0]}} : {}, ref $class || $class;
+}
+
+sub tree {
+  my $self = shift;
+  return $self->{tree} unless @_;
+  $self->{tree} = shift;
+  return $self;
+}
+
 sub matches {
   my $tree = shift->tree;
   return $tree->[0] ne 'tag' ? undef : _match(_compile(shift), $tree, $tree);
@@ -544,8 +555,15 @@ carefully since it is very dynamic.
 
 =head1 METHODS
 
-L<DOM::Tiny::CSS> inherits a constructor from L<Class::Tiny::Object|Class::Tiny/"Object construction">,
-and implements the following methods.
+L<DOM::Tiny::CSS> implements the following methods.
+
+=head2 new
+
+  my $css = DOM::Tiny::CSS->new;
+  my $css = DOM::Tiny::CSS->new(tree => $tree);
+  my $css = DOM::Tiny::CSS->new({tree => $tree});
+
+Construct a new hash-based L<DOM::Tiny::CSS> object.
 
 =head2 matches
 
index 042ae5f..dfcb190 100644 (file)
@@ -4,7 +4,6 @@ use strict;
 use warnings;
 use DOM::Tiny::Entities qw(html_escape html_unescape);
 use Scalar::Util 'weaken';
-use Class::Tiny::Chained 'xml', { tree => sub { ['root'] } };
 
 our $VERSION = '0.001';
 
@@ -95,6 +94,25 @@ my %BLOCK = map { $_ => 1 } (
   qw(tbody td template textarea tfoot th thead title tr tt u ul xmp)
 );
 
+sub new {
+  my $class = shift;
+  bless @_ ? @_ > 1 ? {@_} : {%{$_[0]}} : {}, ref $class || $class;
+}
+
+sub tree {
+  my $self = shift;
+  return exists $self->{tree} ? $self->{tree} : ($self->{tree} = ['root']) unless @_;
+  $self->{tree} = shift;
+  return $self;
+}
+
+sub xml {
+  my $self = shift;
+  return $self->{xml} unless @_;
+  $self->{xml} = shift;
+  return $self;
+}
+
 sub parse {
   my ($self, $html) = (shift, "$_[0]");
 
@@ -311,8 +329,15 @@ auto detection based on processing instructions.
 
 =head1 METHODS
 
-L<DOM::Tiny::HTML> inherits a constructor from L<Class::Tiny::Object|Class::Tiny/"Object construction">,
-and implements the following methods.
+L<DOM::Tiny::HTML> implements the following methods.
+
+=head2 new
+
+  my $html = DOM::Tiny::HTML->new;
+  my $html = DOM::Tiny::HTML->new(xml => 1);
+  my $html = DOM::Tiny::HTML->new({xml => 1});
+
+Construct a new hash-based L<DOM::Tiny::HTML> object.
 
 =head2 parse