The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.
Changes 03
LICENSE 11
MANIFEST 02
META.json 23
META.yml 78
Makefile.PL 2411
lib/Data/Section/Simple.pm 216
t/multi-processes.t 045
t/release-pod-syntax.t 32
9 files changed (This is a version diff) 3991
@@ -1,5 +1,8 @@
 Revision history for Perl extension Data::Section::Simple
 
+0.06  2014-04-12 06:10:47 CST
+        - Fix race condition in a forked environment (hirose31) #4
+
 0.05  2013-06-06 14:13:22 PDT
         - use MakeMaker
 
@@ -22,7 +22,7 @@ This is free software, licensed under:
                      Version 1, February 1989
 
  Copyright (C) 1989 Free Software Foundation, Inc.
- 51 Franklin St, Suite 500, Boston, MA  02110-1335  USA
+ 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 
  Everyone is permitted to copy and distribute verbatim copies
  of this license document, but changing it is not allowed.
@@ -1,3 +1,4 @@
+# This file was automatically generated by Dist::Zilla::Plugin::Manifest v5.015.
 Changes
 LICENSE
 MANIFEST
@@ -12,6 +13,7 @@ t/DataInCode.pm
 t/Foo.pm
 t/basic.t
 t/data.t
+t/multi-processes.t
 t/no-datat.t
 t/pkg_oo.t
 t/release-pod-syntax.t
@@ -4,7 +4,7 @@
       "Tatsuhiko Miyagawa <miyagawa@bulknews.net>"
    ],
    "dynamic_config" : 0,
-   "generated_by" : "Dist::Milla version v1.0.2, Dist::Zilla version 4.300034, CPAN::Meta::Converter version 2.131560",
+   "generated_by" : "Dist::Milla version v1.0.4, Dist::Zilla version 5.015, CPAN::Meta::Converter version 2.140640",
    "license" : [
       "perl_5"
    ],
@@ -58,9 +58,10 @@
          "web" : "https://github.com/miyagawa/Data-Section-Simple"
       }
    },
-   "version" : "0.05",
+   "version" : "0.06",
    "x_contributors" : [
       "Bruce Gray <bruce.gray@acm.org>",
+      "HIROSE Masaaki <hirose31@gmail.com>",
       "Tatsuhiko Miyagawa <miyagawa@gmail.com>",
       "tokuhirom <tokuhirom@gmail.com>"
    ]
@@ -3,16 +3,16 @@ abstract: 'Read data from __DATA__'
 author:
   - 'Tatsuhiko Miyagawa <miyagawa@bulknews.net>'
 build_requires:
-  Test::More: 0.88
-  Test::Requires: 0
+  Test::More: '0.88'
+  Test::Requires: '0'
 configure_requires:
-  ExtUtils::MakeMaker: 6.30
+  ExtUtils::MakeMaker: '6.30'
 dynamic_config: 0
-generated_by: 'Dist::Milla version v1.0.2, Dist::Zilla version 4.300034, CPAN::Meta::Converter version 2.131560'
+generated_by: 'Dist::Milla version v1.0.4, Dist::Zilla version 5.015, CPAN::Meta::Converter version 2.140640'
 license: perl
 meta-spec:
   url: http://module-build.sourceforge.net/META-spec-v1.4.html
-  version: 1.4
+  version: '1.4'
 name: Data-Section-Simple
 no_index:
   directory:
@@ -23,13 +23,14 @@ no_index:
     - eg
     - examples
 requires:
-  perl: 5.008001
+  perl: '5.008001'
 resources:
   bugtracker: https://github.com/miyagawa/Data-Section-Simple/issues
   homepage: https://github.com/miyagawa/Data-Section-Simple
   repository: https://github.com/miyagawa/Data-Section-Simple.git
-version: 0.05
+version: '0.06'
 x_contributors:
   - 'Bruce Gray <bruce.gray@acm.org>'
+  - 'HIROSE Masaaki <hirose31@gmail.com>'
   - 'Tatsuhiko Miyagawa <miyagawa@gmail.com>'
   - 'tokuhirom <tokuhirom@gmail.com>'
@@ -1,4 +1,5 @@
 
+# This file was automatically generated by Dist::Zilla::Plugin::MakeMaker v5.015.
 use strict;
 use warnings;
 
