foobara 0.6.3 → 0.6.5

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: 936be6174137c2740ff9ba0bf5470251901aa9dc61bd841baf4af7dc0041e899
4
- data.tar.gz: fc49e694263c62adefef802dfa8e469aff130237ec815602cab0aaa92983a132
3
+ metadata.gz: 8f7628f3975299e2c2d578d47b6ea01cf00d10d0c64566b01d307ae44d400cd6
4
+ data.tar.gz: 7e1964b48bea37ba9206c85d171c0c52985e9499131a3e96bcf661559730b4da
5
5
  SHA512:
6
- metadata.gz: bacfb096227c140aace0cd32ed77b1f436872936b07a346a2fac976b83b478a4d9babcb217454874e39c3c944cb664562edf777d863856f8e510bfbccea1105a
7
- data.tar.gz: 63d4cf117cadd2f5e6d9f5a8e220f28e1f726c5781578097899d9a7cda2f2727036d7354338bef46465452c44d36e4c0ddd878ec9c89a6ec976316240c2a452f
6
+ metadata.gz: 8061eb55fbc5879d63532708009f9591f4c5c9766a6a282612b51fa8c48a80e537ad5f4e488150f57434cf50a621d4a0c687efcc0963508808470e00c5c0b76b
7
+ data.tar.gz: f593b3dcc25323a6253c928ed4d4735386e65c0cebf4e4ef6d219d8ac8dccfa253b1223aa85d227c66ffdf2c409a39d0ea8632ac90cc489ff8b529b9f41f8913
data/.ruby-version CHANGED
@@ -1 +1 @@
1
- 4.0.6
1
+ 4.0.7
data/CHANGELOG.md CHANGED
@@ -1,3 +1,12 @@
1
+ # [0.6.5] - 2026-10-04
2
+
3
+ - Fix a problem where some nested sugary types don't expand correctly when using attributes dsl
4
+ - Add command name to error message when a result can't be cast to the result type
5
+
6
+ # [0.6.4] - 2026-09-11
7
+
8
+ - Track which models instances ignore unsupported attributes to prevent various issues, including breaking domain mappers
9
+
1
10
  # [0.6.3] - 2026-09-11
2
11
 
3
12
  - Eliminate usage of removed JSON.fast_generate
@@ -0,0 +1,16 @@
1
+ require "foobara/builtin_types"
2
+ require "bigdecimal"
3
+
4
+ module Foobara
5
+ module BigDecimal
6
+ class << self
7
+ def install!
8
+ BuiltinTypes.build_and_register!(:big_decimal, BuiltinTypes[:number])
9
+ end
10
+
11
+ def reset_all = install!
12
+ end
13
+ end
14
+ end
15
+
16
+ Foobara.project("big_decimal", project_path: "#{__dir__}/../..")
@@ -4,7 +4,15 @@ module Foobara
4
4
  module Result
5
5
  include Concern
6
6
 
7
- class CouldNotProcessResult < Outcome::UnsuccessfulOutcomeError; end
7
+ class CouldNotProcessResult < Outcome::UnsuccessfulOutcomeError;
8
+ attr_accessor :command
9
+
10
+ def initialize(command, errors)
11
+ self.command = command
12
+
13
+ super(errors, prefix: command.class.full_command_name)
14
+ end
15
+ end
8
16
 
9
17
  private
10
18
 
@@ -16,7 +24,7 @@ module Foobara
16
24
  if outcome.success?
17
25
  outcome.result
18
26
  else
19
- raise CouldNotProcessResult, outcome.errors
27
+ raise CouldNotProcessResult.new(self, outcome.errors)
20
28
  end
21
29
  end
22
30
  end
@@ -2,8 +2,6 @@ require "foobara/type_declarations"
2
2
 
3
3
  require "date"
4
4
  require "time"
5
- # TODO: get this out of here
6
- require "bigdecimal"
7
5
 
8
6
  module Foobara
9
7
  # TODO: rename this to PrimitiveTypes and deprecate the name BuiltinTypes
