foobara 0.8.0 → 0.8.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: a8d77b6195861bb3659af86790096cc49ecc48d02e7a92ebfadf05a612b62b3e
4
- data.tar.gz: 58d3e97dfda3003354d06d97f17f4bd034461d8ce48d9e17b65b4ce9b0e62c53
3
+ metadata.gz: 8fee679ea0c3530123d404942baa9c01c5ae0f45f459cafd04d172573bdc06d2
4
+ data.tar.gz: c0c540fb7b0b955cefc534132ef5e52be427bbb183514c53f0ff9b9fa4e06522
5
5
  SHA512:
6
- metadata.gz: 04f58adfb26a188858319187d46cc9ee63b887cfaeae075a76a50264b66b1529714b76909dd8022cfb86191a42f6da6209adab9e15dc3aef2117830213f85b05
7
- data.tar.gz: 340c6e764fd9f341b81139e9702b38df9478d0b037c1b60b1d82f6727e028406325d211ae35821486bd0d30e85a7c96e112fcdda27927063355d9157d35f64be
6
+ metadata.gz: 13ecaf175130d2e601f2e698186869f30214d8a4e95a320d5bb8b594807c764e03f6626d703995852a625722b2cac3ffc926cb7b2071b3750858e2828ea7eae8
7
+ data.tar.gz: 5f7a31a516dcd8e784c07c8f9762ed2d1b5e7a00dddef036db1401378a40885d5584ebe180d596a3ac8b73c47cd86504c7a3291c956ba2700d15bdc0bb66c2ac
data/CHANGELOG.md CHANGED
@@ -1,3 +1,8 @@
1
+ # [0.8.1] - 2026-11-29
2
+
3
+ - Fix a bug where SomeModel.new wouldn't apply default attributes
4
+ - Improve error message when a foobara type doesn't exist because it hasn't been loaded yet
5
+
1
6
  # [0.8.0] - 2026-11-17
2
7
 
3
8
  - Eliminate dependency on the bigdecimal gem and relocate it to foobara-big-decimal-type
data/README.md CHANGED
@@ -1,5 +1,7 @@
1
1
  Foobara is a software framework that is command-centric and discoverable.
2
2
 
