collapstring 0.1.2 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +13 -5
- data/README.md +1 -1
- data/ext/collapstring/collapstring.c +19 -2
- data/test/collapstring/tests.rb +6 -4
- metadata +13 -17
- data/.travis.yml +0 -8
- data/Gemfile +0 -2
- data/Rakefile +0 -16
- data/collapstring.gemspec +0 -25
checksums.yaml
CHANGED
@@ -1,7 +1,15 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
|
2
|
+
!binary "U0hBMQ==":
|
3
|
+
metadata.gz: !binary |-
|
4
|
+
OGQwMTE0NTQyYzUyNmM4NGEzZWRlYmI2OTA0NWZiODZkYzZkMjJmMw==
|
5
|
+
data.tar.gz: !binary |-
|
6
|
+
NTAyYzA5MjcyM2NlZWJhYzM0MTNkZTNkMmE2YWM3MTYzMGExZTViYQ==
|
5
7
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
|
8
|
+
metadata.gz: !binary |-
|
9
|
+
YzA3YWUxMzkyOTNhOThiMjI2YTQ1ZTRjNjE4YTJkMjMzZDJmNTM3NmZjZDg3
|
10
|
+
N2QwMzg4YTI0YmVlMmI5ZjRhZjhlOTE2OGEwOWJlOWMyZmJlYzVkYzUyOWFi
|
11
|
+
ZjdmZGJjZGI1ZDU5MmU2NjQwZjcxYzY3YTk1MTc3OGRiMWMyN2Q=
|
12
|
+
data.tar.gz: !binary |-
|
13
|
+
NzlkYjY2OWZiNGJlNGJlNTYxNDEwOGU0YTEzOGU5YjczMjJiZTE2ZjQ3MDlh
|
14
|
+
ODFmMTFiZDUwOTkzODIwMjFkMzhiNjY1OTJjNDM2ZDE3NTg3YmE4OTk4M2Yw
|
15
|
+
MGI5MmM0YTk0YTVmNTQ4OWYzYWQ1Yzg5M2NhMmY1OGM1MjBhMmQ=
|
data/README.md
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
#include <assert.h>
|
2
2
|
#include <ruby.h>
|
3
3
|
#include <stddef.h>
|
4
|
+
#include <stdlib.h>
|
4
5
|
|
5
6
|
typedef enum {
|
6
7
|
C_S_OUT,
|
@@ -115,17 +116,33 @@ static VALUE collapstring_collapse_bang(VALUE self, VALUE src)
|
|
115
116
|
return rb_str_resize(src, dst_idx);
|
116
117
|
}
|
117
118
|
|
118
|
-
static VALUE collapstring_collapse(VALUE self, VALUE src)
|
119
|
+
static VALUE collapstring_collapse(VALUE self, VALUE src)
|
120
|
+
{
|
119
121
|
VALUE dst = rb_obj_clone(src);
|
120
122
|
assert(dst);
|
121
123
|
collapstring_collapse_bang(self, dst);
|
122
124
|
return dst;
|
123
125
|
}
|
124
126
|
|
127
|
+
static VALUE collapstring_fuzz(VALUE self, VALUE length)
|
128
|
+
{
|
129
|
+
static char *chars = "\'\"\\ ";
|
130
|
+
Check_Type(length, T_FIXNUM);
|
131
|
+
int i, l = NUM2INT(length);
|
132
|
+
VALUE res = rb_str_new(NULL, 0);
|
133
|
+
assert(res);
|
134
|
+
for (i = 0; i < l; i++) {
|
135
|
+
res = rb_str_cat(res, chars + rand() % 4, 1);
|
136
|
+
}
|
137
|
+
return res;
|
138
|
+
}
|
139
|
+
|
125
140
|
void Init_collapstring(void)
|
126
141
|
{
|
127
142
|
VALUE module = rb_define_module("Collapstring");
|
128
143
|
assert(module);
|
129
|
-
rb_define_module_function(module, "collapse!",
|
144
|
+
rb_define_module_function(module, "collapse!",
|
145
|
+
collapstring_collapse_bang, 1);
|
130
146
|
rb_define_module_function(module, "collapse", collapstring_collapse, 1);
|
147
|
+
rb_define_module_function(module, "fuzz", collapstring_fuzz, 1);
|
131
148
|
}
|
data/test/collapstring/tests.rb
CHANGED
@@ -48,10 +48,12 @@ class TestCollapstring < Test::Unit::TestCase
|
|
48
48
|
assert_equal %[\\a "], Collapstring.collapse(%[\\a "])
|
49
49
|
end
|
50
50
|
|
51
|
-
def
|
52
|
-
|
53
|
-
|
54
|
-
|
51
|
+
def test_long_strs
|
52
|
+
[100, 1000, 1_000_000].each do |size|
|
53
|
+
long_str = 'a"b"\'c\'' * size
|
54
|
+
assert_equal long_str, Collapstring.collapse!(long_str)
|
55
|
+
assert_equal long_str, Collapstring.collapse(long_str)
|
56
|
+
end
|
55
57
|
end
|
56
58
|
|
57
59
|
def test_preserves_original_string
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: collapstring
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Pierre Carrier
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-06-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -28,30 +28,30 @@ dependencies:
|
|
28
28
|
name: rake
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- -
|
31
|
+
- - ~>
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: '
|
33
|
+
version: '10.3'
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- -
|
38
|
+
- - ~>
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: '
|
40
|
+
version: '10.3'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: rake-compiler
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- -
|
45
|
+
- - ~>
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: '0'
|
47
|
+
version: '0.9'
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- -
|
52
|
+
- - ~>
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: '0'
|
54
|
+
version: '0.9'
|
55
55
|
description: Collapse quoted strings in strings
|
56
56
|
email:
|
57
57
|
- pierre@gcarrier.fr
|
@@ -60,12 +60,8 @@ extensions:
|
|
60
60
|
- ext/collapstring/extconf.rb
|
61
61
|
extra_rdoc_files: []
|
62
62
|
files:
|
63
|
-
- .travis.yml
|
64
|
-
- Gemfile
|
65
63
|
- LICENSE.txt
|
66
64
|
- README.md
|
67
|
-
- Rakefile
|
68
|
-
- collapstring.gemspec
|
69
65
|
- ext/collapstring/collapstring.c
|
70
66
|
- ext/collapstring/extconf.rb
|
71
67
|
- test/collapstring/tests.rb
|
@@ -79,17 +75,17 @@ require_paths:
|
|
79
75
|
- lib
|
80
76
|
required_ruby_version: !ruby/object:Gem::Requirement
|
81
77
|
requirements:
|
82
|
-
- - '>='
|
78
|
+
- - ! '>='
|
83
79
|
- !ruby/object:Gem::Version
|
84
80
|
version: '0'
|
85
81
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
86
82
|
requirements:
|
87
|
-
- - '>='
|
83
|
+
- - ! '>='
|
88
84
|
- !ruby/object:Gem::Version
|
89
85
|
version: '0'
|
90
86
|
requirements: []
|
91
87
|
rubyforge_project:
|
92
|
-
rubygems_version: 2.
|
88
|
+
rubygems_version: 2.2.2
|
93
89
|
signing_key:
|
94
90
|
specification_version: 4
|
95
91
|
summary: Collapse quoted strings in strings. Does not support JRuby.
|
data/.travis.yml
DELETED
data/Gemfile
DELETED
data/Rakefile
DELETED
@@ -1,16 +0,0 @@
|
|
1
|
-
require 'bundler/gem_tasks'
|
2
|
-
require 'rake/testtask'
|
3
|
-
|
4
|
-
require 'rake/extensiontask'
|
5
|
-
|
6
|
-
Rake::ExtensionTask.new 'collapstring'
|
7
|
-
|
8
|
-
Rake::TestTask.new do |t|
|
9
|
-
t.libs = %w[lib test]
|
10
|
-
t.test_files = FileList['test/**/test*.rb']
|
11
|
-
end
|
12
|
-
|
13
|
-
Rake::Task[:test].prerequisites.unshift :compile
|
14
|
-
|
15
|
-
desc 'Run tests'
|
16
|
-
task :default => :test
|
data/collapstring.gemspec
DELETED
@@ -1,25 +0,0 @@
|
|
1
|
-
# coding: utf-8
|
2
|
-
lib = File.expand_path '../lib', __FILE__
|
3
|
-
$LOAD_PATH.unshift lib unless $LOAD_PATH.include? lib
|
4
|
-
|
5
|
-
Gem::Specification.new do |spec|
|
6
|
-
spec.name = 'collapstring'
|
7
|
-
spec.version = '0.1.2'
|
8
|
-
spec.authors = ['Pierre Carrier']
|
9
|
-
spec.email = ['pierre@gcarrier.fr']
|
10
|
-
spec.description = 'Collapse quoted strings in strings'
|
11
|
-
spec.summary = 'Collapse quoted strings in strings. Does not support JRuby.'
|
12
|
-
spec.homepage = 'https://github.com/airbnb/collapstring'
|
13
|
-
spec.license = 'MIT'
|
14
|
-
|
15
|
-
spec.files = `git ls-files`.split $/
|
16
|
-
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename f }
|
17
|
-
spec.test_files = spec.files.grep %r{^(test|spec|features)/}
|
18
|
-
spec.require_paths = %w[lib]
|
19
|
-
|
20
|
-
spec.extensions = %w[ext/collapstring/extconf.rb]
|
21
|
-
|
22
|
-
spec.add_development_dependency 'bundler', '~> 1.3'
|
23
|
-
spec.add_development_dependency 'rake'
|
24
|
-
spec.add_development_dependency 'rake-compiler'
|
25
|
-
end
|