@@ -46,7 +44,6 @@ module Foobara
46
44
  number = build_and_register!(:number, atomic_duck, ::Object)
47
45
  build_and_register!(:integer, number)
48
46
  build_and_register!(:float, number)
49
- build_and_register!(:big_decimal, number)
50
47
  # Let's skip these for now since they rarely come up in business contexts and both could be
51
48
  # represented by a tuple of numbers.
52
49
  # build_and_register!(:rational, number)
@@ -3,10 +3,12 @@ module Foobara
3
3
  class UnsuccessfulOutcomeError < StandardError
4
4
  attr_accessor :errors, :backtrace_when_raised
5
5
 
6
- def initialize(errors)
6
+ def initialize(errors, message: errors.map(&:message).join(", "), prefix: nil)
7
7
  self.errors = errors
8
8
 
9
- message = errors.map(&:message).join(", ")
9
+ if prefix
10
+ message = "#{prefix}: #{message}"
11
+ end
10
12
 
11
13
  super(message)
12
14
  end
@@ -2,7 +2,6 @@ require "foobara/builtin_types"
2
2
 
3
3
  require "date"
4
4
  require "time"
5
- require "bigdecimal"
6
5
 
7
6
  module Foobara
8
7
  class Model
@@ -200,6 +200,10 @@ module Foobara
200
200
  end
201
201
  end
202
202
 
203
+ if Thread.inheritable_thread_local_var_get(:foobara_ignore_unexpected_attributes)
204
+ @ignore_unexpected_attributes = true
205
+ end
206
+
203
207
  validate = options[:validate]
204
208
 
205
209
  if attributes.nil?
@@ -241,6 +245,8 @@ module Foobara
241
245
  validate! if validate # TODO: test this code path
242
246
  end
243
247
 
248
+ def ignore_unexpected_attributes? = @ignore_unexpected_attributes
249
+
244
250
  def model_name
245
251
  self.class.model_name
246
252
  end
@@ -333,7 +339,16 @@ module Foobara
333
339
  end
334
340
 
335
341
  def validation_errors
336
- attributes_type.process_value(attributes).error_collection
342
+ errors = attributes_type.process_value(attributes).error_collection
343
+
344
+ unexpected_attributes_class =
345
+ BuiltinTypes::Attributes::SupportedProcessors::ElementTypeDeclarations::UnexpectedAttributesError
346
+
347
+ if ignore_unexpected_attributes?
348
+ errors.reject { unexpected_attributes_class === it }
349
+ else
350
+ errors
351
+ end
337
352
  end
338
353
 
339
354
  def validate!
@@ -46,6 +46,12 @@ module Foobara
46
46
  end
47
47
 
48
48
  def install!
49
+ # simplecov:disable
50
+ if is_installed
51
+ raise "Foobara.install! was already invoked"
52
+ end
53
+ # simplecov:enable
54
+
49
55
  self.is_installed = true
50
56
  all_projects.each_value(&:install!)
51
57
  end
@@ -57,7 +63,7 @@ module Foobara
57
63
 
58
64
  def raise_if_production!(method_name = nil)
59
65
  if method_name
60
- warn "DEPRECATION WARNING: Passing method_name is deprecated."
66
+ warn "DEPRECATION WARNING: Passing a method_name to Foobara.raise_if_production is deprecated."
61
67
  else
62
68
  method_name = caller_locations.map(&:label).find { |label| !label.start_with?("block in") }
63
69
  end
@@ -83,6 +83,17 @@ module Foobara
83
83
  end
84
84
  end
85
85
 
86
+ if type && !type.is_a?(::Symbol)
87
+ type = Domain.current.foobara_type_from_declaration(type)
88
+
89
+ type = if type.registered?
90
+ type.reference_symbol
91
+ else
92
+ declaration = type.declaration_data.merge(declaration)
93
+ declaration[:type]
94
+ end
95
+ end
96
+
86
97
  processor_symbols.each do |processor_symbol|
87
98
  case processor_symbol
88
99
  when ::String
