immosquare-extensions 0.1.12 → 0.1.13
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/immosquare-extensions/file.rb +7 -2
- data/lib/immosquare-extensions/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5b4cad039db2d2b1ee44eb735d1c6c710893b4aca057782689e060eb065275bb
|
4
|
+
data.tar.gz: 4a87efbeca74628edbc47da54e24a9287dd765e248e7900a269c93f5ccad9dcc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5c448e5db2ad0358f3e5bf5ea27cd184a5a8bfc159269a1dc7b93bc4b497f7555021c2c2a82071b925da25456839272f7b875060846f2f4c5e5e1707df983232
|
7
|
+
data.tar.gz: 5437907a34109b7edfb622eed9fa081ba878ef9c207261a7ed389b8b7276a8ea0bcedff2b065663b5f2c42cb976be0f229cefcafc3aae3666f3b1903e5e6e167
|
@@ -18,8 +18,13 @@ class File
|
|
18
18
|
##============================================================##
|
19
19
|
## Read all lines from the file
|
20
20
|
## https://gist.github.com/guilhermesimoes/d69e547884e556c3dc95
|
21
|
+
## Detect the encoding of the file using uchardet
|
22
|
+
## Read the content of the file with the detected encoding,
|
23
|
+
## falling back to UTF-8 if the detected encoding is empty or invalid.
|
21
24
|
##============================================================##
|
22
|
-
|
25
|
+
detected_encoding = `uchardet #{file_path}`.strip
|
26
|
+
encoding_to_use = detected_encoding.empty? ? "UTF-8" : "#{detected_encoding}:UTF-8"
|
27
|
+
content = File.read(file_path, :encoding => encoding_to_use)
|
23
28
|
|
24
29
|
##===========================================================================##
|
25
30
|
## Remove all trailing empty lines at the end of the file
|
@@ -34,7 +39,7 @@ class File
|
|
34
39
|
##===========================================================================##
|
35
40
|
## Write the modified lines back to the file
|
36
41
|
##===========================================================================##
|
37
|
-
File.write(file_path, content)
|
42
|
+
File.write(file_path, content, :encoding => encoding_to_use)
|
38
43
|
|
39
44
|
##===========================================================================##
|
40
45
|
## Return the total number of lines in the modified file
|
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.
|
4
|
+
version: 0.1.13
|
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-
|
11
|
+
date: 2024-02-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: unicode_utils
|