relaxo-model 0.14.0 → 0.17.2

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
- SHA1:
3
- metadata.gz: 0ffd8121a4211d7a2a7784a2bac1b9e41c5e097d
4
- data.tar.gz: 5ff99d733bef43e782787ad2c26b4c7a1fe33078
2
+ SHA256:
3
+ metadata.gz: 76ee0fe261863b66948d14dbb488758149f2e5f13fcbd422f7734bd36997f2f4
4
+ data.tar.gz: 7c03bdd20c4075b211be89ab7ae531702450c54e066bce7eecb966d64eccbbb5
5
5
  SHA512:
6
- metadata.gz: 03d7a1767e7e18bbe664d1688b40a232b08519cb0447beaf8897d30ebe7c2ad573a27b83585fea00c5ed268d640b5ef86f3c53e7f0cff5814641eb8c137cfbb0
7
- data.tar.gz: 5948aa957ad6b4e3ee4a9c437d03de63722b51865da23a1b26cc5b7765e6d9f8049184678bee0a572825d8f275d698176b92e9aa9e21fe2618c89c98ac3520ba
6
+ metadata.gz: f693733a825e2e4571b048ac4af7396c5268ee6fb86467518c040cd44b673a7c2f782f4b6733eb2002186432906af5297e92af85585206c3357b6756ec2c3f9c
7
+ data.tar.gz: af576f5cbe754244eaf31a1f9300fa9f3b52aeeec4dd41b6912f2665028c49ee5b8550d5c571c956d7a0ea099b040ed51ba88fa2c212f33c9050d36d242ec3bb
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2012 Samuel G. D. Williams. <http://www.oriontransfer.co.nz>
1
+ # Copyright, 2012, by Samuel G. D. Williams. <http://www.codeotaku.com>
2
2
  #
3
3
  # Permission is hereby granted, free of charge, to any person obtaining a copy
4
4
  # of this software and associated documentation files (the "Software"), to deal
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2012 Samuel G. D. Williams. <http://www.oriontransfer.co.nz>
1
+ # Copyright, 2012, by Samuel G. D. Williams. <http://www.codeotaku.com>
2
2
  #
3
3
  # Permission is hereby granted, free of charge, to any person obtaining a copy
4
4
  # of this software and associated documentation files (the "Software"), to deal
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2012 Samuel G. D. Williams. <http://www.oriontransfer.co.nz>
1
+ # Copyright, 2012, by Samuel G. D. Williams. <http://www.codeotaku.com>
2
2
  #
3
3
  # Permission is hereby granted, free of charge, to any person obtaining a copy
4
4
  # of this software and associated documentation files (the "Software"), to deal
@@ -22,6 +22,9 @@ require 'relaxo/model/base'
22
22
 
23
23
  module Relaxo
24
24
  module Model
25
+ class SerializationError < RuntimeError
26
+ end
27
+
25
28
  # Represents an underlying object with changes which can be persisted.
26
29
  module Component
27
30
  def self.included(child)
@@ -51,7 +54,8 @@ module Relaxo
51
54
  # Attributes that have been changed or de-serialized from the dataset:
52
55
  attr :changed
53
56
 
54
- def reload
57
+ def reload(dataset = @dataset)
58
+ @dataset = dataset
55
59
  @changed.clear
56
60
  self.load_object
57
61
  end
@@ -102,11 +106,11 @@ module Relaxo
102
106
  end
103
107
  end
104
108
 
105
- def validate
109
+ def validate(changeset)
106
110
  # Do nothing :)
107
111
  end
108
112
 
109
- def to_hash
113
+ def to_h
110
114
  @attributes
111
115
  end
112
116
 
@@ -131,14 +135,18 @@ module Relaxo
131
135
  # Moves values from `@changed` into `@attributes`.
132
136
  def flatten!
133
137
  self.class.properties.each do |key, klass|
