muina 0.2.7 → 0.2.8

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: e332fc84025e98889254f51b55415027318beded22c686e3b7d77df43de9fc07
4
- data.tar.gz: 2341f1c5eceef5625b93a56f4e152e1eeb641e946611d484e3a9f3bab7103f5d
3
+ metadata.gz: 406f36585e9a83b4436c4d055ad66e3c5387f4a9102cc5e441999379625fab21
4
+ data.tar.gz: 11feb70f115ddfa6b68357c70e3bf38727dc1fac02d18540e1f2ebd56ff46024
5
5
  SHA512:
6
- metadata.gz: 1093293b6f0d073e1e8caa54929215fcb04c20906e18db3db6467596d245db9dbff1b4d7bc9f3e5ecb763e0344d41873d6588e7b597459c56c5e2b896bf3560a
7
- data.tar.gz: 2c2ca8dcf28eaf9531e84dbdb8a45c13489ddd04488491127436d4650ff4e32e154e160f9b91f9a82d383892b0719a5b965b403a03672ee95d43071148ce9505
6
+ metadata.gz: 52000f4ca1c38ddbf38ca826ed94d295d6119d00c40851fdd311ae6d3c1bb6fee42d5dd58f3e1a8b937b4eb0f1bf373949ded1d7ade0f88ea2c005ee38fc4b04
7
+ data.tar.gz: ed926845c343654537e5bb2078b1a28911fbfad27af85b7df2e4ac11c5539ecc8234357cfb234ec1e21c832a2dba44bc99373535138071e8f2bd7f71a94e3566
data/.rubocop.yml CHANGED
@@ -92,6 +92,9 @@ Sorbet/StrictSigil:
92
92
  Style/Alias:
93
93
  EnforcedStyle: prefer_alias_method
94
94
 
95
+ Style/AccessorGrouping:
96
+ Enabled: false
97
+
95
98
  Style/ArrayCoercion:
96
99
  Safe: false
97
100
  Enabled: true
@@ -121,6 +124,12 @@ Style/DocumentationMethod:
121
124
  Style/EmptyCaseCondition:
122
125
  Enabled: false
123
126
 
127
+ Style/GuardClause:
128
+ Enabled: false
129
+
130
+ Style/IfUnlessModifier:
131
+ Enabled: false
132
+
124
133
  Style/ImplicitRuntimeError:
125
134
  Enabled: true
126
135
 
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- muina (0.2.7)
4
+ muina (0.2.8)
5
5
  actionpack
6
6
  sorbet-rails
7
7
  sorbet-runtime
@@ -86,8 +86,8 @@ GEM
86
86
  i18n (1.8.10)
87
87
  concurrent-ruby (~> 1.0)
88
88
  io-console (0.5.9)
89
- irb (1.3.6)
90
- reline (>= 0.2.5)
89
+ irb (1.3.7)
90
+ reline (>= 0.2.7)
91
91
  lefthook (0.7.6)
92
92
  listen (3.6.0)
93
93
  rb-fsevent (~> 0.10, >= 0.10.3)
@@ -134,7 +134,7 @@ GEM
134
134
  rails-dom-testing (2.0.3)
135
135
  activesupport (>= 4.2.0)
136
136
  nokogiri (>= 1.6)
137
- rails-html-sanitizer (1.3.0)
137
+ rails-html-sanitizer (1.4.1)
138
138
  loofah (~> 2.3)
139
139
  rainbow (3.0.0)
140
140
  rake (13.0.6)
@@ -142,7 +142,7 @@ GEM
142
142
  rb-inotify (0.10.1)
143
143
  ffi (~> 1.0)
144
144
  regexp_parser (2.1.1)
145
- reline (0.2.6)
145
+ reline (0.2.7)
146
146
  io-console (~> 0.5)
147
147
  rexml (3.2.5)
148
148
  rspec (3.10.0)
@@ -158,18 +158,18 @@ GEM
158
158
  diff-lcs (>= 1.2.0, < 2.0)
159
159
  rspec-support (~> 3.10.0)
160
160
  rspec-support (3.10.2)
161
- rubocop (1.18.4)
161
+ rubocop (1.19.0)
162
162
  parallel (~> 1.10)
163
163
  parser (>= 3.0.0.0)
164
164
  rainbow (>= 2.2.2, < 4.0)
165
165
  regexp_parser (>= 1.8, < 3.0)
166
166
  rexml
