u-case 2.1.1 → 2.5.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.
@@ -4,7 +4,7 @@ module Micro
4
4
  class Case
5
5
  class Safe < ::Micro::Case
6
6
  def call
7
- super
7
+ __call
8
8
  rescue => exception
9
9
  raise exception if Error::ByWrongUsage.check(exception)
10
10
 
@@ -19,7 +19,7 @@ module Micro
19
19
 
20
20
  private
21
21
 
22
- def use_case_result(use_case, result, input)
22
+ def next_use_case_result(use_case, result, input)
23
23
  begin
24
24
  instance = use_case.__new__(result, input)
25
25
  instance.call
@@ -36,8 +36,8 @@ module Micro
36
36
  Flow::Reducer.build(Array(args))
37
37
  end
38
38
 
39
- def self.flow(*args)
40
- @__flow ||= __set_flow__(Flow::Reducer, args)
39
+ def self.__flow_reducer
40
+ Flow::Reducer
41
41
  end
42
42
  end
43
43
  end
@@ -0,0 +1,19 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Micro
4
+ class Case
5
+ module Utils
6
+ def self.symbolize_hash_keys(hash)
7
+ if Kind::Of::Hash(hash).respond_to?(:transform_keys)
8
+ hash.transform_keys { |key| key.to_sym rescue key }
9
+ else
10
+ hash.each_with_object({}) do |(k, v), memo|
11
+ key = k.to_sym rescue k
12
+
13
+ memo[key] = v
14
+ end
15
+ end
16
+ end
17
+ end
18
+ end
19
+ end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Micro
4
4
  class Case
5
- VERSION = '2.1.1'.freeze
5
+ VERSION = '2.5.0'.freeze
6
6
  end
7
7
  end
@@ -7,7 +7,7 @@ module Micro
7
7
  include Micro::Attributes::Features::ActiveModelValidations
8
8
 
9
9
  def self.auto_validation_disabled?
10
- @disable_auto_validation
10
+ return @disable_auto_validation if defined?(@disable_auto_validation)
11
11
  end
12
12
 
13
13
  def self.disable_auto_validation
@@ -15,8 +15,8 @@ module Micro
15
15
  end
16
16
 
17
17
  def initialize(input)
18
- @__input = input
19
- self.attributes = input
18
+ __setup_use_case(input)
19
+
20
20
  run_validations! if respond_to?(:run_validations!, true)
21
21
  end
22
22
 
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'kind/active_model/validation'
4
+
5
+ require 'micro/case/with_activemodel_validation'
@@ -1,3 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'micro/case/with_validation'
3
+ warn 'Deprecation: "u-case/with_validation" will be deprecated in the next major release.' \
4
+ 'Please use "u-case/with_activemodel_validation" instead of it.'
5
+
6
+ require 'u-case/with_activemodel_validation'
@@ -14,20 +14,8 @@ Gem::Specification.new do |spec|
14
14
  spec.homepage = 'https://github.com/serradura/u-case'
15
15
  spec.license = 'MIT'
16
16
 
17
- # Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
18
- # to allow pushing to a single host or delete this section to allow pushing to any host.
19
- if spec.respond_to?(:metadata)
20
- # spec.metadata["allowed_push_host"] = "TODO: Set to 'http://mygemserver.com'"
21
-
22
- # spec.metadata["homepage_uri"] = spec.homepage
23
- # spec.metadata["source_code_uri"] = "TODO: Put your gem's public repo URL here."
24
- # spec.metadata["changelog_uri"] = "TODO: Put your gem's CHANGELOG.md URL here."
25
- else
26
- raise 'RubyGems 2.0 or newer is required to protect against public gem pushes.'
27
- end
17
+ raise 'RubyGems 2.0 or newer is required to protect against public gem pushes.' unless spec.respond_to?(:metadata)
28
18
 
29
- # Specify which files should be added to the gem when it is released.
30
- # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
31
19
  spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
32
20
  `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features|assets|benchmarks|comparisons|examples)/}) }
33
21
  end
@@ -37,8 +25,9 @@ Gem::Specification.new do |spec|
37
25
 
38
26
  spec.required_ruby_version = '>= 2.2.0'
39
27
 
28
+ spec.add_runtime_dependency 'kind', '~> 3.0'
40
29
  spec.add_runtime_dependency 'u-attributes', '~> 1.1'
41
30
 
42
31
  spec.add_development_dependency 'bundler'
43
- spec.add_development_dependency 'rake', '~> 10.0'
32
+ spec.add_development_dependency 'rake', '~> 13.0'
44
33
  end
metadata CHANGED
@@ -1,15 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: u-case
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.1
4
+ version: 2.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rodrigo Serradura
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-12-12 00:00:00.000000000 Z
11
+ date: 2020-06-26 00:00:00.000000000 Z
12
12
  dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: kind
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '3.0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '3.0'
13
27
  - !ruby/object:Gem::Dependency
14
28
  name: u-attributes
15
29
  requirement: !ruby/object:Gem::Requirement
@@ -44,14 +58,14 @@ dependencies:
44
58
  requirements:
45
59
  - - "~>"
46
60
  - !ruby/object:Gem::Version
47
- version: '10.0'
61
+ version: '13.0'
48
62
  type: :development
49
63
  prerelease: false
50
64
  version_requirements: !ruby/object:Gem::Requirement
51
65
  requirements:
52
66
  - - "~>"
53
67
  - !ruby/object:Gem::Version
54
- version: '10.0'
68
+ version: '13.0'
55
69
  description: Create simple and powerful use cases as objects.
56
70
  email:
57
71
  - rodrigo.serradura@gmail.com
@@ -78,9 +92,11 @@ files:
78
92
  - lib/micro/case/safe.rb
79
93
  - lib/micro/case/safe/flow.rb
80
94
  - lib/micro/case/strict.rb
95
+ - lib/micro/case/utils.rb
81
96
  - lib/micro/case/version.rb
82
- - lib/micro/case/with_validation.rb
97
+ - lib/micro/case/with_activemodel_validation.rb
83
98
  - lib/u-case.rb
99
+ - lib/u-case/with_activemodel_validation.rb
84
100
  - lib/u-case/with_validation.rb
85
101
  - test.sh
86
102
  - u-case.gemspec
@@ -103,7 +119,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
103
119
  - !ruby/object:Gem::Version
104
120
  version: '0'
105
121
  requirements: []
106
- rubygems_version: 3.0.3
122
+ rubygems_version: 3.0.6
107
123
  signing_key:
108
124
  specification_version: 4
109
125
  summary: Create simple and powerful use cases as objects.