[libtest-bdd-cucumber-perl] 30/52: strip asterisk from i18n definitions since it doesn't work anyway.

Intrigeri intrigeri at moszumanska.debian.org
Thu Jun 19 10:18:34 UTC 2014


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 dddf824d77b844d6787901c8b987e96e87d5fe24
Author: glauschwuffel <glauschwuffel at nomaden.org>
Date:   Thu May 29 14:25:22 2014 +0200

    strip asterisk from i18n definitions since it doesn't work anyway.
    
    pherkin (in contrast to cucumber) handles Given, Then and When steps differently. When using an asterisk as the step keyword (as you can with cucumber), pherkin uses the last verb for the step keyword and tries to find a step definition for that.'
---
 {examples/i18n => i18n}/de/features/basic.feature  |  0
 .../features/step_definitions/calculator_steps.pl  |  0
 lib/Test/BDD/Cucumber/I18n.pm                      | 24 +++++++++++++++++-----
 3 files changed, 19 insertions(+), 5 deletions(-)

diff --git a/examples/i18n/de/features/basic.feature b/i18n/de/features/basic.feature
similarity index 100%
rename from examples/i18n/de/features/basic.feature
rename to i18n/de/features/basic.feature
diff --git a/examples/i18n/de/features/step_definitions/calculator_steps.pl b/i18n/de/features/step_definitions/calculator_steps.pl
similarity index 100%
rename from examples/i18n/de/features/step_definitions/calculator_steps.pl
rename to i18n/de/features/step_definitions/calculator_steps.pl
diff --git a/lib/Test/BDD/Cucumber/I18n.pm b/lib/Test/BDD/Cucumber/I18n.pm
index 5490123..eeb5015 100644
--- a/lib/Test/BDD/Cucumber/I18n.pm
+++ b/lib/Test/BDD/Cucumber/I18n.pm
@@ -21,6 +21,9 @@ 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;
@@ -39,6 +42,14 @@ 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;
 }
@@ -56,13 +67,13 @@ sub langdef {
 }
 
 sub readable_keywords {
-    my ($string, $transform)=@_;
+    my ( $string, $transform ) = @_;
 
-    my @keywords= grep { $_ ne '*' } split(/\|/, $string);
+    my @keywords = split( /\|/, $string );
 
     @keywords = map { $transform->($_) } @keywords if $transform;
 
-    return join(', ', map { '"'.$_.'"' } @keywords);
+    return join( ', ', map { '"' . $_ . '"' } @keywords );
 }
 
 sub keyword_to_subname {
@@ -77,8 +88,9 @@ sub keyword_to_subname {
 =head1 LANGUAGES
 
 Languages are defined in a JSON-based hash in the __DATA__ section of this file.
-That hash is based on the i18n.json of the Gherkin project (the parser for
-features that the original Cucumber tool uses).
+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>.
@@ -116,6 +128,8 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 
 =cut
 
+1;
+
 __DATA__
 {
 	"en": {

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



More information about the Pkg-perl-cvs-commits mailing list