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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 408ceaca49432fc3be46b178ad26f733c48d81c9
4
- data.tar.gz: 5b7b79891270d0c9e0e473607052fe6b62c985f7
3
+ metadata.gz: 542e9e0f4408ff9f256d1975cf5c5a735de6a712
4
+ data.tar.gz: 0913c0c30b22c00ee3c2c68f767dbb45c6f3e55d
5
5
  SHA512:
6
- metadata.gz: d0f6cf8e4813555f8264d1e2e68e3a3a6ca14fb2d918141747099cf46fd794bd695a799d2046e7632873bf55d08c82bf01f4cc994c0270da8a5a3e0ff1a750b3
7
- data.tar.gz: 4e7a281c47cee1924d1bddfc1bde4bc55461acd07dbe4bd7bc2fd109d01d8522b2a164c244fc2c3b3ca0329e9b518f32dfdb251422e73d4cb3464879b7e68400
6
+ metadata.gz: 4e7add263084790c134e34f25bec48cc037c5c8ab78a80eea7d2630be494b2bb37ba479810618a62393c46ae6e6f7fcbb9967e822906502cfacacdf1195a68c2
7
+ data.tar.gz: 172ff5c399d9110f9eb171f4885460fd81760d378e903fbb1294528dafd904c014e0806520e4f7f8e140441b95ac1525386e4a5102cfd0119d573b34e0ac3db2
data/lib/tusks.rb CHANGED
@@ -1,3 +1,8 @@
1
- require 'tusks/types/init'
2
- require 'tusks/error/init'
3
- require 'tusks/connection'
1
+ require 'pg'
2
+
3
+ %w(array connection float hash integer error nil string version).each do |lib|
4
+ require "tusks/#{lib}"
5
+ end
6
+
7
+ module Tusks
8
+ end
File without changes
@@ -50,9 +50,9 @@ module Tusks
50
50
  end
51
51
 
52
52
  def execute_function(sproc_name, *args)
53
- connect if !connected?
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)
@@ -0,0 +1,5 @@
1
+ module Tusks
2
+ class TusksError < StandardError; end
3
+ class NestedArrayError < TusksError; end
4
+ class UnsupportedTypeError < TusksError; end
5
+ end
File without changes
File without changes
File without changes
File without changes
File without changes
data/lib/tusks/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Tusks
2
- VERSION = '0.0.0'
2
+ VERSION = '0.0.1'
3
3
  end
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.stub(:execute_function)
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.stub(:execute_function).and_return([])
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.stub(:execute_function).and_return([{
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.stub(:execute_function).and_return([])
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.stub(:execute_function).and_return([])
82
- @connection.should receive(:execute_function).with(:many, 'arg 1', 'arg 2')
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.stub(:execute_function).and_return([
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.stub(:execute_function).and_return []
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.stub(:to_pg_s).and_return('arg1#to_pg_s')
138
- arg2.stub(:to_pg_s).and_return('arg2#to_pg_s')
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') }.should eql 'SELECT * FROM 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
data/tusks.gemspec CHANGED
@@ -22,4 +22,6 @@ Gem::Specification.new do |s|
22
22
  s.require_paths = ['lib']
23
23
 
24
24
  s.add_development_dependency 'rspec', '~> 3.0', '>= 3.0.0'
25
+
26
+ s.add_runtime_dependency 'pg', '~> 0.17', '>= 0.17.1'
25
27
  end
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.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/init.rb
49
- - lib/tusks/error/nested_array_error.rb
50
- - lib/tusks/error/tusks_error.rb
51
- - lib/tusks/error/unsupported_type_error.rb
52
- - lib/tusks/types/array.rb
53
- - lib/tusks/types/float.rb
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/types/array_spec.rb
63
- - spec/tusks/types/float_spec.rb
64
- - spec/tusks/types/hash_spec.rb
65
- - spec/tusks/types/integer_spec.rb
66
- - spec/tusks/types/nil_spec.rb
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/types/array_spec.rb
97
- - spec/tusks/types/float_spec.rb
98
- - spec/tusks/types/hash_spec.rb
99
- - spec/tusks/types/integer_spec.rb
100
- - spec/tusks/types/nil_spec.rb
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
@@ -1,3 +0,0 @@
1
- require_relative 'tusks_error'
2
- require_relative 'nested_array_error'
3
- require_relative 'unsupported_type_error'
@@ -1,3 +0,0 @@
1
- module Tusks
2
- class NestedArrayError < TusksError; end
3
- end
@@ -1,3 +0,0 @@
1
- module Tusks
2
- class TusksError < StandardError; end
3
- end
@@ -1,3 +0,0 @@
1
- module Tusks
2
- class UnsupportedTypeError < TusksError; end
3
- end
@@ -1,6 +0,0 @@
1
- require_relative 'array'
2
- require_relative 'float'
3
- require_relative 'hash'
4
- require_relative 'integer'
5
- require_relative 'nil'
6
- require_relative 'string'