3
+ [![Ruby Users Forum](https://img.shields.io/discourse/topics?server=https%3A%2F%2Fwww.rubyforum.org&style=flat&logo=discourse&label=Ruby%20Users%20Forum)](https://www.rubyforum.org/tag/foobara)
4
+
3
5
  Domain operations are
4
6
  encapsulated in commands, which serve as the public interface to systems, and which automatically
5
7
  provide machine-readable formal metadata about those commands.
@@ -2128,6 +2130,8 @@ TODO: give some code examples
2128
2130
 
2129
2131
  Are you actually trying to build something with Foobara? Happy to help! miles@foobara.org
2130
2132
 
2133
+ You can also use the `foobara` tag on the [Ruby Users Forum](https://www.rubyforum.org/tag/foobara/129)
2134
+
2131
2135
  # Contributing
2132
2136
 
2133
2137
  There are many ways you could help! There are tasks in the codebase for all skill levels including absolute beginner.
@@ -659,10 +659,10 @@ module Foobara
659
659
  !command_class.builtin?
660
660
  unless command.allowed_rule
661
661
  raise NoAllowedRuleGivenError,
662
- "Must connect #{command.full_command_name} with an `allowed_if:` " \
663
- "because `requires_allowed_rule` is true. You can use `allow_if: :always` if want to always allow " \
664
- "this command to be ran or you can also use `requires_allowed_rule: false` " \
665
- "when creating the connector if you don't want to enforce allowed_if: for all connected commands."
662
+ "Must connect #{command.full_command_name} with an `allow_if:` " \
663
+ "because `requires_allowed_rule` is true. You can use `allow_if: :always` if you want to always " \
664
+ "allow this command to be run or you can also use `requires_allowed_rule: false` " \
665
+ "when creating the connector if you don't want to enforce allow_if: for all connected commands."
666
666
  end
667
667
  end
668
668
 
@@ -47,8 +47,8 @@ module Foobara
47
47
  super
48
48
  self.is_loaded = false
49
49
  else
50
- super
51
50
  self.is_loaded = true
51
+ super
52
52
  end
53
53
  end
54
54
  end
@@ -214,25 +214,15 @@ module Foobara
214
214
 
215
215
  validate = options[:validate]
216
216
 
217
- if attributes.nil?
218
- if validate
219
- # simplecov:disable
220
- raise ArgumentError, "Cannot use validate option without attributes"
221
- # simplecov:enable
222
- end
223
- else
224
- if Thread.inheritable_thread_local_var_get(:foobara_ignore_unexpected_attributes)
225
- outcome = attributes_type.process_value(attributes)
217
+ outcome = attributes_type.process_value(attributes || {})
226
218
 
227
- if outcome.success?
228
- attributes = outcome.result
229
- end
230
- end
219
+ if outcome.success?
220
+ attributes = outcome.result
221
+ end
231
222
 
232
- self.mutable = true
233
- attributes.each_pair do |attribute_name, value|
234
- write_attribute(attribute_name, value)
235
- end
223
+ self.mutable = true
224
+ attributes&.each_pair do |attribute_name, value|
225
+ write_attribute(attribute_name, value)
236
226
  end
237
227
 
238
228
  mutable = if options.key?(:mutable)
@@ -307,7 +307,7 @@ module Foobara
307
307
 
308
308
  unless object
309
309
  # simplecov:disable
310
- raise NotFoundError, "Could not find #{name}"
310
+ raise NotFoundError, name
311
311
  # simplecov:enable
312
312
  end
313
313
 
@@ -73,7 +73,15 @@ module Foobara
73
73
  end
74
74
  end
75
75
 
76
- class NotFoundError < StandardError; end
76
+ class NotFoundError < StandardError
77
+ attr_accessor :symbol
78
+
79
+ def initialize(symbol)
80
+ self.symbol = symbol
81
+
82
+ super("Could not find #{symbol}")
83
+ end
84
+ end
77
85
 
78
86
  def initialize(scoped_name_or_path = nil, parent_namespace: nil)
79
87
  NamespaceHelpers.initialize_foobara_namespace(self, scoped_name_or_path, parent_namespace:)
@@ -4,6 +4,12 @@ module Foobara
4
4
  module TypeDeclarations
5
5
  module Handlers
6
6
  class RegisteredTypeDeclaration < TypeDeclarationHandler
7
+ class NotRegisteredError < Foobara::Error
8
+ context :symbol
9
+
10
+ def message = "Not registered: #{context}"
11
+ end
12
+
7
13
  # TODO: seems like we have more base classes than we need
8
14
  class ToTypeTransformer < TypeDeclarations::ToTypeTransformer
9
15
  def transform(strict_type_declaration)
@@ -15,7 +21,13 @@ module Foobara
15
21
 
16
22
  return type if type
17
23
 
18
- type = lookup_type!(strict_type_declaration[:type], mode: Namespace::LookupMode::ABSOLUTE)
24
+ type_symbol = if strict_type_declaration.reference?
25
+ strict_type_declaration.declaration_data
26
+ else
27
+ strict_type_declaration[:type]
28
+ end
29
+
30
+ type = lookup_type!(type_symbol, mode: Namespace::LookupMode::ABSOLUTE)
19
31
 
20
32
  strict_type_declaration.base_type = type
21
33
  end
@@ -23,6 +35,18 @@ module Foobara
23
35
  def target_classes(strict_type_declaration)
24
36
  registered_type(strict_type_declaration).target_classes
25
37
  end
38
+
39
+ def process_value(strict_type_declaration)
40
+ super
41
+ rescue Foobara::Namespace::NotFoundError => e
42
+ raise unless strict_type_declaration.reference?
43
+
44
+ type_symbol = strict_type_declaration.declaration_data
45
+
46
+ raise if e.symbol != type_symbol
47
+
48
+ Outcome.error(NotRegisteredError.new(context: type_symbol))
49
+ end
26
50
  end
27
51
  end
28
52
  end
data/version.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  module Foobara
2
2
  module Version
3
- VERSION = "0.8.0".freeze
3
+ VERSION = "0.8.1".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.8.0
4
+ version: 0.8.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Miles Georgi
@@ -513,6 +513,7 @@ metadata:
513
513
  homepage_uri: https://foobara.org
514
514
  source_code_uri: https://github.com/foobara/foobara
515
515
  changelog_uri: https://github.com/foobara/foobara/blob/main/CHANGELOG.md
516
+ mailing_list_uri: https://www.rubyforum.org/tag/foobara
516
517
  rubygems_mfa_required: 'true'
517
518
  rdoc_options: []
518
519
  require_paths: