servitium 1.3.0 → 1.3.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: fa6706af0892ab90d3f327cac1d97b5e6ed7b0c6e9fa6fa06484058d9733d78a
4
- data.tar.gz: 0bf72aac0656de3572940cc6a40dbe3952eb406f7895a002994db1ad7987dc84
3
+ metadata.gz: d69acb44ae4a39d61e34493dd4c295bf9c202e35757e5c11235cb988e81fa4c2
4
+ data.tar.gz: 4c17667332f963b0686a71654ce944af6ca021bc57a1a4b25b094fa8c94c00a6
5
5
  SHA512:
6
- metadata.gz: 989ad0d166962653b196c3bdee84878b6f7143c8c190a2cddb9f635d65bb5f64e9555978ebc84a54d6f848f930b678f3b6e089cbceef9f60c52c62a408527d0a
7
- data.tar.gz: aba51072b58ada34593d1d368f18e13d708f72d5f5cc5567cf4b1602d6750f7f52346ac4303aa3d8f7074a35a014875da8dc60f970c76a24ed06d57a70c43bf2
6
+ metadata.gz: 80181d971d20a9686faf0882c69ab8e0c1c17af829c444267b41ce62cd0d63e7b7594722999072042adebfe70c9e0124db6349f537540229f423f50c1006b339
7
+ data.tar.gz: 9b06e3e670be995a0cbb8d47fc22b5805117ca7802d35514b1a8379c7609ae3e25606517f6db8915ded834713fceb4c97c44410f42442ab57bb17e13a314e07c
data/.rubocop.yml CHANGED
@@ -7,6 +7,7 @@ inherit_gem:
7
7
  standard: config/base.yml
8
8
 
9
9
  AllCops:
10
+ TargetRubyVersion: 3.3
10
11
  NewCops: enable
11
12
  Exclude:
12
13
  - node_modules/**/*
data/Gemfile CHANGED
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- source 'https://rubygems.org'
3
+ source "https://rubygems.org"
4
4
  git_source(:entdec) { |repo_name| "git@github.com:#{repo_name}.git" }
5
5
 
6
6
  # Specify your gem's dependencies in servitium.gemspec
data/Rakefile CHANGED
@@ -1,14 +1,14 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'bundler/gem_tasks'
4
- require 'rake/testtask'
3
+ require "bundler/gem_tasks"
4
+ require "rake/testtask"
5
5
 
6
6
  Rake::TestTask.new(:test) do |t|
7
- t.libs << 'test'
8
- t.libs << 'lib'
9
- t.test_files = FileList['test/**/*_test.rb']
7
+ t.libs << "test"
8
+ t.libs << "lib"
9
+ t.test_files = FileList["test/**/*_test.rb"]
10
10
  end
11
11
 
12
- Rake.add_rakelib 'lib/tasks'
12
+ Rake.add_rakelib "lib/tasks"
13
13
 
14
14
  task default: :test
@@ -1,17 +1,17 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'rails/generators'
3
+ require "rails/generators"
4
4
 
5
5
  module Servitium
6
6
  class ServiceGenerator < ::Rails::Generators::NamedBase
7
- desc 'Generates a service and context'
7
+ desc "Generates a service and context"
8
8
 
9
- source_root File.expand_path('templates', __dir__)
9
+ source_root File.expand_path("templates", __dir__)
10
10
 
11
11
  def copy_initializer_file
12
- template 'service.rb', "app/services/#{file_name}_service.rb"
13
- template 'context.rb', "app/services/#{file_name}_context.rb"
14
- template 'service_test.rb', "test/services/#{file_name}_service_test.rb"
12
+ template "service.rb", "app/services/#{file_name}_service.rb"
13
+ template "context.rb", "app/services/#{file_name}_context.rb"
14
+ template "service_test.rb", "test/services/#{file_name}_service_test.rb"
15
15
  end
16
16
  end
17
17
  end
