fasterer-csv 1.5.1 → 1.5.3
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.
- data/VERSION +1 -1
- data/fasterer-csv.gemspec +2 -2
- data/lib/fasterer_csv.rb +12 -17
- data/pkg/fasterer-csv-1.5.2.gem +0 -0
- metadata +4 -4
- data/pkg/fasterer-csv-1.5.0.gem +0 -0
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.5.
|
1
|
+
1.5.3
|
data/fasterer-csv.gemspec
CHANGED
@@ -5,7 +5,7 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{fasterer-csv}
|
8
|
-
s.version = "1.5.
|
8
|
+
s.version = "1.5.3"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Mason"]
|
@@ -43,7 +43,7 @@ Gem::Specification.new do |s|
|
|
43
43
|
"pkg/fasterer-csv-1.2.0.gem",
|
44
44
|
"pkg/fasterer-csv-1.4.0.gem",
|
45
45
|
"pkg/fasterer-csv-1.4.1.gem",
|
46
|
-
"pkg/fasterer-csv-1.5.
|
46
|
+
"pkg/fasterer-csv-1.5.2.gem",
|
47
47
|
"spec/fasterer_csv_spec.rb",
|
48
48
|
"spec/spec.opts",
|
49
49
|
"spec/spec_helper.rb"
|
data/lib/fasterer_csv.rb
CHANGED
@@ -32,7 +32,7 @@ module FastererCSV
|
|
32
32
|
len = header.to_s.length if header.to_s.length > len
|
33
33
|
end
|
34
34
|
headers.each_with_index do |header, i|
|
35
|
-
|
35
|
+
error << sprintf("%-32s : %s\n", header, row[i])
|
36
36
|
end
|
37
37
|
puts error
|
38
38
|
raise error if @fail_on_malformed_columns
|
@@ -61,7 +61,7 @@ module FastererCSV
|
|
61
61
|
end
|
62
62
|
|
63
63
|
def index(columns, reindex = false)
|
64
|
-
columns = columns.compact.uniq.sort{ |a, b| a.to_s <=> b.to_s }.map { |column| Row.to_key(column) }
|
64
|
+
columns = columns.compact.uniq.sort { |a, b| a.to_s <=> b.to_s }.map { |column| Row.to_key(column) }
|
65
65
|
|
66
66
|
key = columns.join('|#|')
|
67
67
|
|
@@ -83,7 +83,7 @@ module FastererCSV
|
|
83
83
|
def lookup(key)
|
84
84
|
|
85
85
|
values = []
|
86
|
-
columns = key.keys.compact.uniq.sort{ |a, b| a.to_s <=> b.to_s }.map do |column|
|
86
|
+
columns = key.keys.compact.uniq.sort { |a, b| a.to_s <=> b.to_s }.map do |column|
|
87
87
|
values << key[column]
|
88
88
|
Row.to_key(column)
|
89
89
|
end
|
@@ -199,7 +199,7 @@ module FastererCSV
|
|
199
199
|
alias_method :values, :to_a
|
200
200
|
|
201
201
|
alias_method :has_key?, :key?
|
202
|
-
alias_method :member?,
|
202
|
+
alias_method :member?, :key?
|
203
203
|
alias_method :include?, :key?
|
204
204
|
|
205
205
|
alias_method :has_value?, :value?
|
@@ -270,7 +270,10 @@ module FastererCSV
|
|
270
270
|
end
|
271
271
|
|
272
272
|
class IOWriter
|
273
|
-
def initialize(file, quot = '~', sep = ',', quotenum = false)
|
273
|
+
def initialize(file, quot = '~', sep = ',', quotenum = false)
|
274
|
+
@first = true; @io = file; @quot = quot; @sep = sep; @quotenum = quotenum
|
275
|
+
end
|
276
|
+
|
274
277
|
def <<(row)
|
275
278
|
raise "can only write arrays! #{row.class} #{row.inspect}" unless row.is_a? Array
|
276
279
|
if @first && row.is_a?(Row)
|
@@ -285,23 +288,15 @@ module FastererCSV
|
|
285
288
|
class << self
|
286
289
|
|
287
290
|
def headers(file, quot = '~', sep = ',', fail_on_malformed = true, column = NoConversion.new, &block)
|
288
|
-
parse_headers(File.open(file, 'r') {|io| io.gets }, quot, sep, fail_on_malformed, column, &block)
|
291
|
+
parse_headers(File.open(file, 'r') { |io| io.gets }, quot, sep, fail_on_malformed, column, &block)
|
289
292
|
end
|
290
293
|
|
291
294
|
def read(file, quot = '~', sep = ',', fail_on_malformed = true, column = NoConversion.new, &block)
|
292
|
-
|
295
|
+
parse(File.open(file, 'r') { |io| io.sysread(File.size(file)) }, quot, sep, fail_on_malformed, column, &block)
|
293
296
|
end
|
294
297
|
|
295
298
|
def convread(file, quot = '~', sep = ',', fail_on_malformed = true, column = NumericConversion.new, &block)
|
296
|
-
|
297
|
-
end
|
298
|
-
|
299
|
-
def read_stream(io, stream_length, quot = '~', sep = ',', fail_on_malformed = true, column = NoConversion.new, &block)
|
300
|
-
parse(io.sysread(stream_length), quot, sep, fail_on_malformed, column, &block)
|
301
|
-
end
|
302
|
-
|
303
|
-
def convread_stream(io, stream_length, quot = '~', sep = ',', fail_on_malformed = true, column = NumericConversion.new, &block)
|
304
|
-
parse(io.sysread(stream_length), quot, sep, fail_on_malformed, column, &block)
|
299
|
+
parse(File.open(file, 'r') { |io| io.sysread(File.size(file)) }, quot, sep, fail_on_malformed, column, &block)
|
305
300
|
end
|
306
301
|
|
307
302
|
def parse_headers(data, quot = '~', sep = ',', fail_on_malformed = true, column = NoConversion.new, &block)
|
@@ -392,7 +387,7 @@ module FastererCSV
|
|
392
387
|
quot = (val.is_a?(Symbol) || !numquot) ? need_quot : num_quot
|
393
388
|
val = String(val)
|
394
389
|
if val.length == 0
|
395
|
-
|
390
|
+
q * 2
|
396
391
|
else
|
397
392
|
val[quot] ? q + val.gsub(q, q * 2) + q : val
|
398
393
|
end
|
Binary file
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fasterer-csv
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 5
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 1
|
8
8
|
- 5
|
9
|
-
-
|
10
|
-
version: 1.5.
|
9
|
+
- 3
|
10
|
+
version: 1.5.3
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Mason
|
@@ -55,7 +55,7 @@ files:
|
|
55
55
|
- pkg/fasterer-csv-1.2.0.gem
|
56
56
|
- pkg/fasterer-csv-1.4.0.gem
|
57
57
|
- pkg/fasterer-csv-1.4.1.gem
|
58
|
-
- pkg/fasterer-csv-1.5.
|
58
|
+
- pkg/fasterer-csv-1.5.2.gem
|
59
59
|
- spec/fasterer_csv_spec.rb
|
60
60
|
- spec/spec.opts
|
61
61
|
- spec/spec_helper.rb
|
data/pkg/fasterer-csv-1.5.0.gem
DELETED
Binary file
|