cdq 0.1.10 → 0.1.11
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/README.md +23 -21
- data/lib/cdq.rb +9 -0
- data/lib/cdq/version.rb +1 -1
- data/motion/cdq.rb +3 -1
- data/motion/cdq/collection_proxy.rb +2 -0
- data/motion/cdq/targeted_query.rb +2 -0
- data/motion/managed_object.rb +13 -0
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
MzdmYTFjN2U5ZTg1ZmExOTM3ODM3NGU0MDE3M2E3NTBmYjNmNTU5NQ==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
YTA3Nzc3YmFiZGZkNjE0Njk2NGFkNmUwOTU5OWFiZjFiNTY3Y2IzMw==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
Y2FkMTlkNmNmZGRiZjc2Y2ViNjlhOTBhY2I5YjA5MDFhZGQ5YjMxYmMxMTVj
|
10
|
+
MWRjZGE5NmVjOGUzNzE5YWFkODhjNjAxNDVhOWEwZDQwMGVmY2E2NDVlNTVl
|
11
|
+
YWM2Y2EzYzU4MzA3MmY0YTliODhkNTdhYWJkNDhlYjdhNjMwYzE=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
ZDM3Y2Y2MWQwZTRhYWIzMWEyZjZjZTFjMzI2MmM1ZmM0MjliYzU3YjQwYWZk
|
14
|
+
NDM3MTFhZDIxYzNjNmRhNmZiYTA3MzE4ZjA0YmJlOTY0MTMxNDZhMzU5Yjdk
|
15
|
+
MzkwYjU5OGQ1YzM3MDM3OWI2YmRhMjQ1ZjAwNTUzMmI1YjQ3NGQ=
|
data/README.md
CHANGED
@@ -9,10 +9,15 @@ XCode, or you can use [ruby-xcdm](https://github.com/infinitered/ruby-xcdm).
|
|
9
9
|
[![Build Status](https://travis-ci.org/infinitered/cdq.png?branch=master)](https://travis-ci.org/infinitered/cdq)
|
10
10
|
[![Gem Version](https://badge.fury.io/rb/cdq.png)](http://badge.fury.io/rb/cdq)
|
11
11
|
|
12
|
-
##
|
12
|
+
## Get Started
|
13
|
+
1. [Introducing CDQ](#introducingCDQ)
|
14
|
+
2. [Greenfield Quick Start Tutorial](https://github.com/infinitered/cdq/wiki/Greenfield-Quick-Start)
|
15
|
+
3. [Cheat Sheet](https://github.com/infinitered/cdq/wiki/CDQ-Cheat-Sheet)
|
16
|
+
4. [API docs](http://rubydoc.info/github/infinitered/cdq)
|
13
17
|
|
14
|
-
|
15
|
-
|
18
|
+
## Introducing CDQ
|
19
|
+
|
20
|
+
CDQ began its life as a fork of [MotionData](https://github.com/alloy/MotionData), but it became obvious I
|
16
21
|
wanted to take things in a different direction, so I cut loose and ended up
|
17
22
|
rewriting almost everything. If you pay attention, you can still find the
|
18
23
|
genetic traces, so thanks to @alloy for sharing his work and letting me learn
|
@@ -23,7 +28,7 @@ avoiding too much abstraction or method pollution on top of the SDK. While it
|
|
23
28
|
borrows many ideas from ActiveRecord (especially AREL), it is designed to
|
24
29
|
harmonize with Core Data's way of doing things first.
|
25
30
|
|
26
|
-
I am actively developing and improving CDQ (updated
|
31
|
+
I am actively developing and improving CDQ (updated September 2014) so if you have
|
27
32
|
trouble or find a bug, please open a ticket!
|
28
33
|
|
29
34
|
### Why use a static Data Model?
|
@@ -34,17 +39,6 @@ schema as it grows, if you can follow a few [simple rules](https://developer.app
|
|
34
39
|
|
35
40
|
## Installing
|
36
41
|
|
37
|
-
### Quick Start:
|
38
|
-
|
39
|
-
For brand-new apps, or just to try it out, check out the
|
40
|
-
[Greenfield Quick Start](https://github.com/infinitered/cdq/wiki/Greenfield-Quick-Start) tutorial.
|
41
|
-
There's also a
|
42
|
-
[Cheat Sheet](https://github.com/infinitered/cdq/wiki/CDQ-Cheat-Sheet)
|
43
|
-
and
|
44
|
-
[API docs](http://rubydoc.info/github/infinitered/cdq).
|
45
|
-
|
46
|
-
### Even Quicker Start:
|
47
|
-
|
48
42
|
```bash
|
49
43
|
$ gem install cdq
|
50
44
|
$ motion create my_app # if needed
|
@@ -59,7 +53,7 @@ This way assumes you want to use ruby-xcdm. Run ```cdq -h``` for list of more g
|
|
59
53
|
```ruby
|
60
54
|
gem 'cdq'
|
61
55
|
```
|
62
|
-
|
56
|
+
<br />
|
63
57
|
If you want to see bleeding-edge changes, point Bundler at the git repo:
|
64
58
|
|
65
59
|
```ruby
|
@@ -174,6 +168,15 @@ all the data over to your main context all at once. CDQ makes that easy too:
|
|
174
168
|
cdq.save
|
175
169
|
```
|
176
170
|
|
171
|
+
### Reading
|
172
|
+
|
173
|
+
```ruby
|
174
|
+
author = Author.create(name: "Le Guin", publish_count: 150, first_published: 1970)
|
175
|
+
author.name # => "Le Guin"
|
176
|
+
author.publish_count # => 150
|
177
|
+
author.attributes # => { "name" => "Le Guin", "publish_count" => 150, "first_published" => 1970 }
|
178
|
+
```
|
179
|
+
|
177
180
|
### Updating
|
178
181
|
```ruby
|
179
182
|
author = Author.first
|
@@ -204,9 +207,7 @@ All of these queries are infinitely daisy-chainable, and almost everything is
|
|
204
207
|
possible to do using only chained methods, no need to drop into NSPredicate format
|
205
208
|
strings unless you want to.
|
206
209
|
|
207
|
-
Here are some examples. See the [cheat
|
208
|
-
sheet](https://github.com/infinitered/cdq/wiki/CDQ-Cheat-Sheet) for a complete
|
209
|
-
list.
|
210
|
+
Here are some examples. **See the [cheat sheet](https://github.com/infinitered/cdq/wiki/CDQ-Cheat-Sheet) for a complete list.**
|
210
211
|
|
211
212
|
### Conditions
|
212
213
|
|
@@ -214,7 +215,8 @@ list.
|
|
214
215
|
Author.where(:name).eq('Shakespeare')
|
215
216
|
Author.where(:publish_count).gt(10)
|
216
217
|
Author.where(name: 'Shakespeare', publish_count: 15)
|
217
|
-
Author.where("name LIKE
|
218
|
+
Author.where("name LIKE %@", '*kesp*')
|
219
|
+
Author.where("name LIKE %@", 'Shakespear?')
|
218
220
|
```
|
219
221
|
|
220
222
|
### Sorts, Limits and Offsets
|
@@ -332,7 +334,7 @@ enable, initialize like this:
|
|
332
334
|
cdq.stores.new(iCloud: true, container: "com.your.container.id")
|
333
335
|
```
|
334
336
|
|
335
|
-
You can also set up iCloud in your cdq.yml file.
|
337
|
+
You can also set up iCloud in your cdq.yml file.
|
336
338
|
|
337
339
|
## Documentation
|
338
340
|
|
data/lib/cdq.rb
CHANGED
@@ -14,4 +14,13 @@ Motion::Project::App.setup do |app|
|
|
14
14
|
app.files.unshift(Dir.glob(File.join(parent, "motion/*.rb")))
|
15
15
|
app.frameworks += %w{ CoreData }
|
16
16
|
app.vendor_project(File.join(parent, 'vendor/cdq/ext'), :static)
|
17
|
+
if app.respond_to?(:xcdm)
|
18
|
+
cdqfile = File.join(app.project_dir, 'resources/cdq.yml')
|
19
|
+
if File.exists?(cdqfile)
|
20
|
+
hash = YAML.load(File.read(cdqfile))
|
21
|
+
if hash
|
22
|
+
app.xcdm.name = hash['model_name'] || hash['name']
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
17
26
|
end
|
data/lib/cdq/version.rb
CHANGED
data/motion/cdq.rb
CHANGED
@@ -53,8 +53,10 @@ module CDQ
|
|
53
53
|
if obj.isSubclassOfClass(NSManagedObject)
|
54
54
|
entities = NSDictionary.dictionaryWithDictionary(
|
55
55
|
@@base_object.models.current.entitiesByName)
|
56
|
+
entity_name = obj.name.split("::").last
|
57
|
+
# NOTE attempt to look up the entity
|
56
58
|
entity_description =
|
57
|
-
entities[
|
59
|
+
entities[entity_name] ||
|
58
60
|
entities[obj.ancestors[1].name]
|
59
61
|
if entity_description.nil?
|
60
62
|
raise "Cannot find an entity named #{obj.name}"
|
data/motion/managed_object.rb
CHANGED
@@ -81,6 +81,10 @@ class CDQManagedObject < CoreDataQueryManagedObjectBase
|
|
81
81
|
cdq.save
|
82
82
|
end
|
83
83
|
|
84
|
+
def attribute_names
|
85
|
+
self.entity_description.attributesByName.keys
|
86
|
+
end
|
87
|
+
|
84
88
|
def cdq(obj = nil)
|
85
89
|
if obj
|
86
90
|
super(obj)
|
@@ -106,6 +110,15 @@ class CDQManagedObject < CoreDataQueryManagedObjectBase
|
|
106
110
|
description
|
107
111
|
end
|
108
112
|
|
113
|
+
# Returns a hash of attributes for the object
|
114
|
+
def attributes
|
115
|
+
h = {}
|
116
|
+
entity.attributesByName.each do |name, desc|
|
117
|
+
h[name] = send name
|
118
|
+
end
|
119
|
+
h
|
120
|
+
end
|
121
|
+
|
109
122
|
def log(log_type = nil)
|
110
123
|
out = "\nOID: "
|
111
124
|
out << oid
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cdq
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.11
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- infinitered
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2014-
|
12
|
+
date: 2014-11-22 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: ruby-xcdm
|
@@ -20,7 +20,7 @@ dependencies:
|
|
20
20
|
version: '0.0'
|
21
21
|
- - ! '>='
|
22
22
|
- !ruby/object:Gem::Version
|
23
|
-
version: 0.0.
|
23
|
+
version: 0.0.8
|
24
24
|
type: :runtime
|
25
25
|
prerelease: false
|
26
26
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -30,7 +30,7 @@ dependencies:
|
|
30
30
|
version: '0.0'
|
31
31
|
- - ! '>='
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: 0.0.
|
33
|
+
version: 0.0.8
|
34
34
|
- !ruby/object:Gem::Dependency
|
35
35
|
name: motion-yaml
|
36
36
|
requirement: !ruby/object:Gem::Requirement
|