cdq 0.1.1
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 +15 -0
- data/.gitignore +11 -0
- data/Gemfile +7 -0
- data/Gemfile.lock +32 -0
- data/README.md +173 -0
- data/Rakefile +24 -0
- data/app/app_delegate.rb +13 -0
- data/app/test_models.rb +15 -0
- data/cdq.gemspec +18 -0
- data/lib/cdq.rb +12 -0
- data/lib/cdq/version.rb +4 -0
- data/motion/cdq.rb +58 -0
- data/motion/cdq/collection_proxy.rb +29 -0
- data/motion/cdq/config.rb +67 -0
- data/motion/cdq/context.rb +190 -0
- data/motion/cdq/model.rb +32 -0
- data/motion/cdq/object.rb +83 -0
- data/motion/cdq/object_proxy.rb +30 -0
- data/motion/cdq/partial_predicate.rb +53 -0
- data/motion/cdq/query.rb +128 -0
- data/motion/cdq/relationship_query.rb +122 -0
- data/motion/cdq/store.rb +52 -0
- data/motion/cdq/targeted_query.rb +170 -0
- data/motion/managed_object.rb +98 -0
- data/resources/CDQ.xcdatamodeld/.xccurrentversion +8 -0
- data/resources/CDQ.xcdatamodeld/0.0.1.xcdatamodel/contents +34 -0
- data/resources/Default-568h@2x.png +0 -0
- data/resources/KEEPME +0 -0
- data/schemas/001_baseline.rb +44 -0
- data/spec/cdq/collection_proxy_spec.rb +51 -0
- data/spec/cdq/config_spec.rb +74 -0
- data/spec/cdq/context_spec.rb +92 -0
- data/spec/cdq/managed_object_spec.rb +81 -0
- data/spec/cdq/model_spec.rb +14 -0
- data/spec/cdq/module_spec.rb +44 -0
- data/spec/cdq/object_proxy_spec.rb +37 -0
- data/spec/cdq/object_spec.rb +58 -0
- data/spec/cdq/partial_predicate_spec.rb +52 -0
- data/spec/cdq/query_spec.rb +127 -0
- data/spec/cdq/relationship_query_spec.rb +75 -0
- data/spec/cdq/store_spec.rb +39 -0
- data/spec/cdq/targeted_query_spec.rb +120 -0
- data/spec/helpers/thread_helper.rb +16 -0
- data/spec/integration_spec.rb +38 -0
- data/vendor/cdq/ext/CoreDataQueryManagedObjectBase.h +8 -0
- data/vendor/cdq/ext/CoreDataQueryManagedObjectBase.m +22 -0
- metadata +138 -0
@@ -0,0 +1,16 @@
|
|
1
|
+
module Bacon
|
2
|
+
class Context
|
3
|
+
# Executes a given block on an async concurrent GCD queue (which is a
|
4
|
+
# different thread) and returns the return value of the block, which is
|
5
|
+
# expected to be either true or false.
|
6
|
+
def on_thread(&block)
|
7
|
+
@result = false
|
8
|
+
group = Dispatch::Group.new
|
9
|
+
Dispatch::Queue.concurrent.async(group) do
|
10
|
+
@result = block.call
|
11
|
+
end
|
12
|
+
group.wait
|
13
|
+
@result
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
|
2
|
+
describe "Integration Tests" do
|
3
|
+
|
4
|
+
before do
|
5
|
+
|
6
|
+
class << self
|
7
|
+
include CDQ
|
8
|
+
end
|
9
|
+
|
10
|
+
cdq.setup
|
11
|
+
|
12
|
+
@author = Author.create(name: "Albert Einstein")
|
13
|
+
|
14
|
+
@fundamentals = @author.articles.create(body: "...", published: true, publishedAt: Time.local(1940),
|
15
|
+
title: "Considerations concering the fundamentals of theoretical physics")
|
16
|
+
|
17
|
+
@gravitation = @author.articles.create(body: "...", published: true, publishedAt: Time.local(1937),
|
18
|
+
title: "On gravitational waves")
|
19
|
+
|
20
|
+
@fcite = @fundamentals.citations.create(journal: "Science", timestamp: Time.local(1940))
|
21
|
+
@gcite = @gravitation.citations.create(journal: "Nature", timestamp: Time.local(1941))
|
22
|
+
|
23
|
+
cdq.save(always_wait: true)
|
24
|
+
end
|
25
|
+
|
26
|
+
after do
|
27
|
+
cdq.reset!
|
28
|
+
end
|
29
|
+
|
30
|
+
it "should be able to combine simple queries" do
|
31
|
+
@author.articles.count.should == 2
|
32
|
+
@author.articles.first.citations.count.should == 1
|
33
|
+
@author.articles.where(:title).matches('.*fundamentals.*').first.citations.array.should == [@fcite]
|
34
|
+
|
35
|
+
@gcite.article.author.should == @author
|
36
|
+
end
|
37
|
+
|
38
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
#import "CoreDataQueryManagedObjectBase.h"
|
2
|
+
#import <objc/runtime.h>
|
3
|
+
|
4
|
+
@implementation CoreDataQueryManagedObjectBase
|
5
|
+
|
6
|
+
- (id)relationshipByName:(NSString *)name;
|
7
|
+
{
|
8
|
+
// should be overriden by the subclass
|
9
|
+
printf("Unimplemented\n");
|
10
|
+
abort();
|
11
|
+
return nil;
|
12
|
+
}
|
13
|
+
|
14
|
+
+ (void)defineRelationshipMethod:(NSString *)name;
|
15
|
+
{
|
16
|
+
IMP imp = imp_implementationWithBlock(^id(CoreDataQueryManagedObjectBase *entity) {
|
17
|
+
return [entity relationshipByName:name];
|
18
|
+
});
|
19
|
+
class_addMethod([self class], NSSelectorFromString(name), imp, "@@:");
|
20
|
+
}
|
21
|
+
|
22
|
+
@end
|
metadata
ADDED
@@ -0,0 +1,138 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: cdq
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- infinitered
|
8
|
+
- kemiller
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2013-12-14 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: ruby-xcdm
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
requirements:
|
18
|
+
- - ~>
|
19
|
+
- !ruby/object:Gem::Version
|
20
|
+
version: '0.0'
|
21
|
+
- - ! '>='
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: 0.0.5
|
24
|
+
type: :runtime
|
25
|
+
prerelease: false
|
26
|
+
version_requirements: !ruby/object:Gem::Requirement
|
27
|
+
requirements:
|
28
|
+
- - ~>
|
29
|
+
- !ruby/object:Gem::Version
|
30
|
+
version: '0.0'
|
31
|
+
- - ! '>='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 0.0.5
|
34
|
+
- !ruby/object:Gem::Dependency
|
35
|
+
name: motion-yaml
|
36
|
+
requirement: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ! '>='
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
type: :runtime
|
42
|
+
prerelease: false
|
43
|
+
version_requirements: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ! '>='
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
description: Core Data Query for RubyMotion
|
49
|
+
email:
|
50
|
+
- ken@infinitered.com
|
51
|
+
executables: []
|
52
|
+
extensions: []
|
53
|
+
extra_rdoc_files: []
|
54
|
+
files:
|
55
|
+
- .gitignore
|
56
|
+
- Gemfile
|
57
|
+
- Gemfile.lock
|
58
|
+
- README.md
|
59
|
+
- Rakefile
|
60
|
+
- app/app_delegate.rb
|
61
|
+
- app/test_models.rb
|
62
|
+
- cdq.gemspec
|
63
|
+
- lib/cdq.rb
|
64
|
+
- lib/cdq/version.rb
|
65
|
+
- motion/cdq.rb
|
66
|
+
- motion/cdq/collection_proxy.rb
|
67
|
+
- motion/cdq/config.rb
|
68
|
+
- motion/cdq/context.rb
|
69
|
+
- motion/cdq/model.rb
|
70
|
+
- motion/cdq/object.rb
|
71
|
+
- motion/cdq/object_proxy.rb
|
72
|
+
- motion/cdq/partial_predicate.rb
|
73
|
+
- motion/cdq/query.rb
|
74
|
+
- motion/cdq/relationship_query.rb
|
75
|
+
- motion/cdq/store.rb
|
76
|
+
- motion/cdq/targeted_query.rb
|
77
|
+
- motion/managed_object.rb
|
78
|
+
- resources/CDQ.xcdatamodeld/.xccurrentversion
|
79
|
+
- resources/CDQ.xcdatamodeld/0.0.1.xcdatamodel/contents
|
80
|
+
- resources/Default-568h@2x.png
|
81
|
+
- resources/KEEPME
|
82
|
+
- schemas/001_baseline.rb
|
83
|
+
- spec/cdq/collection_proxy_spec.rb
|
84
|
+
- spec/cdq/config_spec.rb
|
85
|
+
- spec/cdq/context_spec.rb
|
86
|
+
- spec/cdq/managed_object_spec.rb
|
87
|
+
- spec/cdq/model_spec.rb
|
88
|
+
- spec/cdq/module_spec.rb
|
89
|
+
- spec/cdq/object_proxy_spec.rb
|
90
|
+
- spec/cdq/object_spec.rb
|
91
|
+
- spec/cdq/partial_predicate_spec.rb
|
92
|
+
- spec/cdq/query_spec.rb
|
93
|
+
- spec/cdq/relationship_query_spec.rb
|
94
|
+
- spec/cdq/store_spec.rb
|
95
|
+
- spec/cdq/targeted_query_spec.rb
|
96
|
+
- spec/helpers/thread_helper.rb
|
97
|
+
- spec/integration_spec.rb
|
98
|
+
- vendor/cdq/ext/CoreDataQueryManagedObjectBase.h
|
99
|
+
- vendor/cdq/ext/CoreDataQueryManagedObjectBase.m
|
100
|
+
homepage: http://github.com/infinitered/cdq
|
101
|
+
licenses: []
|
102
|
+
metadata: {}
|
103
|
+
post_install_message:
|
104
|
+
rdoc_options: []
|
105
|
+
require_paths:
|
106
|
+
- lib
|
107
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
108
|
+
requirements:
|
109
|
+
- - ! '>='
|
110
|
+
- !ruby/object:Gem::Version
|
111
|
+
version: '0'
|
112
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
113
|
+
requirements:
|
114
|
+
- - ! '>='
|
115
|
+
- !ruby/object:Gem::Version
|
116
|
+
version: '0'
|
117
|
+
requirements: []
|
118
|
+
rubyforge_project:
|
119
|
+
rubygems_version: 2.1.5
|
120
|
+
signing_key:
|
121
|
+
specification_version: 4
|
122
|
+
summary: Core Data Query for RubyMotion
|
123
|
+
test_files:
|
124
|
+
- spec/cdq/collection_proxy_spec.rb
|
125
|
+
- spec/cdq/config_spec.rb
|
126
|
+
- spec/cdq/context_spec.rb
|
127
|
+
- spec/cdq/managed_object_spec.rb
|
128
|
+
- spec/cdq/model_spec.rb
|
129
|
+
- spec/cdq/module_spec.rb
|
130
|
+
- spec/cdq/object_proxy_spec.rb
|
131
|
+
- spec/cdq/object_spec.rb
|
132
|
+
- spec/cdq/partial_predicate_spec.rb
|
133
|
+
- spec/cdq/query_spec.rb
|
134
|
+
- spec/cdq/relationship_query_spec.rb
|
135
|
+
- spec/cdq/store_spec.rb
|
136
|
+
- spec/cdq/targeted_query_spec.rb
|
137
|
+
- spec/helpers/thread_helper.rb
|
138
|
+
- spec/integration_spec.rb
|