pg_array_parser 0.0.8pre → 0.0.8pre2
Sign up to get free protection for your applications and to get access to all the features.
- data/ext/pg_array_parser/extconf.rb +2 -5
- data/lib/pg_array_parser/version.rb +1 -1
- data/pg_array_parser.gemspec +15 -4
- metadata +4 -9
- data/.gitignore +0 -21
- data/.travis.yml +0 -10
- data/ext/pg_array_parser/PgArrayParserEngine.java +0 -118
- data/ext/pg_array_parser/PgArrayParserEngineService.java +0 -26
- data/lib/pg_array_parser.jar +0 -0
data/pg_array_parser.gemspec
CHANGED
@@ -6,15 +6,26 @@ Gem::Specification.new do |gem|
|
|
6
6
|
gem.email = ["git@danmcclain.net"]
|
7
7
|
gem.description = %q{Simple library to parse PostgreSQL arrays into a array of strings}
|
8
8
|
gem.summary = %q{Converts PostgreSQL array strings into arrays of strings}
|
9
|
-
gem.homepage = ""
|
9
|
+
gem.homepage = "https://github.com/dockyard/pg_array_parser"
|
10
|
+
|
11
|
+
gem.files = [ 'CHANGELOG.md',
|
12
|
+
'Gemfile',
|
13
|
+
'README.md',
|
14
|
+
'Rakefile',
|
15
|
+
'lib/pg_array_parser.rb',
|
16
|
+
'lib/pg_array_parser/version.rb',
|
17
|
+
'pg_array_parser.gemspec',
|
18
|
+
'spec/parser_spec.rb',
|
19
|
+
'spec/spec_helper.rb'
|
20
|
+
]
|
10
21
|
|
11
|
-
gem.files = `git ls-files`.split($\)
|
12
22
|
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
13
23
|
if RUBY_PLATFORM =~ /java/
|
14
|
-
gem.files
|
15
|
-
gem.files
|
24
|
+
gem.files << 'ext/pg_array_parser/PgArrayParserEngine.java'
|
25
|
+
gem.files << 'ext/pg_array_parser/PgArrayParserEngineService.java'
|
16
26
|
gem.files << 'lib/pg_array_parser.jar'
|
17
27
|
else
|
28
|
+
gem.files << 'ext/pg_array_parser/pg_array_parser.c'
|
18
29
|
gem.extensions = ['ext/pg_array_parser/extconf.rb']
|
19
30
|
end
|
20
31
|
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pg_array_parser
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.8pre2
|
5
5
|
prerelease: 5
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -67,23 +67,18 @@ extensions:
|
|
67
67
|
- ext/pg_array_parser/extconf.rb
|
68
68
|
extra_rdoc_files: []
|
69
69
|
files:
|
70
|
-
- .gitignore
|
71
|
-
- .travis.yml
|
72
70
|
- CHANGELOG.md
|
73
71
|
- Gemfile
|
74
72
|
- README.md
|
75
73
|
- Rakefile
|
76
|
-
- ext/pg_array_parser/PgArrayParserEngine.java
|
77
|
-
- ext/pg_array_parser/PgArrayParserEngineService.java
|
78
|
-
- ext/pg_array_parser/extconf.rb
|
79
|
-
- ext/pg_array_parser/pg_array_parser.c
|
80
|
-
- lib/pg_array_parser.jar
|
81
74
|
- lib/pg_array_parser.rb
|
82
75
|
- lib/pg_array_parser/version.rb
|
83
76
|
- pg_array_parser.gemspec
|
84
77
|
- spec/parser_spec.rb
|
85
78
|
- spec/spec_helper.rb
|
86
|
-
|
79
|
+
- ext/pg_array_parser/pg_array_parser.c
|
80
|
+
- ext/pg_array_parser/extconf.rb
|
81
|
+
homepage: https://github.com/dockyard/pg_array_parser
|
87
82
|
licenses: []
|
88
83
|
post_install_message:
|
89
84
|
rdoc_options: []
|
data/.gitignore
DELETED
@@ -1,21 +0,0 @@
|
|
1
|
-
*.gem
|
2
|
-
*.rbc
|
3
|
-
.bundle
|
4
|
-
.config
|
5
|
-
.yardoc
|
6
|
-
Gemfile.lock
|
7
|
-
InstalledFiles
|
8
|
-
_yardoc
|
9
|
-
coverage
|
10
|
-
doc/
|
11
|
-
lib/bundler/man
|
12
|
-
pkg
|
13
|
-
rdoc
|
14
|
-
spec/reports
|
15
|
-
test/tmp
|
16
|
-
test/version_tmp
|
17
|
-
tmp
|
18
|
-
benchmark.rb
|
19
|
-
bin/*
|
20
|
-
.rbenv-version*
|
21
|
-
lib/pg_array_parser.bundle
|
data/.travis.yml
DELETED
@@ -1,118 +0,0 @@
|
|
1
|
-
package pgarrayparser;
|
2
|
-
|
3
|
-
import org.jruby.*;
|
4
|
-
import org.jruby.anno.JRubyClass;
|
5
|
-
import org.jruby.anno.JRubyMethod;
|
6
|
-
import org.jruby.runtime.ThreadContext;
|
7
|
-
import org.jruby.runtime.builtin.IRubyObject;
|
8
|
-
|
9
|
-
@JRubyClass(name = "PgArrayParser::PgArrayParserEngine")
|
10
|
-
public class PgArrayParserEngine extends RubyObject {
|
11
|
-
|
12
|
-
public PgArrayParserEngine(final Ruby runtime, RubyClass rubyClass) {
|
13
|
-
super(runtime, rubyClass);
|
14
|
-
}
|
15
|
-
|
16
|
-
@JRubyMethod(name = "parse_pg_array")
|
17
|
-
public RubyArray parse_pg_array( ThreadContext context, IRubyObject value) {
|
18
|
-
String content = value.asJavaString();
|
19
|
-
return parseData(context, content, 0);
|
20
|
-
}
|
21
|
-
|
22
|
-
private static RubyArray parseData( ThreadContext context, String content, int index)
|
23
|
-
{
|
24
|
-
RubyArray items = RubyArray.newArray(context.getRuntime());
|
25
|
-
|
26
|
-
for( int x = index; x < content.length(); x++ ) {
|
27
|
-
|
28
|
-
char token = content.charAt(x);
|
29
|
-
|
30
|
-
switch (token) {
|
31
|
-
case '{':
|
32
|
-
x = parseArrayContents( context, items, content, x + 1 );
|
33
|
-
break;
|
34
|
-
case '}':
|
35
|
-
return items;
|
36
|
-
}
|
37
|
-
|
38
|
-
}
|
39
|
-
|
40
|
-
return items;
|
41
|
-
}
|
42
|
-
|
43
|
-
private static int parseArrayContents( ThreadContext context, RubyArray items, String content, int index ) {
|
44
|
-
|
45
|
-
StringBuilder currentItem = new StringBuilder();
|
46
|
-
boolean isEscaping = false;
|
47
|
-
boolean isQuoted = false;
|
48
|
-
boolean wasQuoted = false;
|
49
|
-
|
50
|
-
int x = index;
|
51
|
-
|
52
|
-
for(; x < content.length(); x++ ) {
|
53
|
-
|
54
|
-
char token = content.charAt(x);
|
55
|
-
|
56
|
-
if ( isEscaping ) {
|
57
|
-
currentItem.append( token );
|
58
|
-
isEscaping = false;
|
59
|
-
} else {
|
60
|
-
if ( isQuoted ) {
|
61
|
-
switch (token) {
|
62
|
-
case '"':
|
63
|
-
isQuoted = false;
|
64
|
-
wasQuoted = true;
|
65
|
-
break;
|
66
|
-
case '\\':
|
67
|
-
isEscaping = true;
|
68
|
-
break;
|
69
|
-
default:
|
70
|
-
currentItem.append(token);
|
71
|
-
}
|
72
|
-
} else {
|
73
|
-
switch (token) {
|
74
|
-
case '\\':
|
75
|
-
isEscaping = true;
|
76
|
-
break;
|
77
|
-
case ',':
|
78
|
-
addItem(context, items, currentItem, wasQuoted);
|
79
|
-
currentItem = new StringBuilder();
|
80
|
-
wasQuoted = false;
|
81
|
-
break;
|
82
|
-
case '"':
|
83
|
-
isQuoted = true;
|
84
|
-
break;
|
85
|
-
case '{':
|
86
|
-
RubyArray internalItems = RubyArray.newArray(context.getRuntime());
|
87
|
-
x = parseArrayContents( context, internalItems, content, x + 1 );
|
88
|
-
items.add(internalItems);
|
89
|
-
break;
|
90
|
-
case '}':
|
91
|
-
addItem(context, items, currentItem, wasQuoted);
|
92
|
-
return x;
|
93
|
-
default:
|
94
|
-
currentItem.append(token);
|
95
|
-
}
|
96
|
-
}
|
97
|
-
}
|
98
|
-
|
99
|
-
}
|
100
|
-
|
101
|
-
return x;
|
102
|
-
}
|
103
|
-
|
104
|
-
private static void addItem( ThreadContext context, RubyArray items, StringBuilder builder, boolean quoted ) {
|
105
|
-
String value = builder.toString();
|
106
|
-
|
107
|
-
if ( !quoted && value.length() == 0 ) {
|
108
|
-
return;
|
109
|
-
}
|
110
|
-
|
111
|
-
if ( !quoted && "NULL".equalsIgnoreCase( value ) ) {
|
112
|
-
items.add(context.getRuntime().getNil());
|
113
|
-
} else {
|
114
|
-
items.add(RubyString.newString( context.getRuntime(), value ));
|
115
|
-
}
|
116
|
-
}
|
117
|
-
|
118
|
-
}
|
@@ -1,26 +0,0 @@
|
|
1
|
-
package pgarrayparser;
|
2
|
-
|
3
|
-
import org.jruby.Ruby;
|
4
|
-
import org.jruby.RubyClass;
|
5
|
-
import org.jruby.RubyModule;
|
6
|
-
import org.jruby.runtime.ObjectAllocator;
|
7
|
-
import org.jruby.runtime.builtin.IRubyObject;
|
8
|
-
import org.jruby.runtime.load.BasicLibraryService;
|
9
|
-
|
10
|
-
import java.io.IOException;
|
11
|
-
|
12
|
-
public class PgArrayParserEngineService implements BasicLibraryService {
|
13
|
-
|
14
|
-
public boolean basicLoad(Ruby runtime) throws IOException {
|
15
|
-
|
16
|
-
RubyModule pgArrayParser = runtime.defineModule("PgArrayParser");
|
17
|
-
RubyClass pgArrayParserEngine = pgArrayParser.defineClassUnder("PgArrayParserEngine", runtime.getObject(), new ObjectAllocator() {
|
18
|
-
public IRubyObject allocate(Ruby runtime, RubyClass rubyClass) {
|
19
|
-
return new PgArrayParserEngine(runtime, rubyClass);
|
20
|
-
}
|
21
|
-
});
|
22
|
-
|
23
|
-
pgArrayParserEngine.defineAnnotatedMethods(PgArrayParserEngine.class);
|
24
|
-
return true;
|
25
|
-
}
|
26
|
-
}
|
data/lib/pg_array_parser.jar
DELETED
Binary file
|