167
- rubocop-ast (>= 1.8.0, < 2.0)
167
+ rubocop-ast (>= 1.9.1, < 2.0)
168
168
  ruby-progressbar (~> 1.7)
169
169
  unicode-display_width (>= 1.4.0, < 3.0)
170
- rubocop-ast (1.9.1)
170
+ rubocop-ast (1.10.0)
171
171
  parser (>= 3.0.1.1)
172
- rubocop-performance (1.11.4)
172
+ rubocop-performance (1.11.5)
173
173
  rubocop (>= 1.7.0, < 2.0)
174
174
  rubocop-ast (>= 0.4.0)
175
175
  rubocop-rake (0.6.0)
@@ -191,8 +191,8 @@ GEM
191
191
  simplecov_json_formatter (~> 0.1)
192
192
  simplecov-html (0.12.3)
193
193
  simplecov_json_formatter (0.1.3)
194
- sorbet (0.5.9030)
195
- sorbet-static (= 0.5.9030)
194
+ sorbet (0.5.9048)
195
+ sorbet-static (= 0.5.9048)
196
196
  sorbet-coerce (0.5.0)
197
197
  polyfill (~> 1.8)
198
198
  safe_type (~> 1.1, >= 1.1.1)
@@ -203,9 +203,9 @@ GEM
203
203
  parser (>= 2.7)
204
204
  sorbet-coerce (>= 0.2.6)
205
205
  sorbet-runtime (>= 0.5)
206
- sorbet-runtime (0.5.9030)
207
- sorbet-static (0.5.9030-universal-darwin-20)
208
- sorbet-static (0.5.9030-x86_64-linux)
206
+ sorbet-runtime (0.5.9048)
207
+ sorbet-static (0.5.9048-universal-darwin-20)
208
+ sorbet-static (0.5.9048-x86_64-linux)
209
209
  sorbet-struct-comparable (1.1.0)
210
210
  sorbet-runtime (>= 0.5)
211
211
  spoom (1.1.2)
@@ -6,13 +6,15 @@ module Muina
6
6
  class Step < Value
7
7
  # Commands are meant to run code with side effects and return no value.
8
8
  class Command < self
9
- def call(action = Object.new)
9
+ def call(action = Object.new) # rubocop:disable Metrics/MethodLength
10
10
  return if action.instance_variable_get(:@__failure__)
11
11
 
12
12
  case result = Muina::Result() { action.instance_eval(&step) }
13
13
  when Muina::Result::Success then success
14
14
  when Muina::Result::Failure then failure(action, result)
15
- else nil
15
+ # :nocov:
16
+ else T.absurd(result)
17
+ # :nocov:
16
18
  end
17
19
  end
18
20
 
@@ -8,16 +8,20 @@ module Muina
8
8
  class Query < self
9
9
  const :name, Symbol
10
10
 
11
- def call(action = Object.new)
11
+ def call(action = Object.new) # rubocop:disable Metrics/MethodLength
12
12
  return if action.instance_variable_get(:@__failure__)
13
13
 
14
14
  case result = Muina::Result() { action.instance_eval(&step) }
15
15
  when Muina::Result::Success then success(action, result)
16
16
  when Muina::Result::Failure then failure(action, result)
17
- else nil
17
+ # :nocov:
18
+ else T.absurd(result)
19
+ # :nocov:
18
20
  end
19
21
  end
20
22
 
23
+ private
24
+
21
25
  def success(action, result)
22
26
  action.instance_variable_set("@#{name}", result.value!)
23
27
  end
@@ -6,7 +6,9 @@ module Muina
6
6
  class Step < Value
7
7
  # Final step of a successful Action
8
8
  class Result < self
9
+ # Eval the step and save the result
9
10
  class Caller
11
+ # Save result on succesful side
10
12
  class Successful < self
11
13
  def initialize(action, result)
12
14
  super()
@@ -19,6 +21,7 @@ module Muina
19
21
  end
20
22
  end
21
23
 
24
+ # Save result on failure side
22
25
  class Failed < self
23
26
  def initialize(action, result)
24
27
  super()
@@ -35,7 +38,9 @@ module Muina
35
38
  case result = Muina::Result() { action.instance_eval(&step) }
36
39
  when Muina::Result::Success then Caller::Successful.new(action, result)
37
40
  when Muina::Result::Failure then Caller::Failed.new(action, result)
41
+ # :nocov:
38
42
  else T.absurd(result)
43
+ # :nocov:
39
44
  end
40
45
  end
41
46
  end
