immosquare-extensions 0.1.13 → 0.1.15

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
  SHA256:
3
- metadata.gz: 5b4cad039db2d2b1ee44eb735d1c6c710893b4aca057782689e060eb065275bb
4
- data.tar.gz: 4a87efbeca74628edbc47da54e24a9287dd765e248e7900a269c93f5ccad9dcc
3
+ metadata.gz: 9eac5ff3164cb73f659292ba3a389b9213f647e5c5c54f9da0c6535ec68ca573
4
+ data.tar.gz: e1bc371e64193f0d4750298aa0c5e18a88827caa5c2d4826885a8caa530f4ccd
5
5
  SHA512:
6
- metadata.gz: 5c448e5db2ad0358f3e5bf5ea27cd184a5a8bfc159269a1dc7b93bc4b497f7555021c2c2a82071b925da25456839272f7b875060846f2f4c5e5e1707df983232
7
- data.tar.gz: 5437907a34109b7edfb622eed9fa081ba878ef9c207261a7ed389b8b7276a8ea0bcedff2b065663b5f2c42cb976be0f229cefcafc3aae3666f3b1903e5e6e167
6
+ metadata.gz: 734f2700c95e499f2a4fa35f7b7b7fc80f81aac58d5480332db03490919b5cec8fad77355cc9d5014c21b613144eca10981818422420fe64a54dc4ff5bb210ef
7
+ data.tar.gz: a8076f8d899a9fa2bb6b54b09e15c2b6674f59141fc1d4d17e90e481f9de7c362fef9ffa5ebc0b9d7b7c55aeebc28a5ee338c0dad1d5775cfceb7d87a7304297
@@ -14,6 +14,17 @@ class File
14
14
  ## The total number of lines in the normalized file.
15
15
  ##===========================================================================##
16
16
  def self.normalize_last_line(file_path)
17
+ ##============================================================##
18
+ ## Get the file size
19
+ ##============================================================##
20
+ file_size = File.size?(file_path)
21
+
22
+ ##============================================================##
23
+ ## If the file is empty (0 bytes), there's nothing to normalize.
24
+ ##============================================================##
25
+ return 0 if file_size.nil? || file_size == 0
26
+
27
+
17
28
  end_of_line = $INPUT_RECORD_SEPARATOR || "\n"
18
29
  ##============================================================##
19
30
  ## Read all lines from the file
@@ -22,8 +33,41 @@ class File
22
33
  ## Read the content of the file with the detected encoding,
23
34
  ## falling back to UTF-8 if the detected encoding is empty or invalid.
24
35
  ##============================================================##
25
- detected_encoding = `uchardet #{file_path}`.strip
26
- encoding_to_use = detected_encoding.empty? ? "UTF-8" : "#{detected_encoding}:UTF-8"
36
+ detected_encoding = `uchardet #{file_path}`.strip
37
+ encoding_whitelist = [
38
+ "UTF-8", # Encodage universel pour texte avec ou sans accents
39
+ "Windows-1252", # Utilisé couramment pour les langues occidentales
40
+ "ISO-8859-1", # L'encodage Latin-1, très utilisé en Europe Occidentale
41
+ "Windows-1250", # Europe Centrale et Orientale
42
+ "ISO-8859-2", # Pour les langues d'Europe Centrale
43
+ "Windows-1251", # Cyrillic; utilisé pour le russe, bulgare, serbe cyrillique
44
+ "KOI8-R", # Russe
45
+ "ISO-8859-5", # Encodage cyrillique
46
+ "ISO-8859-7", # Grec
47
+ "Windows-1253", # Grec
48
+ "ISO-8859-9", # Turc
49
+ "Windows-1254", # Turc
50
+ "ISO-8859-15", # Variante de l'ISO-8859-1 qui couvre plus de caractères
51
+ "Windows-1256", # Arabe
52
+ "ISO-8859-6", # Arabe
53
+ "Windows-1255", # Hébreu
54
+ "ISO-8859-8", # Hébreu
55
+ "Big5", # Chinois traditionnel
56
+ "GB2312", # Chinois simplifié
57
+ "Shift_JIS", # Japonais
58
+ "EUC-JP", # Japonais
59
+ "EUC-KR", # Coréen
60
+ "ISO-2022-JP", # Encodage pour le courrier électronique en japonais
61
+ "ISO-2022-KR", # Coréen
62
+ "ISO-2022-CN", # Chinois
63
+ "UTF-16LE", # UTF-16 Little Endian
64
+ "UTF-16BE", # UTF-16 Big Endian
65
+ "UTF-32LE", # UTF-32 Little Endian
66
+ "UTF-32BE" # UTF-32 Big Endian
67
+ ]
68
+
69
+
70
+ encoding_to_use = detected_encoding.empty? || !encoding_whitelist.include?(detected_encoding) ? "UTF-8" : "#{detected_encoding}:UTF-8"
27
71
  content = File.read(file_path, :encoding => encoding_to_use)
28
72
 
29
73
  ##===========================================================================##
@@ -1,3 +1,3 @@
1
1
  module ImmosquareExtensions
2
- VERSION = "0.1.13".freeze
2
+ VERSION = "0.1.15".freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: immosquare-extensions
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.13
4
+ version: 0.1.15
5
5
  platform: ruby
6
6
  authors:
7
7
  - IMMO SQUARE
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-02-06 00:00:00.000000000 Z
11
+ date: 2024-03-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: unicode_utils