Hello community,

here is the log from the commit of package rubygem-po_to_json for 
openSUSE:Factory checked in at 2015-02-22 17:26:40
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/rubygem-po_to_json (Old)
 and      /work/SRC/openSUSE:Factory/.rubygem-po_to_json.new (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Package is "rubygem-po_to_json"

Changes:
--------
--- /work/SRC/openSUSE:Factory/rubygem-po_to_json/rubygem-po_to_json.changes    
2015-02-20 12:01:09.000000000 +0100
+++ 
/work/SRC/openSUSE:Factory/.rubygem-po_to_json.new/rubygem-po_to_json.changes   
    2015-02-22 17:26:41.000000000 +0100
@@ -1,0 +2,8 @@
+Fri Feb 20 14:13:49 UTC 2015 - tboer...@suse.com
+
+- Updated to 0.1.0
+  - Transfer from github.com/nubis/po_to_json
+  - Added TravisCI, Rubocop and Coveralls
+  - Updated structure to my opinionated gem style
+
+-------------------------------------------------------------------

Old:
----
  po_to_json-0.0.7.gem

New:
----
  po_to_json-0.1.0.gem

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Other differences:
------------------
++++++ rubygem-po_to_json.spec ++++++
--- /var/tmp/diff_new_pack.GS7OuB/_old  2015-02-22 17:26:42.000000000 +0100
+++ /var/tmp/diff_new_pack.GS7OuB/_new  2015-02-22 17:26:42.000000000 +0100
@@ -1,7 +1,7 @@
 #
 # spec file for package rubygem-po_to_json
 #
-# Copyright (c) 2014 SUSE LINUX Products GmbH, Nuernberg, Germany.
+# Copyright (c) 2015 SUSE LINUX Products GmbH, Nuernberg, Germany.
 #
 # All modifications and additions to the file contributed by third parties
 # remain the property of their copyright owners, unless otherwise agreed
@@ -24,25 +24,24 @@
 #
 
 Name:           rubygem-po_to_json
-Version:        0.0.7
+Version:        0.1.0
 Release:        0
 %define mod_name po_to_json
 %define mod_full_name %{mod_name}-%{version}
 BuildRoot:      %{_tmppath}/%{name}-%{version}-build
-BuildRequires:  ruby-macros >= 5
-BuildRequires:  %{ruby}
 BuildRequires:  %{rubygem gem2rpm}
-Url:            https://github.com/nubis/po_to_json
+BuildRequires:  %{ruby}
+BuildRequires:  ruby-macros >= 5
+Url:            https://github.com/webhippie/po_to_json
 Source:         http://rubygems.org/gems/%{mod_full_name}.gem
 Source1:        gem2rpm.yml
-Summary:        Convert gettext PO files to json
+Summary:        Convert gettext PO files to JSON
 License:        MIT
 Group:          Development/Languages/Ruby
 
 %description
-Convert gettext PO files to json to use in your javascript app, based
-po2json.pl (by DuckDuckGo, Inc. http://duckduckgo.com/, Torsten Raudssus
-<tors...@raudss.us>.).
+Convert gettext PO files to JSON objects so that you can use it in your
+application.
 
 %prep
 
@@ -50,7 +49,7 @@
 
 %install
 %gem_install \
-  --doc-files="README.md MIT-LICENSE" \
+  --doc-files="CHANGELOG.md README.md LICENSE" \
   -f
 
 %gem_packages

++++++ gem2rpm.yml ++++++
--- /var/tmp/diff_new_pack.GS7OuB/_old  2015-02-22 17:26:42.000000000 +0100
+++ /var/tmp/diff_new_pack.GS7OuB/_new  2015-02-22 17:26:42.000000000 +0100
@@ -21,7 +21,7 @@
 # ## used by gem2rpm
 # :patches:
 #   foo.patch: -p1
-#   bar.patch: 
+#   bar.patch:
 # ## used by gem2rpm
 # :sources:
 # - foo.desktop
@@ -69,4 +69,4 @@
 #       /bin/echo foo
 #
 ---
-:license: MIT
+:sources:

++++++ po_to_json-0.0.7.gem -> po_to_json-0.1.0.gem ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/CHANGELOG.md new/CHANGELOG.md
--- old/CHANGELOG.md    1970-01-01 01:00:00.000000000 +0100
+++ new/CHANGELOG.md    1970-01-01 01:00:00.000000000 +0100
@@ -0,0 +1,7 @@
+# Changelog
+
+## [0.1.0](https://github.com/webhippie/po_to_json/releases/tag/v0.1.0) - 
2015-02-19
+
+* Transfer from github.com/nubis/po_to_json
+* Added TravisCI, Rubocop and Coveralls
+* Updated structure to my opinionated gem style
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/LICENSE new/LICENSE
--- old/LICENSE 1970-01-01 01:00:00.000000000 +0100
+++ new/LICENSE 1970-01-01 01:00:00.000000000 +0100
@@ -0,0 +1,22 @@
+The MIT License (MIT)
+
+Copyright (c) 2012-2015 Dropmysite.com <https://dropmyemail.com>
+Copyright (c) 2015 Webhippie <http://www.webhippie.de>
+
+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.
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/MIT-LICENSE new/MIT-LICENSE
--- old/MIT-LICENSE     1970-01-01 01:00:00.000000000 +0100
+++ new/MIT-LICENSE     1970-01-01 01:00:00.000000000 +0100
@@ -1,20 +0,0 @@
-Copyright 2012 Dropmysite.com. https://dropmyemail.com
-
-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.
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/README.md new/README.md
--- old/README.md       1970-01-01 01:00:00.000000000 +0100
+++ new/README.md       1970-01-01 01:00:00.000000000 +0100
@@ -1,50 +1,95 @@
-## po_to_json
+# PoToJson
 
-Convert gettext PO files to json to use in your javascript app, based 
po2json.pl (by DuckDuckGo, Inc. http://duckduckgo.com/, Torsten Raudssus 
<tors...@raudss.us>.
+[![Gem 
Version](http://img.shields.io/gem/v/po_to_json.svg)](https://rubygems.org/gems/po_to_json)
+[![Build 
Status](https://secure.travis-ci.org/webhippie/po_to_json.svg)](https://travis-ci.org/webhippie/po_to_json)
+[![Code 
Climate](https://codeclimate.com/github/webhippie/po_to_json.svg)](https://codeclimate.com/github/webhippie/po_to_json)
+[![Test 
Coverage](https://codeclimate.com/github/webhippie/po_to_json/badges/coverage.svg)](https://codeclimate.com/github/webhippie/po_to_json)
+[![Dependency 
Status](https://gemnasium.com/webhippie/po_to_json.svg)](https://gemnasium.com/webhippie/po_to_json)
 
-Ideally you'll use this on a rake task that creates json versions of your po 
files, which can later be used from javascript
-with Jed ( http://slexaxton.github.com/Jed/ )
+Convert gettext PO files to JSON to use in your javascript app, based on
+po2json.pl by [DuckDuckGo, Inc.](http://duckduckgo.com/). Ideally you'll use
+this on a Rake task that creates JSON versions of your PO files, which can
+later be used from javascript with [Jed](http://slexaxton.github.io/Jed/)
 
-## Installing
 
-Via rubygems:
-```ruby
-gem install po_to_json
-```
+## Versions
+
+This gem is tested on the following versions automated through TravisCI:
+
+* Ruby
+  * 1.9.3
+  * 2.0.0
+  * 2.1.0
+* Json
+  * 1.6.8
+  * 1.7.7
+  * 1.8.2
+
+
+## Installation
 
-In your gemfile:
 ```ruby
-gem 'po_to_json'
+gem "po_to_json", "~> 0.1.0"
 ```
 
+
 ## Usage
 
-Most common use would be to generate a Jed ready javascript file. For example, 
in a Rails 3 project:
+Most common use would be to generate a Jed ready javascript file. For example,
+in a Rails project:
 
 ```ruby
-require 'po_to_json'
-json_string = 
PoToJson.new("#{Rails.root}/locale/es/app.po").generate_for_jed('es')
-File.open("#{Rails.root}/app/assets/javascripts/locale/es/app.js",'w').write(json_string)
+require "po_to_json"
+
+json = PoToJson.new(
+  Rails.root.join("locale", "de", "app.po")
+).generate_for_jed("de")
+
+Rails.root.join("app", "assets", "javascripts", "locale", "de", 
"app.js").write(json)
 ```
 
-If you need a pretty json, add `:pretty => true` to `generate_for_jed`, like
+If you need a pretty json, add `pretty: true` to `generate_for_jed`, like the
+following example:
 
 ```ruby
-json_string = 
PoToJson.new("#{Rails.root}/locale/es/app.po").generate_for_jed('es', :pretty 
=> true)
+require "po_to_json"
+
+json = PoToJson.new(
+  Rails.root.join("locale", "de", "app.po")
+).generate_for_jed("de", pretty: true)
+
+Rails.root.join("app", "assets", "javascripts", "locale", "de", 
"app.js").write(json)
 ```
 
-The javascript file generated has a global 'locales' object with an attribute 
corresponding to the generated language:
+The javascript file generated has a global "locales" object with an attribute
+corresponding to the generated language:
 
 ```javascript
-i18n = new Jed(locales['es'])
-i18n.gettext('Hello World') // Should evaluate to 'Hola Mundo'
+i18n = new Jed(locales["de"])
+i18n.gettext("Hello World") // Should evaluate to "Hallo Welt"
 ```
 
-## Maintainers
 
-* eromirou (https://github.com/eromirou)
-* Nubis (https://github.com/nubis)
+## Contributing
+
+Fork -> Patch -> Spec -> Push -> Pull Request
+
+
+## Authors
+
+* [Thomas Boerger](https://github.com/tboerger)
+* [Nubis](https://github.com/nubis)
+* [Other 
contributors](https://github.com/webhippie/po_to_json/graphs/contributors)
+
 
 ## License
 
-MIT License. Copyright 2012 Dropmysite.com. https://dropmyemail.com
+MIT
+
+
+## Copyright
+
+```
+Copyright (c) 2012-2015 Dropmysite.com <https://dropmyemail.com>
+Copyright (c) 2015 Webhippie <http://www.webhippie.de>
+```
Files old/checksums.yaml.gz and new/checksums.yaml.gz differ
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/lib/po_to_json/version.rb 
new/lib/po_to_json/version.rb
--- old/lib/po_to_json/version.rb       1970-01-01 01:00:00.000000000 +0100
+++ new/lib/po_to_json/version.rb       1970-01-01 01:00:00.000000000 +0100
@@ -0,0 +1,40 @@
+# -*- coding: UTF-8 -*-
+#
+# Copyright (c) 2012-2015 Dropmysite.com <https://dropmyemail.com>
+# Copyright (c) 2015 Webhippie <http://www.webhippie.de>
+#
+# 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.
+#
+
+class PoToJson
+  class Version
+    MAJOR = 0
+    MINOR = 1
+    PATCH = 0
+
+    PRE = nil
+
+    class << self
+      def to_s
+        [MAJOR, MINOR, PATCH, PRE].compact.join(".")
+      end
+    end
+  end
+end
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/lib/po_to_json.rb new/lib/po_to_json.rb
--- old/lib/po_to_json.rb       1970-01-01 01:00:00.000000000 +0100
+++ new/lib/po_to_json.rb       1970-01-01 01:00:00.000000000 +0100
@@ -1,172 +1,329 @@
-require 'json'
+# -*- coding: UTF-8 -*-
+#
+# Copyright (c) 2012-2015 Dropmysite.com <https://dropmyemail.com>
+# Copyright (c) 2015 Webhippie <http://www.webhippie.de>
+#
+# 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.
+#
+
+ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile", __FILE__)
+
+if File.exist? ENV["BUNDLE_GEMFILE"]
+  require "bundler"
+  Bundler.setup(:default)
+else
+  gem "json", version: ">= 1.6.0"
+end
+
+require "json"
 
 class PoToJson
+  autoload :Version, File.expand_path("../po_to_json/version", __FILE__)
 
+  attr_accessor :files
+  attr_accessor :glue
+  attr_accessor :options
+  attr_accessor :errors
+  attr_accessor :values
+  attr_accessor :buffer
+  attr_accessor :lastkey
+  attr_accessor :trans
+
+  def initialize(files, glue = "|")
+    @files = files
+    @glue = glue
+  end
 
-  # Gettext translations may be contextualized like so User|name
-  # The default 'GLUE' in rails gettext is '|' so we use that here too.
-  def initialize(path_to_po, context_glue = '|')
-    # Gettext translations may be contextualized like so User|name
-    # The default 'GLUE' in rails gettext is '|' so we use that here too.
-    @context_glue = context_glue
-    @path_to_po = path_to_po
+  def generate_for_jed(language, overwrite = {})
+    @options = parse_options(overwrite.merge(language: language))
+    @parsed ||= inject_meta(parse_document)
+
+    generated = build_json_for(build_jed_for(@parsed))
+
+    [
+      "var #{@options[:variable]} = #{@options[:variable]} || {};",
+      "#{@options[:variable]}['#{@options[:language]}'] = #{generated};"
+    ].join(" ")
   end
 
+  def generate_for_json(language, overwrite = {})
+    @options = parse_options(overwrite.merge(language: language))
+    @parsed ||= inject_meta(parse_document)
 
-  # Generates a jed-compatible js file from the current PO.
-  # This include adding some wrapping structure to the translations and
-  # making sure the minimum headers required by Jed are provided.
-  # Jed is a js gettext library ( http://slexaxton.github.com/Jed/ )
-  # The generated file leaves the generated json inside a global locales
-  # object which you can use to instatiate Jed:
-  # >>> i18n = new Jed(locales['es'])
-  # >>> i18n.gettext('Hello World')
-  # => 'Hola Mundo'
-  def generate_for_jed(language_code, opts={})
-    @parsed ||= self.parse
-
-    @parsed['']['lang'] = language_code
-    @parsed['']['domain'] = 'app'
-    @parsed['']['plural_forms'] ||= @parsed['']['Plural-Forms']
-
-    jed_json = {
-      :domain => 'app',
-      :locale_data => { :app => @parsed }
-    }
+    generated = build_json_for(build_json_for(@parsed))
 
-    if opts[:pretty]
-      "var locales = locales || {}; locales['#{language_code}'] = 
#{JSON.pretty_generate(jed_json)};"
-    else
-      "var locales = locales || {}; locales['#{language_code}'] = 
#{JSON.generate(jed_json)};"
-    end
+    fail "Not implemented yet, current value is #{generated}!"
   end
 
+  def parse_document
+    reset_buffer
+    reset_result
 
-  # Messages in a PO file are defined as a series of 'key value' pairs,
-  # values may span over more than one line. Each key defines an attribute
-  # of the message, like message id, context, pluralization options, etc.
-  # Each message is separated by a blank line.
-  # The parser reads attributes until it finds an empty line, at that point
-  # it saves the attributes read so far into a message and stores it in a hash
-  # to be later turned into a json object.
-  def parse
-    @parsed_values = {}
-    @buffer = {}
-    @last_key_type = ""
-    @errors = []
-    File.foreach(@path_to_po) do |line|
-      line = line.chomp
-      case line
-        # Empty lines means we have parsed one full message
-        # so far and need to flush the buffer
-        when /^$/ then flush_buffer
+    File.foreach(files) do |line|
+      matches_values_for(line.chomp)
+    end
 
-        # These are the po file comments
-        # The second '#' in the following regex is in square brackets
-        # b/c it messed up my syntax highlighter, no other reason.
-        when /^(#[^~]|[#]$)/ then next
+    flush_buffer
+    parse_header
 
-        when /^(?:#~ )?msgctxt\s+(.*)/ then add_to_buffer($1, :msgctxt)
+    values
+  end
 
-        when /^(?:#~ )?msgid\s+(.*)/ then add_to_buffer($1, :msgid)
+  def flush_buffer
+    return unless buffer[:msgid]
 
-        when /^(?:#~ )?msgid_plural\s+(.*)/ then add_to_buffer($1, 
:msgid_plural)
+    build_trans
+    assign_trans
 
-        when /^(?:#~ )?msgstr\s+(.*)/ then add_to_buffer($1, :msgstr_0)
+    reset_buffer
+  end
 
-        when /^(?:#~ )?msgstr\[0\]\s+(.*)/ then add_to_buffer($1, :msgstr_0)
+  def parse_header
+    return if reject_header
 
-        when /^(?:#~ )?msgstr\[(\d+)\]\s+(.*)/ then add_to_buffer($2, 
"msgstr_#{$1}".to_sym)
+    values[""][1].split("\\n").each do |line|
+      next if line.empty?
+      build_header_for(line)
+    end
 
-        when /^(?:#~ )?"/ then add_to_buffer(line)
+    values[""] = headers
+  end
 
-        else
-          @errors << ["Strange line #{line}"]
-      end
+  def reject_header
+    if values[""].nil? || values[""][1].nil?
+      values[""] = {}
+      true
+    else
+      false
     end
+  end
 
-    # In case the file did not end with a newline, we want to flush the buffer
-    # one more time to write the last message too.
-    flush_buffer
+  protected
 
-    # This will turn the header values into a friendlier json structure too.
-    parse_header_lines
+  def trans
+    @trans ||= []
+  end
 
-    return @parsed_values
+  def errors
+    @errors ||= []
   end
 
-  def flush_buffer
-    return unless @buffer[:msgid]
+  def values
+    @values ||= {}
+  end
+
+  def buffer
+    @buffer ||= {}
+  end
+
+  def headers
+    @headers ||= {}
+  end
+
+  def lastkey
+    @lastkey ||= ""
+  end
 
-    msg_ctxt_id = if @buffer[:msgctxt] && @buffer[:msgctxt].size > 0
-      @buffer[:msgctxt] + @context_glue + @buffer[:msgid]
+  def reset_result
+    @values = {}
+    @errors = []
+  end
+
+  def reset_buffer
+    @buffer = {}
+    @trans = []
+    @lastkey = ""
+  end
+
+  def detect_ctxt
+    msgctxt = buffer[:msgctxt]
+    msgid = buffer[:msgid]
+
+    if msgctxt && msgctxt.size > 0
+      [msgctxt, glue, msgid].join("")
     else
-      @buffer[:msgid]
+      msgid
     end
+  end
 
-    msgid_plural = if @buffer[:msgid_plural] && @buffer[:msgid_plural].size > 0
-      @buffer[:msgid_plural]
-    end
+  def detect_plural
+    plural = buffer[:msgid_plural]
+    plural if plural && plural.size > 0
+  end
 
-    # find msgstr_* translations and push them on
-    trans = []
-    @buffer.each do |key, string|
-      trans[$1.to_i] = string if key.to_s =~ /^msgstr_(\d+)/
+  def build_trans
+    buffer.each do |key, string|
+      trans[$1.to_i] = string if key.to_s.match(/^msgstr_(\d+)/)
     end
-    trans.unshift(msgid_plural)
 
-    @parsed_values[msg_ctxt_id] = trans if trans.size > 1
+    trans.unshift(detect_plural)
+  end
 
-    @buffer = {}
-    @last_key_type = ""
+  def assign_trans
+    values[detect_ctxt] = trans if trans.size > 1
   end
 
-  # The buffer keeps key/value pairs for all the config options
-  # defined on an entry, including the message id and value.
-  # For continued lines, the key_type can be empty, so the last
-  # used key type will be used. Also, the content will be appended
-  # to the last key rather than assigned.
-  def add_to_buffer(value, key_type = nil)
+  def push_buffer(value, key = nil)
     value = $1 if value =~ /^"(.*)"/
-    value.gsub(/\\"/, '"')
+    value.gsub(/\\"/, "\"")
 
-    if key_type.nil?
-      @buffer[@last_key_type] += value
+    if key.nil?
+      buffer[lastkey] = [
+        buffer[lastkey],
+        value
+      ].join("")
     else
-      @buffer[key_type] = value
-      @last_key_type = key_type
+      buffer[key] = value
+      @lastkey = key
     end
   end
 
-  # The parsed values are expected to have an empty string key ("")
-  # which corresponds to the po file metadata defined in it's header.
-  # the header has information like the translator, the pluralization, etc.
-  # Each header line is subseqently parsed into a more usable hash.
-  def parse_header_lines
-    if @parsed_values[""].nil? || @parsed_values[""][1].nil?
-      @parsed_values[""] = {}
-      return
+  def parse_options(options)
+    defaults = {
+      pretty: false,
+      domain: "app",
+      variable: "locales"
+    }
+
+    defaults.merge(options)
+  end
+
+  def inject_meta(hash)
+    hash[""]["lang"] ||= options[:language]
+    hash[""]["domain"] ||= options[:domain]
+    hash[""]["plural_forms"] ||= hash[""]["Plural-Forms"]
+
+    hash
+  end
+
+  def build_header_for(line)
+    if line =~ /(.*?):(.*)/
+      key, value = $1, $2
+
+      if headers.key? key
+        errors.push "Duplicate header: #{line}"
+      elsif key =~ /#-#-#-#-#/
+        errors.push "Marked header: #{line}"
+      else
+        headers[key] = value.strip
+      end
+    else
+      errors.push "Malformed header: #{line}"
     end
+  end
+
+  def build_json_for(hash)
+    if options[:pretty]
+      JSON.pretty_generate(hash)
+    else
+      JSON.generate(hash)
+    end
+  end
+
+  def build_jed_for(hash)
+    {
+      domain: options[:domain],
+      locale_data: {
+        options[:domain] => hash
+      }
+    }
+  end
+
+  def matches_values_for(line)
+    return if generic_rejects? line
+    return if generic_detects? line
 
-    headers = {}
-    # Heading lines may have escaped newlines in them
-    @parsed_values[""][1].split(/\\n/).each do |line|
-      next if line.size == 0
+    return if iterate_detects_for(line)
+
+    errors.push "Strange line #{line}"
+  end
 
-      if line =~ /(.*?):(.*)/
-        key, value = $1, $2
-        if headers[key] && headers[key].size > 0
-          @errors << ["Duplicate header line: #{line}"]
-        elsif key =~ /#-#-#-#-#/
-          @errors << ["Marker in header line: #{line}"]
+  def iterate_detects_for(line)
+    specific_detects.each do |detect|
+      match = line.match(detect[:regex])
+
+      if match
+        if detect[:index]
+          push_buffer(match[detect[:index]], detect[:key].call(match))
         else
-          headers[key] = value
+          push_buffer(line)
         end
-      else
-        @errors << ["Malformed header #{line}"]
+
+        return true
       end
     end
 
-    @parsed_values[""] = headers
+    false
+  end
+
+  def generic_rejects?(line)
+    if line.match(/^$/) || line.match(/^(#[^~]|[#]$)/)
+      flush_buffer && true
+    else
+      false
+    end
+  end
+
+  def generic_detects?(line)
+    match = line.match(/^(?:#~ )?msgctxt\s+(.*)/)
+
+    if match
+      push_buffer(
+        match[1],
+        :msgctxt
+      )
+
+      return true
+    end
+
+    false
+  end
+
+  def specific_detects
+    [{
+      regex: /^(?:#~ )?msgctxt\s+(.*)/,
+      index: 1,
+      key: proc { :msgctxt }
+    }, {
+      regex: /^(?:#~ )?msgid\s+(.*)/,
+      index: 1,
+      key: proc { :msgid }
+    }, {
+      regex: /^(?:#~ )?msgid_plural\s+(.*)/,
+      index: 1,
+      key: proc { :msgid_plural }
+    }, {
+      regex: /^(?:#~ )?msgstr\s+(.*)/,
+      index: 1,
+      key: proc { :msgstr_0 }
+    }, {
+      regex: /^(?:#~ )?msgstr\[0\]\s+(.*)/,
+      index: 1,
+      key: proc { :msgstr_0 }
+    }, {
+      regex: /^(?:#~ )?msgstr\[(\d+)\]\s+(.*)/,
+      index: 2,
+      key: proc { |m| "msgstr_#{m[1]}".to_sym }
+    }, {
+      regex: /^(?:#~ )?"/,
+      index: nil
+    }]
   end
 end
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/metadata new/metadata
--- old/metadata        1970-01-01 01:00:00.000000000 +0100
+++ new/metadata        1970-01-01 01:00:00.000000000 +0100
@@ -1,66 +1,130 @@
 --- !ruby/object:Gem::Specification
 name: po_to_json
 version: !ruby/object:Gem::Version
-  version: 0.0.7
-  prerelease: 
+  version: 0.1.0
 platform: ruby
 authors:
+- Thomas Boerger
 - Nubis
-- eromirou
 autorequire: 
 bindir: bin
 cert_chain: []
-date: 2013-05-02 00:00:00.000000000 Z
+date: 2015-02-20 00:00:00.000000000 Z
 dependencies:
 - !ruby/object:Gem::Dependency
-  name: json
+  name: bundler
   requirement: !ruby/object:Gem::Requirement
-    none: false
     requirements:
-    - - ! '>='
+    - - '>='
       - !ruby/object:Gem::Version
         version: '0'
-  type: :runtime
+  type: :development
+  prerelease: false
+  version_requirements: !ruby/object:Gem::Requirement
+    requirements:
+    - - '>='
+      - !ruby/object:Gem::Version
+        version: '0'
+- !ruby/object:Gem::Dependency
+  name: rake
+  requirement: !ruby/object:Gem::Requirement
+    requirements:
+    - - '>='
+      - !ruby/object:Gem::Version
+        version: '0'
+  type: :development
+  prerelease: false
+  version_requirements: !ruby/object:Gem::Requirement
+    requirements:
+    - - '>='
+      - !ruby/object:Gem::Version
+        version: '0'
+- !ruby/object:Gem::Dependency
+  name: yard
+  requirement: !ruby/object:Gem::Requirement
+    requirements:
+    - - '>='
+      - !ruby/object:Gem::Version
+        version: '0'
+  type: :development
   prerelease: false
   version_requirements: !ruby/object:Gem::Requirement
-    none: false
     requirements:
-    - - ! '>='
+    - - '>='
       - !ruby/object:Gem::Version
         version: '0'
-description: Convert gettext PO files to json to use in your javascript app, 
based
-  po2json.pl (by DuckDuckGo, Inc. http://duckduckgo.com/, Torsten Raudssus 
<tors...@raudss.us>.)
-email: nu...@woobiz.com.ar
+- !ruby/object:Gem::Dependency
+  name: rspec
+  requirement: !ruby/object:Gem::Requirement
+    requirements:
+    - - '>='
+      - !ruby/object:Gem::Version
+        version: '0'
+  type: :development
+  prerelease: false
+  version_requirements: !ruby/object:Gem::Requirement
+    requirements:
+    - - '>='
+      - !ruby/object:Gem::Version
+        version: '0'
+- !ruby/object:Gem::Dependency
+  name: json
+  requirement: !ruby/object:Gem::Requirement
+    requirements:
+    - - '>='
+      - !ruby/object:Gem::Version
+        version: 1.6.0
+  type: :runtime
+  prerelease: false
+  version_requirements: !ruby/object:Gem::Requirement
+    requirements:
+    - - '>='
+      - !ruby/object:Gem::Version
+        version: 1.6.0
+description: |2
+      Convert gettext PO files to JSON objects so that you can use it in your
+      application.
+email:
+- tho...@webhippie.de
+- nu...@woobiz.com.ar
 executables: []
 extensions: []
 extra_rdoc_files: []
 files:
-- lib/po_to_json.rb
+- CHANGELOG.md
 - README.md
-- MIT-LICENSE
-homepage: https://github.com/nubis/po_to_json
-licenses: []
+- LICENSE
+- lib/po_to_json.rb
+- lib/po_to_json/version.rb
+- spec/spec_helper.rb
+- spec/fixtures/test.po
+- spec/po_to_json_spec.rb
+homepage: https://github.com/webhippie/po_to_json
+licenses:
+- MIT
+metadata: {}
 post_install_message: 
 rdoc_options: []
 require_paths:
 - lib
 required_ruby_version: !ruby/object:Gem::Requirement
-  none: false
   requirements:
-  - - ! '>='
+  - - '>='
     - !ruby/object:Gem::Version
       version: '0'
 required_rubygems_version: !ruby/object:Gem::Requirement
-  none: false
   requirements:
-  - - ! '>='
+  - - '>='
     - !ruby/object:Gem::Version
       version: '0'
 requirements: []
 rubyforge_project: 
-rubygems_version: 1.8.23
+rubygems_version: 2.0.3
 signing_key: 
-specification_version: 3
-summary: Convert gettext PO files to json
-test_files: []
+specification_version: 4
+summary: Convert gettext PO files to JSON
+test_files:
+- spec/spec_helper.rb
+- spec/fixtures/test.po
+- spec/po_to_json_spec.rb
 has_rdoc: 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/spec/fixtures/test.po new/spec/fixtures/test.po
--- old/spec/fixtures/test.po   1970-01-01 01:00:00.000000000 +0100
+++ new/spec/fixtures/test.po   1970-01-01 01:00:00.000000000 +0100
@@ -0,0 +1,69 @@
+# SOME DESCRIPTIVE TITLE.
+# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
+# This file is distributed under the same license as the PACKAGE package.
+# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
+msgid ""
+msgstr ""
+"Project-Id-Version: version 0.0.1\n"
+"POT-Creation-Date: 2009-02-26 19:50+0100\n"
+"PO-Revision-Date: 2011-12-04 18:54+0900\n"
+"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
+"Language-Team: LANGUAGE <l...@li.org>\n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=UTF-8\n"
+"Content-Transfer-Encoding: 8bit\n"
+"Plural-Forms: nplurals=INTEGER; plural=EXPRESSION;\n"
+
+#: app/helpers/translation_helper.rb:3
+msgid "%{relative_time} ago"
+msgstr "vor %{relative_time}"
+
+#: app/views/cars/show.html.erb:5
+msgid "Axis"
+msgid_plural "Axis"
+msgstr[0] "Achse"
+msgstr[1] "Achsen"
+
+#: app/controllers/cars_controller.rb:47
+msgid "Car was successfully created."
+msgstr "Auto wurde erfolgreich gespeichert"
+
+#: app/controllers/cars_controller.rb:64
+msgid "Car was successfully updated."
+msgstr "Auto wurde erfolgreich aktualisiert"
+
+#: app/views/cars/show.html.erb:1 locale/model_attributes.rb:3
+msgid "Car|Model"
+msgstr "Modell"
+
+msgid "Untranslated"
+msgstr ""
+
+#: app/views/cars/show.html.erb:3 locale/model_attributes.rb:4
+msgid "Car|Wheels count"
+msgstr "Räderzahl"
+
+#: app/views/cars/show.html.erb:7
+msgid "Created"
+msgstr "Erstellt"
+
+#: app/views/cars/show.html.erb:9
+msgid "Month"
+msgstr "Monat"
+
+#: locale/model_attributes.rb:2
+msgid "car"
+msgstr "Auto"
+
+#: locale/testlog_phrases.rb:2
+msgid "this is a dynamic translation which was found!"
+msgstr ""
+"Dies ist eine dynamische Übersetzung, die "
+"gefunden wurde!"
+
+#: locale/test_escape.rb:2
+msgid "You should escape '\\' as '\\\\'."
+msgstr "Du solltest '\\' als '\\\\' escapen."
+
+msgid "Umläüte"
+msgstr "Umlaute"
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/spec/po_to_json_spec.rb new/spec/po_to_json_spec.rb
--- old/spec/po_to_json_spec.rb 1970-01-01 01:00:00.000000000 +0100
+++ new/spec/po_to_json_spec.rb 1970-01-01 01:00:00.000000000 +0100
@@ -0,0 +1,196 @@
+# -*- coding: UTF-8 -*-
+#
+# Copyright (c) 2012-2015 Dropmysite.com <https://dropmyemail.com>
+# Copyright (c) 2015 Webhippie <http://www.webhippie.de>
+#
+# 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.
+#
+
+require "spec_helper"
+
+describe PoToJson do
+  let(:po_to_json) do
+    @subject = PoToJson.new(
+      File.expand_path("../fixtures/test.po", __FILE__)
+    )
+  end
+
+  describe "parsing" do
+    subject do
+      po_to_json.parse_document
+    end
+
+    it "should find the last author" do
+      expect(subject[""]["Last-Translator"]).to(
+        eq("FULL NAME <EMAIL@ADDRESS>")
+      )
+    end
+
+    it "should parse embedded variables" do
+      expect(subject["%{relative_time} ago"]).to(
+        eq([nil, "vor %{relative_time}"])
+      )
+    end
+
+    it "should match pluralizations" do
+      expect(subject["Axis"]).to(
+        eq(["Axis", "Achse", "Achsen"])
+      )
+    end
+
+    it "should match glued values" do
+      expect(subject["Car|Model"]).to(
+        eq([nil, "Modell"])
+      )
+    end
+
+    it "should match embedded glue" do
+      expect(subject["Car|Wheels count"]).to(
+        eq([nil, "Räderzahl"])
+      )
+    end
+
+    it "should return empty strings as well" do
+      expect(subject["Untranslated"]).to(
+        eq([nil, ""])
+      )
+    end
+
+    it "should match german umlauts" do
+      expect(subject["Umläüte"]).to(
+        eq([nil, "Umlaute"])
+      )
+    end
+
+    it "should match escaped values" do
+      expect(subject["You should escape '\\\\' as '\\\\\\\\'."]).to(
+        eq([nil, "Du solltest '\\\\' als '\\\\\\\\' escapen."])
+      )
+    end
+
+    it "should match multiline translations" do
+      expect(subject["this is a dynamic translation which was found!"]).to(
+        eq([nil, "Dies ist eine dynamische Übersetzung, die gefunden wurde!"])
+      )
+    end
+
+    it "should match simple strings" do
+      expect(subject["Car was successfully created."]).to(
+        eq([nil, "Auto wurde erfolgreich gespeichert"])
+      )
+
+      expect(subject["Car was successfully updated."]).to(
+        eq([nil, "Auto wurde erfolgreich aktualisiert"])
+      )
+
+      expect(subject["Created"]).to(
+        eq([nil, "Erstellt"])
+      )
+
+      expect(subject["Month"]).to(
+        eq([nil, "Monat"])
+      )
+
+      expect(subject["car"]).to(
+        eq([nil, "Auto"])
+      )
+    end
+  end
+
+  describe "generate jed compatible" do
+    describe "with minified output" do
+      subject do
+        po_to_json.generate_for_jed("de")
+      end
+
+      it "should output the var definition" do
+        expect(
+          subject.include?("var locales = locales || {}; locales['de'] = ")
+        ).to be_truthy
+      end
+
+      it "should include domain string" do
+        expect(
+          subject.include?('"domain":"app"')
+        ).to be_truthy
+      end
+
+      it "should include lang string" do
+        expect(
+          subject.include?('"lang":"de"')
+        ).to be_truthy
+      end
+
+      it "should include pluralization" do
+        val = '"plural_forms":"nplurals=INTEGER; plural=EXPRESSION;"'
+        expect(
+          subject.include? val
+        ).to be_truthy
+      end
+
+      it "should include a single line break" do
+        expect(
+          subject.count("\n")
+        ).to be < 1
+      end
+    end
+
+    context "with pretty output" do
+      subject do
+        po_to_json.generate_for_jed("de", pretty: true)
+      end
+
+      it "should output the var definition" do
+        expect(
+          subject.include?("var locales = locales || {}; locales['de'] = ")
+        ).to be_truthy
+      end
+
+      it "should include domain string" do
+        expect(
+          subject.include?('"domain": "app"')
+        ).to be_truthy
+      end
+
+      it "should include lang string" do
+        expect(
+          subject.include?('"lang": "de"')
+        ).to be_truthy
+      end
+
+      it "should include pluralization" do
+        val = '"plural_forms": "nplurals=INTEGER; plural=EXPRESSION;"'
+        expect(
+          subject.include? val
+        ).to be_truthy
+      end
+
+      it "should include multiple line breaks" do
+        expect(
+          subject.count("\n")
+        ).to be > 0
+      end
+    end
+  end
+
+  # describe "generate simple hashes" do
+  #   pending "have to be implemented"
+  # end
+end
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/spec/spec_helper.rb new/spec/spec_helper.rb
--- old/spec/spec_helper.rb     1970-01-01 01:00:00.000000000 +0100
+++ new/spec/spec_helper.rb     1970-01-01 01:00:00.000000000 +0100
@@ -0,0 +1,54 @@
+# -*- coding: UTF-8 -*-
+#
+# Copyright (c) 2012-2015 Dropmysite.com <https://dropmyemail.com>
+# Copyright (c) 2015 Webhippie <http://www.webhippie.de>
+#
+# 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.
+#
+
+require "simplecov"
+
+if ENV["CODECLIMATE_REPO_TOKEN"]
+  require "coveralls"
+  require "codeclimate-test-reporter"
+
+  Coveralls.wear!
+  CodeClimate::TestReporter.start
+
+  SimpleCov.start do
+    add_filter "/spec"
+
+    formatter SimpleCov::Formatter::MultiFormatter[
+      SimpleCov::Formatter::HTMLFormatter,
+      CodeClimate::TestReporter::Formatter
+    ]
+  end
+else
+  SimpleCov.start do
+    add_filter "/spec"
+  end
+end
+
+require "po_to_json"
+require "rspec"
+
+RSpec.configure do |config|
+  config.mock_with :rspec
+end

-- 
To unsubscribe, e-mail: opensuse-commit+unsubscr...@opensuse.org
For additional commands, e-mail: opensuse-commit+h...@opensuse.org

Reply via email to