immosquare-yaml 0.1.19 → 0.1.20
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-yaml/version.rb +1 -1
- data/lib/immosquare-yaml.rb +2 -43
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 467e395c6883993cd3a7496ca196e0aae40fc5b0b51159e8710b3b852cc8857f
|
4
|
+
data.tar.gz: b066518248c9f75656bc6fc880f14d82a78aae511272f353df7319ec2ec69bdd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 64b828a55553839f8baa4f3da05ce2f2d7f7b6ef1d9a3340cf413467e27337db80b142ac7ae52742a74107175d7baa169e1fd7eab21d383b94888b2f754fd1ba
|
7
|
+
data.tar.gz: 7583b3bc085e7c25808cc4a0caec2b03cdd825929d7e79aa365b494a4546afbb0f9c3d393500c346fd640a4728e6f98abd70be21d948ce695e5efc0d82311c0b
|
data/lib/immosquare-yaml.rb
CHANGED
@@ -240,48 +240,7 @@ module ImmosquareYaml
|
|
240
240
|
|
241
241
|
private
|
242
242
|
|
243
|
-
##===========================================================================##
|
244
|
-
## This method ensures the file ends with a single newline, facilitating
|
245
|
-
## cleaner multi-line blocks. It operates by reading all lines of the file,
|
246
|
-
## removing any empty lines at the end, and then appending a newline.
|
247
|
-
## This guarantees the presence of a newline at the end, and also prevents
|
248
|
-
## multiple newlines from being present at the end.
|
249
|
-
##
|
250
|
-
## Params:
|
251
|
-
## +file_path+:: The path to the file to be normalized.
|
252
|
-
##
|
253
|
-
## Returns:
|
254
|
-
## The total number of lines in the normalized file.
|
255
|
-
##===========================================================================##
|
256
|
-
def normalize_last_line(file_path)
|
257
|
-
end_of_line = $INPUT_RECORD_SEPARATOR
|
258
|
-
##============================================================##
|
259
|
-
## Read all lines from the file
|
260
|
-
## https://gist.github.com/guilhermesimoes/d69e547884e556c3dc95
|
261
|
-
##============================================================##
|
262
|
-
content = File.read(file_path)
|
263
|
-
|
264
243
|
|
265
|
-
##===========================================================================##
|
266
|
-
## Remove all trailing empty lines at the end of the file
|
267
|
-
##===========================================================================##
|
268
|
-
content.gsub!(/#{Regexp.escape(end_of_line)}+\z/, "")
|
269
|
-
|
270
|
-
##===========================================================================##
|
271
|
-
## Append an EOL at the end to maintain the file structure
|
272
|
-
##===========================================================================##
|
273
|
-
content << end_of_line
|
274
|
-
|
275
|
-
##===========================================================================##
|
276
|
-
## Write the modified lines back to the file
|
277
|
-
##===========================================================================##
|
278
|
-
File.write(file_path, content)
|
279
|
-
|
280
|
-
##===========================================================================##
|
281
|
-
## Return the total number of lines in the modified file
|
282
|
-
##===========================================================================##
|
283
|
-
content.lines.size
|
284
|
-
end
|
285
244
|
|
286
245
|
##============================================================##
|
287
246
|
## Deeply cleans the specified YAML file
|
@@ -299,7 +258,7 @@ module ImmosquareYaml
|
|
299
258
|
## This also allows us to get the total number of lines in the file,
|
300
259
|
## helping us to determine when we are processing the last line
|
301
260
|
###===================================================================================#
|
302
|
-
line_count = normalize_last_line(file_path)
|
261
|
+
line_count = File.normalize_last_line(file_path)
|
303
262
|
|
304
263
|
|
305
264
|
File.foreach(file_path) do |current_line|
|
@@ -802,7 +761,7 @@ module ImmosquareYaml
|
|
802
761
|
deep_transform_values(nested_hash) do |value|
|
803
762
|
if value.is_a?(Array) && !value[0].nil? && value[0].instance_of?(String) && value[0].start_with?(CUSTOM_SEPARATOR) && value[0].end_with?(CUSTOM_SEPARATOR)
|
804
763
|
style_type = value[0].gsub(CUSTOM_SEPARATOR, NOTHING)
|
805
|
-
indent_supp = style_type.scan(/\d+/).first
|
764
|
+
indent_supp = style_type.scan(/\d+/).first.to_i
|
806
765
|
indent_supp = [indent_supp - INDENT_SIZE, 0].max
|
807
766
|
value[1] = value[1].map {|l| "#{SPACE * indent_supp}#{l}" }
|
808
767
|
text = value[1].join(NEWLINE)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: immosquare-yaml
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.20
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- IMMO SQUARE
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2024-02-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: httparty
|
@@ -33,7 +33,7 @@ dependencies:
|
|
33
33
|
version: '0'
|
34
34
|
- - ">="
|
35
35
|
- !ruby/object:Gem::Version
|
36
|
-
version: 0.1.
|
36
|
+
version: 0.1.13
|
37
37
|
type: :runtime
|
38
38
|
prerelease: false
|
39
39
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -43,7 +43,7 @@ dependencies:
|
|
43
43
|
version: '0'
|
44
44
|
- - ">="
|
45
45
|
- !ruby/object:Gem::Version
|
46
|
-
version: 0.1.
|
46
|
+
version: 0.1.13
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: iso-639
|
49
49
|
requirement: !ruby/object:Gem::Requirement
|