134
- if @changed.include?(key)
135
- if klass
136
- @attributes[key] = klass.convert_to_primative(@changed.delete(key))
137
- else
138
- @attributes[key] = @changed.delete(key)
138
+ begin
139
+ if @changed.include?(key)
140
+ if klass
141
+ @attributes[key] = klass.convert_to_primative(@changed.delete(key))
142
+ else
143
+ @attributes[key] = @changed.delete(key)
144
+ end
145
+ elsif !@attributes.include?(key) and klass.respond_to?(:default)
146
+ @attributes[key] = klass.default
139
147
  end
140
- elsif !@attributes.include?(key) and klass.respond_to?(:default)
141
- @attributes[key] = klass.default
148
+ rescue
149
+ raise SerializationError, "Failed to flatten #{key.inspect} of type #{klass.inspect}!"
142
150
  end
143
151
  end
144
152
 
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2012 Samuel G. D. Williams. <http://www.oriontransfer.co.nz>
1
+ # Copyright, 2012, by Samuel G. D. Williams. <http://www.codeotaku.com>
2
2
  #
3
3
  # Permission is hereby granted, free of charge, to any person obtaining a copy
4
4
  # of this software and associated documentation files (the "Software"), to deal
@@ -24,7 +24,7 @@ require 'msgpack'
24
24
 
25
25
  module Relaxo
26
26
  module Model
27
- class ValidationError < StandardError
27
+ class ValidationFailure < StandardError
28
28
  def initialize(document, errors)
29
29
  @document = document
30
30
  @errors = errors
@@ -79,7 +79,7 @@ module Relaxo
79
79
  # Fetch a record or create a model object from a hash of attributes.
80
80
  def fetch(dataset, path = nil, **attributes)
81
81
  if path and object = dataset.read(path)
82
- instance = self.new(dataset, object, attributes)
82
+ instance = self.new(dataset, object, **attributes)
83
83
 
84
84
  instance.load_object
85
85
 
@@ -133,9 +133,9 @@ module Relaxo
133
133
  end
134
134
 
135
135
  # Make a copy of the record, as if calling create.
136
- def dup
136
+ def dup(dataset = @dataset)
137
137
  # Splat already calls dup internally I guess.
138
- clone = self.class.new(@dataset, nil, @changed.dup, **@attributes)
138
+ clone = self.class.new(dataset, nil, @changed.dup, **@attributes)
139
139
 
140
140
  clone.after_create
141
141
 
@@ -147,7 +147,7 @@ module Relaxo
147
147
 
148
148
  self.class.keys.each do |name, key|
149
149
  # @attributes is not modified until we call self.dump (which flattens @attributes into @changes). When we generate paths, we want to ensure these are done based on the non-mutable state of the object.
150
- yield key.object_path(self, @attributes)
150
+ yield key.object_path(self, **@attributes)
151
151
  end
152
152
  end
153
153
 
@@ -157,7 +157,7 @@ module Relaxo
157
157
 
158
158
  before_save
159
159
 
160
- if errors = self.validate
160
+ if errors = self.validate(dataset)
161
161
  return errors
162
162
  end
163
163
 
@@ -191,7 +191,7 @@ module Relaxo
191
191
  result = self.save(dataset)
192
192
 
193
193
  if result != true
194
- raise ValidationErrors.new(result)
194
+ raise ValidationFailure.new(self, result)
195
195
  end
196
196
 
197
197
  return self
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2012 Samuel G. D. Williams. <http://www.oriontransfer.co.nz>
1
+ # Copyright, 2012, by Samuel G. D. Williams. <http://www.codeotaku.com>
2
2
  #
3
3
  # Permission is hereby granted, free of charge, to any person obtaining a copy
4
4
  # of this software and associated documentation files (the "Software"), to deal
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2012 Samuel G. D. Williams. <http://www.oriontransfer.co.nz>
1
+ # Copyright, 2012, by Samuel G. D. Williams. <http://www.codeotaku.com>
2
2
  #
3
3
  # Permission is hereby granted, free of charge, to any person obtaining a copy
4
4
  # of this software and associated documentation files (the "Software"), to deal
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2012 Samuel G. D. Williams. <http://www.oriontransfer.co.nz>
1
+ # Copyright, 2012, by Samuel G. D. Williams. <http://www.codeotaku.com>
2
2
  #
3
3
  # Permission is hereby granted, free of charge, to any person obtaining a copy
4
4
  # of this software and associated documentation files (the "Software"), to deal
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2012 Samuel G. D. Williams. <http://www.oriontransfer.co.nz>
1
+ # Copyright, 2012, by Samuel G. D. Williams. <http://www.codeotaku.com>
2
2
  #
3
3
  # Permission is hereby granted, free of charge, to any person obtaining a copy
4
4
  # of this software and associated documentation files (the "Software"), to deal
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2012 Samuel G. D. Williams. <http://www.oriontransfer.co.nz>
1
+ # Copyright, 2012, by Samuel G. D. Williams. <http://www.codeotaku.com>
2
2
  #
3
3
  # Permission is hereby granted, free of charge, to any person obtaining a copy
4
4
  # of this software and associated documentation files (the "Software"), to deal
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2012 Samuel G. D. Williams. <http://www.oriontransfer.co.nz>
1
+ # Copyright, 2012, by Samuel G. D. Williams. <http://www.codeotaku.com>
2
2
  #
3
3
  # Permission is hereby granted, free of charge, to any person obtaining a copy
4
4
  # of this software and associated documentation files (the "Software"), to deal
@@ -1,4 +1,4 @@
1
- # Copyright, 2017, by Samuel G. D. Williams. <http://www.oriontransfer.co.nz>
1
+ # Copyright, 2017, by Samuel G. D. Williams. <http://www.codeotaku.com>
2
2
  #
3
3
  # Permission is hereby granted, free of charge, to any person obtaining a copy
4
4
  # of this software and associated documentation files (the "Software"), to deal
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2012 Samuel G. D. Williams. <http://www.oriontransfer.co.nz>
1
+ # Copyright, 2012, by Samuel G. D. Williams. <http://www.codeotaku.com>
2
2
  #
3
3
  # Permission is hereby granted, free of charge, to any person obtaining a copy
4
4
  # of this software and associated documentation files (the "Software"), to deal
@@ -20,6 +20,6 @@
20
20
 
21
21
  module Relaxo
22
22
  module Model
23
- VERSION = "0.14.0"
23
+ VERSION = "0.17.2"
24
24
  end
25
25
  end
@@ -1,3 +1,22 @@
1
+ # Copyright, 2019, by Samuel G. D. Williams. <http://www.codeotaku.com>
2
+ #
3
+ # Permission is hereby granted, free of charge, to any person obtaining a copy
4
+ # of this software and associated documentation files (the "Software"), to deal
5
+ # in the Software without restriction, including without limitation the rights
6
+ # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
+ # copies of the Software, and to permit persons to whom the Software is
8
+ # furnished to do so, subject to the following conditions:
9
+ #
10
+ # The above copyright notice and this permission notice shall be included in
11
+ # all copies or substantial portions of the Software.
12
+ #
13
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
+ # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
+ # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
+ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
+ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19
+ # THE SOFTWARE.
1
20
 
2
21
  require 'relaxo/model'
3
22
 
@@ -10,7 +29,7 @@ class Aggregate
10
29
  end
11
30
 
12
31
  RSpec.describe Relaxo::Model::Document do
13
- let(:database_path) {File.join(__dir__, 'test')}
32
+ let(:database_path) {'tmp/attributes'}
14
33
  let(:database) {Relaxo.connect(database_path)}
15
34
 
16
35
  let(:document_path) {'test/document.json'}
@@ -1,3 +1,22 @@
1
+ # Copyright, 2019, by Samuel G. D. Williams. <http://www.codeotaku.com>
2
+ #
3
+ # Permission is hereby granted, free of charge, to any person obtaining a copy
4
+ # of this software and associated documentation files (the "Software"), to deal
5
+ # in the Software without restriction, including without limitation the rights
6
+ # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
+ # copies of the Software, and to permit persons to whom the Software is
8
+ # furnished to do so, subject to the following conditions:
9
+ #
10
+ # The above copyright notice and this permission notice shall be included in
11
+ # all copies or substantial portions of the Software.
12
+ #
13
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
+ # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
+ # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
+ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
+ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19
+ # THE SOFTWARE.
1
20
 
