PoParser 1.0.0 → 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +1 -0
- data/Gemfile +1 -1
- data/README.md +3 -3
- data/lib/poparser/transformer.rb +4 -4
- data/lib/poparser/version.rb +1 -1
- data/poparser.gemspec +3 -3
- data/spec/poparser/entry_spec.rb +14 -14
- data/spec/poparser/header_spec.rb +1 -1
- data/spec/poparser/parser_spec.rb +13 -13
- data/spec/spec_helper.rb +1 -1
- metadata +11 -11
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 839ed2d8b43387b11ebee0094af10a6f6e164e51
|
4
|
+
data.tar.gz: 2d1da0390af32f7b1ce6a0b21f78869d6b915013
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4205546fbc30d74e7a4091536a61f198d95c4f347d2166cff0a145475717789e1a79796542c457ece7eb945993d0fc4f88e48d1cf54fc8bc90cbcee61088b773
|
7
|
+
data.tar.gz: 01c7dabb307b9eeba663a0a3ea884d6c01e18886e5d5304a0b6f0bca1c0e36fa127212e5091661de9ce2fc87527af90acade4952f5bdf08470ae926d7b82ceba
|
data/.travis.yml
CHANGED
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
#
|
1
|
+
# PoParser
|
2
2
|
|
3
3
|
[![Build Status](https://travis-ci.org/arashm/PoParser.svg?branch=master)](https://travis-ci.org/arashm/PoParser)
|
4
4
|
[![Coverage Status](https://img.shields.io/coveralls/arashm/PoParser.svg)](https://coveralls.io/r/arashm/PoParser)
|
@@ -11,7 +11,7 @@ A Ruby PO file parser, editor and generator. PO files are translation files gene
|
|
11
11
|
|
12
12
|
Add this line to your application's Gemfile:
|
13
13
|
|
14
|
-
gem '
|
14
|
+
gem 'PoParser'
|
15
15
|
|
16
16
|
And then execute:
|
17
17
|
|
@@ -19,7 +19,7 @@ And then execute:
|
|
19
19
|
|
20
20
|
Or install it yourself as:
|
21
21
|
|
22
|
-
$ gem install
|
22
|
+
$ gem install PoParser
|
23
23
|
|
24
24
|
## Usage
|
25
25
|
|
data/lib/poparser/transformer.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
module PoParser
|
2
|
-
# Converts the array returned from {Parser} to a
|
2
|
+
# Converts the array returned from {Parser} to a usable hash
|
3
3
|
class Transformer
|
4
4
|
def initialize
|
5
5
|
@hash = {}
|
@@ -15,8 +15,8 @@ module PoParser
|
|
15
15
|
|
16
16
|
private
|
17
17
|
# @Note: There was a problem applying all rules together. I don't know
|
18
|
-
# in what order Parslet run rules, but it's not in order. I
|
19
|
-
# making
|
18
|
+
# in what order Parslet run rules, but it's not in order. I ended up
|
19
|
+
# making two separate transform and feed one output to the other.
|
20
20
|
def first_transform
|
21
21
|
Parslet::Transform.new do
|
22
22
|
rule(:msgstr_plural => subtree(:plural)) do
|
@@ -44,7 +44,7 @@ module PoParser
|
|
44
44
|
|
45
45
|
# Merges two hashed together. If both hashes have common keys it
|
46
46
|
# will create an array of them
|
47
|
-
#
|
47
|
+
#
|
48
48
|
# @return [Hash]
|
49
49
|
def merge(newh)
|
50
50
|
@hash.merge!(newh) do |key, oldval, newval|
|
data/lib/poparser/version.rb
CHANGED
data/poparser.gemspec
CHANGED
@@ -19,9 +19,9 @@ Gem::Specification.new do |spec|
|
|
19
19
|
spec.require_paths = ["lib"]
|
20
20
|
|
21
21
|
# Runtime deps
|
22
|
-
spec.add_runtime_dependency "parslet", "~> 1.
|
22
|
+
spec.add_runtime_dependency "parslet", "~> 1.7"
|
23
23
|
|
24
24
|
# Development deps
|
25
|
-
spec.add_development_dependency "bundler", "~> 1.
|
26
|
-
spec.add_development_dependency "rake"
|
25
|
+
spec.add_development_dependency "bundler", "~> 1.10"
|
26
|
+
spec.add_development_dependency "rake", "~> 10.4"
|
27
27
|
end
|
data/spec/poparser/entry_spec.rb
CHANGED
@@ -14,7 +14,7 @@ describe PoParser::Entry do
|
|
14
14
|
|
15
15
|
it 'should respond to labels' do
|
16
16
|
labels.each do |label|
|
17
|
-
@entry.
|
17
|
+
expect(@entry).to respond_to label
|
18
18
|
end
|
19
19
|
end
|
20
20
|
|
@@ -36,38 +36,38 @@ describe PoParser::Entry do
|
|
36
36
|
end
|
37
37
|
|
38
38
|
it 'checks if the entry is translated' do
|
39
|
-
expect(@entry.translated?).to
|
39
|
+
expect(@entry.translated?).to be_falsy
|
40
40
|
@entry.translate ''
|
41
|
-
expect(@entry.translated?).to
|
41
|
+
expect(@entry.translated?).to be_falsy
|
42
42
|
@entry.translate 'translated'
|
43
|
-
expect(@entry.complete?).to
|
43
|
+
expect(@entry.complete?).to be_truthy
|
44
44
|
end
|
45
45
|
|
46
46
|
context 'Plural' do
|
47
47
|
it 'returns false if it\'s not plural' do
|
48
|
-
expect(@entry.plural?).to
|
48
|
+
expect(@entry.plural?).to be_falsy
|
49
49
|
end
|
50
50
|
|
51
51
|
it 'returns true if it\'s plural' do
|
52
52
|
@entry.msgid_plural = 'sth'
|
53
|
-
expect(@entry.plural?).to
|
53
|
+
expect(@entry.plural?).to be_truthy
|
54
54
|
end
|
55
55
|
end
|
56
56
|
|
57
57
|
context 'Flags' do
|
58
58
|
it 'should check if a entry is fuzzy' do
|
59
|
-
expect(@entry.fuzzy?).to
|
59
|
+
expect(@entry.fuzzy?).to be_falsy
|
60
60
|
@entry.flag = 'fuzzy'
|
61
|
-
expect(@entry.fuzzy?).to
|
61
|
+
expect(@entry.fuzzy?).to be_truthy
|
62
62
|
end
|
63
63
|
|
64
64
|
it 'should flag a entry as fuzzy' do
|
65
|
-
expect(@entry.flag_as_fuzzy).to
|
65
|
+
expect(@entry.flag_as_fuzzy).to be_truthy
|
66
66
|
expect(@entry.flag).to eq('fuzzy')
|
67
67
|
end
|
68
68
|
|
69
69
|
it 'should be able to set a custome flag' do
|
70
|
-
expect(@entry.flag_as 'python-format').to
|
70
|
+
expect(@entry.flag_as 'python-format').to be_truthy
|
71
71
|
expect(@entry.flag).to eq('python-format')
|
72
72
|
end
|
73
73
|
end
|
@@ -98,19 +98,19 @@ describe PoParser::Entry do
|
|
98
98
|
end
|
99
99
|
|
100
100
|
it 'checks for chached entries' do
|
101
|
-
expect(@entry.cached?).to
|
101
|
+
expect(@entry.cached?).to be_truthy
|
102
102
|
end
|
103
103
|
|
104
104
|
it 'shouldn be counted as untranslated' do
|
105
|
-
expect(@entry.untranslated?).to
|
105
|
+
expect(@entry.untranslated?).to be_falsy
|
106
106
|
end
|
107
107
|
|
108
108
|
it 'shouldn be counted as translated' do
|
109
|
-
expect(@entry.translated?).to
|
109
|
+
expect(@entry.translated?).to be_falsy
|
110
110
|
end
|
111
111
|
|
112
112
|
it 'shouldn\'t mark it as fuzzy' do
|
113
|
-
expect(@entry.fuzzy?).to
|
113
|
+
expect(@entry.fuzzy?).to be_falsy
|
114
114
|
end
|
115
115
|
end
|
116
116
|
end
|
@@ -13,27 +13,27 @@ describe PoParser::Parser do
|
|
13
13
|
let(:pusc){ po.previous_untraslated_string }
|
14
14
|
|
15
15
|
it 'parses the translator comment' do
|
16
|
-
tc.
|
17
|
-
tc.
|
18
|
-
tc.
|
16
|
+
expect(tc).to parse("# Persian translation for damned-lies 123123\n")
|
17
|
+
expect(tc).to parse("# Copyright (C) 2012 damned-lies's COPYRIGHT HOLDER\n")
|
18
|
+
expect(tc).to parse("# Arash Mousavi <mousavi.arash@gmail.com>, 2014.\n")
|
19
19
|
end
|
20
20
|
|
21
21
|
it 'parses refrence comment' do
|
22
|
-
rc.
|
22
|
+
expect(rc).to parse("#: database-content.py:1 database-content.py:129 settings.py:52\n")
|
23
23
|
end
|
24
24
|
|
25
25
|
it 'parses extracted_comment' do
|
26
|
-
ec.
|
26
|
+
expect(ec).to parse("#. database-content.py:1 database-content.py:129 settings.py:52\n")
|
27
27
|
end
|
28
28
|
|
29
29
|
it 'parses flag_comment' do
|
30
|
-
fc.
|
30
|
+
expect(fc).to parse("#, python-format\n")
|
31
31
|
end
|
32
32
|
|
33
33
|
it 'parses previous_untraslated_string' do
|
34
|
-
pusc.
|
35
|
-
pusc.
|
36
|
-
pusc.
|
34
|
+
expect(pusc).to parse("#| msgid \"\"\n")
|
35
|
+
expect(pusc).to parse("#| \"Hello,\\n\"\n")
|
36
|
+
expect(pusc).to parse("#| \"The new state of %(module)s - %(branch)s - %(domain)s (%(language)s) is \"\n")
|
37
37
|
end
|
38
38
|
|
39
39
|
end
|
@@ -44,13 +44,13 @@ describe PoParser::Parser do
|
|
44
44
|
let(:pofile){ Pathname.new('spec/poparser/fixtures/multiline.po').realpath }
|
45
45
|
|
46
46
|
it 'parses msgid' do
|
47
|
-
msgid.
|
48
|
-
msgid.
|
47
|
+
expect(msgid).to parse "msgid \"The new state of %(module)s - %(branch)s - %(domain)s (%(language)s) is now \"\n"
|
48
|
+
expect(msgid).to parse "msgid \"The new \"state\" of %(module)s - %(branch)s - %(domain)s (%(language)s) is now \"\n"
|
49
49
|
end
|
50
50
|
|
51
51
|
it 'parses msgstr' do
|
52
|
-
msgstr.
|
53
|
-
msgstr.
|
52
|
+
expect(msgstr).to parse "msgstr \"The new state of %(module)s - %(branch)s - %(domain)s (%(language)s) is now \"\n"
|
53
|
+
expect(msgstr).to parse "msgstr \"فعالیت نامعتبر. شاید یک نفر دیگر دقیقا قبل از شما یک فعالیت دیگر ارسال کرده ۱۲۳۱۲۳۱safda \"\n"
|
54
54
|
end
|
55
55
|
|
56
56
|
it 'parses multiline entries' do
|
data/spec/spec_helper.rb
CHANGED
@@ -13,7 +13,7 @@ require 'awesome_print'
|
|
13
13
|
Coveralls.wear!
|
14
14
|
|
15
15
|
RSpec.configure do |config|
|
16
|
-
config.
|
16
|
+
config.raise_errors_for_deprecations!
|
17
17
|
config.run_all_when_everything_filtered = true
|
18
18
|
config.filter_run :focus
|
19
19
|
|
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: 1.0.
|
4
|
+
version: 1.0.1
|
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: 2015-09-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: parslet
|
@@ -16,42 +16,42 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '1.
|
19
|
+
version: '1.7'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '1.
|
26
|
+
version: '1.7'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: bundler
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
31
|
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: '1.
|
33
|
+
version: '1.10'
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: '1.
|
40
|
+
version: '1.10'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: rake
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- - "
|
45
|
+
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: '
|
47
|
+
version: '10.4'
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- - "
|
52
|
+
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: '
|
54
|
+
version: '10.4'
|
55
55
|
description: A PO file parser, editor and generator. PO files are translation files
|
56
56
|
generated by GNU/Gettext tool.
|
57
57
|
email:
|
@@ -117,7 +117,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
117
117
|
version: '0'
|
118
118
|
requirements: []
|
119
119
|
rubyforge_project:
|
120
|
-
rubygems_version: 2.4.
|
120
|
+
rubygems_version: 2.4.6
|
121
121
|
signing_key:
|
122
122
|
specification_version: 4
|
123
123
|
summary: A PO file parser, editor and generator.
|