relaxo-model 0.10.3 → 0.11.0
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
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: e2ad57e6711f00c73b9c202ead6b83a74487d3c6
|
|
4
|
+
data.tar.gz: 4415ddf243915e589262fabd95710bd87f4ca37f
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 2002c6a843e9faa0d161ec038746e14e7e62b1510913ce2a58a6d526a43d89cccca8df7ce0f452ce1d6783d2b841d07b0a94102e954a5ea8a49d5a457e41bb37
|
|
7
|
+
data.tar.gz: 70345816de27d90a95239d35254de896938fb36f2200bb98b4d6dadb1d7ef675b15488ef78286276047e1d4ccd2203655a615a7a8505f8dd3f3f8f88bf431d2b
|
data/lib/relaxo/model/version.rb
CHANGED
|
@@ -1,57 +1,8 @@
|
|
|
1
1
|
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
class Invoice
|
|
5
|
-
class Transaction; end
|
|
6
|
-
|
|
7
|
-
include Relaxo::Model
|
|
8
|
-
|
|
9
|
-
property :id, UUID
|
|
10
|
-
property :number
|
|
11
|
-
property :name
|
|
12
|
-
|
|
13
|
-
property :date, Attribute[Date]
|
|
14
|
-
|
|
15
|
-
view :all, [:type], index: [:id]
|
|
16
|
-
|
|
17
|
-
def transactions
|
|
18
|
-
Invoice::Transaction.by_invoice(@dataset, invoice: self)
|
|
19
|
-
end
|
|
20
|
-
end
|
|
21
|
-
|
|
22
|
-
class Invoice::Transaction
|
|
23
|
-
include Relaxo::Model
|
|
24
|
-
|
|
25
|
-
parent_type Invoice
|
|
26
|
-
|
|
27
|
-
property :id, UUID
|
|
28
|
-
property :invoice, BelongsTo[Invoice]
|
|
29
|
-
property :date, Attribute[Date]
|
|
30
|
-
|
|
31
|
-
view :all, [:type], index: [:id]
|
|
32
|
-
|
|
33
|
-
view :by_invoice, [:type, 'by_invoice', :invoice], index: [[:date, :id]]
|
|
34
|
-
end
|
|
35
|
-
|
|
36
|
-
class User
|
|
37
|
-
include Relaxo::Model
|
|
38
|
-
|
|
39
|
-
property :email, Attribute[String]
|
|
40
|
-
property :name
|
|
41
|
-
property :intro
|
|
42
|
-
|
|
43
|
-
view :all, [:type], index: [:email]
|
|
44
|
-
|
|
45
|
-
view :by_name, [:type, 'by_name'], index: [:name]
|
|
46
|
-
end
|
|
2
|
+
require_relative 'model_context'
|
|
47
3
|
|
|
48
4
|
RSpec.describe Relaxo::Model::Document do
|
|
49
|
-
|
|
50
|
-
let(:database) {Relaxo.connect(database_path)}
|
|
51
|
-
|
|
52
|
-
let(:document_path) {'test/document.json'}
|
|
53
|
-
|
|
54
|
-
before(:each) {FileUtils.rm_rf(database_path)}
|
|
5
|
+
include_context "model"
|
|
55
6
|
|
|
56
7
|
it "should create and save document" do
|
|
57
8
|
model = Invoice.create(database.current,
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
|
|
2
|
+
require 'relaxo/model'
|
|
3
|
+
|
|
4
|
+
class Invoice
|
|
5
|
+
class Transaction; end
|
|
6
|
+
|
|
7
|
+
include Relaxo::Model
|
|
8
|
+
|
|
9
|
+
property :id, UUID
|
|
10
|
+
property :number
|
|
11
|
+
property :name
|
|
12
|
+
|
|
13
|
+
property :date, Attribute[Date]
|
|
14
|
+
|
|
15
|
+
view :all, [:type], index: [:id]
|
|
16
|
+
|
|
17
|
+
def transactions
|
|
18
|
+
Invoice::Transaction.by_invoice(@dataset, invoice: self)
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
class Invoice::Transaction
|
|
23
|
+
include Relaxo::Model
|
|
24
|
+
|
|
25
|
+
parent_type Invoice
|
|
26
|
+
|
|
27
|
+
property :id, UUID
|
|
28
|
+
property :invoice, BelongsTo[Invoice]
|
|
29
|
+
property :date, Attribute[Date]
|
|
30
|
+
|
|
31
|
+
view :all, [:type], index: [:id]
|
|
32
|
+
|
|
33
|
+
view :by_invoice, [:type, 'by_invoice', :invoice], index: [[:date, :id]]
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
class User
|
|
37
|
+
include Relaxo::Model
|
|
38
|
+
|
|
39
|
+
property :email, Attribute[String]
|
|
40
|
+
property :name
|
|
41
|
+
property :intro
|
|
42
|
+
|
|
43
|
+
view :all, [:type], index: [:email]
|
|
44
|
+
|
|
45
|
+
view :by_name, [:type, 'by_name'], index: [:name]
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
RSpec.shared_context "model" do
|
|
49
|
+
let(:database_path) {File.join(__dir__, 'test')}
|
|
50
|
+
let(:database) {Relaxo.connect(database_path)}
|
|
51
|
+
|
|
52
|
+
let(:document_path) {'test/document.json'}
|
|
53
|
+
|
|
54
|
+
before(:each) {FileUtils.rm_rf(database_path)}
|
|
55
|
+
end
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
|
|
2
|
+
require_relative 'model_context'
|
|
3
|
+
|
|
4
|
+
RSpec.describe Relaxo::Model::Recordset do
|
|
5
|
+
include_context 'model'
|
|
6
|
+
|
|
7
|
+
context "with several invoices" do
|
|
8
|
+
before(:each) do
|
|
9
|
+
database.commit(message: "Adding test model") do |dataset|
|
|
10
|
+
@first = Invoice.insert(dataset, name: "Software Development")
|
|
11
|
+
@middle = Invoice.insert(dataset, name: "Website Hosting")
|
|
12
|
+
@last = Invoice.insert(dataset, name: "Backup Services")
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
it "should have a first and last invoice" do
|
|
17
|
+
recordset = Invoice.all(database.current)
|
|
18
|
+
|
|
19
|
+
expect(recordset.count).to be == 3
|
|
20
|
+
expect(recordset).to_not be_empty
|
|
21
|
+
|
|
22
|
+
expect(recordset.first).to be == @first
|
|
23
|
+
expect(recordset.last).to be == @last
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
end
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: relaxo-model
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.11.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Samuel Williams
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2018-02-
|
|
11
|
+
date: 2018-02-11 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: relaxo
|
|
@@ -111,6 +111,8 @@ files:
|
|
|
111
111
|
- relaxo-model.gemspec
|
|
112
112
|
- spec/relaxo/model/attribute_spec.rb
|
|
113
113
|
- spec/relaxo/model/document_spec.rb
|
|
114
|
+
- spec/relaxo/model/model_context.rb
|
|
115
|
+
- spec/relaxo/model/recordset_spec.rb
|
|
114
116
|
homepage: http://www.codeotaku.com/projects/relaxo/model
|
|
115
117
|
licenses:
|
|
116
118
|
- MIT
|
|
@@ -138,3 +140,5 @@ summary: A model layer for CouchDB with minimal global state.
|
|
|
138
140
|
test_files:
|
|
139
141
|
- spec/relaxo/model/attribute_spec.rb
|
|
140
142
|
- spec/relaxo/model/document_spec.rb
|
|
143
|
+
- spec/relaxo/model/model_context.rb
|
|
144
|
+
- spec/relaxo/model/recordset_spec.rb
|