puttext 0.2.0 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +2 -2
- data/lib/puttext/po_file.rb +11 -4
- data/puttext.gemspec +1 -1
- data/spec/unit/po_file_spec.rb +21 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 30ea19d0b5142d39af84debf1a5554e54cd7b28e
|
4
|
+
data.tar.gz: 7e5b71ded6723ffc5a5eab512b871baedb1fe9ce
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c31494729c4e056cdd9eb79f983a232e99f0840ea0786bac4cab16f60b5322ad66d8af1f17e06a00e49c10f2076e4ef9c17f9e396480c8aa6a31dd84558aac3c
|
7
|
+
data.tar.gz: 8d30e26ee2bbbf93ea71260094f23859459fbb6f99723dc0d185111c3fe8a50ecbe7f177425e1028cfd9a0764f5b1a6aa2532cfee4c4ee027ba99070e2cfba10
|
data/Gemfile.lock
CHANGED
data/lib/puttext/po_file.rb
CHANGED
@@ -12,14 +12,11 @@ module PutText
|
|
12
12
|
# be placed in this file.
|
13
13
|
def initialize(entries)
|
14
14
|
@entries = entries
|
15
|
-
|
16
|
-
now = Time.now.strftime('%Y-%m-%d %H:%M%z')
|
17
|
-
|
18
15
|
@header_entry = POEntry.new(
|
19
16
|
flags: ['fuzzy'],
|
20
17
|
msgid: '',
|
21
18
|
msgstr: <<-STRING.unindent
|
22
|
-
POT-Creation-Date: #{now}
|
19
|
+
POT-Creation-Date: #{Time.now.strftime('%Y-%m-%d %H:%M%z')}
|
23
20
|
MIME-Version: 1.0
|
24
21
|
Content-Type: text/plain; charset=UTF-8
|
25
22
|
STRING
|
@@ -45,6 +42,16 @@ module PutText
|
|
45
42
|
end
|
46
43
|
end
|
47
44
|
|
45
|
+
# Merge the contents of another POFile to this POFile.
|
46
|
+
# @param [POFile] other_file the file to merge the contents of to this file.
|
47
|
+
def merge(other_file)
|
48
|
+
unless other_file.is_a?(POFile)
|
49
|
+
raise ArgumentError, 'argument must be a PutText::POFile'
|
50
|
+
end
|
51
|
+
|
52
|
+
@entries += other_file.entries
|
53
|
+
end
|
54
|
+
|
48
55
|
def ==(other)
|
49
56
|
@entries.sort == other.entries.sort
|
50
57
|
end
|
data/puttext.gemspec
CHANGED
data/spec/unit/po_file_spec.rb
CHANGED
@@ -65,4 +65,25 @@ describe PutText::POFile do
|
|
65
65
|
PO
|
66
66
|
end
|
67
67
|
end
|
68
|
+
|
69
|
+
describe '#merge' do
|
70
|
+
let(:entry_1) { PutText::POEntry.new(msgid: 'One error occurred') }
|
71
|
+
let(:entry_2) { PutText::POEntry.new(msgid: 'Another error occurred') }
|
72
|
+
let(:file_1) { described_class.new([entry_1]) }
|
73
|
+
let(:file_2) { described_class.new([entry_2]) }
|
74
|
+
|
75
|
+
context 'POFile is passed as an argument' do
|
76
|
+
before { file_1.merge(file_2) }
|
77
|
+
|
78
|
+
it 'merges the contents of two POFiles' do
|
79
|
+
expect(file_1.entries).to contain_exactly(entry_1, entry_2)
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
context 'an object that is not a POFile is passed as an argument' do
|
84
|
+
it 'raises an ArgumentError' do
|
85
|
+
expect { file_1.merge('string') }.to raise_error(ArgumentError)
|
86
|
+
end
|
87
|
+
end
|
88
|
+
end
|
68
89
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: puttext
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mantas Norvaiša
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-05
|
11
|
+
date: 2017-06-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: parser
|