PoParser 3.2.6 → 3.2.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.editorconfig +20 -0
- data/.github/workflows/ruby.yml +19 -20
- data/.rubocop.yml +9 -8
- data/CHANGELOG.md +16 -0
- data/README.md +1 -0
- data/Rakefile +21 -20
- data/lib/poparser/comment.rb +7 -9
- data/lib/poparser/constants.rb +1 -1
- data/lib/poparser/header.rb +4 -2
- data/lib/poparser/message.rb +4 -4
- data/lib/poparser/po.rb +2 -6
- data/lib/poparser/version.rb +1 -1
- data/spec/poparser/header_spec.rb +14 -0
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 800faf95fab47c838c82c4fa748d344f011480bd5f8c892e3b31fcdd3bb66225
|
4
|
+
data.tar.gz: 0456dc24a2987ac109be0ea3b9d9442b19eb2826fd5aa84511f30089329edf9a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c5bd34cb5a7569cdd93403f0158cb60fd4318e4500070f2493e1a89c476a06f95fb65cbda26cc999528518538901d8e21fb8955fcd3af044aa64236e445dc98c
|
7
|
+
data.tar.gz: e92ed629f246f43a2528b0f3a96d7c2262c671b04b0ef67135b7a635a1cf3635e98a3e27e550e9c18b5b2aabe2b20681467d55061bb8cdad38d98d94ad11bd35
|
data/.editorconfig
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
root = true
|
2
|
+
|
3
|
+
[*]
|
4
|
+
end_of_line = lf
|
5
|
+
indent_size = 2
|
6
|
+
indent_style = space
|
7
|
+
insert_final_newline = true
|
8
|
+
tab_width = 2
|
9
|
+
trim_trailing_whitespace = true
|
10
|
+
charset = utf-8
|
11
|
+
max_line_length = 119
|
12
|
+
|
13
|
+
[*.gemspec]
|
14
|
+
indent_size = 2
|
15
|
+
|
16
|
+
[*.rb]
|
17
|
+
indent_size = 2
|
18
|
+
|
19
|
+
[*.yml,*.yaml]
|
20
|
+
indent_size = 2
|
data/.github/workflows/ruby.yml
CHANGED
@@ -9,33 +9,32 @@ name: Ruby
|
|
9
9
|
|
10
10
|
on:
|
11
11
|
push:
|
12
|
-
branches: [
|
12
|
+
branches: [master]
|
13
13
|
pull_request:
|
14
|
-
branches: [
|
14
|
+
branches: [master]
|
15
15
|
|
16
16
|
jobs:
|
17
17
|
test:
|
18
|
-
|
19
18
|
runs-on: ubuntu-latest
|
20
19
|
strategy:
|
21
20
|
matrix:
|
22
|
-
ruby-version: [
|
21
|
+
ruby-version: ["3.0", "3.1", "3.2", "3.3"]
|
23
22
|
|
24
23
|
steps:
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
24
|
+
- uses: actions/checkout@v2
|
25
|
+
- name: Set up Ruby
|
26
|
+
# To automatically get bug fixes and new Ruby versions for ruby/setup-ruby,
|
27
|
+
# change this to (see https://github.com/ruby/setup-ruby#versioning):
|
28
|
+
# uses: ruby/setup-ruby@v1
|
29
|
+
uses: ruby/setup-ruby@v1
|
30
|
+
with:
|
31
|
+
ruby-version: ${{ matrix.ruby-version }}
|
32
|
+
bundler-cache: true # runs 'bundle install' and caches installed gems automatically
|
33
|
+
- name: Run tests
|
34
|
+
run: bundle exec rake
|
36
35
|
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
36
|
+
- name: Coveralls
|
37
|
+
uses: coverallsapp/github-action@master
|
38
|
+
with:
|
39
|
+
github-token: ${{ secrets.GITHUB_TOKEN }}
|
40
|
+
path-to-lcov: "./coverage/lcov.info"
|
data/.rubocop.yml
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
AllCops:
|
2
|
-
TargetRubyVersion:
|
2
|
+
TargetRubyVersion: 3.3
|
3
3
|
Exclude:
|
4
4
|
- 'spec/**/*'
|
5
5
|
- 'bin/*'
|
@@ -18,17 +18,15 @@ Layout/MultilineMethodCallIndentation:
|
|
18
18
|
Layout/AccessModifierIndentation:
|
19
19
|
EnforcedStyle: outdent
|
20
20
|
|
21
|
-
|
21
|
+
Metrics/MethodLength:
|
22
|
+
Enabled: false
|
23
|
+
|
24
|
+
Layout/ParameterAlignment:
|
22
25
|
EnforcedStyle: with_fixed_indentation
|
23
26
|
|
24
27
|
Style/FrozenStringLiteralComment:
|
25
28
|
Enabled: true
|
26
29
|
|
27
|
-
Style/PercentLiteralDelimiters:
|
28
|
-
PreferredDelimiters:
|
29
|
-
'%i': '()'
|
30
|
-
'%w': '()'
|
31
|
-
|
32
30
|
Style/TrailingCommaInArrayLiteral:
|
33
31
|
Enabled: true
|
34
32
|
EnforcedStyleForMultiline: comma
|
@@ -41,9 +39,12 @@ Style/TrailingCommaInArguments:
|
|
41
39
|
Enabled: true
|
42
40
|
EnforcedStyleForMultiline: comma
|
43
41
|
|
42
|
+
Style/OptionalBooleanParameter:
|
43
|
+
Enabled: false
|
44
|
+
|
44
45
|
Layout/EmptyLines:
|
45
46
|
Enabled: true
|
46
47
|
|
47
48
|
Metrics/LineLength:
|
48
|
-
Max:
|
49
|
+
Max: 120
|
49
50
|
IgnoreCopDirectives: True
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,19 @@
|
|
1
|
+
3.2.8 / 2024-05-09
|
2
|
+
==================
|
3
|
+
|
4
|
+
* Add Report-Msgid-Bugs-To header attribute
|
5
|
+
|
6
|
+
3.2.6 / 2022-04-24
|
7
|
+
==================
|
8
|
+
|
9
|
+
* Update simple_po_parser version to 1.1.6 (#29) Courtesy of @dfherr
|
10
|
+
|
11
|
+
3.2.5 / 2021-01-11
|
12
|
+
==================
|
13
|
+
|
14
|
+
* Dependency updates
|
15
|
+
* Remove support for Ruby 2.4
|
16
|
+
|
1
17
|
3.2.4 / 2019-10-12
|
2
18
|
==================
|
3
19
|
|
data/README.md
CHANGED
data/Rakefile
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'bundler/gem_tasks'
|
2
4
|
require 'rubygems'
|
3
5
|
require 'rake'
|
@@ -5,14 +7,14 @@ require 'rspec/core/rake_task'
|
|
5
7
|
|
6
8
|
RSpec::Core::RakeTask.new(:spec)
|
7
9
|
|
8
|
-
task :
|
10
|
+
task default: :spec
|
9
11
|
|
10
|
-
desc
|
11
|
-
task 'generate_random_pofile', :messages, :obsoletes do |
|
12
|
-
args.with_defaults(:
|
12
|
+
desc 'Generate a random po file. Takes optional rake args for number of entries'
|
13
|
+
task 'generate_random_pofile', :messages, :obsoletes do |_t, args|
|
14
|
+
args.with_defaults(messages: '200', obsoletes: '10')
|
13
15
|
require_relative 'spec/utils/random_pofile_generator'
|
14
16
|
PoParser::RandomPoFileGenerator.generate_file(
|
15
|
-
File.expand_path(
|
17
|
+
File.expand_path('test/benchmark.po', __dir__), args[:messages].to_i, args[:obsoletes].to_i
|
16
18
|
)
|
17
19
|
end
|
18
20
|
|
@@ -20,46 +22,45 @@ namespace :debug do
|
|
20
22
|
require 'benchmark'
|
21
23
|
require_relative 'lib/poparser'
|
22
24
|
|
23
|
-
desc
|
24
|
-
task
|
25
|
-
pofile = File.expand_path(
|
25
|
+
desc 'Benchmark of 10 full PoParser runs of test/benchmark.po'
|
26
|
+
task 'benchmark' do
|
27
|
+
pofile = File.expand_path('test/benchmark.po', __dir__)
|
26
28
|
Benchmark.bmbm do |x|
|
27
|
-
x.report(
|
29
|
+
x.report('Parser:') { 10.times { PoParser.new.parse(pofile) } }
|
28
30
|
end
|
29
31
|
end
|
30
32
|
|
31
|
-
desc
|
33
|
+
desc 'Generate 5 random PO files with 100 to 500 messages and benchmark each full PoParser run'
|
32
34
|
task 'five_random_po_full' do
|
33
35
|
include Benchmark
|
34
36
|
require_relative 'spec/utils/random_pofile_generator'
|
35
|
-
pofile = File.expand_path(
|
36
|
-
Benchmark.benchmark(CAPTION, 6, FORMAT,
|
37
|
+
pofile = File.expand_path('test/benchmark.po.tmp', __dir__)
|
38
|
+
Benchmark.benchmark(CAPTION, 6, FORMAT, 'total:') do |x|
|
37
39
|
total = nil
|
38
40
|
total_length = 0
|
39
|
-
|
41
|
+
6.times do |i|
|
40
42
|
length = (Random.new.rand * 400.0 + 100).to_i
|
41
43
|
total_length += length
|
42
44
|
puts "Benchmarking file of length #{length}"
|
43
45
|
SimplePoParser::RandomPoFileGenerator.generate_file(pofile, length)
|
44
|
-
t = x.report("try#{i}:") {PoParser.new.parse(pofile)}
|
46
|
+
t = x.report("try#{i}:") { PoParser.new.parse(pofile) }
|
45
47
|
File.unlink(pofile)
|
46
|
-
total = total ? total+t : t
|
48
|
+
total = total ? total + t : t
|
47
49
|
end
|
48
50
|
puts "Total message length #{total_length}"
|
49
51
|
[total]
|
50
52
|
end
|
51
53
|
end
|
52
54
|
|
53
|
-
desc
|
54
|
-
task
|
55
|
+
desc 'Show ruby-prof profiler for spec/fixtures/complex_entry.po'
|
56
|
+
task 'profile_parser' do
|
55
57
|
require 'ruby-prof'
|
56
58
|
RubyProf.start
|
57
|
-
po_message = File.read(File.expand_path(
|
59
|
+
po_message = File.read(File.expand_path('spec/simple_po_parser/fixtures/complex_entry.po', __dir__))
|
58
60
|
PoParser.new.parse(po_message)
|
59
61
|
result = RubyProf.stop
|
60
62
|
|
61
63
|
printer = RubyProf::FlatPrinter.new(result)
|
62
|
-
printer.print(
|
64
|
+
printer.print($stdout)
|
63
65
|
end
|
64
|
-
|
65
66
|
end
|
data/lib/poparser/comment.rb
CHANGED
@@ -19,22 +19,20 @@ module PoParser
|
|
19
19
|
if /^previous_/.match?(@type.to_s) # these behave more like messages
|
20
20
|
string = ["#{COMMENTS_LABELS[@type]} \"\"\n"]
|
21
21
|
@value.each do |str|
|
22
|
-
string << "#| \"#{str}\"\n".gsub(
|
22
|
+
string << "#| \"#{str}\"\n".gsub(/\p{Blank}+$/, '')
|
23
23
|
end
|
24
24
|
else
|
25
25
|
string = []
|
26
26
|
@value.each do |str|
|
27
|
-
string << "#{COMMENTS_LABELS[@type]} #{str}\n".gsub(
|
27
|
+
string << "#{COMMENTS_LABELS[@type]} #{str}\n".gsub(/\p{Blank}+$/, '')
|
28
28
|
end
|
29
29
|
end
|
30
|
-
|
30
|
+
string.join
|
31
|
+
elsif /^previous_/.match?(@type.to_s)
|
32
|
+
"#{COMMENTS_LABELS[@type]} \"#{@value}\"\n".gsub(/\p{Blank}+$/, '') # these behave more like messages
|
31
33
|
else
|
32
|
-
|
33
|
-
|
34
|
-
else
|
35
|
-
# removes the space but not newline at the end
|
36
|
-
"#{COMMENTS_LABELS[@type]} #{@value}\n".gsub(/[\p{Blank}]+$/, '')
|
37
|
-
end
|
34
|
+
# removes the space but not newline at the end
|
35
|
+
"#{COMMENTS_LABELS[@type]} #{@value}\n".gsub(/\p{Blank}+$/, '')
|
38
36
|
end
|
39
37
|
end
|
40
38
|
|
data/lib/poparser/constants.rb
CHANGED
@@ -25,7 +25,7 @@ module PoParser
|
|
25
25
|
pot_creation_date: 'POT-Creation-Date',
|
26
26
|
po_revision_date: 'PO-Revision-Date',
|
27
27
|
project_id: 'Project-Id-Version',
|
28
|
-
report_to: '
|
28
|
+
report_to: 'Report-Msgid-Bugs-To',
|
29
29
|
last_translator: 'Last-Translator',
|
30
30
|
team: 'Language-Team',
|
31
31
|
language: 'Language',
|
data/lib/poparser/header.rb
CHANGED
@@ -5,8 +5,10 @@ module PoParser
|
|
5
5
|
class Header
|
6
6
|
attr_reader :entry, :original_configs, :flag
|
7
7
|
attr_accessor :comments, :pot_creation_date, :po_revision_date, :project_id,
|
8
|
-
|
9
|
-
|
8
|
+
:report_to, :last_translator, :team, :language, :charset,
|
9
|
+
:encoding, :plural_forms
|
10
|
+
|
11
|
+
alias report_msgid_bugs_to report_to
|
10
12
|
|
11
13
|
def initialize(entry)
|
12
14
|
@entry = entry
|
data/lib/poparser/message.rb
CHANGED
@@ -25,7 +25,7 @@ module PoParser
|
|
25
25
|
@value.each do |str|
|
26
26
|
lines << "\"#{str}\"\n"
|
27
27
|
end
|
28
|
-
|
28
|
+
lines.join
|
29
29
|
else
|
30
30
|
"#{label} \"#{@value}\"\n"
|
31
31
|
end
|
@@ -42,9 +42,9 @@ module PoParser
|
|
42
42
|
private
|
43
43
|
|
44
44
|
def remove_empty_line
|
45
|
-
|
46
|
-
|
47
|
-
|
45
|
+
return unless @value.is_a?(Array)
|
46
|
+
|
47
|
+
@value.shift if @value.first == ''
|
48
48
|
end
|
49
49
|
|
50
50
|
def label
|
data/lib/poparser/po.rb
CHANGED
@@ -151,10 +151,8 @@ module PoParser
|
|
151
151
|
File.open(@path, 'w') { |file| file.write(to_s) }
|
152
152
|
end
|
153
153
|
|
154
|
-
def each
|
155
|
-
@entries.each
|
156
|
-
yield entry
|
157
|
-
end
|
154
|
+
def each(&block)
|
155
|
+
@entries.each(&block)
|
158
156
|
end
|
159
157
|
|
160
158
|
def inspect
|
@@ -185,13 +183,11 @@ module PoParser
|
|
185
183
|
self
|
186
184
|
end
|
187
185
|
|
188
|
-
# rubocop:disable Style/SafeNavigation
|
189
186
|
def add_entry(entry)
|
190
187
|
return add_header_entry(entry) if entry[:msgid] && entry[:msgid].empty?
|
191
188
|
|
192
189
|
@entries << Entry.new(entry)
|
193
190
|
end
|
194
|
-
# rubocop:enable Style/SafeNavigation
|
195
191
|
|
196
192
|
def add_header_entry(entry)
|
197
193
|
raise('Duplicate entry, header was already instantiated') if @header
|
data/lib/poparser/version.rb
CHANGED
@@ -26,6 +26,20 @@ describe PoParser::Header do
|
|
26
26
|
end
|
27
27
|
end
|
28
28
|
|
29
|
+
it 'returns correct values for labels' do
|
30
|
+
expect(@header.project_id).to eq('gnome-shell-extensions gnome-3-0')
|
31
|
+
expect(@header.report_to).to eq('http://bugzilla.gnome.org/enter_bug.cgi?product=gnome-shell&keywords=I18N+L10N&component=extensions')
|
32
|
+
expect(@header.report_msgid_bugs_to).to eq('http://bugzilla.gnome.org/enter_bug.cgi?product=gnome-shell&keywords=I18N+L10N&component=extensions')
|
33
|
+
expect(@header.pot_creation_date).to eq('2014-08-28 07:40+0000')
|
34
|
+
expect(@header.po_revision_date).to eq('2014-08-28 19:59+0430')
|
35
|
+
expect(@header.last_translator).to eq('Arash Mousavi <mousavi.arash@gmail.com>')
|
36
|
+
expect(@header.team).to eq('Persian <>')
|
37
|
+
expect(@header.language).to eq('fa_IR')
|
38
|
+
expect(@header.charset).to eq('text/plain; charset=UTF-8')
|
39
|
+
expect(@header.encoding).to eq('8bit')
|
40
|
+
expect(@header.plural_forms).to eq('nplurals=1; plural=0;')
|
41
|
+
end
|
42
|
+
|
29
43
|
it 'should convert configs to hash' do
|
30
44
|
expect(@header.original_configs).to eq(
|
31
45
|
{"Project-Id-Version"=>"gnome-shell-extensions gnome-3-0", "Report-Msgid-Bugs-To"=>"http://bugzilla.gnome.org/enter_bug.cgi?product=gnome-shell&keywords=I18N+L10N&component=extensions", "POT-Creation-Date"=>"2014-08-28 07:40+0000", "PO-Revision-Date"=>"2014-08-28 19:59+0430", "Last-Translator"=>"Arash Mousavi <mousavi.arash@gmail.com>", "Language-Team"=>"Persian <>", "Language"=>"fa_IR", "MIME-Version"=>"1.0", "Content-Type"=>"text/plain; charset=UTF-8", "Content-Transfer-Encoding"=>"8bit", "X-Poedit-SourceCharset"=>"utf-8", "X-Generator"=>"Gtranslator 2.91.6", "Plural-Forms"=>"nplurals=1; plural=0;"}
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: PoParser
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.2.
|
4
|
+
version: 3.2.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Arash Mousavi
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2024-05-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: simple_po_parser
|
@@ -60,6 +60,7 @@ executables: []
|
|
60
60
|
extensions: []
|
61
61
|
extra_rdoc_files: []
|
62
62
|
files:
|
63
|
+
- ".editorconfig"
|
63
64
|
- ".github/workflows/ruby.yml"
|
64
65
|
- ".gitignore"
|
65
66
|
- ".rspec"
|
@@ -119,7 +120,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
119
120
|
- !ruby/object:Gem::Version
|
120
121
|
version: '0'
|
121
122
|
requirements: []
|
122
|
-
rubygems_version: 3.
|
123
|
+
rubygems_version: 3.5.10
|
123
124
|
signing_key:
|
124
125
|
specification_version: 4
|
125
126
|
summary: A PO file parser, editor and generator.
|