@@ -14,10 +14,10 @@ module Servitium
14
14
  @capture_exceptions = nil unless defined?(@capture_exceptions)
15
15
  if @capture_exceptions.nil?
16
16
  @capture_exceptions = if superclass < Servitium::Service
17
- superclass.capture_exceptions
18
- else
19
- false
20
- end
17
+ superclass.capture_exceptions
18
+ else
19
+ false
20
+ end
21
21
  end
22
22
  @capture_exceptions
23
23
  end
@@ -3,8 +3,7 @@
3
3
  module Servitium
4
4
  class Configuration
5
5
  attr_accessor :bg_jobs_platform
6
- attr_writer :logger,
7
-
6
+ attr_writer :logger
8
7
  def initialize
9
8
  @logger = Logger.new(STDOUT)
10
9
  @logger.level = Logger::INFO
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'active_model/naming'
4
- require 'active_model/translation'
3
+ require "active_model/naming"
4
+ require "active_model/translation"
5
5
 
6
6
  module Servitium
7
7
  class Context
@@ -18,9 +18,9 @@ module Servitium
18
18
  define_callbacks :perform
19
19
 
20
20
  def initialize(*args)
21
- @success = true
22
- @called = false
23
- @errors = ActiveModel::Errors.new(self)
21
+ @success = true
22
+ @called = false
23
+ @errors = ActiveModel::Errors.new(self)
24
24
  @subcontexts = {}
25
25
 
26
26
  run_callbacks :initialize do
@@ -36,8 +36,8 @@ module Servitium
36
36
  !success?
37
37
  end
38
38
 
39
- alias fail? failure?
40
- alias failed? failure?
39
+ alias_method :fail?, :failure?
40
+ alias_method :failed?, :failure?
41
41
 
42
42
  def fail!(attr, message = :invalid, options = {})
43
43
  @success = false
@@ -6,7 +6,7 @@ module Servitium
6
6
 
7
7
  def initialize(context)
8
8
  @context = context
9
- super(context.errors.full_messages.join(', '))
9
+ super(context.errors.full_messages.join(", "))
10
10
  end
11
11
  end
12
12
  end
@@ -25,14 +25,14 @@ module Servitium
25
25
 
26
26
  def inspect
27
27
  message = super
28
- message += " (success: #{success?}, valid: #{@errors.size.zero?}, errors: #{@errors.full_messages.join(', ')})"
28
+ message += " (success: #{success?}, valid: #{@errors.size.zero?}, errors: #{@errors.full_messages.join(", ")})"
29
29
  message
30
30
  end
31
31
 
32
32
  remove_method :model_name
33
33
 
34
34
  def model_name
35
- @model_name ||= ActiveModel::Name.new(self.class, nil, self.class.name.gsub('Context', ''))
35
+ @model_name ||= ActiveModel::Name.new(self.class, nil, self.class.name.gsub("Context", ""))
36
36
  end
37
37
 
38
38
  def id
@@ -53,13 +53,14 @@ module Servitium
53
53
  end.to_h
54
54
  end
55
55
 
56
- def _destroy; end
56
+ def _destroy
57
+ end
57
58
 
58
59
  private
59
60
 
60
61
  def validate_subcontexts
61
62
  @subcontexts.each do |key, value|
62
- errors.add(key, 'invalid') unless [*value].find_all { |v| v.respond_to?(:invalid?) && v.invalid? }.empty?
63
+ errors.add(key, "invalid") unless [*value].find_all { |v| v.respond_to?(:invalid?) && v.invalid? }.empty?
63
64
  end
64
65
  end
65
66
 
@@ -6,14 +6,14 @@ module Servitium
6
6
  @service_scope ||= nil
7
7
 
8
8
  unless @service_scope.present?
