pg_array_parser 0.0.8 → 0.0.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/ext/pg_array_parser/pg_array_parser.c +7 -5
- data/lib/pg_array_parser/version.rb +1 -1
- data/spec/parser_spec.rb +4 -0
- metadata +9 -18
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 583e3e7c6b543927c466b42f4c285cd183aa8e3f
|
4
|
+
data.tar.gz: 5239939210c83700d10c0b3cf75b81a6a02a16d8
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 0dc05e351d808e23c04d5431e8eeffc070bc6daa4ae1b13d0f37baea633db173b24211717ba8dd5281befb0f09ccd0c93d1ad348133965dd9502cdad5916d9eb
|
7
|
+
data.tar.gz: ccb817079ad4b34b3419a9266b1124b2a63ddea1a1ec0ce5c51520f66c6f8bf8b460bfcca3dde9d91b643e35f350ed74cd846af685d0f411f3e1d442b85ed0a6
|
@@ -1,7 +1,8 @@
|
|
1
1
|
#include <ruby.h>
|
2
|
+
#include <ruby/encoding.h>
|
2
3
|
|
3
4
|
/* Prototype */
|
4
|
-
VALUE read_array(int *index, char *string, int length, char *word);
|
5
|
+
VALUE read_array(int *index, char *string, int length, char *word, rb_encoding *enc);
|
5
6
|
|
6
7
|
VALUE parse_pg_array(VALUE self, VALUE pg_array_string) {
|
7
8
|
|
@@ -9,15 +10,16 @@ VALUE parse_pg_array(VALUE self, VALUE pg_array_string) {
|
|
9
10
|
char *c_pg_array_string = StringValueCStr(pg_array_string);
|
10
11
|
int array_string_length = RSTRING_LEN(pg_array_string);
|
11
12
|
char *word = malloc(array_string_length + 1);
|
13
|
+
rb_encoding *enc = rb_enc_get(pg_array_string);
|
12
14
|
|
13
15
|
int index = 1;
|
14
16
|
|
15
|
-
VALUE return_value = read_array(&index, c_pg_array_string, array_string_length, word);
|
17
|
+
VALUE return_value = read_array(&index, c_pg_array_string, array_string_length, word, enc);
|
16
18
|
free(word);
|
17
19
|
return return_value;
|
18
20
|
}
|
19
21
|
|
20
|
-
VALUE read_array(int *index, char *c_pg_array_string, int array_string_length, char *word)
|
22
|
+
VALUE read_array(int *index, char *c_pg_array_string, int array_string_length, char *word, rb_encoding *enc)
|
21
23
|
{
|
22
24
|
/* Return value: array */
|
23
25
|
VALUE array;
|
@@ -61,7 +63,7 @@ VALUE read_array(int *index, char *c_pg_array_string, int array_string_length, c
|
|
61
63
|
}
|
62
64
|
else
|
63
65
|
{
|
64
|
-
rb_ary_push(array,
|
66
|
+
rb_ary_push(array, rb_enc_str_new(word, word_index, enc));
|
65
67
|
}
|
66
68
|
}
|
67
69
|
if(c == '}')
|
@@ -79,7 +81,7 @@ VALUE read_array(int *index, char *c_pg_array_string, int array_string_length, c
|
|
79
81
|
else if(c == '{')
|
80
82
|
{
|
81
83
|
(*index)++;
|
82
|
-
rb_ary_push(array, read_array(index, c_pg_array_string, array_string_length, word));
|
84
|
+
rb_ary_push(array, read_array(index, c_pg_array_string, array_string_length, word, enc));
|
83
85
|
escapeNext = 1;
|
84
86
|
}
|
85
87
|
else
|
data/spec/parser_spec.rb
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
1
2
|
require 'spec_helper'
|
2
3
|
|
3
4
|
class Parser
|
@@ -51,6 +52,9 @@ describe 'PgArrayParser' do
|
|
51
52
|
parser.parse_pg_array(%[{1,"",3,""}]).should eq ['1', '', '3', '']
|
52
53
|
end
|
53
54
|
|
55
|
+
it 'returns an array containing unicode strings' do
|
56
|
+
parser.parse_pg_array(%[{"Paragraph 399(b)(i) – “valid leave” – meaning"}]).should eq(['Paragraph 399(b)(i) – “valid leave” – meaning'])
|
57
|
+
end
|
54
58
|
end
|
55
59
|
end
|
56
60
|
|
metadata
CHANGED
@@ -1,20 +1,18 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pg_array_parser
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
5
|
-
prerelease:
|
4
|
+
version: 0.0.9
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Dan McClain
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date:
|
11
|
+
date: 2013-08-02 00:00:00.000000000 Z
|
13
12
|
dependencies:
|
14
13
|
- !ruby/object:Gem::Dependency
|
15
14
|
name: rspec
|
16
15
|
requirement: !ruby/object:Gem::Requirement
|
17
|
-
none: false
|
18
16
|
requirements:
|
19
17
|
- - ~>
|
20
18
|
- !ruby/object:Gem::Version
|
@@ -22,7 +20,6 @@ dependencies:
|
|
22
20
|
type: :development
|
23
21
|
prerelease: false
|
24
22
|
version_requirements: !ruby/object:Gem::Requirement
|
25
|
-
none: false
|
26
23
|
requirements:
|
27
24
|
- - ~>
|
28
25
|
- !ruby/object:Gem::Version
|
@@ -30,7 +27,6 @@ dependencies:
|
|
30
27
|
- !ruby/object:Gem::Dependency
|
31
28
|
name: rake
|
32
29
|
requirement: !ruby/object:Gem::Requirement
|
33
|
-
none: false
|
34
30
|
requirements:
|
35
31
|
- - ~>
|
36
32
|
- !ruby/object:Gem::Version
|
@@ -38,7 +34,6 @@ dependencies:
|
|
38
34
|
type: :development
|
39
35
|
prerelease: false
|
40
36
|
version_requirements: !ruby/object:Gem::Requirement
|
41
|
-
none: false
|
42
37
|
requirements:
|
43
38
|
- - ~>
|
44
39
|
- !ruby/object:Gem::Version
|
@@ -46,17 +41,15 @@ dependencies:
|
|
46
41
|
- !ruby/object:Gem::Dependency
|
47
42
|
name: rake-compiler
|
48
43
|
requirement: !ruby/object:Gem::Requirement
|
49
|
-
none: false
|
50
44
|
requirements:
|
51
|
-
- -
|
45
|
+
- - '>='
|
52
46
|
- !ruby/object:Gem::Version
|
53
47
|
version: '0'
|
54
48
|
type: :development
|
55
49
|
prerelease: false
|
56
50
|
version_requirements: !ruby/object:Gem::Requirement
|
57
|
-
none: false
|
58
51
|
requirements:
|
59
|
-
- -
|
52
|
+
- - '>='
|
60
53
|
- !ruby/object:Gem::Version
|
61
54
|
version: '0'
|
62
55
|
description: Simple library to parse PostgreSQL arrays into a array of strings
|
@@ -80,29 +73,27 @@ files:
|
|
80
73
|
- ext/pg_array_parser/extconf.rb
|
81
74
|
homepage: https://github.com/dockyard/pg_array_parser
|
82
75
|
licenses: []
|
76
|
+
metadata: {}
|
83
77
|
post_install_message:
|
84
78
|
rdoc_options: []
|
85
79
|
require_paths:
|
86
80
|
- lib
|
87
81
|
required_ruby_version: !ruby/object:Gem::Requirement
|
88
|
-
none: false
|
89
82
|
requirements:
|
90
|
-
- -
|
83
|
+
- - '>='
|
91
84
|
- !ruby/object:Gem::Version
|
92
85
|
version: '0'
|
93
86
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
94
|
-
none: false
|
95
87
|
requirements:
|
96
|
-
- -
|
88
|
+
- - '>='
|
97
89
|
- !ruby/object:Gem::Version
|
98
90
|
version: '0'
|
99
91
|
requirements: []
|
100
92
|
rubyforge_project:
|
101
|
-
rubygems_version:
|
93
|
+
rubygems_version: 2.0.3
|
102
94
|
signing_key:
|
103
|
-
specification_version:
|
95
|
+
specification_version: 4
|
104
96
|
summary: Converts PostgreSQL array strings into arrays of strings
|
105
97
|
test_files:
|
106
98
|
- spec/parser_spec.rb
|
107
99
|
- spec/spec_helper.rb
|
108
|
-
has_rdoc:
|