datory 1.0.0.rc18 → 1.0.0.rc20

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
  SHA256:
3
- metadata.gz: eb979251a3c5abfb4391233277520df3ae8d03d605cdae59166a80f1c8713b05
4
- data.tar.gz: c5fa307e7db176c5f794f1e00da679cbb03463fb4a2ae588a7ae2bdd3b1df418
3
+ metadata.gz: 7d89294162d1c0f3ba39169be07688e41bd756ce01aca92d819eadb4a2fa17c6
4
+ data.tar.gz: d5f85e0a122bc34fee393bd2fcdb5039e69c6db7500e7d3d6ff3be9db6d482a0
5
5
  SHA512:
6
- metadata.gz: a5e6e7aedec61ea373c9e4df22fe2ded364bc02e9c37b0de0782fdde2e4a52d729b468dd7adfb6252c6b7ea886ffa0d8c3d1ecf37a80620fcff0289676ddc66c
7
- data.tar.gz: 7ba8a8b89b44463649617203976bf99000a12d9e9748acc2c1d45f27bf592e6860d1839b5311b5dcae5825c12d008564b9b9eaf5f9ce12f487ff530745c7ccb0
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 (soon)
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
- user = User.find(...)
23
+ serial = Serial.find(id)
24
24
 
25
- UserDto.serialize(user) # => { ... }
25
+ SerialDto.serialize(serial) # => { ... }
26
26
  ```
27
27
 
28
28
  #### Deserialize
29
29
 
30
30
  ```ruby
31
- UserDto.deserialize(json) # => Datory::Result
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 = UserDto.form(user)
40
+ form = SerialDto.form(serial)
41
41
 
42
- form.target # => UserDto
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 UserDto < Datory::Base
54
+ class SerialDto < Datory::Base
55
55
  uuid :id
56
56
 
57
- string :firstname, to: :first_name
58
- string :lastname, to: :last_name
57
+ string :status
58
+ string :title
59
59
 
60
- string :email
61
- string :phone
62
- string :website
60
+ one :poster, include: ImageDto
63
61
 
64
- date :birthDate, to: :birth_date
62
+ one :ratings, include: RatingsDto
65
63
 
66
- one :login, include: UserLoginDto
67
- one :company, include: UserCompanyDto
64
+ many :countries, include: CountryDto
65
+ many :genres, include: GenreDto
66
+ many :seasons, include: SeasonDto
68
67
 
69
- many :addresses, include: UserAddressDto
68
+ date :premieredOn, to: :premiered_on
70
69
  end
71
70
  ```
72
71
 
73
72
  ```ruby
74
- class UserLoginDto < Datory::Base
73
+ class SeasonDto < Datory::Base
75
74
  uuid :id
76
-
77
- string :username
78
- string :password
79
-
80
- string :md5
81
- string :sha1
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 :firstname, from: String, to: :first_name, as: String
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 :first_name
98
+ string :uuid, to: :id
103
99
  ```
104
100
 
105
101
  #### integer
106
102
 
107
103
  ```ruby
108
- integer :attempts, min: 1, max: 10
104
+ integer :rating, min: 1, max: 10
109
105
  ```
110
106
 
111
107
  #### float
112
108
 
113
109
  ```ruby
114
- float :interest_rate
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 :price
134
+ money :box_office
133
135
  ```
134
136
 
135
137
  #### duration
136
138
 
137
139
  ```ruby
138
- duration :lifetime
140
+ duration :episode_duration
139
141
  ```
140
142
 
141
143
  #### date
142
144
 
143
145
  ```ruby
144
- date :birth_date
146
+ date :premiered_on
145
147
  ```
146
148
 
147
149
  #### time
148
150
 
149
151
  ```ruby
150
- time :registered_at
152
+ time :premiered_at
151
153
  ```
152
154
 
153
155
  #### datetime
154
156
 
155
157
  ```ruby
156
- datetime :registered_at
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 :company, include: UserCompanyDto
166
+ one :poster, include: ImageDto
165
167
  ```
166
168
 
167
169
  #### many
168
170
 
169
171
  ```ruby
170
- many :addresses, include: UserAddressDto
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
- UserDto.info
180
+ SerialDto.info
179
181
  ```
180
182
 
181
183
  ```