9
- parts = (is_a?(Class) ? self : self.class).to_s.underscore.gsub('/', '.').split('.')
10
- parts[-1] = "#{parts.last.gsub('_service', '').pluralize}.service" if parts.last.end_with?('_service')
11
- parts[-1] = "#{parts.last.gsub('_context', '').pluralize}.context" if parts.last.end_with?('_context')
12
- @service_scope = parts.compact.join('.')
9
+ parts = (is_a?(Class) ? self : self.class).to_s.underscore.tr("/", ".").split(".")
10
+ parts[-1] = "#{parts.last.gsub("_service", "").pluralize}.service" if parts.last.end_with?("_service")
11
+ parts[-1] = "#{parts.last.gsub("_context", "").pluralize}.context" if parts.last.end_with?("_context")
12
+ @service_scope = parts.compact.join(".")
13
13
  end
14
14
 
15
- options = { scope: @service_scope }
16
- options[:default] = ::I18n.t(key) unless key.start_with?('.')
15
+ options = {scope: @service_scope}
16
+ options[:default] = ::I18n.t(key) unless key.start_with?(".")
17
17
 
18
18
  ::I18n.t(key, **options.merge(passed_options))
19
19
  end
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'rails'
3
+ require "rails"
4
4
 
5
5
  module Servitium
6
6
  module Rails
@@ -1,4 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'servitium'
4
- require 'servitium/rails/railtie'
3
+ require "servitium"
4
+ require "servitium/rails/railtie"
@@ -10,9 +10,9 @@ module Servitium
10
10
  @validation_context = validation_context
11
11
  end
12
12
 
13
- def attribute(name, *args)
13
+ def attribute(name, *)
14
14
  store << name.to_s
15
- context.send(:attribute, name, *args)
15
+ context.send(:attribute, name, *)
16
16
  end
17
17
 
18
18
  def validates(name, options = {})
@@ -20,9 +20,9 @@ module Servitium
20
20
  context.send(:validates, name, options)
21
21
  end
22
22
 
23
- def validate(name, options = {}, &block)
23
+ def validate(name, options = {}, &)
24
24
  options[:on] ||= validation_context if validation_context
25
- context.send(:validate, name, options, &block)
25
+ context.send(:validate, name, options, &)
26
26
  end
27
27
 
28
28
  def call(block)
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require_relative 'transactional_mixin'
4
- require_relative 'capture_exceptions_mixin'
3
+ require_relative "transactional_mixin"
4
+ require_relative "capture_exceptions_mixin"
5
5
 
6
6
  module Servitium
7
7
  class Service
@@ -12,7 +12,7 @@ module Servitium
12
12
 
13
13
  attr_reader :context, :raise_on_error
14
14
 
15
- alias ctx context
15
+ alias_method :ctx, :context
16
16
 
17
17
  define_callbacks :commit
18
18
  define_callbacks :perform
@@ -63,7 +63,7 @@ module Servitium
63
63
  send(@command)
64
64
  rescue Servitium::ContextFailure => e
65
65
  raise_if_needed(e)
66
- rescue StandardError => e
66
+ rescue => e
67
67
  # If capture exceptions is true, eat the exception and set the context errors.
68
68
  raise unless capture_exceptions
69
69
 
@@ -88,7 +88,7 @@ module Servitium
88
88
  if e
89
89
  raise e
90
90
  elsif context.errors.present?
91
- errors = context.errors.full_messages.join(', ')
91
+ errors = context.errors.full_messages.join(", ")
92
92
  log :error, "raising: #{errors}"
93
93
  raise StandardError, errors
94
94
  end
@@ -121,17 +121,17 @@ module Servitium
121
121
  end
122
122
 
123
123
  class << self
124
- def perform_async(*args)
125
- perform_later(*args)
124
+ def perform_async(*)
125
+ perform_later(*)
126
126
  end
127
127
 
128
- def perform_sync(*args)
129
- perform(*args)
128
+ def perform_sync(*)
129
+ perform(*)
130
130
  end
131
131
 
132
132
  # Main point of entry for services, will raise in case of errors
