uorm 0.0.10 → 0.0.11

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,26 +1,14 @@
1
+ Bundler.require
2
+
1
3
  require 'support/be_collection_of'
4
+ require 'support/test_persistance'
5
+
2
6
  require 'uorm'
3
7
 
4
- # monkey patch to wrap all tests in the reactor
5
- module RSpec
6
- module Core
7
- class ExampleGroup
8
- class << self
9
- alias_method :run_alias, :run
10
- def run(reporter)
11
- if EM.reactor_running?
12
- run_alias reporter
13
- else
14
- out = nil
15
- EM.synchrony do
16
- out = run_alias reporter
17
- EM.next_tick { EM.stop }
18
- end
19
- out
20
- end
21
- end
22
- end
23
- end
8
+ def fail_in sec
9
+ fail_proc = proc do
10
+ raise "Callback not reached in #{Time.now-start} sec"
11
+ EM.stop
24
12
  end
13
+ EM.add_timer sec, fail_proc
25
14
  end
26
-
@@ -0,0 +1,51 @@
1
+ module Uorm
2
+ module Mongo
3
+ class TestPerstistance
4
+ class << self
5
+ def collection= value
6
+ @@collection=value
7
+ end
8
+
9
+ def collection
10
+ @@collection
11
+ end
12
+
13
+ def flush
14
+ @@collection = []
15
+ end
16
+
17
+ def size
18
+ @@collection.size
19
+ end
20
+ end
21
+
22
+ def initialize *args
23
+ self.class.flush
24
+ end
25
+
26
+ def all options = {}
27
+ self.class.collection.map(&:attributes)
28
+ end
29
+
30
+ def find id
31
+ find = self.class.collection.select { |object| object.id == id }.first
32
+ find ? find.attributes : {}
33
+ end
34
+
35
+ def create object
36
+ self.class.collection << object
37
+ end
38
+
39
+ def update object
40
+ end
41
+
42
+ def delete object
43
+ self.class.collection.delete object
44
+ end
45
+
46
+ def size
47
+ self.class.size
48
+ end
49
+ end
50
+ end
51
+ end
@@ -1,11 +1,10 @@
1
1
  # -*- encoding: utf-8 -*-
2
2
  lib = File.expand_path('../lib', __FILE__)
3
3
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
- require 'uorm/version'
5
4
 
6
5
  Gem::Specification.new do |gem|
7
- gem.name = "uorm"
8
- gem.version = Uorm::VERSION
6
+ gem.name = 'uorm'
7
+ gem.version = '0.0.11'
9
8
  gem.authors = ['Dennis Rogenius']
10
9
  gem.email = ['denro03@gmail.com']
11
10
  gem.description = %q{A modular, flexible and lightweight ORM}
@@ -15,16 +14,15 @@ Gem::Specification.new do |gem|
15
14
  gem.files = `git ls-files`.split($/)
16
15
  gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
17
16
  gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
18
- gem.require_paths = ["lib"]
17
+ gem.require_paths = ['lib']
19
18
 
20
- gem.add_dependency 'activesupport'
21
19
  gem.add_dependency 'em-synchrony'
22
20
 
21
+ gem.add_development_dependency 'rake'
23
22
  gem.add_development_dependency 'rspec'
24
23
  gem.add_development_dependency 'debugger'
25
24
  gem.add_development_dependency 'em-mongo'
26
25
  gem.add_development_dependency 'bson_ext'
27
- gem.add_development_dependency 'oj'
28
26
  gem.add_development_dependency 'redis'
29
27
  gem.add_development_dependency 'hiredis'
30
28
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: uorm
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.10
4
+ version: 0.0.11
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,10 +9,10 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-12-30 00:00:00.000000000 Z
12
+ date: 2013-01-22 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
- name: activesupport
15
+ name: em-synchrony
16
16
  requirement: !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
@@ -28,14 +28,14 @@ dependencies:
28
28
  - !ruby/object:Gem::Version
29
29
  version: '0'
30
30
  - !ruby/object:Gem::Dependency
31
- name: em-synchrony
31
+ name: rake
32
32
  requirement: !ruby/object:Gem::Requirement
33
33
  none: false