182
- #<Datory::Info::Result:0x000000011eecd7d0 @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}}, :firstname=>{:from=>{:name=>:firstname, :type=>String, :min=>nil, :max=>nil, :consists_of=>false, :format=>nil}, :to=>{:name=>:first_name, :type=>String, :min=>nil, :max=>nil, :consists_of=>false, :format=>nil, :required=>true, :include=>nil}}, :lastname=>{:from=>{:name=>:lastname, :type=>String, :min=>nil, :max=>nil, :consists_of=>false, :format=>nil}, :to=>{:name=>:last_name, :type=>String, :min=>nil, :max=>nil, :consists_of=>false, :format=>nil, :required=>true, :include=>nil}}, :email=>{:from=>{:name=>:email, :type=>String, :min=>nil, :max=>nil, :consists_of=>false, :format=>nil}, :to=>{:name=>:email, :type=>String, :min=>nil, :max=>nil, :consists_of=>false, :format=>nil, :required=>true, :include=>nil}}, :phone=>{:from=>{:name=>:phone, :type=>String, :min=>nil, :max=>nil, :consists_of=>false, :format=>nil}, :to=>{:name=>:phone, :type=>String, :min=>nil, :max=>nil, :consists_of=>false, :format=>nil, :required=>true, :include=>nil}}, :website=>{:from=>{:name=>:website, :type=>String, :min=>nil, :max=>nil, :consists_of=>false, :format=>nil}, :to=>{:name=>:website, :type=>String, :min=>nil, :max=>nil, :consists_of=>false, :format=>nil, :required=>true, :include=>nil}}, :birthDate=>{:from=>{:name=>:birthDate, :type=>String, :min=>nil, :max=>nil, :consists_of=>false, :format=>:date}, :to=>{:name=>:birth_date, :type=>Date, :min=>nil, :max=>nil, :consists_of=>false, :format=>nil, :required=>true, :include=>nil}}, :login=>{:from=>{:name=>:login, :type=>Hash, :min=>nil, :max=>nil, :consists_of=>false, :format=>nil}, :to=>{:name=>:login, :type=>[Datory::Result, Hash], :min=>nil, :max=>nil, :consists_of=>false, :format=>nil, :required=>true, :include=>Usual::Example1::UserLogin}}, :company=>{:from=>{:name=>:company, :type=>Hash, :min=>nil, :max=>nil, :consists_of=>false, :format=>nil}, :to=>{:name=>:company, :type=>[Datory::Result, Hash], :min=>nil, :max=>nil, :consists_of=>false, :format=>nil, :required=>true, :include=>Usual::Example1::UserCompany}}, :addresses=>{:from=>{:name=>:addresses, :type=>Array, :min=>nil, :max=>nil, :consists_of=>[Datory::Result, Hash], :format=>nil}, :to=>{:name=>:addresses, :type=>Array, :min=>nil, :max=>nil, :consists_of=>[Datory::Result, Hash], :format=>nil, :required=>true, :include=>Usual::Example1::UserAddress}}}>
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
- UserDto.describe
190
+ SerialDto.describe
189
191
  ```
190
192
 
191
193
  ```
192
- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
193
- | UserDto |
194
- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
195
- | Attribute | From | To | As | Include |
196
- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
197
- | id | String | id | String | |
198
- | firstname | String | first_name | String | |
199
- | lastname | String | last_name | String | |
200
- | email | String | email | String | |
201
- | phone | String | phone | String | |
202
- | website | String | website | String | |
203
- | birthDate | String | birth_date | Date | |
204
- | login | Hash | login | [Datory::Result, Hash] | Usual::Example1::UserLogin |
205
- | company | Hash | company | [Datory::Result, Hash] | Usual::Example1::UserCompany |
206
- | addresses | Array | addresses | Array | Usual::Example1::UserAddress |
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
@@ -1,5 +1,5 @@
1
1
  en:
2
- servactory:
2
+ datory:
3
3
  common:
4
4
  undefined_method:
5
5
  missing_name: "[%{service_class_name}] %{error_text}"
@@ -1,5 +1,5 @@
1
1
  ru:
2
- servactory:
2
+ datory:
3
3
  common:
4
4
  undefined_method:
5
5
  missing_name: "[%{service_class_name}] %{error_text}"
@@ -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
- options_for_cents = options.merge(from: Integer)
56
- options_for_currency = options.merge(from: [Symbol, String])
56
+ options = options.slice(:to)
57
57
 
58
- attribute(:"#{name}_cents", **options_for_cents)
59
- attribute(:"#{name}_currency", **options_for_currency)
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,
@@ -26,6 +26,8 @@ module Datory
26
26
  Servactory::ToolKit::DynamicOptions::Max.use
27
27
  ]
28
28
 
29
+ i18n_root_key :datory
30
+
29
31
  predicate_methods_enabled false
30
32
  end
31
33
  end
@@ -5,7 +5,7 @@ module Datory
5
5
  MAJOR = 1
6
6
  MINOR = 0
7
7
  PATCH = 0
8
- PRE = "rc18"
8
+ PRE = "rc20"
9
9
 
10
10
  STRING = [MAJOR, MINOR, PATCH, PRE].compact.join(".")
11
11
  end
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.rc18
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-01 00:00:00.000000000 Z
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.5.1
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.5.1
60
+ version: 2.6.0.rc2
61
61
  - !ruby/object:Gem::Dependency
62
62
  name: terminal-table
63
63
  requirement: !ruby/object:Gem::Requirement