133
- def perform!(*args)
134
- inst = new(*args)
133
+ def perform!(*)
134
+ inst = new(*)
135
135
 
136
136
  begin
137
137
  inst.context.validate!(:in) if inst.context.class.inbound_scope_used
@@ -148,13 +148,13 @@ module Servitium
148
148
  end
149
149
 
150
150
  # Main point of entry for services
151
- def perform(*args)
152
- call(*args).context
151
+ def perform(*)
152
+ call(*).context
153
153
  end
154
154
 
155
155
  # Call the service returning the service instance
156
- def call(*args)
157
- inst = new(*args)
156
+ def call(*)
157
+ inst = new(*)
158
158
  valid_in = inst.context.valid?
159
159
  valid_in &&= inst.context.valid?(:in) if inst.context.class.inbound_scope_used
160
160
  if valid_in
@@ -170,8 +170,8 @@ module Servitium
170
170
  end
171
171
 
172
172
  # Perform this service async
173
- def perform_later(*args)
174
- inst = new(*args)
173
+ def perform_later(*)
174
+ inst = new(*)
175
175
  valid_in = inst.context.valid?
176
176
  valid_in &&= inst.context.valid?(:in) if inst.context.class.inbound_scope_used
177
177
 
@@ -220,44 +220,44 @@ module Servitium
220
220
  end
221
221
 
222
222
  def queue_name
223
- 'default'
223
+ "default"
224
224
  end
225
225
 
226
226
  # Callbacks
227
- def after_commit(*filters, &block)
228
- set_callback(:commit, :after, *filters, &block)
227
+ def after_commit(*filters, &)
228
+ set_callback(:commit, :after, *filters, &)
229
229
  end
230
230
 
231
- def before_perform(*filters, &block)
232
- set_callback(:perform, :before, *filters, &block)
231
+ def before_perform(*filters, &)
232
+ set_callback(:perform, :before, *filters, &)
233
233
  end
234
234
 
235
- def around_perform(*filters, &block)
236
- set_callback(:perform, :around, *filters, &block)
235
+ def around_perform(*filters, &)
236
+ set_callback(:perform, :around, *filters, &)
237
237
  end
238
238
 
239
- def after_perform(*filters, &block)
240
- set_callback(:perform, :after, *filters, &block)
239
+ def after_perform(*filters, &)
240
+ set_callback(:perform, :after, *filters, &)
241
241
  end
242
242
 
243
- def after_failure(*filters, &block)
244
- set_callback(:failure, :after, *filters, &block)
243
+ def after_failure(*filters, &)
244
+ set_callback(:failure, :after, *filters, &)
245
245
  end
246
246
 
247
- def around_async_success(*filters, &block)
248
- set_callback(:async_success, :around, *filters, &block)
247
+ def around_async_success(*filters, &)
248
+ set_callback(:async_success, :around, *filters, &)
249
249
  end
250
250
 
251
- def around_async_failure(*filters, &block)
252
- set_callback(:async_failure, :around, *filters, &block)
251
+ def around_async_failure(*filters, &)
252
+ set_callback(:async_failure, :around, *filters, &)
253
253
  end
254
254
 
255
- def after_async_success(*filters, &block)
256
- set_callback(:async_success, :after, *filters, &block)
255
+ def after_async_success(*filters, &)
256
+ set_callback(:async_success, :after, *filters, &)
257
257
  end
258
258
 
259
- def after_async_failure(*filters, &block)
260
- set_callback(:async_failure, :after, *filters, &block)
259
+ def after_async_failure(*filters, &)
260
+ set_callback(:async_failure, :after, *filters, &)
261
261
  end
262
262
 
263
263
  def context_class
@@ -265,15 +265,15 @@ module Servitium
265
265
  end
266
266
 
267
267
  def context_class_name
268
- name.gsub('Service', 'Context')
268
+ name.gsub("Service", "Context")
269
269
  end
