New Upstream Snapshot - ruby-simple-po-parser

Ready changes

Summary

Merged new upstream version: 1.1.6+git20220324.1.2d2a71f (was: 1.1.5).

Resulting package

Built on 2023-01-11T23:16 (took 7m15s)

The resulting binary packages can be installed (if you have the apt repository enabled) by running one of:

apt install -t fresh-snapshots ruby-simple-po-parser

Lintian Result

Diff

diff --git a/.gitattributes b/.gitattributes
deleted file mode 100644
index 69affb3..0000000
--- a/.gitattributes
+++ /dev/null
@@ -1 +0,0 @@
-spec/simple_po_parser/fixtures/crlf_encoded.po binary
diff --git a/.gitignore b/.gitignore
deleted file mode 100644
index 34beae1..0000000
--- a/.gitignore
+++ /dev/null
@@ -1,8 +0,0 @@
-*.gem
-.bundle
-.ruby-version
-Gemfile.lock
-coverage
-pkg
-test/tmp
-tmp
diff --git a/.travis.yml b/.travis.yml
deleted file mode 100644
index a1d31f4..0000000
--- a/.travis.yml
+++ /dev/null
@@ -1,8 +0,0 @@
-bundler_args: --without development
-language: ruby
-sudo: false
-rvm:
-  - 2.1.9
-  - 2.2.6
-  - 2.3.1
-script: bundle exec rspec spec
diff --git a/CHANGELOG.md b/CHANGELOG.md
index f0d24d7..911c865 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,15 +1,35 @@
-Version 1.1.0
+Changelog
 =============
 
+## Version 1.1.6
+  * fixes parsing of multiline strings that have content on the first line. Fixes issue #3, added via PR #4 by @mgruner
+
+## Version 1.1.5
+ * added support for windows CRLF line endings. Fixes issue #2
+ * Note: CRLF support is enabled if the first line ends in a CRLF and reduces performance by about 50%. Performance for files only using \n is not affected. Files not using \r\n in the first line but somewhere else in the file might trigger errors.
+
+## Version 1.1.4
+  * see 1.1.5. **Shouldn't be used**.
+
+## Version 1.1.3
+
+  * merged PR#1 from @christopherstat for UTF-8 support of legacy ruby versions
+
+## Version 1.1.2
+  * Made the parser thread-safe
+
+## Version 1.1.2
+  * Made the parser thread-safe
+
+## Version 1.1.0
+
   * for line types only parsed once the parser returns a string instead of an array with one string
 
-Version 1.0.1
-=============
+## Version 1.0.1
 
   * added specs
   * fixed minor parser errors
 
-Version 1.0.0
-=============
+## Version 1.0.0
 
   * initial release
diff --git a/Gemfile b/Gemfile
index bddd243..032b2ee 100644
--- a/Gemfile
+++ b/Gemfile
@@ -1,8 +1,9 @@
 source 'https://rubygems.org'
 
 group :test do
-  gem 'coveralls', :require => false
-  gem 'rspec', '~> 3.5.0'
+  gem 'simplecov',      require: false
+  gem 'simplecov-lcov', require: false
+  gem 'rspec', '~> 3.11.0'
   gem 'awesome_print'
   gem 'ruby-prof'
 end
diff --git a/README.md b/README.md
index 01c3a1d..268d07d 100644
--- a/README.md
+++ b/README.md
@@ -1,6 +1,6 @@
 # Simple Po Parser
 
