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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 7424c506cc51203870a3071cf7a09a90e2aa1af9
4
- data.tar.gz: ff7ae48224eb2f8a03bc8d550f23735ea76f003a
3
+ metadata.gz: 400e49daf0cd5e479bdb92f20dd2a4494c80ed9b
4
+ data.tar.gz: 4f0d37929793eb6a23aeb72c0140fe0b6f0dd945
5
5
  SHA512:
6
- metadata.gz: 512fb82572a62c8bc7b27fd1ff82ae8152e7bca9581b0e968c2bcdc1b4f4e2b5a89bcc4562241bc5e8fd22daf7ca33213b205f572319f7f416cf63f22b9e41d2
7
- data.tar.gz: cc89619e0ee8c0b0ed2c799573c5d64fa8e8fcae9d4e47328b5f0719dedffe6668beadf50006a4f4764b187c462c64dee9888ab0914f174c6e574174295f179a
6
+ metadata.gz: e61e518933ce61f7e483feec1f86e1cf6f6dac4cf06344c0862d9a57f9fadfb4b182cf3f0afefad7943288fea1995e1d933ab02bbac2e1045ad23b457420c7c0
7
+ data.tar.gz: 147da0e1416afb8336b013293af4c639517acbb442ac210efa1952bf457efcb8fed32135bcab4003b6a4cb84f1d9f3b17cbd54d89ba4c4ec13a53b58483d5301
@@ -1,3 +1,3 @@
1
1
  module TmxImporter
2
- VERSION = "1.2.1"
2
+ VERSION = "1.3.0"
3
3
  end
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
@@ -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).import
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, encoding: 'utf-16le')
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
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tmx_importer
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.1
4
+ version: 1.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kevin S. Dias