270
270
 
271
271
  def context_class!
272
272
  return context_class if context_class
273
273
 
274
- context_class_parts = context_class_name.split('::')
274
+ context_class_parts = context_class_name.split("::")
275
275
  context_class_name_part = context_class_parts.pop
276
- context_module_name = context_class_parts.join('::')
276
+ context_module_name = context_class_parts.join("::")
277
277
  context_module = context_module_name.present? ? context_module_name.constantize : Object
278
278
 
279
279
  context_module.const_set(context_class_name_part, Class.new(context_base_class_name.constantize))
@@ -283,7 +283,7 @@ module Servitium
283
283
  # Get the base class for new contexts defined using context blocks
284
284
  # Defaults to Servitium::Context
285
285
  def context_base_class_name
286
- @@_context_base_class_name ||= 'Servitium::Context'
286
+ @@_context_base_class_name ||= "Servitium::Context"
287
287
  end
288
288
 
289
289
  # Override the base class for contexts defined using context blocks, you can use this to
@@ -292,19 +292,19 @@ module Servitium
292
292
  @@_context_base_class_name = base_class
293
293
  end
294
294
 
295
- def context(*args, &block)
296
- return initialized_context(*args) unless block_given?
295
+ def context(*, &)
296
+ return initialized_context(*) unless block_given?
297
297
 
298
298
  begin
299
299
  context_class!.new
300
- rescue StandardError
300
+ rescue
301
301
  nil
302
302
  end
303
- context_class!.class_eval(&block)
303
+ context_class!.class_eval(&)
304
304
  end
305
305
 
306
- def initialized_context(*args)
307
- context_class.new(*args)
306
+ def initialized_context(*)
307
+ context_class.new(*)
308
308
  end
309
309
  end
310
310
  end
@@ -2,8 +2,8 @@
2
2
 
3
3
  module Servitium
4
4
  class ServiceActiveJob < ActiveJob::Base
5
- def perform(class_name, *args)
6
- service = class_name.constantize.call(*args)
5
+ def perform(class_name, *)
6
+ service = class_name.constantize.call(*)
7
7
 
8
8
  if service.context.success?
9
9
  service.send(:async_success)
@@ -3,8 +3,8 @@
3
3
  module Servitium
4
4
  class ServiceSidekiqJob
5
5
  include Sidekiq::Job
6
- def perform(class_name, *args)
7
- service = class_name.constantize.call(*args)
6
+ def perform(class_name, *)
7
+ service = class_name.constantize.call(*)
8
8
 
9
9
  if service.context.success?
10
10
  service.send(:async_success)
@@ -4,7 +4,7 @@ module Servitium
4
4
  module SubContexts
5
5
  def sub_context(name)
6
6
  if name.to_s.singularize == name.to_s
7
- define_method("#{name}_attributes=") do |attributes|
7
+ define_method(:"#{name}_attributes=") do |attributes|
8
8
  klass = "#{self.class.name}::#{name.to_s.camelize}".safe_constantize
9
9
 
10
10
  writer = "#{name}="
@@ -19,17 +19,17 @@ module Servitium
19
19
  inst
20
20
  end
21
21
 
22
- define_method("#{name}=") do |attributes|
22
+ define_method(:"#{name}=") do |attributes|
23
23
  klass = "#{self.class.name}::#{name.to_s.camelize}".safe_constantize
24
24
  inst = if attributes.is_a? klass
25
- attributes
26
- else
27
- inst = klass.new(attributes)
28
- inst.supercontext = self
29
- inst
30
- end
25
+ attributes
26
+ else
27
+ inst = klass.new(attributes)
28
+ inst.supercontext = self
29
+ inst
30
+ end
31
31
 
32
- instance_variable_set("@#{name}".to_sym, inst)
32
+ instance_variable_set(:"@#{name}", inst)
33
33
 
34
34
  @subcontexts ||= {}