34
34
  requirements:
35
35
  - - ! '>='
36
36
  - !ruby/object:Gem::Version
37
37
  version: '0'
38
- type: :runtime
38
+ type: :development
39
39
  prerelease: false
40
40
  version_requirements: !ruby/object:Gem::Requirement
41
41
  none: false
@@ -107,22 +107,6 @@ dependencies:
107
107
  - - ! '>='
108
108
  - !ruby/object:Gem::Version
109
109
  version: '0'
110
- - !ruby/object:Gem::Dependency
111
- name: oj
112
- requirement: !ruby/object:Gem::Requirement
113
- none: false
114
- requirements:
115
- - - ! '>='
116
- - !ruby/object:Gem::Version
117
- version: '0'
118
- type: :development
119
- prerelease: false
120
- version_requirements: !ruby/object:Gem::Requirement
121
- none: false
122
- requirements:
123
- - - ! '>='
124
- - !ruby/object:Gem::Version
125
- version: '0'
126
110
  - !ruby/object:Gem::Dependency
127
111
  name: redis
128
112
  requirement: !ruby/object:Gem::Requirement
@@ -170,24 +154,25 @@ files:
170
154
  - Rakefile
171
155
  - lib/uorm.rb
172
156
  - lib/uorm/attributes.rb
173
- - lib/uorm/callbacks.rb
174
- - lib/uorm/dsl.rb
175
- - lib/uorm/field.rb
176
- - lib/uorm/field_collection.rb
157
+ - lib/uorm/attributes/field.rb
158
+ - lib/uorm/attributes/field_collection.rb
159
+ - lib/uorm/attributes/type.rb
160
+ - lib/uorm/crud.rb
161
+ - lib/uorm/crud/callbacks.rb
162
+ - lib/uorm/crud/persistance_helper.rb
163
+ - lib/uorm/hash.rb
177
164
  - lib/uorm/model.rb
178
165
  - lib/uorm/mongo.rb
179
- - lib/uorm/mongo/db.rb
180
166
  - lib/uorm/mongo/object_id.rb
181
167
  - lib/uorm/mongo/persistance.rb
182
168
  - lib/uorm/redis.rb
183
- - lib/uorm/redis/db.rb
169
+ - lib/uorm/redis/adapter.rb
184
170
  - lib/uorm/redis/persistance.rb
185
- - lib/uorm/type.rb
186
- - lib/uorm/version.rb
187
- - spec/em-mongo_spec.rb
188
- - spec/redis_synchrony_spec.rb
171
+ - spec/mongo_spec.rb
172
+ - spec/redis_spec.rb
189
173
  - spec/spec_helper.rb
190
174
  - spec/support/be_collection_of.rb
175
+ - spec/support/test_persistance.rb
191
176
  - uorm.gemspec
192
177
  homepage: https://github.com/denro/uorm
193
178
  licenses: []
@@ -201,12 +186,18 @@ required_ruby_version: !ruby/object:Gem::Requirement
201
186
  - - ! '>='
202
187
  - !ruby/object:Gem::Version
203
188
  version: '0'
189
+ segments:
190
+ - 0
191
+ hash: -4044526249498249411
204
192
  required_rubygems_version: !ruby/object:Gem::Requirement
205
193
  none: false
206
194
  requirements:
207
195
  - - ! '>='
208
196
  - !ruby/object:Gem::Version
209
197
  version: '0'
198
+ segments:
199
+ - 0
200
+ hash: -4044526249498249411
210
201
  requirements: []
211
202
  rubyforge_project:
212
203
  rubygems_version: 1.8.24
@@ -214,7 +205,8 @@ signing_key:
214
205
  specification_version: 3
215
206
  summary: A small ORM for ruby with focus on weight and modularity
216
207
  test_files:
217
- - spec/em-mongo_spec.rb
218
- - spec/redis_synchrony_spec.rb
208
+ - spec/mongo_spec.rb
209
+ - spec/redis_spec.rb
219
210
  - spec/spec_helper.rb
220
211
  - spec/support/be_collection_of.rb