@@ -1,3 +1,5 @@
1
+ require "foobara/project"
2
+
1
3
  module Foobara
2
4
  module Types
3
5
  class << self
@@ -428,12 +428,7 @@ module Foobara
428
428
  remove_sensitive = TypeDeclarations.foobara_manifest_context_remove_sensitive?
429
429
 
430
430
  if registered?
431
- # TODO: we should just use the symbol and nothing else in this context instead of a hash with 1 element.
432
- if scoped_unregistered?
433
- unregistered_foobara_manifest_reference.to_sym
434
- else
435
- foobara_manifest_reference.to_sym
436
- end
431
+ reference_symbol
437
432
  elsif remove_sensitive
438
433
  TypeDeclarations.remove_sensitive_types(declaration_data)
439
434
  else
@@ -441,6 +436,16 @@ module Foobara
441
436
  end
442
437
  end
443
438
 
439
+ def reference_symbol
440
+ raise "Not registered so no reference symbol" unless registered?
441
+
442
+ if scoped_unregistered?
443
+ unregistered_foobara_manifest_reference.to_sym
444
+ else
445
+ foobara_manifest_reference.to_sym
446
+ end
447
+ end
448
+
444
449
  def declaration_data_for_manifest
445
450
  data = declaration_data
446
451
 
data/version.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  module Foobara
2
2
  module Version
3
- VERSION = "0.6.3".freeze
3
+ VERSION = "0.6.5".freeze
4
4
  MINIMUM_RUBY_VERSION = [">= 3.4.0", "< 4.1"].freeze
5
5
  end
6
6
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: foobara
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.3
4
+ version: 0.6.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Miles Georgi
@@ -80,6 +80,9 @@ files:
80
80
  - README.md
81
81
  - lib/foobara.rb
82
82
  - lib/foobara/all.rb
83
+ - projects/big_decimal/lib/foobara/big_decimal.rb
84
+ - projects/big_decimal/src/casters/integer.rb
85
+ - projects/big_decimal/src/casters/string.rb
83
86
  - projects/command/lib/foobara/command.rb
84
87
  - projects/command/src/command.rb
85
88
  - projects/command/src/command_pattern_implementation.rb
@@ -306,8 +309,6 @@ files:
306
309
  - projects/typesystem/projects/builtin_types/src/attributes/supported_validators/required/type_declaration_extension/extend_attributes_type_declaration/type_declaration_validators/array_of_symbols.rb
307
310
  - projects/typesystem/projects/builtin_types/src/attributes/supported_validators/required/type_declaration_extension/extend_attributes_type_declaration/type_declaration_validators/array_with_valid_attribute_names.rb
308
311
  - projects/typesystem/projects/builtin_types/src/attributes/transformers/remove_unexpected_attributes.rb
309
- - projects/typesystem/projects/builtin_types/src/big_decimal/casters/integer.rb
310
- - projects/typesystem/projects/builtin_types/src/big_decimal/casters/string.rb
311
312
  - projects/typesystem/projects/builtin_types/src/boolean/casters/numeric.rb
312
313
  - projects/typesystem/projects/builtin_types/src/boolean/casters/string_or_symbol.rb
313
314
  - projects/typesystem/projects/builtin_types/src/builtin_types.rb
@@ -555,6 +556,7 @@ require_paths:
555
556
  - projects/entities/projects/nested_transactionable/lib
556
557
  - projects/entities/projects/persistence/lib
557
558
  - projects/entities/projects/weak_object_set/lib
559
+ - projects/big_decimal/lib
558
560
  - projects/command/lib
559
561
  - projects/command_connectors/lib
560
562
  - projects/domain_mapper/lib
@@ -575,7 +577,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
575
577
  - !ruby/object:Gem::Version
576
578
  version: '0'
577
579
  requirements: []
578
- rubygems_version: 4.0.16
580
+ rubygems_version: 4.0.20
579
581
  specification_version: 4
580
582
  summary: A command-centric and discoverable software framework with a focus on domain
581
583
  concepts and abstracting away integration code