35
35
  @subcontexts[name] = inst
@@ -37,21 +37,21 @@ module Servitium
37
37
  inst
38
38
  end
39
39
  else
40
- define_method("#{name}_attributes=") do |attributes|
40
+ define_method(:"#{name}_attributes=") do |attributes|
41
41
  klass = "#{self.class.name}::#{name.to_s.singularize.camelize}".safe_constantize
42
42
 
43
43
  if attributes.is_a?(Hash) || attributes.is_a?(ActionController::Parameters)
44
44
  keys = attributes.keys
45
- attributes = (if keys.reject { |k| k == 'TEMPLATE' }.all? { |k| k.to_i.to_s == k }
45
+ attributes = (if keys.reject { |k| k == "TEMPLATE" }.all? { |k| k.to_i.to_s == k }
46
46
  attributes.reject do |k|
47
- k == 'TEMPLATE'
47
+ k == "TEMPLATE"
48
48
  end.values
49
49
  end)
50
50
  end
51
51
 
52
52
  result = []
53
53
  attributes.each do |params|
54
- next if params['_destroy'] == '1' || params[:_destroy] == '1'
54
+ next if params["_destroy"] == "1" || params[:_destroy] == "1"
55
55
 
56
56
  inst = klass.new(params)
57
57
  inst.supercontext = self
@@ -66,25 +66,25 @@ module Servitium
66
66
  result
67
67
  end
68
68
 
69
- define_method("#{name}=") do |attributes|
69
+ define_method(:"#{name}=") do |attributes|
70
70
  klass = "#{self.class.name}::#{name.to_s.singularize.camelize}".safe_constantize
71
71
  result = if attributes.is_a?(Array) && attributes.all? { |a| a.instance_of?(klass) }
72
- attributes
73
- else
74
- if attributes.is_a?(Hash) || attributes.is_a?(ActionController::Parameters)
75
- attributes = (attributes.values if attributes.keys.all? { |k| k.to_i.to_s == k })
76
- end
77
-
78
- result = []
79
- attributes.each do |params|
80
- inst = klass.new(params)
81
- inst.supercontext = self
82
- result.push(inst)
83
- end
84
- result
85
- end
86
-
87
- instance_variable_set("@#{name}".to_sym, result)
72
+ attributes
73
+ else
74
+ if attributes.is_a?(Hash) || attributes.is_a?(ActionController::Parameters)
75
+ attributes = (attributes.values if attributes.keys.all? { |k| k.to_i.to_s == k })
76
+ end
77
+
78
+ result = []
79
+ attributes.each do |params|
80
+ inst = klass.new(params)
81
+ inst.supercontext = self
82
+ result.push(inst)
83
+ end
84
+ result
85
+ end
86
+
87
+ instance_variable_set(:"@#{name}", result)
88
88
 
89
89
  @subcontexts ||= {}
90
90
  @subcontexts[name] = result
@@ -95,11 +95,11 @@ module Servitium
95
95
 
96
96
  if name.to_s.singularize == name.to_s
97
97
  define_method(name.to_s) do
98
- instance_variable_get("@#{name}".to_sym) if instance_variable_defined?("@#{name}".to_sym)
98
+ instance_variable_get(:"@#{name}") if instance_variable_defined?(:"@#{name}")
99
99
  end
100
100
  else
101
101
  define_method(name.to_s) do
102
- value = instance_variable_get("@#{name}".to_sym) if instance_variable_defined?("@#{name}".to_sym)
102
+ value = instance_variable_get(:"@#{name}") if instance_variable_defined?(:"@#{name}")
103
103
  value ||= []
104
104
  value
105
105
  end
@@ -10,14 +10,14 @@ module Servitium
10
10
 
11
11
  module ClassMethods
12
12
  def transactional(value = nil)
13
- @transactional = value if value
13
+ @transactional = value unless value.nil?
14
14
  @transactional = nil unless defined?(@transactional)
15
15
  if @transactional.nil?
16
16
  @transactional = if superclass < Servitium::Service
17
- superclass.transactional
18
- else
19
- false
20
- end
17
+ superclass.transactional
18
+ else
19
+ false
20
+ end
21
21
  end
22
22
  @transactional
23
23
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Servitium
4
- VERSION = "1.3.0"
4
+ VERSION = "1.3.1"
5
5
  end
data/lib/servitium.rb CHANGED
@@ -1,27 +1,26 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'active_model'
4
- require 'active_attr'
5
- require 'active_support'
6
- require 'action_controller'
7
- require 'active_job'
8
- require 'sidekiq'
3
+ require "active_model"
4
+ require "active_attr"
5
+ require "active_support"
6
+ require "action_controller"
7
+ require "active_job"
8
+ require "sidekiq"
9
9
 
10
- require 'servitium/error'
11
- require 'servitium/context_failure'
12
- require 'servitium/i18n'
13
- require 'servitium/sub_contexts'
14
- require 'servitium/scoped_attributes'
15
- require 'servitium/context_model'
16
- require 'servitium/context'
17
- require 'servitium/service_active_job'
18
- require 'servitium/service_sidekiq_job'
19
- require 'servitium/service'
20
- require 'servitium/version'
21
- require 'servitium/configuration'
22
-
23
- require 'servitium/rails' if defined?(::Rails)
10
+ require "servitium/error"
11
+ require "servitium/context_failure"
12
+ require "servitium/i18n"
13
+ require "servitium/sub_contexts"
14
+ require "servitium/scoped_attributes"
15
+ require "servitium/context_model"
16
+ require "servitium/context"
17
+ require "servitium/service_active_job"
18
+ require "servitium/service_sidekiq_job"
19
+ require "servitium/service"
20
+ require "servitium/version"
21
+ require "servitium/configuration"
24
22
 
23
+ require "servitium/rails" if defined?(::Rails)
25
24
 
26
25
  module Servitium
27
26
  class << self
@@ -34,4 +33,4 @@ module Servitium
34
33
  @config ||= Configuration.new
35
34
  end
36
35
  end
37
- end
36
+ end
@@ -1,18 +1,16 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'yaml'
4
- require 'active_support/inflector'
3
+ require "yaml"
4
+ require "active_support/inflector"
5
5
 
6
6
  namespace :servitium do
7
- desc 'Convert localization keys'
7
+ desc "Convert localization keys"
8
8
  task :convert_keys do
9
- locs = YAML.load(File.read('./config/locales/en.yml'))
10
- locs['en']['services'].each_key do |service|
11
- locs['en'][service[0..-9].pluralize] = { 'service' => locs['en']['services'][service].dup }
9
+ locs = YAML.load_file("./config/locales/en.yml")
10
+ locs["en"]["services"].each_key do |service|
11
+ locs["en"][service[0..-9].pluralize] = {"service" => locs["en"]["services"][service].dup}
12
12
  end
13
13
 
14
- File.open('./config/locales/en.yml', 'w') do |f|
15
- f.write YAML.dump(locs)
16
- end
14
+ File.write("./config/locales/en.yml", YAML.dump(locs))
17
15
  end
18
16
  end
data/servitium.gemspec CHANGED
@@ -1,47 +1,47 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require_relative 'lib/servitium/version'
3
+ require_relative "lib/servitium/version"
4
4
 
5
5
  Gem::Specification.new do |spec|
6
- spec.name = 'servitium'
7
- spec.version = Servitium::VERSION
8
- spec.authors = ['Tom de Grunt']
9
- spec.email = ['tom@degrunt.nl']
6
+ spec.name = "servitium"
7
+ spec.version = Servitium::VERSION
8
+ spec.authors = ["Tom de Grunt"]
9
+ spec.email = ["tom@degrunt.nl"]
10
10
 
11
- spec.summary = 'Service objects'
12
- spec.description = 'An implementation of the command pattern for Ruby'
13
- spec.homepage = 'https://entropydecelerator.com/components/servitium'
14
- spec.license = 'MIT'
15
- spec.required_ruby_version = Gem::Requirement.new('>= 2.6.5')
11
+ spec.summary = "Service objects"
12
+ spec.description = "An implementation of the command pattern for Ruby"
13
+ spec.homepage = "https://entropydecelerator.com/components/servitium"
14
+ spec.license = "MIT"
15
+ spec.required_ruby_version = Gem::Requirement.new(">= 2.6.5")
16
16
 
17
- spec.metadata['homepage_uri'] = spec.homepage
18
- spec.metadata['source_code_uri'] = 'https://code.entropydecelerator.com/components/servitium'
17
+ spec.metadata["homepage_uri"] = spec.homepage
18
+ spec.metadata["source_code_uri"] = "https://code.entropydecelerator.com/components/servitium"
19
19
 
20
20
  # Specify which files should be added to the gem when it is released.
21
21
  # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
22
22
  spec.files = Dir.chdir(File.expand_path(__dir__)) do
23
23
  `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
24
24
  end
25
- spec.bindir = 'exe'
26
- spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
27
- spec.require_paths = ['lib']
25
+ spec.bindir = "exe"
26
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
27
+ spec.require_paths = ["lib"]
28
28
 
29
- spec.add_dependency 'active_attr', '~> 0.15'
30
- spec.add_dependency 'activejob', '> 5.1'
31
- spec.add_dependency 'activemodel', '> 5.1'
32
- spec.add_dependency 'activerecord', '> 5.1'
33
- spec.add_dependency 'activesupport', '> 5.1'
34
- spec.add_dependency 'actionpack', '> 5.1'
35
- spec.add_dependency 'i18n', '>= 0.7'
29
+ spec.add_dependency "active_attr", "~> 0.15"
30
+ spec.add_dependency "activejob", "> 5.1"
31
+ spec.add_dependency "activemodel", "> 5.1"
32
+ spec.add_dependency "activerecord", "> 5.1"
33
+ spec.add_dependency "activesupport", "> 5.1"
34
+ spec.add_dependency "actionpack", "> 5.1"
35
+ spec.add_dependency "i18n", ">= 0.7"
36
36
 
37
- spec.add_development_dependency 'auxilium', '>= 3'
38
- spec.add_development_dependency 'minitest', '~> 5.11'
39
- spec.add_development_dependency 'minitest-reporters', '~> 1.1'
40
- spec.add_development_dependency 'pry'
41
- spec.add_development_dependency 'pry-rails', '~> 0.3'
42
- spec.add_development_dependency 'rake', '~> 12.0'
43
- spec.add_development_dependency 'rubocop', '~> 1'
44
- spec.add_development_dependency 'standard', '~> 1'
45
- spec.add_development_dependency 'sqlite3', '~> 1.4'
46
- spec.add_development_dependency 'sidekiq', '~> 7'
37
+ spec.add_development_dependency "auxilium", ">= 3"
38
+ spec.add_development_dependency "minitest", "~> 5.11"
39
+ spec.add_development_dependency "minitest-reporters", "~> 1.1"
40
+ spec.add_development_dependency "pry"
41
+ spec.add_development_dependency "pry-rails", "~> 0.3"
42
+ spec.add_development_dependency "rake", "~> 12.0"
43
+ spec.add_development_dependency "rubocop", "~> 1"
44
+ spec.add_development_dependency "standard", "~> 1"
45
+ spec.add_development_dependency "sqlite3", "~> 1.4"
46
+ spec.add_development_dependency "sidekiq", "~> 7"
47
47
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: servitium
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.0
4
+ version: 1.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tom de Grunt
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2024-04-10 00:00:00.000000000 Z
11
+ date: 2024-11-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: active_attr