This is an automated email from the git hooks/post-receive script.

intrigeri pushed a commit to annotated tag 0.19
in repository libtest-bdd-cucumber-perl.

commit f7db48c14f86186203f3dc5a6b38321b2d0488ff
Author: glauschwuffel <glauschwuf...@nomaden.org>
Date:   Sat May 31 12:21:51 2014 +0200

    wip: move i18n.json from DATA segment to shared file. cleanup to follow
---
 lib/Test/BDD/Cucumber/I18n.pm                    |  16 ++-
 lib/Test/BDD/Cucumber/I18n.pm => share/i18n.json | 133 -----------------------
 t/210_background_sections.t                      |   8 +-
 t/220_tag_parsing.t                              |   4 +
 t/240-localized-features.t                       |  18 ++-
 t/250-i18n-json.t                                |  18 +++
 t/310_auto_corpus.t                              |   5 +
 t/700_tag_processing.t                           |   5 +
 t/800_regressions_010_too_few_features.t         |   8 +-
 t/900_run_cucumber_tests.t                       |   8 +-
 10 files changed, 79 insertions(+), 144 deletions(-)

diff --git a/lib/Test/BDD/Cucumber/I18n.pm b/lib/Test/BDD/Cucumber/I18n.pm
index eeb5015..3e29711 100644
--- a/lib/Test/BDD/Cucumber/I18n.pm
+++ b/lib/Test/BDD/Cucumber/I18n.pm
@@ -32,15 +32,25 @@ use warnings;
 use Encode qw(encode);
 use JSON::XS;
 use utf8;
+use Ouch;
 
 use base 'Exporter';
 
 our @EXPORT_OK=qw(languages langdef has_language readable_keywords 
keyword_to_subname);
 
+use File::ShareDir qw( dist_dir );
+
+my $dir=dist_dir('My-Dist');       # dir with files from $dist/share
+my $filename=$dir.'/i18n.json'; # TODO FileSpec
+ouch 'i18n_error', 'I18n file does not exist', $filename unless -e $filename;
+my $success=open(my $fh, '<', $filename);
+ouch 'i18n_error', "Unable to open i18n file: $!", $filename unless $success;
+
 # Parse keywords hash for all supported languages from the DATA segment
