immosquare-extensions 0.1.10 → 0.1.12

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 937a618cbe172bd91a19e35f4a66981a388886fdddd6453e5a76673feaea0497
4
- data.tar.gz: eeb0e955c984536eec9dbcd7c4a3f3515ee8022250713f932d1874f0f8ef5bcd
3
+ metadata.gz: bee4b681ff194e3739723acbc3026ace76793f7119229cabaa0aa4d795007573
4
+ data.tar.gz: '03689e87c873fe5fcdc6f6b003203a17cc6cea00e3fef4a73176a89fb360de90'
5
5
  SHA512:
6
- metadata.gz: bf79dda7ea083a80aa83e5e04a56684b2fb99779ab7ed551de09a8491feaaff41d55e5f4faa9cb94837280e1622334a23ccafa508aab27d9b645a68b1b43f176
7
- data.tar.gz: e2372301df5d13e3802bacca96d104651b20fd3fcb48ea330183c7bc81887aa85805a6b098e8dec31e2ebda32023496c4853e755a3b1a961e9066bd7e263fd5d
6
+ metadata.gz: d3ae2393f83f0faa8c5fd6bbfdc575c4117682c413adfa4f131aee04acce58c1fb989c252c9e73c1bc38e0c952f1f3eec54abc858896d53014983b68b738cd53
7
+ data.tar.gz: e36f3125e9a7c1bc8399be1a4ca6a61ab3e393537f3430a85eebc45b3340dbef42ce51dbfde3e93132c8f5cc22768eaf57390c5230e7ba973d802828b62191be
@@ -0,0 +1,45 @@
1
+ class File
2
+
3
+ ##===========================================================================##
4
+ ## This method ensures the file ends with a single newline, facilitating
5
+ ## cleaner multi-line blocks. It operates by reading all lines of the file,
6
+ ## removing any empty lines at the end, and then appending a newline.
7
+ ## This guarantees the presence of a newline at the end, and also prevents
8
+ ## multiple newlines from being present at the end.
9
+ ##
10
+ ## Params:
11
+ ## +file_path+:: The path to the file to be normalized.
12
+ ##
13
+ ## Returns:
14
+ ## The total number of lines in the normalized file.
15
+ ##===========================================================================##
16
+ def self.normalize_last_line(file_path)
17
+ end_of_line = $INPUT_RECORD_SEPARATOR || "\n"
18
+ ##============================================================##
19
+ ## Read all lines from the file
20
+ ## https://gist.github.com/guilhermesimoes/d69e547884e556c3dc95
21
+ ##============================================================##
22
+ content = File.read(file_path)
23
+
24
+ ##===========================================================================##
25
+ ## Remove all trailing empty lines at the end of the file
26
+ ##===========================================================================##
27
+ content.gsub!(/#{Regexp.escape(end_of_line)}+\z/, "")
28
+
29
+ ##===========================================================================##
30
+ ## Append an EOL at the end to maintain the file structure
31
+ ##===========================================================================##
32
+ content << end_of_line
33
+
34
+ ##===========================================================================##
35
+ ## Write the modified lines back to the file
36
+ ##===========================================================================##
37
+ File.write(file_path, content)
38
+
39
+ ##===========================================================================##
40
+ ## Return the total number of lines in the modified file
41
+ ##===========================================================================##
42
+ content.lines.size
43
+ end
44
+
45
+ end
@@ -33,8 +33,10 @@ module ImmosquareExtensions
33
33
 
34
34
  if hash.keys.count == 1 && indent > 0
35
35
  key, value = hash.first
36
- value_str = json_representation(value, align, indent_size, indent)
37
- return "{\"#{key}\": #{value_str}}"
36
+ if !value.is_a?(Array)
37
+ value_str = json_representation(value, align, indent_size, indent)
38
+ return "{\"#{key}\": #{value_str}}"
39
+ end
38
40
  end
39
41
 
40
42
  max_key_length = align ? hash.keys.map(&:to_s).map(&:length).max : 0
@@ -1,3 +1,3 @@
1
1
  module ImmosquareExtensions
2
- VERSION = "0.1.10".freeze
2
+ VERSION = "0.1.12".freeze
3
3
  end
@@ -1,5 +1,6 @@
1
1
  require_relative "immosquare-extensions/shared_methods"
2
2
  require_relative "immosquare-extensions/array"
3
+ require_relative "immosquare-extensions/file"
3
4
  require_relative "immosquare-extensions/hash"
4
5
  require_relative "immosquare-extensions/string"
5
6
 
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.10
4
+ version: 0.1.12
5
5
  platform: ruby
6
6
  authors:
7
7
  - IMMO SQUARE
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-10-01 00:00:00.000000000 Z
11
+ date: 2024-02-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: unicode_utils
@@ -36,6 +36,7 @@ extra_rdoc_files: []
36
36
  files:
37
37
  - lib/immosquare-extensions.rb
38
38
  - lib/immosquare-extensions/array.rb
39
+ - lib/immosquare-extensions/file.rb
39
40
  - lib/immosquare-extensions/hash.rb
40
41
  - lib/immosquare-extensions/shared_methods.rb
41
42
  - lib/immosquare-extensions/string.rb