2
21
  require_relative 'model_context'
3
22
 
@@ -1,6 +1,24 @@
1
+ # Copyright, 2019, by Samuel G. D. Williams. <http://www.codeotaku.com>
2
+ #
3
+ # Permission is hereby granted, free of charge, to any person obtaining a copy
4
+ # of this software and associated documentation files (the "Software"), to deal
5
+ # in the Software without restriction, including without limitation the rights
6
+ # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
+ # copies of the Software, and to permit persons to whom the Software is
8
+ # furnished to do so, subject to the following conditions:
9
+ #
10
+ # The above copyright notice and this permission notice shall be included in
11
+ # all copies or substantial portions of the Software.
12
+ #
13
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
+ # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
+ # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
+ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
+ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19
+ # THE SOFTWARE.
1
20
 
2
21
  require 'relaxo/model'
3
-
4
22
  require 'relaxo/model/properties/bcrypt'
5
23
 
6
24
  class Invoice
@@ -54,7 +72,7 @@ class User
54
72
  end
55
73
 
56
74
  RSpec.shared_context "model" do
57
- let(:database_path) {File.join(__dir__, 'test')}
75
+ let(:database_path) {'tmp/model'}
58
76
  let(:database) {Relaxo.connect(database_path)}
59
77
 
60
78
  let(:document_path) {'test/document.json'}
@@ -1,3 +1,22 @@
1
+ # Copyright, 2019, by Samuel G. D. Williams. <http://www.codeotaku.com>
2
+ #
3
+ # Permission is hereby granted, free of charge, to any person obtaining a copy
4
+ # of this software and associated documentation files (the "Software"), to deal
5
+ # in the Software without restriction, including without limitation the rights
6
+ # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
+ # copies of the Software, and to permit persons to whom the Software is
8
+ # furnished to do so, subject to the following conditions:
9
+ #
10
+ # The above copyright notice and this permission notice shall be included in
11
+ # all copies or substantial portions of the Software.
12
+ #
13
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
+ # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
+ # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
+ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
+ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19
+ # THE SOFTWARE.
1
20
 
2
21
  require_relative '../model_context'
3
22
 
@@ -1,3 +1,22 @@
1
+ # Copyright, 2019, by Samuel G. D. Williams. <http://www.codeotaku.com>
2
+ #
3
+ # Permission is hereby granted, free of charge, to any person obtaining a copy
4
+ # of this software and associated documentation files (the "Software"), to deal
5
+ # in the Software without restriction, including without limitation the rights
6
+ # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
+ # copies of the Software, and to permit persons to whom the Software is
8
+ # furnished to do so, subject to the following conditions:
9
+ #
10
+ # The above copyright notice and this permission notice shall be included in
11
+ # all copies or substantial portions of the Software.
12
+ #
13
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
+ # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
+ # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
+ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
+ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19
+ # THE SOFTWARE.
1
20
 
2
21
  require_relative 'model_context'
3
22
 
@@ -0,0 +1,31 @@
1
+ # Copyright, 2019, by Samuel G. D. Williams. <http://www.codeotaku.com>
2
+ #
3
+ # Permission is hereby granted, free of charge, to any person obtaining a copy
4
+ # of this software and associated documentation files (the "Software"), to deal
5
+ # in the Software without restriction, including without limitation the rights
6
+ # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
+ # copies of the Software, and to permit persons to whom the Software is
8
+ # furnished to do so, subject to the following conditions:
9
+ #
10
+ # The above copyright notice and this permission notice shall be included in
11
+ # all copies or substantial portions of the Software.
12
+ #
13
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
+ # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
+ # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
+ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
+ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19
+ # THE SOFTWARE.
20
+
21
+ require "bundler/setup"
22
+ require "covered/rspec"
23
+
24
+ RSpec.configure do |config|
25
+ # Enable flags like --only-failures and --next-failure
26
+ config.example_status_persistence_file_path = ".rspec_status"
27
+
28
+ config.expect_with :rspec do |c|
29
+ c.syntax = :expect
30
+ end
31
+ end
metadata CHANGED
@@ -1,17 +1,17 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: relaxo-model
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.14.0
4
+ version: 0.17.2
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-12 00:00:00.000000000 Z
11
+ date: 2020-05-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: relaxo
14
+ name: msgpack
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
17
  - - "~>"
