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 CHANGED
@@ -1,7 +1,15 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 9c1fe9121d1f1320a0dcbd362eff15541cadfb76
4
- data.tar.gz: 4a1dfc1a09690299de1c5d3a0225e81642f7831d
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ OGQwMTE0NTQyYzUyNmM4NGEzZWRlYmI2OTA0NWZiODZkYzZkMjJmMw==
5
+ data.tar.gz: !binary |-
6
+ NTAyYzA5MjcyM2NlZWJhYzM0MTNkZTNkMmE2YWM3MTYzMGExZTViYQ==
5
7
  SHA512:
6
- metadata.gz: 493568ee700cc96d50d8c26cff018a8e642bb73d273fbe9809fac8a1b4f67c06eee34c731b86046ad2ce80580f2b7d77f23d93845ba43cc88494559397590297
7
- data.tar.gz: a84178b276fac2b58988004706fa5efda08e2df614660593614cca44c255a5b0f36f70808cc778f4e7184ead7a59d36da096459282a7a9e12e3881bc7ac94860
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
@@ -2,7 +2,7 @@
2
2
 
3
3
  # Collapstring
4
4
 
5
- Collapse quoted strings in strings. Does not support JRuby.
5
+ Collapse quoted strings in strings. Supports MRI, Rubinius & JRuby.
6
6
 
7
7
  ## Why?
8
8
 
@@ -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!", collapstring_collapse_bang, 1);
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
  }
@@ -48,10 +48,12 @@ class TestCollapstring < Test::Unit::TestCase
48
48
  assert_equal %[\\a "], Collapstring.collapse(%[\\a "])
49
49
  end
50
50
 
51
- def test_long_str
52
- long_str = 'a' * 1_000_000
53
- assert_equal long_str, Collapstring.collapse!(long_str)
54
- assert_equal long_str, Collapstring.collapse(long_str)
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.1.2
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-03-15 00:00:00.000000000 Z
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: '0'
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: '0'
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.0.14
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.
@@ -1,8 +0,0 @@
1
- language: ruby
2
- cache: bundler
3
- rvm:
4
- - 1.8.7
5
- - 1.9.2
6
- - 1.9.3
7
- - 2.0.0
8
- - 2.1.0
data/Gemfile DELETED
@@ -1,2 +0,0 @@
1
- source 'https://rubygems.org'
2
- gemspec
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
@@ -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