ccsv 1.0.4 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of ccsv might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/CHANGELOG +2 -0
- data/Gemfile.lock +2 -2
- data/Manifest +0 -1
- data/README.rdoc +1 -1
- data/ccsv.gemspec +0 -0
- data/ext/ccsv.c +6 -7
- data/ext/ccsv.h +1 -1
- data/spec/ccsv_spec.rb +20 -0
- metadata +8 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: aefbe3dae70418c87bb8bf08d9a1691b89f84516
|
4
|
+
data.tar.gz: 44e84c6b98ea3c59478626aec0b3df6a0338662a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a9327db799e1a97d5ed02ec93078fccd9d3ec263094ca14cbcef5b05a3d7f806a3b30049ded68842526a5473bd7ae80a334979d616a4a50b1c3bac41fdcba4f9
|
7
|
+
data.tar.gz: 6a61440ff99bb9c15bb4ce3110401467111ed50511ad7211ccd13083ee0627e96e196b690425ea47e98d4ce406d8328b53e81aa164ef37740f4315be781b8943
|
data/CHANGELOG
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
v1.1.0 Added ability to have a multi-character delimiter. Also fixed escaped delimiter support. Included new tests for both cases (abates@omeganetserv.com)
|
2
|
+
|
1
3
|
v1.0.4 Range methods min/max replaced by first/last for stable work (zhum)
|
2
4
|
|
3
5
|
v1.0.3 Benchmarks now in spec-style (zhum).
|
data/Gemfile.lock
CHANGED
data/Manifest
CHANGED
data/README.rdoc
CHANGED
@@ -37,6 +37,6 @@ Third argument is column index, used for filtering, then one or more intervals.
|
|
37
37
|
|
38
38
|
== License
|
39
39
|
|
40
|
-
Copyright 2012-
|
40
|
+
Copyright 2012-2014 Sergey Zhumatiy
|
41
41
|
|
42
42
|
Copyright 2007-2012 Cloudburst, LLC. Licensed under the AFL 3. See the included LICENSE file.
|
data/ccsv.gemspec
CHANGED
Binary file
|
data/ext/ccsv.c
CHANGED
@@ -12,7 +12,7 @@ struct pair_st {
|
|
12
12
|
#define MAX_INTERVALS 1024
|
13
13
|
|
14
14
|
static VALUE foreach(int argc, VALUE* argv, VALUE self) {
|
15
|
-
char DELIM=DEF_DELIM;
|
15
|
+
char *DELIM=DEF_DELIM;
|
16
16
|
char *line = NULL;
|
17
17
|
size_t len = 0;
|
18
18
|
char *token,*start,*nobackslash,*t2, *str;
|
@@ -44,8 +44,7 @@ static VALUE foreach(int argc, VALUE* argv, VALUE self) {
|
|
44
44
|
|
45
45
|
if (argc >1 ) { /* delimiter */
|
46
46
|
tmp_value=rb_ary_entry(rest_args,0);
|
47
|
-
|
48
|
-
DELIM=str[0];
|
47
|
+
DELIM=StringValueCStr(tmp_value);;
|
49
48
|
}
|
50
49
|
|
51
50
|
if (argc >2 ) { /* search index */
|
@@ -101,7 +100,7 @@ static VALUE foreach(int argc, VALUE* argv, VALUE self) {
|
|
101
100
|
ary = rb_ary_new();
|
102
101
|
start=line;
|
103
102
|
nobackslash=line;
|
104
|
-
while(token=
|
103
|
+
while(token=strstr(nobackslash, DELIM)){
|
105
104
|
/*rb_warning("5\n");*/
|
106
105
|
count=0;
|
107
106
|
t2=token-1;
|
@@ -138,14 +137,14 @@ static VALUE foreach(int argc, VALUE* argv, VALUE self) {
|
|
138
137
|
|
139
138
|
rb_ary_store(ary, idx, rb_str_new(start, token-start));
|
140
139
|
idx++;
|
141
|
-
nobackslash=start=token+
|
142
|
-
while(token=
|
140
|
+
nobackslash=start=token+strlen(DELIM);
|
141
|
+
while(token=strstr(nobackslash, DELIM)){
|
143
142
|
count=0;
|
144
143
|
t2=token-1;
|
145
144
|
while((t2>=line) && (*t2=='\\'))
|
146
145
|
{++count;--t2;}
|
147
146
|
if(count%2 ==1){ /* backslashed! skip */
|
148
|
-
nobackslash=token;
|
147
|
+
nobackslash=token+strlen(DELIM);
|
149
148
|
continue;
|
150
149
|
}
|
151
150
|
break;
|
data/ext/ccsv.h
CHANGED
data/spec/ccsv_spec.rb
CHANGED
@@ -51,6 +51,14 @@ describe Ccsv do
|
|
51
51
|
@csv[15000].must_equal(['15001','30002','15004'])
|
52
52
|
end
|
53
53
|
|
54
|
+
it 'reads csv with a multi-character delimiter' do
|
55
|
+
create_csv('|^|')
|
56
|
+
Ccsv.foreach(TEST_CSV,'|^|') do |v|
|
57
|
+
@csv << v
|
58
|
+
end
|
59
|
+
@csv[15000].must_equal(['15001','30002','15004'])
|
60
|
+
end
|
61
|
+
|
54
62
|
it 'raises error' do
|
55
63
|
proc {
|
56
64
|
Ccsv.foreach('/non-existent-file') do |x| end
|
@@ -66,4 +74,16 @@ describe Ccsv do
|
|
66
74
|
@csv.size.must_equal(999)
|
67
75
|
end
|
68
76
|
|
77
|
+
it 'reads a line with an escaped delimiter' do
|
78
|
+
open(TEST_CSV, 'w') do |file|
|
79
|
+
file.puts "field1,field2,field3,field\\,with comma,field5"
|
80
|
+
end
|
81
|
+
Ccsv.foreach(TEST_CSV, ',') do |v|
|
82
|
+
v[0].must_equal('field1')
|
83
|
+
v[1].must_equal('field2')
|
84
|
+
v[2].must_equal('field3')
|
85
|
+
v[3].must_equal('field\\,with comma')
|
86
|
+
v[4].must_equal('field5')
|
87
|
+
end
|
88
|
+
end
|
69
89
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ccsv
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Evan Weaver, Sergey Zhumatiy
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-09-29 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: Ruby CSV parser gem, written in pure C.
|
14
14
|
email: serg@parallel.ru
|
@@ -42,27 +42,27 @@ licenses: []
|
|
42
42
|
metadata: {}
|
43
43
|
post_install_message:
|
44
44
|
rdoc_options:
|
45
|
-
- --line-numbers
|
46
|
-
- --title
|
45
|
+
- "--line-numbers"
|
46
|
+
- "--title"
|
47
47
|
- Ccsv
|
48
|
-
- --main
|
48
|
+
- "--main"
|
49
49
|
- README.rdoc
|
50
50
|
require_paths:
|
51
51
|
- lib
|
52
52
|
- ext
|
53
53
|
required_ruby_version: !ruby/object:Gem::Requirement
|
54
54
|
requirements:
|
55
|
-
- -
|
55
|
+
- - ">="
|
56
56
|
- !ruby/object:Gem::Version
|
57
57
|
version: '0'
|
58
58
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
59
59
|
requirements:
|
60
|
-
- -
|
60
|
+
- - ">="
|
61
61
|
- !ruby/object:Gem::Version
|
62
62
|
version: '1.2'
|
63
63
|
requirements: []
|
64
64
|
rubyforge_project: evan
|
65
|
-
rubygems_version: 2.
|
65
|
+
rubygems_version: 2.2.2
|
66
66
|
signing_key:
|
67
67
|
specification_version: 4
|
68
68
|
summary: A pure-C CSV parser.
|