@@ -25,49 +25,77 @@ dependencies:
25
25
  - !ruby/object:Gem::Version
26
26
  version: '1.0'
27
27
  - !ruby/object:Gem::Dependency
28
- name: msgpack
28
+ name: relaxo
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '1.0'
33
+ version: '1.5'
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.0'
40
+ version: '1.5'
41
41
  - !ruby/object:Gem::Dependency
42
- name: bundler
42
+ name: bake
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - "~>"
45
+ - - ">="
46
46
  - !ruby/object:Gem::Version
47
- version: '1.3'
47
+ version: '0'
48
48
  type: :development
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: '1.3'
54
+ version: '0'
55
55
  - !ruby/object:Gem::Dependency
56
- name: rspec
56
+ name: bake-bundler
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - "~>"
59
+ - - ">="
60
60
  - !ruby/object:Gem::Version
61
- version: 3.4.0
61
+ version: '0'
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - "~>"
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: bake-modernize
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
67
81
  - !ruby/object:Gem::Version
68
- version: 3.4.0
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: bundler
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
69
97
  - !ruby/object:Gem::Dependency
70
- name: rake
98
+ name: covered
71
99
  requirement: !ruby/object:Gem::Requirement
72
100
  requirements:
73
101
  - - ">="
@@ -80,21 +108,26 @@ dependencies:
80
108
  - - ">="
81
109
  - !ruby/object:Gem::Version
82
110
  version: '0'
83
- description: "\t\tRelaxo Model provides a framework for business logic on top of\n\t\tRelaxo.
84
- While it supports some traditional ORM style patterns, it is\n\t\tprimary focus
85
- is to model business processes and logic.\n"
86
- email:
87
- - samuel.williams@oriontransfer.co.nz
111
+ - !ruby/object:Gem::Dependency
112
+ name: rspec
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - "~>"
116
+ - !ruby/object:Gem::Version
117
+ version: '3.4'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - "~>"
123
+ - !ruby/object:Gem::Version
124
+ version: '3.4'
125
+ description:
126
+ email:
88
127
  executables: []
89
128
  extensions: []
90
129
  extra_rdoc_files: []
91
130
  files:
92
- - ".gitignore"
93
- - ".simplecov"
94
- - ".travis.yml"
95
- - Gemfile
96
- - README.md
97
- - Rakefile
98
131
  - lib/relaxo/model.rb
99
132
  - lib/relaxo/model/base.rb
100
133
  - lib/relaxo/model/component.rb
@@ -109,12 +142,12 @@ files:
109
142
  - lib/relaxo/model/properties/uuid.rb
110
143
  - lib/relaxo/model/recordset.rb
111
144
  - lib/relaxo/model/version.rb
112
- - relaxo-model.gemspec
113
145
  - spec/relaxo/model/attribute_spec.rb
114
146
  - spec/relaxo/model/document_spec.rb
115
147
  - spec/relaxo/model/model_context.rb
116
148
  - spec/relaxo/model/properties/bcrypt_spec.rb
117
149
  - spec/relaxo/model/recordset_spec.rb
150
+ - spec/spec_helper.rb
118
151
  homepage: http://www.codeotaku.com/projects/relaxo/model
119
152
  licenses:
120
153
  - MIT
@@ -134,14 +167,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
134
167
  - !ruby/object:Gem::Version
135
168
  version: '0'
136
169
  requirements: []
137
- rubyforge_project:
138
- rubygems_version: 2.6.12
170
+ rubygems_version: 3.1.2
139
171
  signing_key:
140
172
  specification_version: 4
