immosquare-cleaner 0.1.114 → 0.1.115

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: 48d6e303d6532bc4132933f1ec143961ab770f4f1d32386b10ee3b6d623fc6d1
4
- data.tar.gz: 5b850479fbceb265077d86861890efacef110bec49286fc1ca7015026e80c35f
3
+ metadata.gz: 19779dc732954ca8de22b3c3fa9ed64570df1c5962ddd692d3eaead3795bcb33
4
+ data.tar.gz: 8482c46bb1437146f369e6a9e3995f29e9e8e240b08f54adabf2bc22211bf74f
5
5
  SHA512:
6
- metadata.gz: 26f5110d706378b9b09f4e14f00f15f8a4f50b20ab1316a09daa8a4222115fccfed3b65614263a0885ed68a10a7da27fef281f472458cfeb839124c9e4ec0366
7
- data.tar.gz: d2e2959d06b09c83fb2c988a6da6668ea9d46fb1294026a7206b88f71ff561f55a74e2126876b0f2dba535288ee79dbc2e49a4944801add65d53470f56dcc0d7
6
+ metadata.gz: c6651cf24dc96341e01b8e7d94977dbb476725f9d86b2aa7a75f815d36d14ccc2b923511b28aae3d9634e5579d454d630739efab8c7caf4bfb8c490afb6f7dcc
7
+ data.tar.gz: 8f10906affbec34cf93fc92c26af2cf8cf9f9c10e48b7aedfc364fdb5b96a2931f365a503963aa7aa91a8edc6e0b34e0e91e74b022a7488b6719ad3e9ddb2888
@@ -92,7 +92,15 @@ module ImmosquareCleaner
92
92
  ##============================================================##
93
93
  elements_size = []
94
94
  rows = array_to_clean.map do |line|
95
- cells = line.split("|").map(&:strip).reject(&:empty?)
95
+ ##============================================================##
96
+ ## Only the delimiting pipes are dropped, never empty cells:
97
+ ## a table may legitimately hold one (an unnamed first header
98
+ ## above a column of row labels, a value that does not apply).
99
+ ## Rejecting empty cells would shift every following cell one
100
+ ## column to the left and silently file values under the wrong
101
+ ## header. `split("|", -1)` keeps trailing empty fields.
102
+ ##============================================================##
103
+ cells = line.strip.delete_prefix("|").delete_suffix("|").split("|", -1).map(&:strip)
96
104
 
97
105
  ##============================================================##
98
106
  ## We increase the size of the array if needed
@@ -119,7 +127,12 @@ module ImmosquareCleaner
119
127
  line = row.each_with_index.map do |cell, index|
120
128
  max_length = elements_size[index]
121
129
  cell =
122
- if cell&.match(/^-*$/)
130
+ ##============================================================##
131
+ ## At least one dash is required: an empty cell must stay
132
+ ## empty, not be filled with dashes that would read as a
133
+ ## separator row.
134
+ ##============================================================##
135
+ if cell&.match(/\A-+\z/)
123
136
  "-" * max_length
124
137
  else
125
138
  cell.to_s.ljust(max_length)
@@ -132,9 +145,15 @@ module ImmosquareCleaner
132
145
  end
133
146
 
134
147
  def cleaned_line(previous_line, current_line)
135
- return [current_line] if !previous_line
148
+ cleaned_current = current_line.rstrip
149
+
150
+ ##============================================================##
151
+ ## The very first line of the file has no predecessor, so no
152
+ ## list spacing to decide — but it still gets its trailing
153
+ ## whitespace stripped like any other line.
154
+ ##============================================================##
155
+ return ["#{cleaned_current}\n"] if !previous_line
136
156
 
137
- cleaned_current = current_line.rstrip
138
157
  cleaned_previous = previous_line.rstrip
139
158
  blank_line = current_line.gsub("\n", "").empty?
140
159
  previous_is_list = cleaned_previous.lstrip.start_with?("*", "-", "+")
@@ -1,3 +1,3 @@
1
1
  module ImmosquareCleaner
2
- VERSION = "0.1.114".freeze
2
+ VERSION = "0.1.115".freeze
3
3
  end
data/package.json CHANGED
@@ -9,8 +9,8 @@
9
9
  "dependencies": {
10
10
  "@babel/parser": "^8.0.4",
11
11
  "@eslint/js": "^10.0.1",
12
- "@typescript-eslint/eslint-plugin": "^8.66.0",
13
- "@typescript-eslint/parser": "^8.66.0",
12
+ "@typescript-eslint/eslint-plugin": "^8.67.0",
13
+ "@typescript-eslint/parser": "^8.67.0",
14
14
  "@typescript/native": "npm:typescript@^7.0.2",
15
15
  "eslint": "^10.8.1",
16
16
  "eslint-plugin-align-assignments": "^1.1.2",
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: immosquare-cleaner
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.114
4
+ version: 0.1.115
5
5
  platform: ruby
6
6
  authors:
7
7
  - immosquare