212
+ - spec/support/test_persistance.rb
@@ -1,11 +0,0 @@
1
- module Uorm
2
- module Callbacks
3
- class Create
4
- include ::EM::Deferrable
5
- end
6
-
7
- class Update
8
- include ::EM::Deferrable
9
- end
10
- end
11
- end
@@ -1,51 +0,0 @@
1
- module Uorm
2
- module DSL
3
- def self.included base
4
- base.instance_eval do
5
- def all args = {}, &block
6
- if block_given?
7
- persistance.all(args) { |attrs| yield new(attrs) if attrs }
8
- else
9
- persistance.all(args).map { |attrs| new(attrs) }
10
- end
11
- end
12
-
13
- def find id, &block
14
- if block_given?
15
- persistance.find(id) { |attrs| yield new(attrs) if attrs }
16
- else
17
- new persistance.find(id)
18
- end
19
- end
20
-
21
- def create attrs, &block
22
- if block_given?
23
- new(attrs).save &block
24
- else
25
- new(attrs).save
26
- end
27
- end
28
- end
29
- end
30
-
31
- def new?
32
- persistance.new? self
33
- end
34
-
35
- def save &block
36
- new? ? persistance.create(self, &block) : persistance.update(self, &block)
37
- self
38
- end
39
-
40
- def update attrs
41
- update_attributes attrs
42
- persistance.update self
43
- self
44
- end
45
-
46
- def delete
47
- persistance.delete self
48
- self
49
- end
50
- end
51
- end
@@ -1,13 +0,0 @@
1
- module Uorm
2
- class Field < Struct.new :name, :type
3
- def convert value
4
- return unless value
5
- type.convert value
6
- end
7
-
8
- def as_json value
9
- return unless value
10
- type.as_json value
11
- end
12
- end
13
- end
@@ -1,7 +0,0 @@
1
- module Uorm
2
- class FieldCollection < Array
3
- def get name
4
- self.find { |f| f.name.to_sym == name.to_sym }
5
- end
6
- end
7
- end
@@ -1,27 +0,0 @@
1
- module Uorm
2
- module Mongo
3
- class DB
4
- class << self
5
- attr_accessor :name, :pool_size
6
-
7
- def collection coll
8
- db.collection coll
9
- end
10
-
11
- def db
12
- connection.db name
13
- end
14
-
15
- def pool_size
16
- @pool_size ||= 2
17
- end
18
-
19
- def connection
20
- @connection ||= ::EM::Synchrony::ConnectionPool.new(size: pool_size) do
21
- ::EM::Mongo::Connection.new
22
- end
23
- end
24
- end
25
- end
26
- end
27
- end
@@ -1,19 +0,0 @@
1
- module Uorm
2
- module Redis
3
- class DB
4
- class << self
5
- attr_accessor :nr, :pool_size
6
-
7
- def pool_size
8
- @pool_size ||= 2
9
- end
10
-
11
- def client
12
- @client ||= ::EM::Synchrony::ConnectionPool.new(size: pool_size) do
13
- ::Redis.new driver: :synchrony, db: nr
14
- end
15
- end
16
- end
17
- end
18
- end
19
- end
@@ -1,65 +0,0 @@
1
- module Uorm
2
- module Type
3
- class Integer
4
- class << self
5
- def convert value
6
- value.to_i
7
- end
8
-
9
- def as_json value
10
- convert value
11
- end
12
- end
13
- end
14
-
15
- class Boolean
16
- class << self
17
- def convert value
18
- value ? true : false
19
- end
20
-
21
- def as_json value
22
- convert value
23
- end
24
- end
25
- end
26
-
27
- class Float
28
- class << self
29
- def convert value
30
- value.to_f
31
- end
32
-
33
- def as_json value
34
- convert value
35
- end
36
- end
37
- end
38
-
39
- class Time
40
- class << self
41
- def convert value
42
- ::Time.parse value.to_s
43
- rescue
44
- ::Time.utc(value.to_i)
45
- end
46
-
47
- def as_json value
48
- value.to_i
49
- end
50
- end
51
- end
52
-
53
- class String
54
- class << self
55
- def convert value
56
- value.to_s
57
- end
58
-
59
- def as_json value
60
- convert value
61
- end
62
- end
63
- end
64
- end
65
- end