tusks 0.0.0 → 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/tusks.rb +8 -3
- data/lib/tusks/{types/array.rb → array.rb} +0 -0
- data/lib/tusks/connection.rb +2 -2
- data/lib/tusks/error.rb +5 -0
- data/lib/tusks/{types/float.rb → float.rb} +0 -0
- data/lib/tusks/{types/hash.rb → hash.rb} +0 -0
- data/lib/tusks/{types/integer.rb → integer.rb} +0 -0
- data/lib/tusks/{types/nil.rb → nil.rb} +0 -0
- data/lib/tusks/{types/string.rb → string.rb} +0 -0
- data/lib/tusks/version.rb +1 -1
- data/spec/tusks/{types/array_spec.rb → array_spec.rb} +0 -0
- data/spec/tusks/connection_spec.rb +28 -28
- data/spec/tusks/{types/float_spec.rb → float_spec.rb} +0 -0
- data/spec/tusks/{types/hash_spec.rb → hash_spec.rb} +0 -0
- data/spec/tusks/{types/integer_spec.rb → integer_spec.rb} +0 -0
- data/spec/tusks/{types/nil_spec.rb → nil_spec.rb} +0 -0
- data/spec/tusks/{types/string_spec.rb → string_spec.rb} +0 -0
- data/tusks.gemspec +2 -0
- metadata +40 -24
- data/lib/tusks/error/init.rb +0 -3
- data/lib/tusks/error/nested_array_error.rb +0 -3
- data/lib/tusks/error/tusks_error.rb +0 -3
- data/lib/tusks/error/unsupported_type_error.rb +0 -3
- data/lib/tusks/types/init.rb +0 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 542e9e0f4408ff9f256d1975cf5c5a735de6a712
|
4
|
+
data.tar.gz: 0913c0c30b22c00ee3c2c68f767dbb45c6f3e55d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4e7add263084790c134e34f25bec48cc037c5c8ab78a80eea7d2630be494b2bb37ba479810618a62393c46ae6e6f7fcbb9967e822906502cfacacdf1195a68c2
|
7
|
+
data.tar.gz: 172ff5c399d9110f9eb171f4885460fd81760d378e903fbb1294528dafd904c014e0806520e4f7f8e140441b95ac1525386e4a5102cfd0119d573b34e0ac3db2
|
data/lib/tusks.rb
CHANGED
File without changes
|
data/lib/tusks/connection.rb
CHANGED
@@ -50,9 +50,9 @@ module Tusks
|
|
50
50
|
end
|
51
51
|
|
52
52
|
def execute_function(sproc_name, *args)
|
53
|
-
connect if !
|
53
|
+
connect if !in_transaction?
|
54
54
|
@conn.exec(build_sql_string(sproc_name, *args))
|
55
|
-
disconnect
|
55
|
+
disconnect if !in_transaction?
|
56
56
|
end
|
57
57
|
|
58
58
|
def build_sql_string(sproc_name, *args)
|
data/lib/tusks/error.rb
ADDED
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
data/lib/tusks/version.rb
CHANGED
File without changes
|
@@ -6,6 +6,23 @@ module Tusks
|
|
6
6
|
@connection = Connection.new({'key1' => 'value 1', 'key2' => 'value 2'})
|
7
7
|
end
|
8
8
|
|
9
|
+
context 'when first created' do
|
10
|
+
it 'should set the passed in options as the connection options' do
|
11
|
+
expect(@connection.instance_variable_get(:@options)).to eql ({
|
12
|
+
'key1' => 'value 1',
|
13
|
+
'key2' => 'value 2'
|
14
|
+
})
|
15
|
+
end
|
16
|
+
|
17
|
+
it 'should not claim to be in a transaction' do
|
18
|
+
expect(@connection.in_transaction?).to be false
|
19
|
+
end
|
20
|
+
|
21
|
+
it 'should not claim to be connected' do
|
22
|
+
expect(@connection.connected?).to be false
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
9
26
|
context 'after defining a function interface' do
|
10
27
|
before :each do
|
11
28
|
@connection.functions do
|
@@ -29,7 +46,7 @@ module Tusks
|
|
29
46
|
|
30
47
|
context 'a method defined by #no_results' do
|
31
48
|
before :each do
|
32
|
-
@connection.
|
49
|
+
allow(@connection).to receive(:execute_function)
|
33
50
|
end
|
34
51
|
|
35
52
|
it 'should return nil' do
|
@@ -44,14 +61,14 @@ module Tusks
|
|
44
61
|
|
45
62
|
context 'a method defined by #one_result' do
|
46
63
|
it 'should execute the function with the correct name and arguments' do
|
47
|
-
@connection.
|
64
|
+
allow(@connection).to receive(:execute_function).and_return([])
|
48
65
|
expect(@connection).to receive(:execute_function).with(:one, 'arg 1', 'arg 2')
|
49
66
|
@connection.one('arg 1', 'arg 2')
|
50
67
|
end
|
51
68
|
|
52
69
|
context 'that has results' do
|
53
70
|
before :each do
|
54
|
-
@connection.
|
71
|
+
allow(@connection).to receive(:execute_function).and_return([{
|
55
72
|
'key 1' => 'value 1',
|
56
73
|
'key 2' => 'value 2'
|
57
74
|
}])
|
@@ -67,7 +84,7 @@ module Tusks
|
|
67
84
|
|
68
85
|
context 'that has no results' do
|
69
86
|
before :each do
|
70
|
-
@connection.
|
87
|
+
allow(@connection).to receive(:execute_function).and_return([])
|
71
88
|
end
|
72
89
|
|
73
90
|
it 'should return nil' do
|
@@ -78,14 +95,14 @@ module Tusks
|
|
78
95
|
|
79
96
|
context 'a method defined by #many_results' do
|
80
97
|
it 'should execute the function with the correct name and arguments' do
|
81
|
-
@connection.
|
82
|
-
@connection.
|
98
|
+
allow(@connection).to receive(:execute_function).and_return([])
|
99
|
+
expect(@connection).to receive(:execute_function).with(:many, 'arg 1', 'arg 2')
|
83
100
|
@connection.many('arg 1', 'arg 2')
|
84
101
|
end
|
85
102
|
|
86
103
|
context 'that has results' do
|
87
104
|
before :each do
|
88
|
-
@connection.
|
105
|
+
allow(@connection).to receive(:execute_function).and_return([
|
89
106
|
{
|
90
107
|
'key 1' => 'value 1',
|
91
108
|
'key 2' => 'value 2'
|
@@ -114,7 +131,7 @@ module Tusks
|
|
114
131
|
context 'that has no results' do
|
115
132
|
context 'when passed no records' do
|
116
133
|
before :each do
|
117
|
-
@connection.
|
134
|
+
allow(@connection).to receive(:execute_function).and_return []
|
118
135
|
end
|
119
136
|
|
120
137
|
it 'should return an empty array' do
|
@@ -134,8 +151,8 @@ module Tusks
|
|
134
151
|
it 'should build the proper SQL string' do
|
135
152
|
arg1 = double('arg1')
|
136
153
|
arg2 = double('arg2')
|
137
|
-
arg1.
|
138
|
-
arg2.
|
154
|
+
allow(arg1).to receive(:to_pg_s).and_return('arg1#to_pg_s')
|
155
|
+
allow(arg2).to receive(:to_pg_s).and_return('arg2#to_pg_s')
|
139
156
|
|
140
157
|
expect(@connection.instance_eval {
|
141
158
|
build_sql_string(
|
@@ -148,26 +165,9 @@ module Tusks
|
|
148
165
|
|
149
166
|
context 'without arguments' do
|
150
167
|
it 'should build the proper SQL string' do
|
151
|
-
@connection.instance_eval { build_sql_string('function_name') }.
|
168
|
+
expect(@connection.instance_eval { build_sql_string('function_name') }).to eql 'SELECT * FROM function_name()'
|
152
169
|
end
|
153
170
|
end
|
154
171
|
end
|
155
|
-
|
156
|
-
context 'when first created' do
|
157
|
-
it 'should set the passed in options as the connection options' do
|
158
|
-
@connection.instance_variable_get(:@options).should eql ({
|
159
|
-
'key1' => 'value 1',
|
160
|
-
'key2' => 'value 2'
|
161
|
-
})
|
162
|
-
end
|
163
|
-
|
164
|
-
it 'should not claim to be in a transaction' do
|
165
|
-
expect(@connection.in_transaction?).to be false
|
166
|
-
end
|
167
|
-
|
168
|
-
it 'should not claim to be connected' do
|
169
|
-
expect(@connection.connected?).to be false
|
170
|
-
end
|
171
|
-
end
|
172
172
|
end
|
173
173
|
end
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
data/tusks.gemspec
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tusks
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Craig McCown
|
@@ -30,6 +30,26 @@ dependencies:
|
|
30
30
|
- - ">="
|
31
31
|
- !ruby/object:Gem::Version
|
32
32
|
version: 3.0.0
|
33
|
+
- !ruby/object:Gem::Dependency
|
34
|
+
name: pg
|
35
|
+
requirement: !ruby/object:Gem::Requirement
|
36
|
+
requirements:
|
37
|
+
- - "~>"
|
38
|
+
- !ruby/object:Gem::Version
|
39
|
+
version: '0.17'
|
40
|
+
- - ">="
|
41
|
+
- !ruby/object:Gem::Version
|
42
|
+
version: 0.17.1
|
43
|
+
type: :runtime
|
44
|
+
prerelease: false
|
45
|
+
version_requirements: !ruby/object:Gem::Requirement
|
46
|
+
requirements:
|
47
|
+
- - "~>"
|
48
|
+
- !ruby/object:Gem::Version
|
49
|
+
version: '0.17'
|
50
|
+
- - ">="
|
51
|
+
- !ruby/object:Gem::Version
|
52
|
+
version: 0.17.1
|
33
53
|
description: Tusks is built for Ruby application developers who want to access their
|
34
54
|
Postgres database exclusively using functions. It abstracts away ugly serialization
|
35
55
|
functionality, enables easy transaction management, and provides a declarative way
|
@@ -44,27 +64,23 @@ files:
|
|
44
64
|
- LICENSE.md
|
45
65
|
- README.md
|
46
66
|
- lib/tusks.rb
|
67
|
+
- lib/tusks/array.rb
|
47
68
|
- lib/tusks/connection.rb
|
48
|
-
- lib/tusks/error
|
49
|
-
- lib/tusks/
|
50
|
-
- lib/tusks/
|
51
|
-
- lib/tusks/
|
52
|
-
- lib/tusks/
|
53
|
-
- lib/tusks/
|
54
|
-
- lib/tusks/types/hash.rb
|
55
|
-
- lib/tusks/types/init.rb
|
56
|
-
- lib/tusks/types/integer.rb
|
57
|
-
- lib/tusks/types/nil.rb
|
58
|
-
- lib/tusks/types/string.rb
|
69
|
+
- lib/tusks/error.rb
|
70
|
+
- lib/tusks/float.rb
|
71
|
+
- lib/tusks/hash.rb
|
72
|
+
- lib/tusks/integer.rb
|
73
|
+
- lib/tusks/nil.rb
|
74
|
+
- lib/tusks/string.rb
|
59
75
|
- lib/tusks/version.rb
|
60
76
|
- spec/spec_helper.rb
|
77
|
+
- spec/tusks/array_spec.rb
|
61
78
|
- spec/tusks/connection_spec.rb
|
62
|
-
- spec/tusks/
|
63
|
-
- spec/tusks/
|
64
|
-
- spec/tusks/
|
65
|
-
- spec/tusks/
|
66
|
-
- spec/tusks/
|
67
|
-
- spec/tusks/types/string_spec.rb
|
79
|
+
- spec/tusks/float_spec.rb
|
80
|
+
- spec/tusks/hash_spec.rb
|
81
|
+
- spec/tusks/integer_spec.rb
|
82
|
+
- spec/tusks/nil_spec.rb
|
83
|
+
- spec/tusks/string_spec.rb
|
68
84
|
- tusks.gemspec
|
69
85
|
homepage: https://github.com/craigrmccown/tusks
|
70
86
|
licenses:
|
@@ -92,10 +108,10 @@ specification_version: 4
|
|
92
108
|
summary: Easily call PostgreSQL functions from Ruby.
|
93
109
|
test_files:
|
94
110
|
- spec/spec_helper.rb
|
111
|
+
- spec/tusks/array_spec.rb
|
95
112
|
- spec/tusks/connection_spec.rb
|
96
|
-
- spec/tusks/
|
97
|
-
- spec/tusks/
|
98
|
-
- spec/tusks/
|
99
|
-
- spec/tusks/
|
100
|
-
- spec/tusks/
|
101
|
-
- spec/tusks/types/string_spec.rb
|
113
|
+
- spec/tusks/float_spec.rb
|
114
|
+
- spec/tusks/hash_spec.rb
|
115
|
+
- spec/tusks/integer_spec.rb
|
116
|
+
- spec/tusks/nil_spec.rb
|
117
|
+
- spec/tusks/string_spec.rb
|
data/lib/tusks/error/init.rb
DELETED