@@ -24,37 +25,23 @@ my %WriteMakefileArgs = (
     "Test::More" => "0.88",
     "Test::Requires" => 0
   },
-  "VERSION" => "0.05",
+  "VERSION" => "0.06",
   "test" => {
     "TESTS" => "t/*.t"
   }
 );
 
 
-unless ( eval { ExtUtils::MakeMaker->VERSION(6.63_03) } ) {
-  my $tr = delete $WriteMakefileArgs{TEST_REQUIRES};
-  my $br = $WriteMakefileArgs{BUILD_REQUIRES};
-  for my $mod ( keys %$tr ) {
-    if ( exists $br->{$mod} ) {
-      $br->{$mod} = $tr->{$mod} if $tr->{$mod} > $br->{$mod};
-    }
-    else {
-      $br->{$mod} = $tr->{$mod};
-    }
-  }
-}
+my %FallbackPrereqs = (
+  "Test::More" => "0.88",
+  "Test::Requires" => 0
+);
 
-unless ( eval { ExtUtils::MakeMaker->VERSION(6.56) } ) {
-  my $br = delete $WriteMakefileArgs{BUILD_REQUIRES};
-  my $pp = $WriteMakefileArgs{PREREQ_PM};
-  for my $mod ( keys %$br ) {
-    if ( exists $pp->{$mod} ) {
-      $pp->{$mod} = $br->{$mod} if $br->{$mod} > $pp->{$mod};
-    }
-    else {
-      $pp->{$mod} = $br->{$mod};
-    }
-  }
+
+unless ( eval { ExtUtils::MakeMaker->VERSION(6.63_03) } ) {
+  delete $WriteMakefileArgs{TEST_REQUIRES};
+  delete $WriteMakefileArgs{BUILD_REQUIRES};
+  $WriteMakefileArgs{PREREQ_PM} = \%FallbackPrereqs;
 }
 
 delete $WriteMakefileArgs{CONFIGURE_REQUIRES}
@@ -2,7 +2,7 @@ package Data::Section::Simple;
 
 use strict;
 use 5.008_001;
-our $VERSION = '0.05';
+our $VERSION = '0.06';
 
 use base qw(Exporter);
 our @EXPORT_OK = qw(get_data_section);
@@ -20,7 +20,21 @@ sub get_data_section {
         return unless $all;
         return $all->{$_[0]};
     } else {
-        my $d = do { no strict 'refs'; \*{$self->{package}."::DATA"} };
+        my $filepath;
+        if ($self->{package} eq 'main') {
+            my $l = 0;
+            while (my @c = caller($l++)) {
+                $filepath = $c[1];
+            }
+        } else {
+            my $pkg = $self->{package};
+            $pkg =~ s/::/\//g;
+            $pkg .= '.pm';
+            $filepath = $INC{$pkg} if $INC{$pkg};
+        }
+        return unless $filepath;
+
+        open my $d, '<', $filepath or return;
         return unless defined fileno $d;
 
         seek $d, 0, 0;
@@ -0,0 +1,45 @@
+use strict;
+use Data::Section::Simple qw(get_data_section);
+use Test::More;
+
+my $expect =<<HTML;
+<html>
+<body>Foo</body>
+</html>
+
+HTML
+
+my $n = 100;
+while ($n-- > 0) {
+    fork && next;
+    exit(get_data_section('foo.html') eq $expect ? 0 : 1);
+}
+
+my $failed = 0;
+while (waitpid(-1,0) > 0) {
+    $failed = 1 if $? >> 8 != 0;
+}
+
+ok(!$failed);
+
+done_testing;
+
+__DATA__
+
+@@ foo.html
+<html>
+<body>Foo</body>
+</html>
+
+@@ bar.tt  
+[% IF foo %]
+bar
+[% END %]
+
+__END__
+
+=head1 NAME
+
+basic.t
+
+=cut
@@ -7,9 +7,8 @@ BEGIN {
   }
 }
 
+# This file was automatically generated by Dist::Zilla::Plugin::PodSyntaxTests.
 use Test::More;
-
-eval "use Test::Pod 1.41";
-plan skip_all => "Test::Pod 1.41 required for testing POD" if $@;
+use Test::Pod 1.41;
 
 all_pod_files_ok();