cdq 0.1.1 → 0.1.2
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 +8 -8
- data/.gitignore +1 -0
- data/.travis.yml +2 -0
- data/Gemfile.lock +1 -1
- data/README.md +17 -6
- data/Rakefile +4 -0
- data/bin/cdq +9 -0
- data/cdq.gemspec +2 -0
- data/lib/cdq.rb +2 -0
- data/lib/cdq/cli.rb +169 -0
- data/lib/cdq/generators.rb +82 -0
- data/lib/cdq/version.rb +1 -1
- data/motion/cdq.rb +4 -0
- data/motion/cdq/collection_proxy.rb +1 -1
- data/motion/cdq/partial_predicate.rb +3 -3
- data/motion/cdq/query.rb +1 -1
- data/motion/cdq/relationship_query.rb +3 -3
- data/motion/cdq/targeted_query.rb +8 -8
- data/motion/managed_object.rb +4 -4
- data/spec/cdq/module_spec.rb +1 -1
- data/spec/cdq/partial_predicate_spec.rb +1 -1
- data/templates/init/schemas/0001_initial.rb +25 -0
- data/templates/model/app/models/name.rb +3 -0
- data/templates/model/spec/models/name.rb +15 -0
- metadata +11 -3
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
ZmUwYzY4Nzg0NGQxN2E1YWE1ZTMxM2I0M2Y0NzEyMDFkNGU3ZDYwNw==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
MzA2ZGFjODI3MzMwYTYwNDViOTQyNWFhZTljYTMyZTg5NmU4Zjc5Mg==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
YzgxZGYzMjIxZjk3MTYxYThkYTVjMTllNzYyOWJhZjhjMjAyNGU3ODNlZGZm
|
10
|
+
ZmI4NTgzZjVjNjc5YjVmN2YxNGFjN2ZkZDllNTk0YjZiM2MwZjhiYmMzOGJi
|
11
|
+
YzllZDQxN2QxM2Q5ZTM4OTIxNjA4NjA2ZDM3NzQ0YmE0MWMzZWM=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
ZWVjZGUxNTBmYTdkNTMwMDg5NDZhZjRlMTQxYTM3NDU1YWM3YjhkZjcyOTA4
|
14
|
+
ZjRjNjY1YTk2NGU0NTY0YTIzY2JmZmUzMjUzNDIzMjg5NGJkYjhhMjRiZDZh
|
15
|
+
OWI0NDY5ZGQ4YjE4NTllODJiYzI0ZjVmMjg4NzZlZDVmY2Q5MjQ=
|
data/.gitignore
CHANGED
data/.travis.yml
ADDED
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -14,15 +14,30 @@ rewriting almost everything. If you pay attention, you can still find the
|
|
14
14
|
genetic traces, so thanks to @alloy for sharing his work and letting me learn
|
15
15
|
so much.
|
16
16
|
|
17
|
+
[](https://gemnasium.com/infinitered/cdq)
|
18
|
+
[](https://travis-ci.org/infinitered/cdq)
|
19
|
+
[](http://badge.fury.io/rb/cdq)
|
20
|
+
|
17
21
|
### Why use a static Data Model?
|
18
22
|
|
19
23
|
By using a real data model file that gets compiled and included in your bundle,
|
20
24
|
you can take advantage of automatic migration, which simplifies managing your
|
21
|
-
schema as it grows, if you can follow a few simple rules.
|
25
|
+
schema as it grows, if you can follow a few [simple rules](https://developer.apple.com/library/ios/documentation/cocoa/conceptual/CoreDataVersioning/Articles/vmLightweightMigration.html#//apple_ref/doc/uid/TP40004399-CH4-SW2).
|
22
26
|
|
23
27
|
## Installing
|
24
28
|
|
25
|
-
|
29
|
+
##### Quick Start:
|
30
|
+
|
31
|
+
```bash
|
32
|
+
$ gem install cdq
|
33
|
+
$ motion create my_app # if needed
|
34
|
+
$ cd my_app
|
35
|
+
$ cdq init
|
36
|
+
```
|
37
|
+
|
38
|
+
This way assumes you want to use ruby-xcdm. Run ```cdq -h``` for list of more generators.
|
39
|
+
|
40
|
+
##### Using Bundler:
|
26
41
|
|
27
42
|
```ruby
|
28
43
|
gem 'cdq'
|
@@ -52,10 +67,6 @@ class AppDelegate
|
|
52
67
|
true
|
53
68
|
end
|
54
69
|
end
|
55
|
-
|
56
|
-
class TopLevel
|
57
|
-
include CDQ
|
58
|
-
end
|
59
70
|
```
|
60
71
|
|
61
72
|
That's it! You can create specific implementation classes for your entities if
|
data/Rakefile
CHANGED
@@ -22,3 +22,7 @@ require 'ruby-xcdm'
|
|
22
22
|
require 'motion-yaml'
|
23
23
|
|
24
24
|
task :"build:simulator" => :"schema:build"
|
25
|
+
task :"build:simulator" => :"schema:build"
|
26
|
+
task :"build:simulator" => :"schema:build"
|
27
|
+
task :"build:simulator" => :"schema:build"
|
28
|
+
task :"build:simulator" => :"schema:build"
|
data/bin/cdq
ADDED
data/cdq.gemspec
CHANGED
data/lib/cdq.rb
CHANGED
@@ -3,6 +3,8 @@ unless defined?(Motion::Project::App)
|
|
3
3
|
raise "This must be required from within a RubyMotion Rakefile"
|
4
4
|
end
|
5
5
|
|
6
|
+
require 'ruby-xcdm'
|
7
|
+
|
6
8
|
Motion::Project::App.setup do |app|
|
7
9
|
parent = File.join(File.dirname(__FILE__), '..')
|
8
10
|
app.files.unshift(Dir.glob(File.join(parent, "motion/cdq/**/*.rb")))
|
data/lib/cdq/cli.rb
ADDED
@@ -0,0 +1,169 @@
|
|
1
|
+
|
2
|
+
require "cdq/version"
|
3
|
+
require "cdq/generators"
|
4
|
+
|
5
|
+
module CDQ
|
6
|
+
class CommandLine
|
7
|
+
HELP_TEXT = %{Usage:
|
8
|
+
cdq [options] <command> [arguments]
|
9
|
+
|
10
|
+
Commands:
|
11
|
+
cdq init # Add boilerplate setup to use CDQ
|
12
|
+
cdq create model <model> # Create a model and associated files
|
13
|
+
|
14
|
+
Options:
|
15
|
+
}
|
16
|
+
|
17
|
+
attr_reader :singleton_options_passed
|
18
|
+
|
19
|
+
def option_parser(help_text = HELP_TEXT)
|
20
|
+
OptionParser.new do |opts|
|
21
|
+
opts.banner = help_text
|
22
|
+
|
23
|
+
opts.on("-v", "--version", "Print Version") do
|
24
|
+
@singleton_options_passed = true
|
25
|
+
puts CDQ::VERSION
|
26
|
+
end
|
27
|
+
|
28
|
+
opts.on("-h", "--help", "Show this message") do
|
29
|
+
@singleton_options_passed = true
|
30
|
+
puts opts
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
def self.run_all
|
36
|
+
|
37
|
+
actions = { "init" => InitAction, "create" => CreateAction }
|
38
|
+
|
39
|
+
cli = self.new
|
40
|
+
opts = cli.option_parser
|
41
|
+
opts.order!
|
42
|
+
action = ARGV.shift
|
43
|
+
|
44
|
+
if actions[action]
|
45
|
+
actions[action].new.run
|
46
|
+
elsif !cli.singleton_options_passed
|
47
|
+
puts opts
|
48
|
+
end
|
49
|
+
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
class InitAction < CommandLine
|
54
|
+
HELP_TEXT = %{Usage:
|
55
|
+
cdq init [options]
|
56
|
+
|
57
|
+
Run inside a motion directory, it will:
|
58
|
+
* Add cdq and ruby-xcdm to Gemfile, if necessary
|
59
|
+
* Set rake to automatically run schema:build
|
60
|
+
* Create an initial schema file
|
61
|
+
|
62
|
+
Options:
|
63
|
+
}
|
64
|
+
|
65
|
+
def option_parser
|
66
|
+
super(HELP_TEXT).tap do |opts|
|
67
|
+
opts.program_name = "cdq init"
|
68
|
+
|
69
|
+
opts.on("-d", "--dry-run", "Do a Dry Run") do
|
70
|
+
@dry_run = "dry_run"
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
def run
|
76
|
+
opts = option_parser
|
77
|
+
opts.order!
|
78
|
+
|
79
|
+
unless singleton_options_passed
|
80
|
+
CDQ::Generator.new(@dry_run).create('init')
|
81
|
+
|
82
|
+
print " \u0394 Checking bundle for cdq... "
|
83
|
+
unless system('bundle show cdq')
|
84
|
+
print " \u0394 Adding cdq to Gemfile... "
|
85
|
+
File.open("Gemfile", "at") do |gemfile|
|
86
|
+
gemfile.puts("gem 'cdq'")
|
87
|
+
end
|
88
|
+
puts "Done."
|
89
|
+
end
|
90
|
+
|
91
|
+
# print " \u0394 Checking bundle for ruby-xcdm... "
|
92
|
+
# unless system('bundle show ruby-xcdm')
|
93
|
+
# print " \u0394 Adding ruby-xcdm to Gemfile... "
|
94
|
+
# File.open("Gemfile", "at") do |gemfile|
|
95
|
+
# gemfile.puts("gem 'ruby-xcdm'")
|
96
|
+
# end
|
97
|
+
# puts "Done."
|
98
|
+
# end
|
99
|
+
|
100
|
+
print " \u0394 Adding schema:build hook to Rakefile... "
|
101
|
+
File.open("Rakefile", "at") do |rakefile|
|
102
|
+
rakefile.puts('task :"build:simulator" => :"schema:build"')
|
103
|
+
end
|
104
|
+
puts "Done."
|
105
|
+
|
106
|
+
puts %{
|
107
|
+
Now open app/app_delegate.rb, and add
|
108
|
+
|
109
|
+
include CDQ
|
110
|
+
|
111
|
+
at class level, and
|
112
|
+
|
113
|
+
cdq.setup
|
114
|
+
|
115
|
+
wherever you want the stack to get set up, probably right before you set
|
116
|
+
your root controller. Edit your inital schema, create a few models, and
|
117
|
+
you're off and running.
|
118
|
+
}
|
119
|
+
|
120
|
+
end
|
121
|
+
end
|
122
|
+
|
123
|
+
end
|
124
|
+
|
125
|
+
class CreateAction < CommandLine
|
126
|
+
HELP_TEXT = %{
|
127
|
+
Usage:
|
128
|
+
cdq create [options] model <model> # Create a CDQ model and associated test
|
129
|
+
|
130
|
+
Options:
|
131
|
+
}
|
132
|
+
|
133
|
+
def option_parser
|
134
|
+
super(HELP_TEXT).tap do |opts|
|
135
|
+
opts.program_name = "cdq create"
|
136
|
+
|
137
|
+
opts.on("-d", "--dry-run", "Do a Dry Run") do
|
138
|
+
@dry_run = "dry_run"
|
139
|
+
end
|
140
|
+
end
|
141
|
+
end
|
142
|
+
|
143
|
+
def run
|
144
|
+
opts = option_parser
|
145
|
+
opts.order!
|
146
|
+
|
147
|
+
object = ARGV.shift
|
148
|
+
|
149
|
+
unless singleton_options_passed
|
150
|
+
case object
|
151
|
+
when 'model'
|
152
|
+
model_name = ARGV.shift
|
153
|
+
if model_name
|
154
|
+
|
155
|
+
#camelized = model_name.gsub(/[A-Z]/) { |m| "_#{m.downcase}" }.gsub
|
156
|
+
CDQ::Generator.new(@dry_run).create('model', model_name)
|
157
|
+
else
|
158
|
+
puts "Please supply a model name"
|
159
|
+
puts opts
|
160
|
+
end
|
161
|
+
else
|
162
|
+
puts "Invalid object type: #{object}"
|
163
|
+
puts opts
|
164
|
+
end
|
165
|
+
end
|
166
|
+
end
|
167
|
+
|
168
|
+
end
|
169
|
+
end
|
@@ -0,0 +1,82 @@
|
|
1
|
+
|
2
|
+
|
3
|
+
module CDQ
|
4
|
+
class Generator
|
5
|
+
def initialize(options = nil)
|
6
|
+
@dry_run = true if options == 'dry_run'
|
7
|
+
end
|
8
|
+
|
9
|
+
def create(template, name = nil)
|
10
|
+
insert_from_template(template, name)
|
11
|
+
end
|
12
|
+
|
13
|
+
def template_path(template_name)
|
14
|
+
sub_path = "templates/#{template_name}/"
|
15
|
+
|
16
|
+
# First check local directory, use that if it exists
|
17
|
+
if Dir.exist?("#{Dir.pwd}/#{sub_path}")
|
18
|
+
"#{Dir.pwd}/#{sub_path}"
|
19
|
+
else # Then check the gem
|
20
|
+
begin
|
21
|
+
spec = Gem::Specification.find_by_name("cdq")
|
22
|
+
gem_root = spec.gem_dir
|
23
|
+
"#{gem_root}/#{sub_path}"
|
24
|
+
rescue Exception => e
|
25
|
+
puts "CDQ - could not find template directory\n"
|
26
|
+
nil
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
def insert_from_template(template_name, name = nil)
|
32
|
+
puts "\n Creating #{template_name}: #{name}\n\n"
|
33
|
+
|
34
|
+
return unless (@template_path = template_path(template_name))
|
35
|
+
files = Dir["#{@template_path}**/*"].select {|f| !File.directory? f}
|
36
|
+
|
37
|
+
if name
|
38
|
+
@name = name
|
39
|
+
@name_camel_case = @name.split('_').map{|word| word.capitalize}.join
|
40
|
+
end
|
41
|
+
|
42
|
+
files.each do |template_file_path_and_name|
|
43
|
+
@in_app_path = File.dirname(template_file_path_and_name).gsub(@template_path, '')
|
44
|
+
@ext = File.extname(template_file_path_and_name)
|
45
|
+
@file_name = File.basename(template_file_path_and_name, @ext)
|
46
|
+
|
47
|
+
@new_file_name = @file_name.gsub('name', @name || 'name')
|
48
|
+
@new_file_path_name = "#{Dir.pwd}/#{@in_app_path}/#{@new_file_name}#{@ext}"
|
49
|
+
|
50
|
+
if @dry_run
|
51
|
+
puts "\n Instance vars:"
|
52
|
+
self.instance_variables.each{|var| puts " #{var} = #{self.instance_variable_get(var)}"}
|
53
|
+
puts
|
54
|
+
end
|
55
|
+
|
56
|
+
if Dir.exist?(@in_app_path)
|
57
|
+
puts " Using existing directory: #{@in_app_path}"
|
58
|
+
else
|
59
|
+
puts " \u0394 Creating directory: #{@in_app_path}"
|
60
|
+
Dir.mkdir(@in_app_path) unless @dry_run
|
61
|
+
end
|
62
|
+
|
63
|
+
results = load_and_parse_erb(template_file_path_and_name)
|
64
|
+
|
65
|
+
if File.exists?(@new_file_path_name)
|
66
|
+
puts " X File exists, SKIPPING: #{@new_file_path_name}"
|
67
|
+
else
|
68
|
+
puts " \u0394 Creating file: #{@new_file_path_name}"
|
69
|
+
File.open(@new_file_path_name, 'w+') { |file| file.write(results) } unless @dry_run
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
puts "\n Done"
|
74
|
+
end
|
75
|
+
|
76
|
+
def load_and_parse_erb(template_file_name_and_path)
|
77
|
+
template_file = File.open(template_file_name_and_path, 'r').read
|
78
|
+
erb = ERB.new(template_file)
|
79
|
+
erb.result(binding)
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|
data/lib/cdq/version.rb
CHANGED
data/motion/cdq.rb
CHANGED
@@ -17,7 +17,7 @@ module CDQ
|
|
17
17
|
:begins_with => [NSBeginsWithPredicateOperatorType],
|
18
18
|
:ends_with => [NSEndsWithPredicateOperatorType]
|
19
19
|
}
|
20
|
-
|
20
|
+
|
21
21
|
def initialize(key, scope, operation = :and)
|
22
22
|
@key = key
|
23
23
|
@scope = scope
|
@@ -25,14 +25,14 @@ module CDQ
|
|
25
25
|
end
|
26
26
|
|
27
27
|
OPERATORS.each do |op, (type, synonym)|
|
28
|
-
define_method(op) do |value, options = 0|
|
28
|
+
define_method(op) do |value, options = 0|
|
29
29
|
make_scope(type, value, options)
|
30
30
|
end
|
31
31
|
alias_method synonym, op if synonym
|
32
32
|
end
|
33
33
|
|
34
34
|
def between(min, max); make_scope(NSBetweenPredicateOperatorType, [min, max]); end
|
35
|
-
|
35
|
+
|
36
36
|
private
|
37
37
|
|
38
38
|
def make_pred(key, type, value, options = 0)
|
data/motion/cdq/query.rb
CHANGED
@@ -20,7 +20,7 @@ module CDQ
|
|
20
20
|
end
|
21
21
|
|
22
22
|
# Creates a new managed object within the target relationship
|
23
|
-
#
|
23
|
+
#
|
24
24
|
def new(opts = {})
|
25
25
|
super(opts).tap do |obj|
|
26
26
|
add(obj)
|
@@ -28,7 +28,7 @@ module CDQ
|
|
28
28
|
end
|
29
29
|
|
30
30
|
# Add an existing object to the relationship
|
31
|
-
#
|
31
|
+
#
|
32
32
|
def add(obj)
|
33
33
|
if @inverse_rel.isToMany
|
34
34
|
obj.send(@inverse_rel.name).addObject(@owner)
|
@@ -56,7 +56,7 @@ module CDQ
|
|
56
56
|
self
|
57
57
|
end
|
58
58
|
|
59
|
-
# This works in a special way. If we're extending a regular NSSet, it will
|
59
|
+
# This works in a special way. If we're extending a regular NSSet, it will
|
60
60
|
# create a new method that calls allObjects. If we're extending a NSOrderedSet,
|
61
61
|
# the override will not work, and we get the array method already defined on
|
62
62
|
# NSOrderedSet, which is actually exactly what we want.
|
@@ -37,7 +37,7 @@ module CDQ #:nodoc:
|
|
37
37
|
end
|
38
38
|
end
|
39
39
|
|
40
|
-
# Return all matching entities.
|
40
|
+
# Return all matching entities.
|
41
41
|
#
|
42
42
|
# Causes execution.
|
43
43
|
#
|
@@ -58,7 +58,7 @@ module CDQ #:nodoc:
|
|
58
58
|
|
59
59
|
# Return the first entity matching the query.
|
60
60
|
#
|
61
|
-
# Causes execution.
|
61
|
+
# Causes execution.
|
62
62
|
#
|
63
63
|
def first
|
64
64
|
limit(1).array.first
|
@@ -68,7 +68,7 @@ module CDQ #:nodoc:
|
|
68
68
|
# <tt>length</tt> parameter is supplied, fetch a range of length <tt>length</tt>
|
69
69
|
# starting at <tt>index</tt>
|
70
70
|
#
|
71
|
-
# Causes execution.
|
71
|
+
# Causes execution.
|
72
72
|
#
|
73
73
|
def [](index, length = nil)
|
74
74
|
if length
|
@@ -81,7 +81,7 @@ module CDQ #:nodoc:
|
|
81
81
|
# Iterate over each entity matched by the query. You can also use any method from the
|
82
82
|
# Enumerable module in the standard library that does not depend on ordering.
|
83
83
|
#
|
84
|
-
# Causes execution.
|
84
|
+
# Causes execution.
|
85
85
|
#
|
86
86
|
def each(&block)
|
87
87
|
array.each(&block)
|
@@ -96,7 +96,7 @@ module CDQ #:nodoc:
|
|
96
96
|
end
|
97
97
|
end
|
98
98
|
|
99
|
-
# Create a new entity in the current context. Accepts a hash of attributes that will be assigned to
|
99
|
+
# Create a new entity in the current context. Accepts a hash of attributes that will be assigned to
|
100
100
|
# the newly-created entity. Does not save the context.
|
101
101
|
#
|
102
102
|
def new(opts = {})
|
@@ -105,7 +105,7 @@ module CDQ #:nodoc:
|
|
105
105
|
end
|
106
106
|
end
|
107
107
|
|
108
|
-
# Create a new entity in the current context. Accepts a hash of attributes that will be assigned to
|
108
|
+
# Create a new entity in the current context. Accepts a hash of attributes that will be assigned to
|
109
109
|
# the newly-created entity. Does not save the context.
|
110
110
|
#
|
111
111
|
# [TODO: Will apply validation.]
|
@@ -117,7 +117,7 @@ module CDQ #:nodoc:
|
|
117
117
|
# Create a named scope. The query is any valid CDQ query.
|
118
118
|
#
|
119
119
|
# Example:
|
120
|
-
#
|
120
|
+
#
|
121
121
|
# cdq('Author').scope(:first_published, cdq(:published).eq(true).sort_by(:published_at).limit(1))
|
122
122
|
#
|
123
123
|
# cdq('Author').first_published.first => #<Author>
|
@@ -135,7 +135,7 @@ module CDQ #:nodoc:
|
|
135
135
|
# Override the context in which to perform this query. This forever forces the
|
136
136
|
# specified context for this particular query, so if you save the it for later
|
137
137
|
# use (such as defining a scope) bear in mind that changes in the default context
|
138
|
-
# will have no effect when running this.
|
138
|
+
# will have no effect when running this.
|
139
139
|
#
|
140
140
|
def in_context(context)
|
141
141
|
clone(context: context)
|
data/motion/managed_object.rb
CHANGED
@@ -9,7 +9,7 @@
|
|
9
9
|
# Class.cdq.<em>method</em>.
|
10
10
|
#
|
11
11
|
# Examples:
|
12
|
-
#
|
12
|
+
#
|
13
13
|
# MyEntity.where(:name).eq("John").limit(2)
|
14
14
|
# MyEntity.first
|
15
15
|
# MyEntity.create(name: "John")
|
@@ -42,13 +42,13 @@ class CDQManagedObject < CoreDataQueryManagedObjectBase
|
|
42
42
|
cdq.models.current.entitiesByName[name]
|
43
43
|
end
|
44
44
|
|
45
|
-
# Creates a CDQ scope, but also defines a method on the class that returns the
|
45
|
+
# Creates a CDQ scope, but also defines a method on the class that returns the
|
46
46
|
# query directly.
|
47
47
|
#
|
48
48
|
def scope(name, query = nil, &block)
|
49
49
|
cdq.scope(name, query, &block)
|
50
50
|
if query
|
51
|
-
self.class.send(:define_method, name) do
|
51
|
+
self.class.send(:define_method, name) do
|
52
52
|
query
|
53
53
|
end
|
54
54
|
else
|
@@ -62,7 +62,7 @@ class CDQManagedObject < CoreDataQueryManagedObjectBase
|
|
62
62
|
cdq.new(*args)
|
63
63
|
end
|
64
64
|
|
65
|
-
# Pass any unknown methods on to cdq.
|
65
|
+
# Pass any unknown methods on to cdq.
|
66
66
|
#
|
67
67
|
def method_missing(name, *args, &block)
|
68
68
|
cdq.send(name, *args, &block)
|
data/spec/cdq/module_spec.rb
CHANGED
@@ -0,0 +1,25 @@
|
|
1
|
+
|
2
|
+
schema "0001 initial" do
|
3
|
+
|
4
|
+
# Examples:
|
5
|
+
#
|
6
|
+
# entity "Person" do
|
7
|
+
# string :name, optional: false
|
8
|
+
#
|
9
|
+
# has_many :posts
|
10
|
+
# end
|
11
|
+
#
|
12
|
+
# entity "Post" do
|
13
|
+
# string :title, optional: false
|
14
|
+
# string :body
|
15
|
+
#
|
16
|
+
# datetime :created_at
|
17
|
+
# datetime :updated_at
|
18
|
+
#
|
19
|
+
# has_many :replies, inverse: "Post.parent"
|
20
|
+
# belongs_to :parent, inverse: "Post.replies"
|
21
|
+
#
|
22
|
+
# belongs_to :person
|
23
|
+
# end
|
24
|
+
|
25
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
describe '<%= @name_camel_case %>' do
|
2
|
+
|
3
|
+
before do
|
4
|
+
include CDQ
|
5
|
+
cdq.setup
|
6
|
+
end
|
7
|
+
|
8
|
+
after do
|
9
|
+
cdq.reset!
|
10
|
+
end
|
11
|
+
|
12
|
+
it 'should be a <%= @name_camel_case %> entity'
|
13
|
+
<%= @name_camel_case %>.entity_description.name.should == '<%= @name_camel_case %>'
|
14
|
+
end
|
15
|
+
end
|
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.2
|
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:
|
12
|
+
date: 2014-01-02 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: ruby-xcdm
|
@@ -48,19 +48,24 @@ dependencies:
|
|
48
48
|
description: Core Data Query for RubyMotion
|
49
49
|
email:
|
50
50
|
- ken@infinitered.com
|
51
|
-
executables:
|
51
|
+
executables:
|
52
|
+
- cdq
|
52
53
|
extensions: []
|
53
54
|
extra_rdoc_files: []
|
54
55
|
files:
|
55
56
|
- .gitignore
|
57
|
+
- .travis.yml
|
56
58
|
- Gemfile
|
57
59
|
- Gemfile.lock
|
58
60
|
- README.md
|
59
61
|
- Rakefile
|
60
62
|
- app/app_delegate.rb
|
61
63
|
- app/test_models.rb
|
64
|
+
- bin/cdq
|
62
65
|
- cdq.gemspec
|
63
66
|
- lib/cdq.rb
|
67
|
+
- lib/cdq/cli.rb
|
68
|
+
- lib/cdq/generators.rb
|
64
69
|
- lib/cdq/version.rb
|
65
70
|
- motion/cdq.rb
|
66
71
|
- motion/cdq/collection_proxy.rb
|
@@ -95,6 +100,9 @@ files:
|
|
95
100
|
- spec/cdq/targeted_query_spec.rb
|
96
101
|
- spec/helpers/thread_helper.rb
|
97
102
|
- spec/integration_spec.rb
|
103
|
+
- templates/init/schemas/0001_initial.rb
|
104
|
+
- templates/model/app/models/name.rb
|
105
|
+
- templates/model/spec/models/name.rb
|
98
106
|
- vendor/cdq/ext/CoreDataQueryManagedObjectBase.h
|
99
107
|
- vendor/cdq/ext/CoreDataQueryManagedObjectBase.m
|
100
108
|
homepage: http://github.com/infinitered/cdq
|