@@ -0,0 +1,93 @@
1
+ # typed: strict
2
+ # frozen_string_literal: true
3
+
4
+ module Muina
5
+ # Method deprecator
6
+ class Deprecator
7
+ class Error < StandardError; end
8
+
9
+ @instances = T.let(Hash.new { |h, k| h[k] = {} }, T::Hash[String, T.untyped])
10
+
11
+ class << self
12
+ sig { returns(T::Hash[String, T.untyped]) }
13
+ attr_reader :instances
14
+ end
15
+
16
+ sig { returns(T::Hash[String, T.untyped]) }
17
+ def self.renew_instances
18
+ @instances = Hash.new { |h, k| h[k] = {} }
19
+ end
20
+
21
+ sig { params(name: String).void }
22
+ def self.deactivate(name)
23
+ instances[name][:raise] = false
24
+ end
25
+
26
+ sig { params(name: String).void }
27
+ def self.activate(name)
28
+ instances[name][:raise] = true
29
+ end
30
+
31
+ sig { params(name: String).returns(T.nilable(T::Boolean)) }
32
+ def self.raise?(name)
33
+ instances[name][:raise]
34
+ end
35
+
36
+ sig { params(old: String, new: T.nilable(String), logger: T.untyped, raise: T::Boolean).void }
37
+ def self.call(old:, new: nil, logger: default_logger, raise: false)
38
+ new(new: new, old: old, logger: logger, raise: raise).perform
39
+ end
40
+
41
+ sig { returns(Logger) }
42
+ def self.default_logger
43
+ Logger.new($stdout)
44
+ end
45
+
46
+ sig { params(old: T.untyped, logger: T.untyped, new: T.untyped, raise: T.untyped).void }
47
+ def initialize(old:, logger:, new: nil, raise: false)
48
+ @new = T.let(new, T.nilable(String))
49
+ @old = T.let(old, String)
50
+ @logger = T.let(logger, T.untyped)
51
+ @raise = T.let(raise, T::Boolean)
52
+ end
53
+
54
+ sig { returns(T.nilable(String)) }
55
+ attr_reader :new
56
+
57
+ sig { returns(String) }
58
+ attr_reader :old
59
+
60
+ sig { returns(T.untyped) }
61
+ attr_reader :logger
62
+
63
+ sig { returns(T::Boolean) }
64
+ attr_reader :raise
65
+
66
+ sig { returns(T::Boolean) }
67
+ def raise?() @raise end # rubocop:disable Style/SingleLineMethods
68
+
69
+ sig { returns(NilClass) }
70
+ def perform # rubocop:disable Metrics/MethodLength
71
+ logger.warn message
72
+ case conf = self.class.raise?(old)
73
+ when nil then Kernel.raise Muina::Deprecator::Error, message if raise?
74
+ when true then Kernel.raise Muina::Deprecator::Error, message
75
+ when false then nil
76
+ # :nocov:
77
+ else T.absurd(conf)
78
+ # :nocov:
79
+ end
80
+ end
81
+
82
+ private
83
+
84
+ sig { returns(String) }
85
+ def message
86
+ if new
87
+ "Method: #{old} has been DEPRECATED, please use #{new} instead"
88
+ else
89
+ "Method: #{old} has been DEPRECATED with no replacement"
90
+ end
91
+ end
92
+ end
93
+ end
@@ -0,0 +1,20 @@
1
+ # typed: strict
2
+ # frozen_string_literal: true
3
+
4
+ module Muina
5
+ # Immutable Value Object parent class
6
+ class Entity
7
+ include T::Props
8
+ include T::Props::Constructor
9
+
10
+ const :id, Integer
11
+
12
+ def serialize
13
+ self.class.props.keys.to_h { |prop| [prop, __send__(prop)] }
14
+ end
15
+
16
+ def with(hash = {})
17
+ self.class.new(serialize.merge(hash))
18
+ end
19
+ end
20
+ end
data/lib/muina/service.rb CHANGED
@@ -8,18 +8,6 @@ module Muina
8
8
  include T::Props::Constructor
9
9
  include PrivateCreation
10
10
 
11
- def self.inherited(subklass) # rubocop:disable Metrics/MethodLength
12
- super
13
- # :nocov:
14
- TracePoint.trace(:end) do |t|
15
- if subklass < self && !subklass.instance_methods(false).include?(:perform) # rubocop:disable Style/MissingElse
16
- Logger.new($stdout).fatal "#{subklass}#perfrom is not implemented"
17
- end
18
- t.disable
19
- end
20
- # :nocov:
21
- end
22
-
23
11
  def self.call(hash = {})