141
- summary: A model layer for CouchDB with minimal global state.
142
- test_files:
143
- - spec/relaxo/model/attribute_spec.rb
144
- - spec/relaxo/model/document_spec.rb
145
- - spec/relaxo/model/model_context.rb
146
- - spec/relaxo/model/properties/bcrypt_spec.rb
147
- - spec/relaxo/model/recordset_spec.rb
173
+ summary: A model layer for the relaxo document database.
174
+ test_files: []
data/.gitignore DELETED
@@ -1,18 +0,0 @@
1
- *.gem
2
- *.rbc
3
- .bundle
4
- .config
5
- .yardoc
6
- Gemfile.lock
7
- InstalledFiles
8
- _yardoc
9
- coverage
10
- doc/
11
- lib/bundler/man
12
- pkg
13
- rdoc
14
- spec/reports
15
- spec/relaxo/model/test
16
- test/tmp
17
- test/version_tmp
18
- tmp
data/.simplecov DELETED
@@ -1,9 +0,0 @@
1
-
2
- SimpleCov.start do
3
- add_filter "/spec/"
4
- end
5
-
6
- if ENV['TRAVIS']
7
- require 'coveralls'
8
- Coveralls.wear!
9
- end
@@ -1,17 +0,0 @@
1
- language: ruby
2
- sudo: false
3
- before_install:
4
- # For testing purposes:
5
- - git config --global user.name "Samuel Williams"
6
- - git config --global user.email "samuel@oriontransfer.net"
7
- rvm:
8
- - 2.1.8
9
- - 2.2.4
10
- - 2.3.1
11
- - 2.4.0
12
- - rbx-2
13
- env: COVERAGE=true
14
- matrix:
15
- allow_failures:
16
- - rvm: ruby-head
17
- - rvm: "rbx-2"
data/Gemfile DELETED
@@ -1,16 +0,0 @@
1
- source 'https://rubygems.org'
2
-
3
- # Specify your gem's dependencies in relaxo-model.gemspec
4
- gemspec
5
-
6
- gem 'rugged', git: 'git://github.com/libgit2/rugged.git', submodules: true
7
-
8
- group :development do
9
- gem "pry"
10
- gem "bcrypt"
11
- end
12
-
13
- group :test do
14
- gem 'simplecov'
15
- gem 'coveralls', require: false
16
- end
data/README.md DELETED
@@ -1,119 +0,0 @@
1
- # Relaxo Model
2
-
3
- Relaxo Model provides a framework for business logic on top of Relaxo, a document data store built on top of git. While it supports some traditional relational style patterns, it is primary focus is to model business processes and logic at the document level.
4
-
5
- [![Build Status](https://secure.travis-ci.org/ioquatix/relaxo-model.svg)](http://travis-ci.org/ioquatix/relaxo-model)
6
- [![Code Climate](https://codeclimate.com/github/ioquatix/relaxo-model.svg)](https://codeclimate.com/github/ioquatix/relaxo-model)
7
- [![Coverage Status](https://coveralls.io/repos/ioquatix/relaxo-model/badge.svg)](https://coveralls.io/r/ioquatix/relaxo-model)
8
-
9
- ## Basic Usage
10
-
11
- Here is a simple example of a traditional ORM style model:
12
-
13
- ```ruby
14
- require 'relaxo/model'
15
-
16
- database = Relaxo.connect("test")
17
-
18
- trees = [
19
- {:name => 'Hinoki', :planted => Date.parse("2013/11/17")},
20
- {:name => 'Keyaki', :planted => Date.parse("2016/9/24")}
21
- ]
22
-
23
- class Tree
24
- include Relaxo::Model
25
-
26
- property :id, UUID
27
- property :name
28
- property :planted, Attribute[Date]
29
-
30
- view :all, [:type], index: [:id]
31
- end
32
-
33
- database.commit(message: "Create trees") do |changeset|
34
- trees.each do |tree|
35
- Tree.insert(changeset, tree)
36
- end
37
- end
38
-
39
- database.current do |dataset|
40
- Tree.all(dataset).each do |tree|
41
- puts "A #{tree.name} was planted on #{tree.planted.to_s}."
42
-
43
- # Expected output:
44
- # A Hinoki was planted on 2013-11-17.
45
- # A Keyaki was planted on 2016-09-24.
46
- end
47
- end
48
- ```
49
-
50
- ### Non-UUID Primary Key
51
-
52
- ```ruby
53
- #!/usr/bin/env ruby
54
-
55
- gem 'relaxo'
56
-
57
- require 'relaxo/model'
58
-
59
- database = Relaxo.connect("test")
60
-
61
- trees = [
62
- {:name => 'Hinoki', :planted => Date.parse("2013/11/17")},
63
- {:name => 'Keyaki', :planted => Date.parse("2016/9/24")}
64
- ]
65
-
66
- class Tree
67
- include Relaxo::Model
68
-
69
- property :name
70
- property :planted, Attribute[Date]
71
-
72
- view :all, [:type], index: [:name]
73
- end
74
-
75
- database.commit(message: "Create trees") do |changeset|
76
- trees.each do |tree|
77
- Tree.insert(changeset, tree)
78
- end
79
- end
80
-
81
- database.current do |dataset|
82
- trees.each do |tree|
83
- object = Tree.fetch_all(dataset, name: tree[:name])
84
- puts object
85
- end
86
- end
87
- ```
88
-
89
- ## Contributing
90
-
91
- 1. Fork it
92
- 2. Create your feature branch (`git checkout -b my-new-feature`)
93
- 3. Commit your changes (`git commit -am 'Add some feature'`)
94
- 4. Push to the branch (`git push origin my-new-feature`)
95
- 5. Create new Pull Request
96
-
97
- ## License
98
-
99
- Released under the MIT license.
100
-
101
- Copyright, 2017, by [Samuel G. D. Williams](http://www.codeotaku.com/samuel-williams).
102
-
103
- Permission is hereby granted, free of charge, to any person obtaining a copy
104
- of this software and associated documentation files (the "Software"), to deal
105
- in the Software without restriction, including without limitation the rights
106
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
107
- copies of the Software, and to permit persons to whom the Software is
108
- furnished to do so, subject to the following conditions:
109
-
110
- The above copyright notice and this permission notice shall be included in
111
- all copies or substantial portions of the Software.
112
-
113
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
114
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
115
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
116
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
117
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
118
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
119
- THE SOFTWARE.
data/Rakefile DELETED
@@ -1,18 +0,0 @@
1
- require "bundler/gem_tasks"
2
- require "rspec/core/rake_task"
3
-
4
- RSpec::Core::RakeTask.new(:spec) do |task|
5
- task.rspec_opts = ["--require", "simplecov"] if ENV['COVERAGE']
6
- end
7
-
8
- task :default => :spec
9
-
10
- task :console do
11
- require 'pry'
12
-
13
- require_relative 'lib/relaxo/model'
14
-
15
- DB = Relaxo.connect(File.join(__dir__, 'testdb'))
16
-
17
- Pry.start
18
- end
@@ -1,31 +0,0 @@
1
- # coding: utf-8
2
- lib = File.expand_path('../lib', __FILE__)
3
- $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
- require 'relaxo/model/version'
5
-
6
- Gem::Specification.new do |spec|
7
- spec.name = "relaxo-model"
8
- spec.version = Relaxo::Model::VERSION
9
- spec.authors = ["Samuel Williams"]
10
- spec.email = ["samuel.williams@oriontransfer.co.nz"]
11
- spec.description = <<-EOF
12
- Relaxo Model provides a framework for business logic on top of
13
- Relaxo. While it supports some traditional ORM style patterns, it is
14
- primary focus is to model business processes and logic.
15
- EOF
16
- spec.summary = "A model layer for CouchDB with minimal global state."
17
- spec.homepage = "http://www.codeotaku.com/projects/relaxo/model"
18
- spec.license = "MIT"
19
-
20
- spec.files = `git ls-files`.split($/)
21
- spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
22
- spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
23
- spec.require_paths = ["lib"]
24
-
25
- spec.add_dependency("relaxo", "~> 1.0")
26
- spec.add_dependency("msgpack", "~> 1.0")
27
-
28
- spec.add_development_dependency "bundler", "~> 1.3"
29
- spec.add_development_dependency "rspec", "~> 3.4.0"
30
- spec.add_development_dependency "rake"
31
- end