xlf_importer 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 688d9c4a4ae3f47abe702c4177923478e87f3721
4
- data.tar.gz: 3298c459f50ab59d98398f1199540337ea3a0219
3
+ metadata.gz: 111ab9e88af450bb337979392e231b3c5689e986
4
+ data.tar.gz: 7dc297490b93536ab07e32ff05dd181ed41f3fc3
5
5
  SHA512:
6
- metadata.gz: ca63fe876eaf94aaa9680e4d3deb3de9da9fc24d5ee3de02ad08d507e89f2d76a08a191c9cb9f462d2cbc74918d565d924017526d56313400c67abe2d54cfcc2
7
- data.tar.gz: 7d57ffd245a5edc1ed4bb068f6deecbcb22678e64cc047f8f3c04c662d51c61fd1eca11e4f654d8de60af7fc93306ca4fccf5c482ae827a3d73f446499b726ec
6
+ metadata.gz: 63bdf7dde36d3ef0d9898c885613b64ca14b68ac98f0c897b5e2ad97c2b1a9e3b2c196ddf1de965bfda725311008b9233e3f14b5408b0527ce7855767a9e4075
7
+ data.tar.gz: 439aec781d9178166ce126d22494c52ffd62bfff433d30fb696e2811fca4f2c540de6d0c13d055a9266bdfd1e7a02fec1fcd512b3de7912cadcd111a70c9a4a9
data/lib/xlf_importer.rb CHANGED
@@ -131,6 +131,7 @@ module XlfImporter
131
131
  def write_seg(reader, role, language)
132
132
  return if reader.read_string.nil?
133
133
  text = PrettyStrings::Cleaner.new(reader.read_string).pretty.gsub("\\","\").gsub("'",%q(\\\'))
134
+ return if text.nil? || text.empty?
134
135
  word_count = text.gsub("\s+", ' ').split(' ').length
135
136
  @doc[:seg][:vals] << [@doc[:tu][:id], role, word_count, language, text]
136
137
  end
@@ -1,3 +1,3 @@
1
1
  module XlfImporter
2
- VERSION = "0.1.0"
2
+ VERSION = "0.2.0"
3
3
  end
@@ -0,0 +1,15 @@
1
+ <xliff version="1.2"
2
+ xmlns="urn:oasis:names:tc:xliff:document:1.2">
3
+ <file original="hello.txt" source-language="en" target-language="fr"
4
+ datatype="plaintext">
5
+ <body>
6
+ <trans-unit id="hi">
7
+ <source>Hello world</source>
8
+ <target>Bonjour le monde</target>
9
+ <alt-trans>
10
+ <target xml:lang="es">Hola mundo</target>
11
+ </alt-trans>
12
+ </trans-unit>
13
+ </body>
14
+ </file>
15
+ </xliff>
@@ -32,6 +32,12 @@ describe XlfImporter do
32
32
  expect(xlf.import[1][2][3]).to eq('es')
33
33
  end
34
34
 
35
+ it 'imports sample_alt_3.xlf' do
36
+ file_path = File.expand_path('../xlf_importer/spec/test_sample_files/sample_alt_3.xlf')
37
+ xlf = XlfImporter::Xlf.new(file_path: file_path, encoding: 'UTF-8')
38
+ expect(xlf.import[1][2][3]).to eq('es')
39
+ end
40
+
35
41
  it 'imports sample_alt_2.xlf' do
36
42
  file_path = File.expand_path('../xlf_importer/spec/test_sample_files/sample_alt_2.xlf')
37
43
  xlf = XlfImporter::Xlf.new(file_path: file_path, encoding: 'UTF-8')
@@ -50,6 +56,12 @@ describe XlfImporter do
50
56
  expect(xlf.import[1][3][0]).to eq(xlf.import[0][1][0])
51
57
  end
52
58
 
59
+ it 'imports sample_alt_2.xlf' do
60
+ file_path = File.expand_path('../xlf_importer/spec/test_sample_files/sample_alt_2.xlf')
61
+ xlf = XlfImporter::Xlf.new(file_path: file_path, encoding: 'UTF-8')
62
+ expect(xlf.import[1].length).to eq(5)
63
+ end
64
+
53
65
  it 'imports a UTF-16 XLIFF file' do
54
66
  file_path = File.expand_path('../xlf_importer/spec/test_sample_files/sample_utf-16.xlf')
55
67
  xlf = XlfImporter::Xlf.new(file_path: file_path)
data/xlf_importer.gemspec CHANGED
@@ -21,7 +21,7 @@ Gem::Specification.new do |spec|
21
21
  spec.add_development_dependency "bundler", "~> 1.9"
22
22
  spec.add_development_dependency "rake", "~> 10.0"
23
23
  spec.add_development_dependency "rspec"
24
- spec.add_runtime_dependency "libxml-ruby"
24
+ spec.add_runtime_dependency "libxml-ruby", "2.8.0"
25
25
  spec.add_runtime_dependency "pretty_strings", "~> 0.5.0"
26
26
  spec.add_runtime_dependency "charlock_holmes_bundle_icu", "~> 0.6.9.2"
27
27
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: xlf_importer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kevin S. Dias
@@ -56,16 +56,16 @@ dependencies:
56
56
  name: libxml-ruby
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - ">="
59
+ - - '='
60
60
  - !ruby/object:Gem::Version
61
- version: '0'
61
+ version: 2.8.0
62
62
  type: :runtime
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - ">="
66
+ - - '='
67
67
  - !ruby/object:Gem::Version
68
- version: '0'
68
+ version: 2.8.0
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: pretty_strings
71
71
  requirement: !ruby/object:Gem::Requirement
@@ -112,6 +112,7 @@ files:
112
112
  - lib/xlf_importer/version.rb
113
113
  - spec/spec_helper.rb
114
114
  - spec/test_sample_files/sample_alt_2.xlf
115
+ - spec/test_sample_files/sample_alt_3.xlf
115
116
  - spec/test_sample_files/sample_alt_translation.xlf
116
117
  - spec/test_sample_files/sample_utf-16.xlf
117
118
  - spec/xlf_importer_spec.rb
@@ -135,13 +136,14 @@ required_rubygems_version: !ruby/object:Gem::Requirement
135
136
  version: '0'
136
137
  requirements: []
137
138
  rubyforge_project:
138
- rubygems_version: 2.4.1
139
+ rubygems_version: 2.4.8
139
140
  signing_key:
140
141
  specification_version: 4
141
142
  summary: XLIFF / XLF file importer
142
143
  test_files:
143
144
  - spec/spec_helper.rb
144
145
  - spec/test_sample_files/sample_alt_2.xlf
146
+ - spec/test_sample_files/sample_alt_3.xlf
145
147
  - spec/test_sample_files/sample_alt_translation.xlf
146
148
  - spec/test_sample_files/sample_utf-16.xlf
147
149
  - spec/xlf_importer_spec.rb