ucasy 0.2.1 → 0.3.1

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: 29058478e94580310ea89c45c5531835040a19cbcc917692b1751320402e5347
4
- data.tar.gz: b9337d673be5c35c9b963c47c7c5ab511e1832971a6a2bc2ed04380900e4f43b
3
+ metadata.gz: e7c90b6337701466204322d4fdf2e71eac93847ce081f03242f2f8c546b5784a
4
+ data.tar.gz: fc44d55cb55eff9d475d92410de535a5b6c0635b0fa9abff0017824cfb50f427
5
5
  SHA512:
6
- metadata.gz: 2744ea8225b49381136a444e2f0a3cf400280198e3448bc0e179fe045115c73b658ba15e3f116038466ffed3ca089d2c6f5cd0ba3c7a70969635ea8b3f50f74a
7
- data.tar.gz: b99d19a8c712b1c1cfc0ddfe3692e2eba0247d98661bcfb6a17f9247872300bb4fa9213579e68ee08b237740ef84c019258bb128531acfaafdb661336f278715
6
+ metadata.gz: '09bb26e1a813e87623c03c7259ae60dad0731cec0a6377d9788fcdc4fb64d77cf037537b7f07f922aa090521ce64b3c72d09cd908fc79aca00c1ccb883adeca2'
7
+ data.tar.gz: bb98680a8ef3d2a6b76affacf522156970f277c1631d26e11003034ce6c161b3fb9976cfc1266bef05d86b018449cda3a5710cbd70942881512cda685fd5589a
data/README.md CHANGED
@@ -102,6 +102,15 @@ class AuthenticateUser < UseCaseBase
102
102
  end
103
103
  ```
104
104
 
105
+ You can filter attributes. Only `context.login` and `context.password` will be validated in example below:
106
+
107
+ ```rb
108
+ class AuthenticateUser < UseCaseBase
109
+ validate(AuthenticateUserValidation, :login, :password)
110
+ ...
111
+ end
112
+ ```
113
+
105
114
  Adds a validation
106
115
 
107
116
  ```rb
data/lib/ucasy/base.rb CHANGED
@@ -10,11 +10,12 @@ module Ucasy
10
10
  new(context).perform
11
11
  end
12
12
 
13
- def validate(validator_class)
13
+ def validate(validator_class, *validator_attribute_keys)
14
14
  @validator_class = validator_class
15
+ @validator_attribute_keys = validator_attribute_keys
15
16
  end
16
17
 
17
- attr_reader :validator_class
18
+ attr_reader :validator_class, :validator_attribute_keys
18
19
 
19
20
  def required_attributes(*attributes)
20
21
  @required_attributes = attributes
@@ -51,7 +52,7 @@ module Ucasy
51
52
  def validate!
52
53
  return if self.class.validator_class.blank?
53
54
 
54
- validator = Validators::Validate.call(self.class.validator_class, context.to_h)
55
+ validator = Validators::Validate.call(self.class.validator_class, validator_attributes)
55
56
 
56
57
  if validator.valid?
57
58
  validator.to_context.each do |key, value|
@@ -62,6 +63,12 @@ module Ucasy
62
63
  end
63
64
  end
64
65
 
66
+ def validator_attributes
67
+ return context.to_h if self.class.validator_attribute_keys.blank?
68
+
69
+ context.to_h.slice(*self.class.validator_attribute_keys)
70
+ end
71
+
65
72
  def validate_required_attributes!
66
73
  Validators::RequiredAttributes.call(context, self.class._required_attributes, self.class)
67
74
  end
data/lib/ucasy/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Ucasy
2
- VERSION = "0.2.1"
2
+ VERSION = "0.3.1"
3
3
  end
data/ucasy.gemspec CHANGED
@@ -28,4 +28,6 @@ Gem::Specification.new do |spec|
28
28
  spec.bindir = "exe"
29
29
  spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
30
30
  spec.require_paths = ["lib"]
31
+ # https://github.com/ruby/ostruct?tab=readme-ov-file#usage
32
+ spec.add_dependency "ostruct", ">= 0"
31
33
  end
metadata CHANGED
@@ -1,16 +1,28 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ucasy
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Lavenda Software
8
- autorequire:
9
8
  bindir: exe
10
9
  cert_chain: []
11
- date: 2024-10-25 00:00:00.000000000 Z
12
- dependencies: []
13
- description:
10
+ date: 2025-05-25 00:00:00.000000000 Z
11
+ dependencies:
12
+ - !ruby/object:Gem::Dependency
13
+ name: ostruct
14
+ requirement: !ruby/object:Gem::Requirement
15
+ requirements:
16
+ - - ">="
17
+ - !ruby/object:Gem::Version
18
+ version: '0'
19
+ type: :runtime
20
+ prerelease: false
21
+ version_requirements: !ruby/object:Gem::Requirement
22
+ requirements:
23
+ - - ">="
24
+ - !ruby/object:Gem::Version
25
+ version: '0'
14
26
  email:
15
27
  - lavenda@lavenda.com.br
16
28
  executables: []
@@ -45,7 +57,6 @@ metadata:
45
57
  homepage_uri: https://github.com/LavendaSoftware/ucasy
46
58
  source_code_uri: https://github.com/LavendaSoftware/ucasy/blob/main/README.md
47
59
  changelog_uri: https://github.com/LavendaSoftware/ucasy/commits/main
48
- post_install_message:
49
60
  rdoc_options: []
50
61
  require_paths:
51
62
  - lib
@@ -60,8 +71,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
60
71
  - !ruby/object:Gem::Version
61
72
  version: '0'
62
73
  requirements: []
63
- rubygems_version: 3.5.21
64
- signing_key:
74
+ rubygems_version: 3.6.4
65
75
  specification_version: 4
66
76
  summary: Ucasy is just a quick test suite setup for Rails application
67
77
  test_files: []