datory 1.0.0.rc18 → 1.0.0.rc20
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +58 -57
- data/config/locales/en.yml +1 -1
- data/config/locales/ru.yml +1 -1
- data/lib/datory/attributes/dsl.rb +13 -4
- data/lib/datory/context/workspace.rb +0 -13
- data/lib/datory/service/base.rb +2 -0
- data/lib/datory/version.rb +1 -1
- metadata +6 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7d89294162d1c0f3ba39169be07688e41bd756ce01aca92d819eadb4a2fa17c6
|
4
|
+
data.tar.gz: d5f85e0a122bc34fee393bd2fcdb5039e69c6db7500e7d3d6ff3be9db6d482a0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 58752a040a8c9a9f48adb20c9cfe5251469e47df3f384a63fa0c2d70e5983a4244aae2ce73e91c6fef5727e44bc996ce68a641daef5fac01797a7de055116645
|
7
|
+
data.tar.gz: 77a9dcc175d8b1a0304d7b8d4d3597077848304f7220396eb62bf6d4d177f8e11b514040dda727a2ad04a76d5d3eff8662dcebc04d7f0193414929dd42a3a728
|
data/README.md
CHANGED
@@ -3,7 +3,7 @@
|
|
3
3
|
<a href="https://github.com/servactory/datory/releases"><img src="https://img.shields.io/github/release-date/servactory/datory" alt="Release Date"></a>
|
4
4
|
</p>
|
5
5
|
|
6
|
-
## Documentation
|
6
|
+
## Documentation
|
7
7
|
|
8
8
|
See [datory.servactory.com](https://datory.servactory.com) for documentation.
|
9
9
|
|
@@ -20,15 +20,15 @@ gem "datory"
|
|
20
20
|
#### Serialize
|
21
21
|
|
22
22
|
```ruby
|
23
|
-
|
23
|
+
serial = Serial.find(id)
|
24
24
|
|
25
|
-
|
25
|
+
SerialDto.serialize(serial) # => { ... }
|
26
26
|
```
|
27
27
|
|
28
28
|
#### Deserialize
|
29
29
|
|
30
30
|
```ruby
|
31
|
-
|
31
|
+
SerialDto.deserialize(json) # => Datory::Result
|
32
32
|
```
|
33
33
|
|
34
34
|
#### Form
|
@@ -37,9 +37,9 @@ For serialization, the `form` method is also available.
|
|
37
37
|
This prepares a `Form` object, which has a set of additional methods such as `valid?` and `invalid?`.
|
38
38
|
|
39
39
|
```ruby
|
40
|
-
form =
|
40
|
+
form = SerialDto.form(serial)
|
41
41
|
|
42
|
-
form.target # =>
|
42
|
+
form.target # => SerialDto
|
43
43
|
form.model # => { ... }
|
44
44
|
|
45
45
|
form.valid? # => true
|
@@ -51,38 +51,34 @@ form.serialize # => { ... }
|
|
51
51
|
#### Examples
|
52
52
|
|
53
53
|
```ruby
|
54
|
-
class
|
54
|
+
class SerialDto < Datory::Base
|
55
55
|
uuid :id
|
56
56
|
|
57
|
-
string :
|
58
|
-
string :
|
57
|
+
string :status
|
58
|
+
string :title
|
59
59
|
|
60
|
-
|
61
|
-
string :phone
|
62
|
-
string :website
|
60
|
+
one :poster, include: ImageDto
|
63
61
|
|
64
|
-
|
62
|
+
one :ratings, include: RatingsDto
|
65
63
|
|
66
|
-
|
67
|
-
|
64
|
+
many :countries, include: CountryDto
|
65
|
+
many :genres, include: GenreDto
|
66
|
+
many :seasons, include: SeasonDto
|
68
67
|
|
69
|
-
|
68
|
+
date :premieredOn, to: :premiered_on
|
70
69
|
end
|
71
70
|
```
|
72
71
|
|
73
72
|
```ruby
|
74
|
-
class
|
73
|
+
class SeasonDto < Datory::Base
|
75
74
|
uuid :id
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
duration :lifetime
|
84
|
-
|
85
|
-
datetime :registered_at
|
75
|
+
uuid :serial_id
|
76
|
+
|
77
|
+
integer :number
|
78
|
+
|
79
|
+
many :episodes, include: EpisodeDto
|
80
|
+
|
81
|
+
date :premiered_on
|
86
82
|
end
|
87
83
|
```
|
88
84
|
|
@@ -93,25 +89,31 @@ end
|
|
93
89
|
#### attribute
|
94
90
|
|
95
91
|
```ruby
|
96
|
-
attribute :
|
92
|
+
attribute :uuid, from: String, to: :id, as: String, format: :uuid
|
97
93
|
```
|
98
94
|
|
99
95
|
#### string
|
100
96
|
|
101
97
|
```ruby
|
102
|
-
string :
|
98
|
+
string :uuid, to: :id
|
103
99
|
```
|
104
100
|
|
105
101
|
#### integer
|
106
102
|
|
107
103
|
```ruby
|
108
|
-
integer :
|
104
|
+
integer :rating, min: 1, max: 10
|
109
105
|
```
|
110
106
|
|
111
107
|
#### float
|
112
108
|
|
113
109
|
```ruby
|
114
|
-
float :
|
110
|
+
float :rating
|
111
|
+
```
|
112
|
+
|
113
|
+
#### boolean
|
114
|
+
|
115
|
+
```ruby
|
116
|
+
boolean :default
|
115
117
|
```
|
116
118
|
|
117
119
|
### Helpers
|
@@ -129,31 +131,31 @@ uuid :id
|
|
129
131
|
It will prepare two attributes `*_cents` and `*_currency`.
|
130
132
|
|
131
133
|
```ruby
|
132
|
-
money :
|
134
|
+
money :box_office
|
133
135
|
```
|
134
136
|
|
135
137
|
#### duration
|
136
138
|
|
137
139
|
```ruby
|
138
|
-
duration :
|
140
|
+
duration :episode_duration
|
139
141
|
```
|
140
142
|
|
141
143
|
#### date
|
142
144
|
|
143
145
|
```ruby
|
144
|
-
date :
|
146
|
+
date :premiered_on
|
145
147
|
```
|
146
148
|
|
147
149
|
#### time
|
148
150
|
|
149
151
|
```ruby
|
150
|
-
time :
|
152
|
+
time :premiered_at
|
151
153
|
```
|
152
154
|
|
153
155
|
#### datetime
|
154
156
|
|
155
157
|
```ruby
|
156
|
-
|
158
|
+
time :premiered_at
|
157
159
|
```
|
158
160
|
|
159
161
|
### Nesting
|
@@ -161,13 +163,13 @@ datetime :registered_at
|
|
161
163
|
#### one
|
162
164
|
|
163
165
|
```ruby
|
164
|
-
one :
|
166
|
+
one :poster, include: ImageDto
|
165
167
|
```
|
166
168
|
|
167
169
|
#### many
|
168
170
|
|
169
171
|
```ruby
|
170
|
-
many :
|
172
|
+
many :seasons, include: SeasonDto
|
171
173
|
```
|
172
174
|
|
173
175
|
## Object information
|
@@ -175,36 +177,35 @@ many :addresses, include: UserAddressDto
|
|
175
177
|
### Info
|
176
178
|
|
177
179
|
```ruby
|
178
|
-
|
180
|
+
SerialDto.info
|
179
181
|
```
|
180
182
|
|
181
183
|
```
|
182
|
-
#<Datory::Info::Result:
|
184
|
+
#<Datory::Info::Result:0x0000000124aa7bc8 @attributes={:id=>{:from=>{:name=>:id, :type=>String, :min=>nil, :max=>nil, :consists_of=>false, :format=>:uuid}, :to=>{:name=>:id, :type=>String, :min=>nil, :max=>nil, :consists_of=>false, :format=>:uuid, :required=>true, :include=>nil}}, :status=>{:from=>{:name=>:status, :type=>String, :min=>nil, :max=>nil, :consists_of=>false, :format=>nil}, :to=>{:name=>:status, :type=>String, :min=>nil, :max=>nil, :consists_of=>false, :format=>nil, :required=>true, :include=>nil}}, :title=>{:from=>{:name=>:title, :type=>String, :min=>nil, :max=>nil, :consists_of=>false, :format=>nil}, :to=>{:name=>:title, :type=>String, :min=>nil, :max=>nil, :consists_of=>false, :format=>nil, :required=>true, :include=>nil}}, :poster=>{:from=>{:name=>:poster, :type=>Hash, :min=>nil, :max=>nil, :consists_of=>false, :format=>nil}, :to=>{:name=>:poster, :type=>[Datory::Result, Hash], :min=>nil, :max=>nil, :consists_of=>false, :format=>nil, :required=>true, :include=>Usual::Example1::Image}}, :ratings=>{:from=>{:name=>:ratings, :type=>Hash, :min=>nil, :max=>nil, :consists_of=>false, :format=>nil}, :to=>{:name=>:ratings, :type=>[Datory::Result, Hash], :min=>nil, :max=>nil, :consists_of=>false, :format=>nil, :required=>true, :include=>Usual::Example1::Ratings}}, :countries=>{:from=>{:name=>:countries, :type=>Array, :min=>nil, :max=>nil, :consists_of=>[Datory::Result, Hash], :format=>nil}, :to=>{:name=>:countries, :type=>Array, :min=>nil, :max=>nil, :consists_of=>[Datory::Result, Hash], :format=>nil, :required=>true, :include=>Usual::Example1::Country}}, :genres=>{:from=>{:name=>:genres, :type=>Array, :min=>nil, :max=>nil, :consists_of=>[Datory::Result, Hash], :format=>nil}, :to=>{:name=>:genres, :type=>Array, :min=>nil, :max=>nil, :consists_of=>[Datory::Result, Hash], :format=>nil, :required=>true, :include=>Usual::Example1::Genre}}, :seasons=>{:from=>{:name=>:seasons, :type=>Array, :min=>nil, :max=>nil, :consists_of=>[Datory::Result, Hash], :format=>nil}, :to=>{:name=>:seasons, :type=>Array, :min=>nil, :max=>nil, :consists_of=>[Datory::Result, Hash], :format=>nil, :required=>true, :include=>Usual::Example1::Season}}, :premieredOn=>{:from=>{:name=>:premieredOn, :type=>String, :min=>nil, :max=>nil, :consists_of=>false, :format=>:date}, :to=>{:name=>:premiered_on, :type=>Date, :min=>nil, :max=>nil, :consists_of=>false, :format=>nil, :required=>true, :include=>nil}}}>
|
183
185
|
```
|
184
186
|
|
185
187
|
### Describe
|
186
188
|
|
187
189
|
```ruby
|
188
|
-
|
190
|
+
SerialDto.describe
|
189
191
|
```
|
190
192
|
|
191
193
|
```
|
192
|
-
|
193
|
-
|
|
194
|
-
|
195
|
-
| Attribute
|
196
|
-
|
197
|
-
| id
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
207
|
-
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
194
|
+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
195
|
+
| SerialDto |
|
196
|
+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
197
|
+
| Attribute | From | To | As | Include |
|
198
|
+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
199
|
+
| id | String | id | String | |
|
200
|
+
| status | String | status | String | |
|
201
|
+
| title | String | title | String | |
|
202
|
+
| poster | Hash | poster | [Datory::Result, Hash] | ImageDto |
|
203
|
+
| ratings | Hash | ratings | [Datory::Result, Hash] | RatingsDto |
|
204
|
+
| countries | Array | countries | Array | CountryDto |
|
205
|
+
| genres | Array | genres | Array | GenreDto |
|
206
|
+
| seasons | Array | seasons | Array | SeasonDto |
|
207
|
+
| premieredOn | String | premiered_on | Date | |
|
208
|
+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
208
209
|
```
|
209
210
|
|
210
211
|
## Contributing
|
data/config/locales/en.yml
CHANGED
data/config/locales/ru.yml
CHANGED
@@ -47,34 +47,38 @@ module Datory
|
|
47
47
|
########################################################################
|
48
48
|
|
49
49
|
def uuid(name, **options)
|
50
|
+
options = options.slice(:to)
|
50
51
|
options = options.merge(format: :uuid)
|
51
52
|
string(name, **options)
|
52
53
|
end
|
53
54
|
|
54
55
|
def money(name, **options)
|
55
|
-
|
56
|
-
options_for_currency = options.merge(from: [Symbol, String])
|
56
|
+
options = options.slice(:to)
|
57
57
|
|
58
|
-
|
59
|
-
|
58
|
+
integer :"#{name}_cents", **options
|
59
|
+
string :"#{name}_currency", **options
|
60
60
|
end
|
61
61
|
|
62
62
|
def duration(name, **options)
|
63
|
+
options = options.slice(:to)
|
63
64
|
options = options.merge(from: String, as: ActiveSupport::Duration, format: { from: :duration })
|
64
65
|
string(name, **options)
|
65
66
|
end
|
66
67
|
|
67
68
|
def date(name, **options)
|
69
|
+
options = options.slice(:to)
|
68
70
|
options = options.merge(from: String, as: Date, format: { from: :date })
|
69
71
|
string(name, **options)
|
70
72
|
end
|
71
73
|
|
72
74
|
def time(name, **options)
|
75
|
+
options = options.slice(:to)
|
73
76
|
options = options.merge(from: String, as: Time, format: { from: :time })
|
74
77
|
string(name, **options)
|
75
78
|
end
|
76
79
|
|
77
80
|
def datetime(name, **options)
|
81
|
+
options = options.slice(:to)
|
78
82
|
options = options.merge(from: String, as: DateTime, format: { from: :datetime })
|
79
83
|
string(name, **options)
|
80
84
|
end
|
@@ -96,6 +100,11 @@ module Datory
|
|
96
100
|
attribute(name, **options)
|
97
101
|
end
|
98
102
|
|
103
|
+
def boolean(name, **options)
|
104
|
+
options = options.merge(from: [TrueClass, FalseClass])
|
105
|
+
attribute(name, **options)
|
106
|
+
end
|
107
|
+
|
99
108
|
########################################################################
|
100
109
|
|
101
110
|
def collection_of_attributes
|
@@ -3,19 +3,6 @@
|
|
3
3
|
module Datory
|
4
4
|
module Context
|
5
5
|
module Workspace
|
6
|
-
def attributes
|
7
|
-
@attributes ||= Attributes.new(
|
8
|
-
context: self,
|
9
|
-
incoming_attributes: incoming_attributes,
|
10
|
-
collection_of_attributes: collection_of_attributes
|
11
|
-
)
|
12
|
-
end
|
13
|
-
|
14
|
-
private
|
15
|
-
|
16
|
-
attr_reader :incoming_attributes,
|
17
|
-
:collection_of_attributes
|
18
|
-
|
19
6
|
def _serialize(model:, collection_of_attributes:)
|
20
7
|
serialize(
|
21
8
|
model: model,
|
data/lib/datory/service/base.rb
CHANGED
data/lib/datory/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: datory
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.0.
|
4
|
+
version: 1.0.0.rc20
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Anton Sokolov
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-05-
|
11
|
+
date: 2024-05-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -48,16 +48,16 @@ dependencies:
|
|
48
48
|
name: servactory
|
49
49
|
requirement: !ruby/object:Gem::Requirement
|
50
50
|
requirements:
|
51
|
-
- -
|
51
|
+
- - '='
|
52
52
|
- !ruby/object:Gem::Version
|
53
|
-
version: 2.
|
53
|
+
version: 2.6.0.rc2
|
54
54
|
type: :runtime
|
55
55
|
prerelease: false
|
56
56
|
version_requirements: !ruby/object:Gem::Requirement
|
57
57
|
requirements:
|
58
|
-
- -
|
58
|
+
- - '='
|
59
59
|
- !ruby/object:Gem::Version
|
60
|
-
version: 2.
|
60
|
+
version: 2.6.0.rc2
|
61
61
|
- !ruby/object:Gem::Dependency
|
62
62
|
name: terminal-table
|
63
63
|
requirement: !ruby/object:Gem::Requirement
|