swift 0.4.3 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- data/API.rdoc +90 -0
- data/README.rdoc +14 -6
- data/Rakefile +1 -0
- data/VERSION +1 -1
- data/examples/async.rb +11 -6
- data/examples/db.rb +5 -1
- data/examples/scheme.rb +10 -2
- data/ext/adapter.cc +259 -0
- data/ext/adapter.h +13 -0
- data/ext/extconf.rb +21 -0
- data/ext/iostream.cc +44 -0
- data/ext/iostream.h +17 -0
- data/ext/pool.cc +89 -0
- data/ext/pool.h +8 -0
- data/ext/query.cc +38 -0
- data/ext/query.h +17 -0
- data/ext/request.cc +44 -0
- data/ext/request.h +10 -0
- data/ext/result.cc +246 -0
- data/ext/result.h +17 -0
- data/ext/statement.cc +87 -0
- data/ext/statement.h +12 -0
- data/ext/swift.cc +31 -739
- data/ext/swift.h +35 -0
- data/lib/swift/adapter.rb +4 -7
- data/lib/swift/attribute.rb +8 -2
- data/lib/swift/db.rb +7 -16
- data/lib/swift/identity_map.rb +8 -0
- data/lib/swift/migrations.rb +15 -0
- data/lib/swift/pool.rb +2 -1
- data/lib/swift/scheme.rb +0 -8
- data/lib/swift/validations.rb +27 -0
- data/lib/swift.rb +0 -5
- data/swift.gemspec +40 -11
- data/test/helper.rb +6 -6
- data/test/test_adapter.rb +9 -16
- data/test/test_error.rb +26 -0
- data/test/test_io.rb +6 -4
- data/test/test_pool.rb +1 -1
- data/test/test_scheme.rb +51 -0
- data/test/test_timestamps.rb +27 -14
- data/test/test_transactions.rb +76 -0
- data/test/test_validations.rb +46 -0
- metadata +55 -10
@@ -0,0 +1,46 @@
|
|
1
|
+
require_relative 'helper'
|
2
|
+
require 'swift/validations'
|
3
|
+
|
4
|
+
describe 'validations' do
|
5
|
+
before do
|
6
|
+
@user = Class.new(Swift::Scheme) do
|
7
|
+
store :users
|
8
|
+
attribute :id, Swift::Type::Integer, serial: true, key: true
|
9
|
+
attribute :name, Swift::Type::String
|
10
|
+
|
11
|
+
validations do |errors|
|
12
|
+
errors << [:name, 'is blank'] if name.to_s.empty?
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
describe 'validate' do
|
18
|
+
it 'returns errors' do
|
19
|
+
assert_kind_of Swift::Errors, @user.new.validate
|
20
|
+
end
|
21
|
+
|
22
|
+
it 'has errors when invalid' do
|
23
|
+
assert !@user.new.validate.empty?
|
24
|
+
end
|
25
|
+
|
26
|
+
it 'has no errors when valid' do
|
27
|
+
assert @user.new(name: 'Apple Arthurton').validate.empty?
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
describe 'valid?' do
|
32
|
+
it 'fails when invalid' do
|
33
|
+
assert !@user.new.valid?
|
34
|
+
end
|
35
|
+
|
36
|
+
it 'passes when valid' do
|
37
|
+
assert @user.new(name: 'Apple Arthurton').valid?
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
describe 'errors' do
|
42
|
+
it 'has relation' do
|
43
|
+
assert_kind_of Swift::Scheme, @user.new.validate.relation
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
metadata
CHANGED
@@ -4,9 +4,9 @@ version: !ruby/object:Gem::Version
|
|
4
4
|
prerelease: false
|
5
5
|
segments:
|
6
6
|
- 0
|
7
|
-
-
|
8
|
-
-
|
9
|
-
version: 0.
|
7
|
+
- 5
|
8
|
+
- 0
|
9
|
+
version: 0.5.0
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Shane Hanna
|
@@ -15,13 +15,14 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2010-08-
|
18
|
+
date: 2010-08-30 00:00:00 +10:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
22
22
|
name: minitest
|
23
23
|
prerelease: false
|
24
24
|
requirement: &id001 !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
25
26
|
requirements:
|
26
27
|
- - ">="
|
27
28
|
- !ruby/object:Gem::Version
|
@@ -32,6 +33,19 @@ dependencies:
|
|
32
33
|
version: 1.7.0
|
33
34
|
type: :development
|
34
35
|
version_requirements: *id001
|
36
|
+
- !ruby/object:Gem::Dependency
|
37
|
+
name: eventmachine
|
38
|
+
prerelease: false
|
39
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
40
|
+
none: false
|
41
|
+
requirements:
|
42
|
+
- - ">="
|
43
|
+
- !ruby/object:Gem::Version
|
44
|
+
segments:
|
45
|
+
- 0
|
46
|
+
version: "0"
|
47
|
+
type: :development
|
48
|
+
version_requirements: *id002
|
35
49
|
description: A rational rudimentary database abstraction.
|
36
50
|
email:
|
37
51
|
- shane.hanna@gmail.com
|
@@ -44,30 +58,55 @@ extra_rdoc_files:
|
|
44
58
|
- LICENSE
|
45
59
|
- README.rdoc
|
46
60
|
files:
|
61
|
+
- API.rdoc
|
47
62
|
- LICENSE
|
48
63
|
- README.rdoc
|
49
64
|
- Rakefile
|
50
65
|
- VERSION
|
66
|
+
- ext/adapter.cc
|
67
|
+
- ext/adapter.h
|
51
68
|
- ext/extconf.rb
|
69
|
+
- ext/iostream.cc
|
70
|
+
- ext/iostream.h
|
71
|
+
- ext/pool.cc
|
72
|
+
- ext/pool.h
|
73
|
+
- ext/query.cc
|
74
|
+
- ext/query.h
|
75
|
+
- ext/request.cc
|
76
|
+
- ext/request.h
|
77
|
+
- ext/result.cc
|
78
|
+
- ext/result.h
|
79
|
+
- ext/statement.cc
|
80
|
+
- ext/statement.h
|
52
81
|
- ext/swift.cc
|
82
|
+
- ext/swift.h
|
53
83
|
- lib/swift.rb
|
54
84
|
- lib/swift/adapter.rb
|
55
85
|
- lib/swift/attribute.rb
|
56
86
|
- lib/swift/db.rb
|
57
87
|
- lib/swift/header.rb
|
58
88
|
- lib/swift/identity_map.rb
|
89
|
+
- lib/swift/migrations.rb
|
59
90
|
- lib/swift/pool.rb
|
60
91
|
- lib/swift/scheme.rb
|
61
92
|
- lib/swift/type.rb
|
93
|
+
- lib/swift/validations.rb
|
62
94
|
- swift.gemspec
|
63
95
|
- test/helper.rb
|
64
96
|
- test/house-explode.jpg
|
65
97
|
- test/test_adapter.rb
|
66
98
|
- test/test_encoding.rb
|
99
|
+
- test/test_error.rb
|
67
100
|
- test/test_identity_map.rb
|
68
101
|
- test/test_io.rb
|
69
102
|
- test/test_pool.rb
|
103
|
+
- test/test_scheme.rb
|
70
104
|
- test/test_timestamps.rb
|
105
|
+
- test/test_transactions.rb
|
106
|
+
- test/test_validations.rb
|
107
|
+
- examples/scheme.rb
|
108
|
+
- examples/async.rb
|
109
|
+
- examples/db.rb
|
71
110
|
has_rdoc: true
|
72
111
|
homepage: http://github.com/shanna/swift
|
73
112
|
licenses: []
|
@@ -78,6 +117,7 @@ rdoc_options:
|
|
78
117
|
require_paths:
|
79
118
|
- lib
|
80
119
|
required_ruby_version: !ruby/object:Gem::Requirement
|
120
|
+
none: false
|
81
121
|
requirements:
|
82
122
|
- - ">="
|
83
123
|
- !ruby/object:Gem::Version
|
@@ -85,6 +125,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
85
125
|
- 0
|
86
126
|
version: "0"
|
87
127
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
128
|
+
none: false
|
88
129
|
requirements:
|
89
130
|
- - ">="
|
90
131
|
- !ruby/object:Gem::Version
|
@@ -94,18 +135,22 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
94
135
|
requirements: []
|
95
136
|
|
96
137
|
rubyforge_project:
|
97
|
-
rubygems_version: 1.3.
|
138
|
+
rubygems_version: 1.3.7
|
98
139
|
signing_key:
|
99
140
|
specification_version: 3
|
100
141
|
summary: A rational rudimentary database abstraction.
|
101
142
|
test_files:
|
102
|
-
- test/
|
143
|
+
- test/test_pool.rb
|
103
144
|
- test/test_io.rb
|
145
|
+
- test/test_validations.rb
|
146
|
+
- test/test_transactions.rb
|
147
|
+
- test/test_adapter.rb
|
148
|
+
- test/test_identity_map.rb
|
149
|
+
- test/test_error.rb
|
150
|
+
- test/helper.rb
|
104
151
|
- test/test_encoding.rb
|
105
152
|
- test/test_timestamps.rb
|
106
|
-
- test/
|
107
|
-
- test/test_identity_map.rb
|
108
|
-
- test/test_pool.rb
|
109
|
-
- examples/async.rb
|
153
|
+
- test/test_scheme.rb
|
110
154
|
- examples/scheme.rb
|
155
|
+
- examples/async.rb
|
111
156
|
- examples/db.rb
|