collapstring 0.2.0-java

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: dab0a565d03c7b08e5db9c15a7697831d93cec81
4
+ data.tar.gz: 68e1ea2601c549785bd73fe6ec63e98ad16c4909
5
+ SHA512:
6
+ metadata.gz: 2c42318112eabd648ca22c380065c64f8163b7e59e786f7d494248e3cd06987a68a34566963841f8ff84678e76dc8a97f6a777025d7d4f91a00dc1a23c02aba1
7
+ data.tar.gz: 2e099d7ff5873ea45e54f8cb95492b081345205eab5bdf3cd7fd18ec255a8734256e8581408e18a1afba8e489a5d153f3b956296816d0d81803c3baf85da613d
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 Airbnb, Inc.
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,38 @@
1
+ [![Build Status](https://travis-ci.org/airbnb/collapstring.png?branch=master)](https://travis-ci.org/airbnb/collapstring)
2
+
3
+ # Collapstring
4
+
5
+ Collapse quoted strings in strings. Supports MRI, Rubinius & JRuby.
6
+
7
+ ## Why?
8
+
9
+ It's a simple, reliable and fast way to start making MySQL
10
+ requests shorter in a SQL logging pipeline.
11
+
12
+ ## Installation
13
+
14
+ Add this line to your application's Gemfile:
15
+
16
+ gem 'collapstring'
17
+
18
+ And then execute:
19
+
20
+ $ bundle
21
+
22
+ Or install it yourself as:
23
+
24
+ $ gem install collapstring
25
+
26
+ ## Usage
27
+
28
+ require 'collapstring'
29
+ Collapstring.collapse 'SELECT "hello \"world\"";'
30
+ Collapstring.collapse! 'SELECT "hello \"world\"";' # _could_ be in-place
31
+
32
+ ## Contributing
33
+
34
+ 1. Fork it
35
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
36
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
37
+ 4. Push to the branch (`git push origin my-new-feature`)
38
+ 5. Create new Pull Request
Binary file
@@ -0,0 +1,65 @@
1
+ require 'collapstring'
2
+ require 'test/unit'
3
+
4
+ class TestCollapstring < Test::Unit::TestCase
5
+ def test_arity
6
+ assert_raise ArgumentError do
7
+ Collapstring.collapse
8
+ end
9
+
10
+ assert_raise ArgumentError do
11
+ Collapstring.collapse('foo', 'bar')
12
+ end
13
+ end
14
+
15
+ def test_type_safety
16
+ assert_raise TypeError do
17
+ Collapstring.collapse 1
18
+ end
19
+ end
20
+
21
+ def test_cases
22
+ assert_equal %[], Collapstring.collapse(%[])
23
+
24
+ assert_equal %[noop], Collapstring.collapse(%[noop])
25
+
26
+ assert_equal %[''], Collapstring.collapse(%['foo'])
27
+ assert_equal %[""], Collapstring.collapse(%["foo"])
28
+
29
+ assert_equal %[single \\], Collapstring.collapse(%[single \\])
30
+ assert_equal %[single '], Collapstring.collapse(%[single '])
31
+ assert_equal %[single "], Collapstring.collapse(%[single "])
32
+
33
+ assert_equal %[''], Collapstring.collapse(%['a\\'b'])
34
+ assert_equal %[''], Collapstring.collapse(%['a\\"b'])
35
+ assert_equal %[""], Collapstring.collapse(%["a\\'b"])
36
+ assert_equal %[""], Collapstring.collapse(%["a\\'b"])
37
+
38
+ assert_equal %[a\\b], Collapstring.collapse(%[a\\b])
39
+ assert_equal %[a\\\\b], Collapstring.collapse(%[a\\\\b])
40
+
41
+ assert_equal %[\\'], Collapstring.collapse(%[\\'])
42
+ assert_equal %[\\"], Collapstring.collapse(%[\\"])
43
+
44
+ assert_equal %[""], Collapstring.collapse(%["\\a"])
45
+ assert_equal %[''], Collapstring.collapse(%['\\a'])
46
+
47
+ assert_equal %[\\a '], Collapstring.collapse(%[\\a '])
48
+ assert_equal %[\\a "], Collapstring.collapse(%[\\a "])
49
+ end
50
+
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
57
+ end
58
+
59
+ def test_preserves_original_string
60
+ original = 'foo "bar" baz'
61
+ copy = original.dup
62
+ assert_equal 'foo "" baz', Collapstring.collapse(copy)
63
+ assert_equal original, copy
64
+ end
65
+ end
metadata ADDED
@@ -0,0 +1,91 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: collapstring
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.2.0
5
+ platform: java
6
+ authors:
7
+ - Pierre Carrier
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-06-10 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ requirement: !ruby/object:Gem::Requirement
15
+ requirements:
16
+ - - ~>
17
+ - !ruby/object:Gem::Version
18
+ version: '1.3'
19
+ name: bundler
20
+ prerelease: false
21
+ type: :development
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ~>
25
+ - !ruby/object:Gem::Version
26
+ version: '1.3'
27
+ - !ruby/object:Gem::Dependency
28
+ requirement: !ruby/object:Gem::Requirement
29
+ requirements:
30
+ - - ~>
31
+ - !ruby/object:Gem::Version
32
+ version: '10.3'
33
+ name: rake
34
+ prerelease: false
35
+ type: :development
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ~>
39
+ - !ruby/object:Gem::Version
40
+ version: '10.3'
41
+ - !ruby/object:Gem::Dependency
42
+ requirement: !ruby/object:Gem::Requirement
43
+ requirements:
44
+ - - ~>
45
+ - !ruby/object:Gem::Version
46
+ version: '0.9'
47
+ name: rake-compiler
48
+ prerelease: false
49
+ type: :development
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ~>
53
+ - !ruby/object:Gem::Version
54
+ version: '0.9'
55
+ description: Collapse quoted strings in strings
56
+ email:
57
+ - pierre@gcarrier.fr
58
+ executables: []
59
+ extensions: []
60
+ extra_rdoc_files: []
61
+ files:
62
+ - LICENSE.txt
63
+ - README.md
64
+ - test/collapstring/tests.rb
65
+ - lib/collapstring.jar
66
+ homepage: https://github.com/airbnb/collapstring
67
+ licenses:
68
+ - MIT
69
+ metadata: {}
70
+ post_install_message:
71
+ rdoc_options: []
72
+ require_paths:
73
+ - lib
74
+ required_ruby_version: !ruby/object:Gem::Requirement
75
+ requirements:
76
+ - - '>='
77
+ - !ruby/object:Gem::Version
78
+ version: '0'
79
+ required_rubygems_version: !ruby/object:Gem::Requirement
80
+ requirements:
81
+ - - '>='
82
+ - !ruby/object:Gem::Version
83
+ version: '0'
84
+ requirements: []
85
+ rubyforge_project:
86
+ rubygems_version: 2.1.9
87
+ signing_key:
88
+ specification_version: 4
89
+ summary: Collapse quoted strings in strings. Does not support JRuby.
90
+ test_files:
91
+ - test/collapstring/tests.rb