24
12
  new(hash).__send__(:perform)
25
13
  end
data/lib/muina/value.rb CHANGED
@@ -12,5 +12,13 @@ module Muina
12
12
  super(hash)
13
13
  freeze
14
14
  end
15
+
16
+ def serialize
17
+ self.class.props.keys.to_h { |prop| [prop, __send__(prop)] }
18
+ end
19
+
20
+ def with(hash = {})
21
+ self.class.new(serialize.merge(hash))
22
+ end
15
23
  end
16
24
  end
data/lib/muina/version.rb CHANGED
@@ -2,6 +2,6 @@
2
2
  # frozen_string_literal: true
3
3
 
4
4
  module Muina
5
- VERSION = '0.2.7'
5
+ VERSION = '0.2.8'
6
6
  public_constant :VERSION
7
7
  end
data/rbi/muina.rbi CHANGED
@@ -25,7 +25,7 @@ module Muina
25
25
  sig { params(error: T.untyped).returns(Muina::Result::Failure) }
26
26
  def self.Failure(error); end
27
27
 
28
- sig { params(blk: T.untyped).returns(Muina::Result) }
28
+ sig { params(blk: T.untyped).returns(T.any(Muina::Result::Success, Muina::Result::Failure)) }
29
29
  def self.Result(&blk); end
30
30
 
31
31
  class Action
@@ -117,6 +117,38 @@ module Muina
117
117
  end
118
118
 
119
119
  class Result < self
120
+ class Caller
121
+ class Successful
122
+ sig { params(action: T.untyped, result: T.untyped).void }
123
+ def initialize(action, result)
124
+ @action = T.let(@action, Muina::Action)
125
+ @result = T.let(@result, Muina::Result)
126
+ end
127
+
128
+ sig { void }
129
+ def call; end
130
+ end
131
+
132
+ class Failed
133
+ sig { params(action: T.untyped, result: T.untyped).void }
134
+ def initialize(action, result)
135
+ @action = T.let(@action, Muina::Action)
136
+ @result = T.let(@result, Muina::Result)
137
+ end
138
+
139
+ sig { void }
140
+ def call; end
141
+ end
142
+
143
+ sig do
144
+ params(action: T.untyped, step: T.untyped)
145
+ .returns(
146
+ T.any(Muina::Action::Step::Result::Caller::Successful, Muina::Action::Step::Result::Caller::Failed)
147
+ )
148
+ end
149
+ def self.for(action, step); end
150
+ end
151
+
120
152
  sig { params(action: T.untyped).void }
121
153
  def call(action); end
122
154
 
@@ -131,6 +163,14 @@ module Muina
131
163
  end
132
164
  end
133
165
 
166
+ class Entity
167
+ sig { returns(Muina::SymbolHash) }
168
+ def serialize; end
169
+
170
+ sig { params(hash: SymbolHash).returns(Muina::Entity) }
171
+ def with(hash); end
172
+ end
173
+
134
174
  class Params
135
175
  include T::Props
136
176
  include T::Props::Constructor
@@ -237,9 +277,6 @@ module Muina
237
277
  include T::Props::Constructor
238
278
  include PrivateCreation
239
279
 
240
- sig { params(subklass: Class).void }
241
- def self.inherited(subklass); end
242
-
243
280
  sig { params(hash: SymbolHash).returns(T.untyped) }
244
281
  def self.call(hash = {}); end
245
282
  class << self; alias_method :[], :call; end
@@ -264,5 +301,11 @@ module Muina
264
301
 
265
302
  sig { params(hash: SymbolHash).void }
266
303
  def initialize(hash = {}); end
304
+
305
+ sig { returns(Muina::SymbolHash) }
306
+ def serialize; end
307
+
308
+ sig { params(hash: SymbolHash).returns(Muina::Value) }
309
+ def with(hash); end
267
310
  end
268
311
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: muina
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.7
4
+ version: 0.2.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - vaporyhumo
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-08-11 00:00:00.000000000 Z
11
+ date: 2021-08-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: actionpack
@@ -130,6 +130,8 @@ files:
130
130
  - lib/muina/action/step/result.rb
131
131
  - lib/muina/any.rb
132
132
  - lib/muina/classes.rb
133
+ - lib/muina/deprecator.rb
134
+ - lib/muina/entity.rb
133
135
  - lib/muina/module.rb
134
136
  - lib/muina/parameters.rb
135
137
  - lib/muina/params.rb