tmx_importer 1.2.1 → 1.3.0
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/lib/tmx_importer/version.rb +1 -1
- data/lib/tmx_importer.rb +8 -0
- data/spec/tmx_importer_spec.rb +3 -3
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 400e49daf0cd5e479bdb92f20dd2a4494c80ed9b
|
4
|
+
data.tar.gz: 4f0d37929793eb6a23aeb72c0140fe0b6f0dd945
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e61e518933ce61f7e483feec1f86e1cf6f6dac4cf06344c0862d9a57f9fadfb4b182cf3f0afefad7943288fea1995e1d933ab02bbac2e1045ad23b457420c7c0
|
7
|
+
data.tar.gz: 147da0e1416afb8336b013293af4c639517acbb442ac210efa1952bf457efcb8fed32135bcab4003b6a4cb84f1d9f3b17cbd54d89ba4c4ec13a53b58483d5301
|
data/lib/tmx_importer/version.rb
CHANGED
data/lib/tmx_importer.rb
CHANGED
@@ -12,6 +12,14 @@ module TmxImporter
|
|
12
12
|
@content = File.read(open(@file_path)) if !args[:encoding].eql?('UTF-8')
|
13
13
|
if args[:encoding].nil?
|
14
14
|
@encoding = CharlockHolmes::EncodingDetector.detect(@content[0..100_000])[:encoding]
|
15
|
+
if @encoding.nil?
|
16
|
+
encoding_in_file = @content.dup.force_encoding('utf-8').scrub!("*").gsub!(/\0/, '').scan(/(?<=encoding=").*(?=")/)[0].upcase
|
17
|
+
if encoding_in_file.eql?('UTF-8')
|
18
|
+
@encoding = ('UTF-8')
|
19
|
+
elsif encoding_in_file.eql?('UTF-16')
|
20
|
+
@encoding = ('UTF-16LE')
|
21
|
+
end
|
22
|
+
end
|
15
23
|
else
|
16
24
|
@encoding = args[:encoding].upcase
|
17
25
|
end
|
data/spec/tmx_importer_spec.rb
CHANGED
@@ -85,8 +85,8 @@ describe TmxImporter do
|
|
85
85
|
describe '#import' do
|
86
86
|
it 'imports a UTF-8 TMX file' do
|
87
87
|
file_path = File.expand_path('../tmx_importer/spec/test_sample_files/test_tm(utf-8).tmx')
|
88
|
-
tmx = TmxImporter::Tmx.new(file_path: file_path)
|
89
|
-
expect(tmx[1][2][3]).to eq("de-DE")
|
88
|
+
tmx = TmxImporter::Tmx.new(file_path: file_path)
|
89
|
+
expect(tmx.import[1][2][3]).to eq("de-DE")
|
90
90
|
end
|
91
91
|
|
92
92
|
it 'imports a UTF-8 TMX file 2' do
|
@@ -97,7 +97,7 @@ describe TmxImporter do
|
|
97
97
|
|
98
98
|
it 'imports a UTF-16LE TMX file' do
|
99
99
|
file_path = File.expand_path('../tmx_importer/spec/test_sample_files/test_tm(utf-16LE).tmx')
|
100
|
-
tmx = TmxImporter::Tmx.new(file_path: file_path
|
100
|
+
tmx = TmxImporter::Tmx.new(file_path: file_path)
|
101
101
|
expect(tmx.import[1][3][4]).to eq("Backrest adjustment")
|
102
102
|
end
|
103
103
|
|