-[![Build Status](https://travis-ci.org/experteer/simple_po_parser.svg?branch=master)](https://travis-ci.org/experteer/simple_po_parser)
+[![CI](https://github.com/experteer/simple_po_parser/actions/workflows/ci.yml/badge.svg)](https://github.com/experteer/simple_po_parser/actions/workflows/ci.yml)
 [![Coverage Status](https://img.shields.io/coveralls/experteer/simple_po_parser.svg)](https://coveralls.io/github/experteer/simple_po_parser)
 [![Gem Version](https://badge.fury.io/rb/simple_po_parser.svg)](https://badge.fury.io/rb/simple_po_parser)
 
diff --git a/Rakefile b/Rakefile
index 6a3038c..b3024ab 100644
--- a/Rakefile
+++ b/Rakefile
@@ -20,15 +20,15 @@ namespace :parser do
   require 'benchmark'
   require 'simple_po_parser'
 
-  desc "Benchmark of 100 full PoParser runs of test/benchmark.po"
+  desc "Benchmark of 1000 full PoParser runs of test/benchmark.po"
   task "benchmark" do
     pofile = File.expand_path("test/benchmark.po", __dir__)
     Benchmark.bmbm do |x|
-      x.report("Parser:") {100.times { SimplePoParser.parse(pofile) }}
+      x.report("Parser:") {1000.times { SimplePoParser.parse(pofile) }}
     end
   end
 
-  desc "Generate 5 random PO files with 100 to 500 messages and benchmark each full PoParser run"
+  desc "Generate 5 random PO files with 1000 to 5000 messages and benchmark each full PoParser run"
   task 'five_random_po_full' do
     include Benchmark
     require_relative 'spec/utils/random_pofile_generator'
@@ -37,7 +37,7 @@ namespace :parser do
       total = nil
       total_length = 0
       for i in 0..5 do
-        length = (Random.new.rand * 400.0 + 100).to_i
+        length = (Random.new.rand * 4000.0 + 1000).to_i
         total_length += length
         puts "Benchmarking file of length #{length}"
         SimplePoParser::RandomPoFileGenerator.generate_file(pofile, length)
diff --git a/debian/changelog b/debian/changelog
index 605156f..f014e8a 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,9 @@
+ruby-simple-po-parser (1.1.6+git20220324.1.2d2a71f-1) UNRELEASED; urgency=low
+
+  * New upstream snapshot.
+
+ -- Debian Janitor <janitor@jelmer.uk>  Wed, 11 Jan 2023 23:11:35 -0000
+
 ruby-simple-po-parser (1.1.5-2) unstable; urgency=medium
 
   * Team upload
diff --git a/lib/simple_po_parser/parser.rb b/lib/simple_po_parser/parser.rb
index fa46af5..a452be7 100644
--- a/lib/simple_po_parser/parser.rb
+++ b/lib/simple_po_parser/parser.rb
@@ -109,7 +109,7 @@ module SimplePoParser
           skip_whitespace
           text = message_line
           add_result(:msgctxt, text)
-          message_multiline(:msgctxt) if text.empty?
+          message_multiline(:msgctxt) if @scanner.peek(1) == '"'
         end
         msgid
       rescue PoSyntaxError => pe
@@ -127,7 +127,7 @@ module SimplePoParser
           skip_whitespace
           text = message_line
           add_result(:msgid, text)
-          message_multiline(:msgid) if text.empty?
+          message_multiline(:msgid) if @scanner.peek(1) == '"'
           if msgid_plural
             msgstr_plural
           else
@@ -155,7 +155,7 @@ module SimplePoParser
           skip_whitespace
           text = message_line
           add_result(:msgid_plural, text)
-          message_multiline(:msgid_plural) if text.empty?
+          message_multiline(:msgid_plural) if @scanner.peek(1) == '"'
           true
         else
           false
@@ -174,7 +174,7 @@ module SimplePoParser
           skip_whitespace
           text = message_line
           add_result(:msgstr, text)
-          message_multiline(:msgstr) if text.empty?
+          message_multiline(:msgstr) if @scanner.peek(1) == '"'
           skip_whitespace
           raise PoSyntaxError, "Unexpected content after expected message end #{@scanner.peek(10).inspect}" unless @scanner.eos?
         else
@@ -202,7 +202,7 @@ module SimplePoParser
           skip_whitespace
           text = message_line
           add_result(msgstr_key, text)
-          message_multiline(msgstr_key) if text.empty?
+          message_multiline(msgstr_key) if @scanner.peek(1) == '"'
           msgstr_plural(num+1)
         elsif num == 0 # and msgstr_key was false
           raise PoSyntaxError, "Plural message without msgstr[0] is not allowed. Line started unexpectedly with #{@scanner.peek(10).inspect}."
@@ -238,7 +238,7 @@ module SimplePoParser
           skip_whitespace
           text = message_line
           add_result(key, text)
-          previous_multiline(key) if text.empty?
+          previous_multiline(key) if @scanner.match?(/#\|\p{Blank}*"/)
         else
           raise PoSyntaxError, "Previous comments must start with '#| msg'. #{@scanner.peek(10).inspect} unknown."
         end
@@ -265,8 +265,10 @@ module SimplePoParser
 
     # parses a multiline message
     #
-    # multiline messages are indicated by an empty content as first line and the next line
-    # starting with the double quote character
+    # Multiline messages are usually indicated by an empty string as the first line,
+    # followed by more lines starting with the double quote character.
+    #
+    # However, according to the PO file standard, the first line can also contain content.
     def message_multiline(key)
       begin
         skip_whitespace
diff --git a/lib/simple_po_parser/version.rb b/lib/simple_po_parser/version.rb
index 72bfaab..2fce2ef 100644
--- a/lib/simple_po_parser/version.rb
+++ b/lib/simple_po_parser/version.rb
@@ -1,5 +1,5 @@
 # encoding: utf-8
 
 module SimplePoParser
-  VERSION = "1.1.5"
+  VERSION = "1.1.6"
 end
diff --git a/spec/simple_po_parser/fixtures/multiline.po b/spec/simple_po_parser/fixtures/multiline.po
new file mode 100644
index 0000000..bbe887c
--- /dev/null
+++ b/spec/simple_po_parser/fixtures/multiline.po
@@ -0,0 +1,10 @@
+#| msgid "multiline\n"
+#|"previous messageid"
+#|"with non-empty first line"
+msgid ""
+"multiline string "
+"with empty first line "
+"and trailing spaces"
+msgstr "multiline string"
+"with non-empty first line"
+"and no trailing spaces"
\ No newline at end of file
diff --git a/spec/simple_po_parser/parser_spec.rb b/spec/simple_po_parser/parser_spec.rb
index 3791741..dbc91e9 100644
--- a/spec/simple_po_parser/parser_spec.rb
+++ b/spec/simple_po_parser/parser_spec.rb
@@ -4,6 +4,7 @@ describe SimplePoParser::Parser do
   let (:po_header) { File.read(File.expand_path("fixtures/header.po", __dir__))}
   let(:po_complex_message) { File.read(File.expand_path("fixtures/complex_entry.po", __dir__))}
   let(:po_simple_message) { File.read(File.expand_path("fixtures/simple_entry.po", __dir__))}
+  let(:po_multiline_message) { File.read(File.expand_path("fixtures/multiline.po", __dir__))}
 
   it "parses the PO header" do
     expected_result = {
@@ -27,6 +28,15 @@ describe SimplePoParser::Parser do
     expect(SimplePoParser::Parser.new.parse(po_simple_message)).to eq(expected_result)
   end
 
+  it "parses the multiline entry as expected" do
+    expected_result = {
+      :msgid => ["", "multiline string ", "with empty first line ", "and trailing spaces"],
+      :msgstr => ["multiline string", "with non-empty first line", "and no trailing spaces"],
+      :previous_msgid => ["multiline\\n", "previous messageid", "with non-empty first line"],
+    }
+    expect(SimplePoParser::Parser.new.parse(po_multiline_message)).to eq(expected_result)
+  end
+
   it "parses the complex entry as expected" do
     expected_result = {
       :translator_comment => ["translator-comment", ""],
diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb
index c4dbafa..8900bed 100644
--- a/spec/spec_helper.rb
+++ b/spec/spec_helper.rb
@@ -6,17 +6,26 @@
 # See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
 
 require 'simplecov'
-require 'coveralls'
 require 'awesome_print'
 
-SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter.new(
-  [SimpleCov::Formatter::HTMLFormatter,
-  Coveralls::SimpleCov::Formatter]
-  )
+SimpleCov.formatter = SimpleCov::Formatter::HTMLFormatter
 
 SimpleCov.start do
-    add_group "gem", "lib"
-    add_group "spec", "spec"
+  if ENV['CI']
+    require 'simplecov-lcov'
+
+    SimpleCov::Formatter::LcovFormatter.config do |c|
+      c.report_with_single_file = true
+      c.single_report_path = 'coverage/lcov.info'
+    end
+
+    formatter SimpleCov::Formatter::LcovFormatter
+  end
+  
+  add_filter "version.rb"
+
+  add_group "gem", "lib"
+  add_group "spec", "spec"
 end
 
 require 'simple_po_parser'

Debdiff

[The following lists of changes regard files as different if they have different names, permissions or owners.]

Files in second set of .debs but not in first

-rw-r--r--  root/root   /usr/share/rubygems-integration/all/gems/simple_po_parser-1.1.6/lib/simple_po_parser.rb
-rw-r--r--  root/root   /usr/share/rubygems-integration/all/gems/simple_po_parser-1.1.6/lib/simple_po_parser/error.rb
-rw-r--r--  root/root   /usr/share/rubygems-integration/all/gems/simple_po_parser-1.1.6/lib/simple_po_parser/parser.rb
-rw-r--r--  root/root   /usr/share/rubygems-integration/all/gems/simple_po_parser-1.1.6/lib/simple_po_parser/tokenizer.rb
-rw-r--r--  root/root   /usr/share/rubygems-integration/all/gems/simple_po_parser-1.1.6/lib/simple_po_parser/version.rb
-rw-r--r--  root/root   /usr/share/rubygems-integration/all/specifications/simple_po_parser-1.1.6.gemspec

Files in first set of .debs but not in second

-rw-r--r--  root/root   /usr/share/rubygems-integration/all/gems/simple_po_parser-1.1.5/lib/simple_po_parser.rb
-rw-r--r--  root/root   /usr/share/rubygems-integration/all/gems/simple_po_parser-1.1.5/lib/simple_po_parser/error.rb
-rw-r--r--  root/root   /usr/share/rubygems-integration/all/gems/simple_po_parser-1.1.5/lib/simple_po_parser/parser.rb
-rw-r--r--  root/root   /usr/share/rubygems-integration/all/gems/simple_po_parser-1.1.5/lib/simple_po_parser/tokenizer.rb
-rw-r--r--  root/root   /usr/share/rubygems-integration/all/gems/simple_po_parser-1.1.5/lib/simple_po_parser/version.rb
-rw-r--r--  root/root   /usr/share/rubygems-integration/all/specifications/simple_po_parser-1.1.5.gemspec

No differences were encountered in the control files

More details

Full run details