immosquare-yaml 0.1.11 → 0.1.12
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/immosquare-yaml/version.rb +1 -1
- data/lib/immosquare-yaml.rb +13 -5
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 573eadd9feb826e6365b2a86d74f224315a4cf04fae6636be0259587f4701da6
|
4
|
+
data.tar.gz: a8fe5672e271f2cf620a4d1f6091a4a3eb1be22dc8713b95568ed79c4d7b5927
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5ef47496ea01d662155006e97039e951b47fc601d1ec803293240b574e317f1e45821c2aa9e8c5e4baeb3a36ab8bd9ecbe362f4142a8cefb1718b1356e6af366
|
7
|
+
data.tar.gz: 766fc004a23ee4bc5bc6893492242d8029fa866faa1aa840963af12c1c49f26a2c8323e8805bf23aca68e3f3d716d7f6bbcd3206ea007eb867a073ba799aa980
|
data/lib/immosquare-yaml.rb
CHANGED
@@ -1,9 +1,15 @@
|
|
1
|
+
require "English"
|
1
2
|
require_relative "immosquare-yaml/configuration"
|
2
3
|
require_relative "immosquare-yaml/shared_methods"
|
3
4
|
require_relative "immosquare-yaml/translate"
|
4
5
|
require_relative "immosquare-yaml/railtie" if defined?(Rails)
|
5
6
|
|
6
|
-
|
7
|
+
##===========================================================================##
|
8
|
+
## Importing the 'English' library allows us to use more human-readable
|
9
|
+
## global variables, such as $INPUT_RECORD_SEPARATOR instead of $/,
|
10
|
+
## which enhances code clarity and makes it easier to understand
|
11
|
+
## the purpose of these variables in our code.
|
12
|
+
##===========================================================================##
|
7
13
|
module ImmosquareYaml
|
8
14
|
extend SharedMethods
|
9
15
|
|
@@ -222,21 +228,23 @@ module ImmosquareYaml
|
|
222
228
|
## The total number of lines in the normalized file.
|
223
229
|
##===========================================================================##
|
224
230
|
def normalize_last_line(file_path)
|
231
|
+
end_of_line = $INPUT_RECORD_SEPARATOR
|
225
232
|
##============================================================##
|
226
233
|
## Read all lines from the file
|
227
234
|
## https://gist.github.com/guilhermesimoes/d69e547884e556c3dc95
|
228
235
|
##============================================================##
|
229
236
|
content = File.read(file_path)
|
230
237
|
|
238
|
+
|
231
239
|
##===========================================================================##
|
232
240
|
## Remove all trailing empty lines at the end of the file
|
233
|
-
content.gsub!(/#{Regexp.escape($INPUT_RECORD_SEPARATOR)}+\z/, "")
|
234
241
|
##===========================================================================##
|
242
|
+
content.gsub!(/#{Regexp.escape(end_of_line)}+\z/, "")
|
235
243
|
|
236
244
|
##===========================================================================##
|
237
|
-
## Append
|
238
|
-
|
239
|
-
content
|
245
|
+
## Append an EOL at the end to maintain the file structure
|
246
|
+
##===========================================================================##
|
247
|
+
content << end_of_line
|
240
248
|
|
241
249
|
##===========================================================================##
|
242
250
|
## Write the modified lines back to the file
|