smarter_csv 1.11.0.pre1 → 1.11.0.pre2

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: f4f709c1e38fd4e755802a17103231bd17ba58f54ce2d3fd9f8ad57222704114
4
- data.tar.gz: 3ac00625a1478793b9cf9272862e448de4ca80784db71ebce3060d0ae34623ad
3
+ metadata.gz: 9027a37c4b29e68fcbc559a6a8285e5076684883612e98b13f116526dadc6e4b
4
+ data.tar.gz: 43cfa0254ac2caa8ca02a8863fc790f1c56beb0b16e175a16fd947f92eda8c08
5
5
  SHA512:
6
- metadata.gz: dec4c77b2b4019788ff576e0d58c913e4eb5d284f7c06bc95554dc3a83985a6a5ce38fbd3fbe851d7a5944ea53621bab7dc70d270b0fdf786624d7b32a631395
7
- data.tar.gz: 3b9cdea9f632698d78c749196c225726ff37bc807a0f10ca6b9f1df5c9e4cd5ad15415c81042277461bd1a2449f1f07e24ecebb1b2e1dcff63759c26cc92f67f
6
+ metadata.gz: d5b2eac35e33bdeb9ec632578207c47f34a08a4595c1ebf04929a7fe302efc3fc08565c0d6fc6454fd538b99cc1c4a5662599a88693e3aa1b80c5c0c7fc1b05e
7
+ data.tar.gz: 36f622f12d5412ef8919c30a267def315985aef4b3f33c209341a046442795bb66df6c8ebb97399f35e24fd565df658a0e4b7a94d3563831d7ce32facbeab33f
@@ -170,22 +170,19 @@ module SmarterCSV
170
170
  end
171
171
 
172
172
  class << self
173
+ # Counts the number of quote characters in a line, excluding escaped quotes.
174
+ # FYI: using Ruby built-in regex processing to determine the number of quotes
173
175
  def count_quote_chars(line, quote_char)
174
176
  return 0 if line.nil? || quote_char.nil? || quote_char.empty?
175
177
 
176
- count = 0
177
- escaped = false
178
+ # Escaped quote character (e.g., if quote_char is ", then escaped is \")
179
+ escaped_quote = Regexp.escape(quote_char)
178
180
 
179
- line.each_char do |char|
180
- if char == '\\' && !escaped
181
- escaped = true
182
- else
183
- count += 1 if char == quote_char && !escaped
184
- escaped = false
185
- end
186
- end
181
+ # Pattern to match a quote character not preceded by a backslash
182
+ pattern = /(?<!\\)(?:\\\\)*#{escaped_quote}/
187
183
 
188
- count
184
+ # Count occurrences
185
+ line.scan(pattern).count
189
186
  end
190
187
 
191
188
  def has_acceleration?
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module SmarterCSV
4
- VERSION = "1.11.0.pre1"
4
+ VERSION = "1.11.0.pre2"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: smarter_csv
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.11.0.pre1
4
+ version: 1.11.0.pre2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tilo Sloboda
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-01-13 00:00:00.000000000 Z
11
+ date: 2024-01-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: awesome_print