motion-yapper 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 7395ef1251cdd8864f3acb18c0a151766fd10835
4
- data.tar.gz: 121948cad3cc4af4fa4e4ae0b8d6e979610eb645
3
+ metadata.gz: a84ae5876199c1963faf27d9b340e08f58098b38
4
+ data.tar.gz: ff44ac1c1dfc0d9f52f346de7c3f1610c5cc5f65
5
5
  SHA512:
6
- metadata.gz: 6675d2d18eaef05d80678a3f22edc55ac5d4a908ee9b66c621ea31c9a7a4bd1048a0b02dd69e95ad7c02d064e0d6d97f57b4ec45e84d0fe99f12a166f302891b
7
- data.tar.gz: a174b03c1edbb8ae5099e571ce9e8595e9fc2044384f176071777aeb911d4afcda3a7fc3f9d3dbb16a868a83cad22cd48c1c7d07645230024efda2d7c56662a0
6
+ metadata.gz: 7cea8c8b4460163e19a71dc9ec12d6d140f6c60c23a297d2cf1059f8bb9e7bfd7acf98791889cdb2b89bdb19b35f2d62f14c51cf045da662ca61a7bdbea7672b
7
+ data.tar.gz: 73bafc0b2a32159fcc14a4f883fb576d8f62f29da48931c6237d6202cc174fdead933d992093011e67208e8c906de57146b2487add1b0d162640fd48b0e51b29
data/README.md CHANGED
@@ -1,9 +1,116 @@
1
- yapper [![Build Status](https://travis-ci.org/kareemk/yapper.png?branch=master)](https://travis-ci.org/kareemk/yapper)
1
+ yapper [![Build Status](https://travis-ci.org/kareemk/yapper.svg?branch=master)](https://travis-ci.org/kareemk/yapper)
2
2
  ======
3
3
 
4
- RubyMotion ORM for YapDatabase
4
+ RubyMotion ORM for the wonderful [YapDatabase](https://github.com/yaptv/YapDatabase). Key features:
5
+ * Schemaless (define fields in your models)
6
+ * Very fast (thanks to YapDatabase's architecture)
7
+ * Chainable criteria
8
+ * One-many relationships
9
+ * On-the-fly reindexing
10
+ * Thread safe
5
11
 
6
- **WARNING: Under heavy development. Use with extreme caution. Stable version will be out soon.**
12
+ Show me
13
+ -------
14
+
15
+ ```ruby
16
+ class User
17
+ include Yapper::Document
18
+
19
+ field :name, :type => String
20
+ field :email, :type => String
21
+ field :bio, :type => String
22
+
23
+ has_many :locations
24
+
25
+ index :name, :email
26
+ end
27
+
28
+ class Location
29
+ include Yapper::Document
30
+
31
+ belongs_to :user
32
+
33
+ field :address
34
+ field :city
35
+
36
+ index :city
37
+ end
38
+
39
+ # Create
40
+ user = User.create(:name => 'John Malkovich')
41
+ location = Location.create(:user => user, :address => 'One Main', :city => 'Brooklyn')
42
+
43
+ # Update
44
+ user.update_attributes(:email => 'john@malkovich.com')
45
+
46
+ # Wait for a document to exist
47
+ User.when(id) { |user| puts "Got #{user.name}" }
48
+
49
+ # Query (note you can only query on indexed fields)
50
+ User.where(:email => 'john@malkovich.com')
51
+
52
+ # Return all documents
53
+ User.all
54
+
55
+ # Chain queries
56
+ User.where(:email => 'john@malkovich.com').where(:name => "John")
57
+
58
+ # Count
59
+ User.count
60
+ User.where(:email => 'john@malkovich.com').where(:name => "John").count
61
+
62
+ # Limit
63
+ User.where(:email => 'john@malkovich.com').where(:name => "John").limit(1)
64
+
65
+ # First
66
+ User.where(:email => 'john@malkovich.com').where(:name => "John").first
67
+
68
+ # Last
69
+ User.where(:email => 'john@malkovich.com').where(:name => "John").last
70
+
71
+ # On relations
72
+ user.locations.where(:city => 'Brooklyn').first
73
+
74
+ ```
75
+
76
+ See the [specs](https://github.com/kareemk/yapper/tree/master/spec/integration)
77
+ for more detail.
78
+
79
+ Status
80
+ ------
81
+
82
+ *Beta*. There are a lot of features missing that you'll probably want.
83
+ Open an [Issue](https://github.com/kareemk/yapper/issues) or better yet create a
84
+ pull request and let's make this happen.
85
+
86
+ Current roadmap:
87
+ * Performance optimizations (using a read-only connection on the main thread)
88
+ * Richer querying (not, or, custom sql)
89
+ * [Views](https://github.com/yaptv/YapDatabase/wiki/Views)
90
+ * [Full-text search](https://github.com/yaptv/YapDatabase/wiki/Full-Text-Search)
91
+ * RESTful API support
92
+
93
+
94
+ Prerequisites
95
+ -------------
96
+
97
+ Motion CocoaPods
98
+ ```ruby
99
+ gem install motion-cocoapods
100
+ pod setup
101
+ ```
102
+
103
+ Install
104
+ -------
105
+
106
+ ```ruby
107
+ gem install motion-yapper
108
+ ```
109
+ or add the following line to your Gemfile:
110
+ ```ruby
111
+ gem 'motion-yapper'
112
+ ```
113
+ and run `bundle install`
7
114
 
8
115
  License
9
116
  -------
@@ -52,6 +52,10 @@ module Yapper::Document
52
52
 
53
53
  set_defaults
54
54
 
55
+ if options[:pristine]
56
+ self.changes = {}
57
+ end
58
+
55
59
  self
56
60
  end
57
61
 
@@ -74,10 +78,6 @@ module Yapper::Document
74
78
  Log.warn "#{k} not defined on #{self.class}"
75
79
  end
76
80
  end
77
-
78
- if options[:pristine]
79
- self.changes = {}
80
- end
81
81
  end
82
82
  alias_method :attributes=, :assign_attributes
83
83
 
@@ -1,3 +1,3 @@
1
1
  module Yapper
2
- VERSION = '0.0.2'
2
+ VERSION = '0.0.3'
3
3
  end
@@ -17,8 +17,8 @@ Gem::Specification.new do |gem|
17
17
  gem.require_paths = ["lib"]
18
18
  gem.version = Yapper::VERSION
19
19
 
20
- gem.add_dependency 'motion-support', '~> 0.2'
21
- gem.add_dependency 'motion-cocoapods', '~> 1.4'
22
- gem.add_dependency 'motion-logger', '~> 0.1'
20
+ gem.add_dependency 'motion-support', '~> 0.2.0'
21
+ gem.add_dependency 'motion-cocoapods', '~> 1.4.0'
22
+ gem.add_dependency 'motion-logger', '~> 0.1.0'
23
23
  gem.add_development_dependency 'motion-redgreen', '~> 0.1'
24
24
  end
@@ -71,6 +71,10 @@ describe 'Criteria' do
71
71
  WhereDocument.all.to_a.count.should == 6
72
72
  end
73
73
 
74
+ it 'returns documents that do not contain changes' do
75
+ WhereDocument.all.first.changes.should == {}
76
+ end
77
+
74
78
  describe 'with a document that has no indexes' do
75
79
  before do
76
80
  class NoIndexDocument
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: motion-yapper
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kareem Kouddous
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-03-23 00:00:00.000000000 Z
11
+ date: 2014-06-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: motion-support
@@ -16,42 +16,42 @@ dependencies:
16
16
  requirements:
17
17
  - - ~>
18
18
  - !ruby/object:Gem::Version
19
- version: '0.2'
19
+ version: 0.2.0
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - ~>
25
25
  - !ruby/object:Gem::Version
26
- version: '0.2'
26
+ version: 0.2.0
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: motion-cocoapods
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - ~>
32
32
  - !ruby/object:Gem::Version
33
- version: '1.4'
33
+ version: 1.4.0
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - ~>
39
39
  - !ruby/object:Gem::Version
40
- version: '1.4'
40
+ version: 1.4.0
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: motion-logger
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
45
  - - ~>
46
46
  - !ruby/object:Gem::Version
47
- version: '0.1'
47
+ version: 0.1.0
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - ~>
53
53
  - !ruby/object:Gem::Version
54
- version: '0.1'
54
+ version: 0.1.0
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: motion-redgreen
57
57
  requirement: !ruby/object:Gem::Requirement