-my $json      = join '', (<DATA>);
-my $json_utf8 = encode('UTF-8', $json);
-my $langdefs  = decode_json( $json_utf8 );
+#my $json      = join '', (<DATA>);
+my $json      = join '', (<$fh>);
+#my $json_utf8 = encode('UTF-8', $json);
+my $langdefs  = decode_json( $json );
 
 # strip asterisks from the keyword definitions since they don't work anyway
 for my $language ( languages() ) {
diff --git a/lib/Test/BDD/Cucumber/I18n.pm b/share/i18n.json
similarity index 87%
copy from lib/Test/BDD/Cucumber/I18n.pm
copy to share/i18n.json
index eeb5015..97e2a2f 100644
--- a/lib/Test/BDD/Cucumber/I18n.pm
+++ b/share/i18n.json
@@ -1,136 +1,3 @@
-package Test::BDD::Cucumber::I18n;
-
-=head1 NAME
-
-Test::BDD::Cucumber::I18N - Internationalization
-
-=head1 DESCRIPTION
-
-Internationalization of feature files and step definitions.
-
-=head1 SYNOPSIS
-
-use Test::BDD::Cucumber::I18N qw(languages has_language langdef);
-
-# get codes of supported languages
-my @supported_languages = languages();
-
-# look up if a language is supported
-my $language_is_supported = has_language('de');
-
-# get definition of a language
-my $langdef = langdef('de');
-
-# get readable keyword definitions
-my $string = readable_keywords
-
-=cut
-
-use strict;
-use warnings;
-
-use Encode qw(encode);
-use JSON::XS;
-use utf8;
-
-use base 'Exporter';
-
-our @EXPORT_OK=qw(languages langdef has_language readable_keywords 
keyword_to_subname);
-
-# Parse keywords hash for all supported languages from the DATA segment
-my $json      = join '', (<DATA>);
-my $json_utf8 = encode('UTF-8', $json);
-my $langdefs  = decode_json( $json_utf8 );
-
-# strip asterisks from the keyword definitions since they don't work anyway
-for my $language ( languages() ) {
-  my $langdef=langdef($language);
-    for my $key ( keys %$langdef ) {
-      $langdef->{$key} =~ s{\Q*|\E}{};
-    }
-}
-
-sub languages {
-    return keys $langdefs;
-}
-
-sub has_language {
-    my ($language) = @_;
-    exists $langdefs->{$language};
-}
-
-sub langdef {
-    my ($language) = @_;
-
-    return unless has_language($language);
-    return $langdefs->{$language};
-}
-
-sub readable_keywords {
-    my ( $string, $transform ) = @_;
-
-    my @keywords = split( /\|/, $string );
-
-    @keywords = map { $transform->($_) } @keywords if $transform;
-
-    return join( ', ', map { '"' . $_ . '"' } @keywords );
-}
-
-sub keyword_to_subname {
-    my ($word)=@_;
-
-    # remove non-word characters so we have a decent sub name
-    $word =~ s{[^\p{Word}]}{}g;
-
-    return $word;
-}
-
-=head1 LANGUAGES
-
-Languages are defined in a JSON-based hash in the __DATA__ section of this 
file.
-That hash the i18n.json of the Gherkin project (the parser for
-features that the original Cucumber tool uses). Just copy Gherkin's i18n.json
-in the data section to update language definitions.
-
-Gherkin can be found at L<https://github.com/cucumber/gherkin>,
-its i18n.json at 
L<https://github.com/cucumber/gherkin/blob/master/lib/gherkin/i18n.json>.
-
-=head1 AUTHOR
-
-Gregor Goldbach C<glauschwuf...@nomaden.org>
-(based on the works of Pablo Duboue)
-
-=head1 LICENSE
-
-Copyright 2014, Gregor Goldbach; Licensed under the same terms as Perl
-
-Definition of languages based on data from Gherkin.
-Copyright (c) 2009-2013 Mike Sassak, Gregory Hnatiuk, Aslak Helles√ły
-
-Permission is hereby granted, free of charge, to any person obtaining
-a copy of this software and associated documentation files (the
-"Software"), to deal in the Software without restriction, including
-without limitation the rights to use, copy, modify, merge, publish,
-distribute, sublicense, and/or sell copies of the Software, and to
-permit persons to whom the Software is furnished to do so, subject to
-the following conditions:
-
-The above copyright notice and this permission notice shall be
-included in all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-
-=cut
-
-1;
-
-__DATA__
 {
        "en": {
          "name": "English",
diff --git a/t/210_background_sections.t b/t/210_background_sections.t
index ac62e73..a0c4d4a 100644
--- a/t/210_background_sections.t
+++ b/t/210_background_sections.t
@@ -4,6 +4,12 @@ use strict;
 use warnings;
 
 use Test::More;
+
+use Test::File::ShareDir
+  -share => {
+    -dist   => { 'My-Dist'    => 'share' }
+  };
+
 use Test::BDD::Cucumber::Parser;
 use Test::BDD::Cucumber::Executor;
 use Test::BDD::Cucumber::Harness::Data;
@@ -76,4 +82,4 @@ is( $step_status->(1), 'failing', "Step 2 fails" );
 is( $step_status->(2), 'pending', "Step 3 pending" );
 is( $step_status->(3), 'pending', "Step 4 pending" );
 
-done_testing();
\ No newline at end of file
+done_testing();
diff --git a/t/220_tag_parsing.t b/t/220_tag_parsing.t
index f545321..38498f7 100644
--- a/t/220_tag_parsing.t
+++ b/t/220_tag_parsing.t
@@ -4,6 +4,10 @@ use strict;
 use warnings;
 
 use Test::More;
+use Test::File::ShareDir
+  -share => {
+    -dist   => { 'My-Dist'    => 'share' }
+  };
 use Test::BDD::Cucumber::Parser;
 
 my $feature_with_background = <<'HEREDOC'
diff --git a/t/240-localized-features.t b/t/240-localized-features.t
index bcf716e..46d3bd1 100644
--- a/t/240-localized-features.t
+++ b/t/240-localized-features.t
@@ -4,17 +4,25 @@ use strict;
 use warnings;
 
 use Test::More;
+
+use Test::File::ShareDir
+  -share => {
+    -dist   => { 'My-Dist'    => 'share' }
+  };
+
 use Test::BDD::Cucumber::Parser;
 
 my $files = {
-   en => 'examples/calculator/features/basic.feature',
-   es => 'examples/calculator/features/basic.feature.es'
+    en => 'examples/calculator/features/basic.feature',
+    es => 'examples/calculator/features/basic.feature.es'
 };
 
-for my $language (keys %$files) {
-    my $feature = Test::BDD::Cucumber::Parser->parse_file( $files->{$language} 
);
+for my $language ( keys %$files ) {
+    my $feature =
+      Test::BDD::Cucumber::Parser->parse_file( $files->{$language} );
 
-    isa_ok $feature, 'Test::BDD::Cucumber::Model::Feature';
+    isa_ok $feature, 'Test::BDD::Cucumber::Model::Feature',
+      "feature in language '$language' can be parsed";
     is $feature->language, $language, 'feature language';
 }
 
diff --git a/t/250-i18n-json.t b/t/250-i18n-json.t
new file mode 100644
index 0000000..d3bc7e8
--- /dev/null
+++ b/t/250-i18n-json.t
@@ -0,0 +1,18 @@
+#!perl
+
+use strict;
+use warnings;
+
+use Test::More;
+
+use Test::File::ShareDir
+  -share => {
+    -dist   => { 'My-Dist'    => 'share' }
+  };
+# include it *after* Test::File::ShareDir since we need the share dir
+use Test::BDD::Cucumber::I18n qw(languages);
+
+my @languages = languages();
+ok scalar @languages, 'languages can be retrieved';
+
+done_testing;
diff --git a/t/310_auto_corpus.t b/t/310_auto_corpus.t
index 6bc2948..2281d25 100755
--- a/t/310_auto_corpus.t
+++ b/t/310_auto_corpus.t
@@ -7,11 +7,16 @@ use FindBin::libs;
 use Test::More;
 use Test::Differences;
 use Test::DumpFeature;
+use Test::File::ShareDir
+  -share => {
+    -dist   => { 'My-Dist'    => 'share' }
+  };
 use Test::BDD::Cucumber::Parser;
 use YAML::Syck;
 use File::Slurp;
 use File::Find::Rule;
 
+
 my @files = @ARGV;
 @files = File::Find::Rule
     ->file()->name( '*.feature_corpus' )->in( 't/auto_corpus/' )
diff --git a/t/700_tag_processing.t b/t/700_tag_processing.t
index 6565ad2..d640fbf 100644
--- a/t/700_tag_processing.t
+++ b/t/700_tag_processing.t
@@ -5,9 +5,14 @@ use warnings;
 
 use Test::More;
 use FindBin::libs;
+use Test::File::ShareDir
+  -share => {
+    -dist   => { 'My-Dist'    => 'share' }
+  };
 use App::pherkin;
 use Data::Dumper;
 
+
 for my $test (
     [
         'Single tag: -t @cow',
diff --git a/t/800_regressions_010_too_few_features.t 
b/t/800_regressions_010_too_few_features.t
index aa78a5d..94315b4 100644
--- a/t/800_regressions_010_too_few_features.t
+++ b/t/800_regressions_010_too_few_features.t
@@ -4,6 +4,12 @@ use strict;
 use warnings;
 
 use Test::More;
+
+use Test::File::ShareDir
+  -share => {
+    -dist   => { 'My-Dist'    => 'share' }
+  };
+
 use Test::BDD::Cucumber::Parser;
 
 my $feature = Test::BDD::Cucumber::Parser->parse_file(
@@ -25,4 +31,4 @@ for my $scenario_name (
 
 ok( $feature->background, "Background section exists" );
 
-done_testing();
\ No newline at end of file
+done_testing();
diff --git a/t/900_run_cucumber_tests.t b/t/900_run_cucumber_tests.t
index fbc7ac6..5f3bb6f 100644
--- a/t/900_run_cucumber_tests.t
+++ b/t/900_run_cucumber_tests.t
@@ -2,9 +2,15 @@
 
 use strict;
 use warnings;
-use FindBin::libs;
 
+use FindBin::libs;
 use Test::More;
+
+use Test::File::ShareDir
+  -share => {
+    -dist   => { 'My-Dist'    => 'share' }
+  };
+
 use Test::BDD::Cucumber::Loader;
 use Test::BDD::Cucumber::Harness::TestBuilder;
 

-- 
Alioth's /usr/local/bin/git-commit-notice on 
/srv/git.debian.org/git/pkg-perl/packages/libtest-bdd-cucumber-perl.git

_______________________________________________
Pkg-perl-cvs-commits mailing list
Pkg-perl-cvs-commits@lists.alioth.debian.org
http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/pkg-perl-cvs-commits

Reply via email to