foobara 0.7.5 → 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: 2b1f7ca252d5b1f089c46c2bb7462cd3fc59d2140eff8ffb156d0236c5ce3c1a
4
- data.tar.gz: a8fdfa3f7c271648abed29612e3373e7cd4b09104204a90d0f4befa771214064
3
+ metadata.gz: 8fee679ea0c3530123d404942baa9c01c5ae0f45f459cafd04d172573bdc06d2
4
+ data.tar.gz: c0c540fb7b0b955cefc534132ef5e52be427bbb183514c53f0ff9b9fa4e06522
5
5
  SHA512:
6
- metadata.gz: 494ab94671b30308f0cec81fb32aa1801080bfeed0da2c53713f5b85a23917ad0c1eb32576d7fe7a5549765336d70673bfa46f8bc2b02b41a040f27accd1cb1e
7
- data.tar.gz: 0c5defe3e4d38eb4cdd56194fdcd339666d726526003b97a989e227fb26ebec46ec7127a244eb5b13ced2c8386d88a55f08e401dd659681db2d1446976600ba4
6
+ metadata.gz: 13ecaf175130d2e601f2e698186869f30214d8a4e95a320d5bb8b594807c764e03f6626d703995852a625722b2cac3ffc926cb7b2071b3750858e2828ea7eae8
7
+ data.tar.gz: 5f7a31a516dcd8e784c07c8f9762ed2d1b5e7a00dddef036db1401378a40885d5584ebe180d596a3ac8b73c47cd86504c7a3291c956ba2700d15bdc0bb66c2ac
data/.ruby-version CHANGED
@@ -1 +1 @@
1
- 4.0.7
1
+ 4.0.9
data/CHANGELOG.md CHANGED
@@ -1,3 +1,12 @@
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
+
6
+ # [0.8.0] - 2026-11-17
7
+
8
+ - Eliminate dependency on the bigdecimal gem and relocate it to foobara-big-decimal-type
9
+
1
10
  # [0.7.5] - 2026-10-20
2
11
 
3
12
  - Make sure DetachedEntity handle reregistered types properly
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:)
@@ -18,14 +18,14 @@ module Foobara
18
18
  @all_projects ||= {}
19
19
  end
20
20
 
21
- def project(symbol, project_path: nil, eager_load_src: true)
21
+ def project(symbol, project_path: nil, eager_load_src: true, require_path: nil)
22
22
  if all_projects.key?(symbol)
23
23
  # simplecov:disable
24
24
  raise ArgumentError, "Project #{symbol} already loaded"
25
25
  # simplecov:enable
26
26
  end
27
27
 
28
- project = Project.new(symbol, project_path:, eager_load_src:)
28
+ project = Project.new(symbol, project_path:, eager_load_src:, require_path:)
29
29
  project.load
30
30
 
31
31
  all_projects[symbol] = project
@@ -1,17 +1,14 @@
1
1
  module Foobara
2
2
  class Project
3
- attr_accessor :symbol, :project_path, :eager_load_src
3
+ attr_accessor :symbol, :project_path, :eager_load_src, :require_path
4
4
 
5
- def initialize(symbol, project_path: nil, eager_load_src: true)
5
+ def initialize(symbol, project_path: nil, eager_load_src: true, require_path: nil)
6
+ self.require_path = require_path || "foobara/#{symbol}"
6
7
  self.eager_load_src = eager_load_src
7
8
  self.symbol = symbol
8
9
  self.project_path = project_path || "#{__dir__}/../../#{symbol}"
9
10
  end
10
11
 
11
- def require_path
12
- "foobara/#{symbol}"
13
- end
14
-
15
12
  def module_name
16
13
  Util.classify(symbol)
17
14
  end
@@ -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.7.5".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.7.5
4
+ version: 0.8.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Miles Georgi
@@ -9,20 +9,6 @@ bindir: bin
9
9
  cert_chain: []
10
10
  date: 1980-01-02 00:00:00.000000000 Z
11
11
  dependencies:
12
- - !ruby/object:Gem::Dependency
13
- name: bigdecimal
14
- requirement: !ruby/object:Gem::Requirement
15
- requirements:
16
- - - ">="
17
- - !ruby/object:Gem::Version
18
- version: '0'
19
- type: :runtime
20
- prerelease: false
21
- version_requirements: !ruby/object:Gem::Requirement
22
- requirements:
23
- - - ">="
24
- - !ruby/object:Gem::Version
25
- version: '0'
26
12
  - !ruby/object:Gem::Dependency
27
13
  name: foobara-lru-cache
28
14
  requirement: !ruby/object:Gem::Requirement
@@ -80,9 +66,6 @@ files:
80
66
  - README.md
81
67
  - lib/foobara.rb
82
68
  - 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
86
69
  - projects/command/lib/foobara/command.rb
87
70
  - projects/command/src/command.rb
88
71
  - projects/command/src/command_pattern_implementation.rb
@@ -530,6 +513,7 @@ metadata:
530
513
  homepage_uri: https://foobara.org
531
514
  source_code_uri: https://github.com/foobara/foobara
532
515
  changelog_uri: https://github.com/foobara/foobara/blob/main/CHANGELOG.md
516
+ mailing_list_uri: https://www.rubyforum.org/tag/foobara
533
517
  rubygems_mfa_required: 'true'
534
518
  rdoc_options: []
535
519
  require_paths:
@@ -556,7 +540,6 @@ require_paths:
556
540
  - projects/entities/projects/nested_transactionable/lib
557
541
  - projects/entities/projects/persistence/lib
558
542
  - projects/entities/projects/weak_object_set/lib
559
- - projects/big_decimal/lib
560
543
  - projects/command/lib
561
544
  - projects/command_connectors/lib
562
545
  - projects/domain_mapper/lib
@@ -577,7 +560,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
577
560
  - !ruby/object:Gem::Version
578
561
  version: '0'
579
562
  requirements: []
580
- rubygems_version: 4.0.20
563
+ rubygems_version: 4.0.24
581
564
  specification_version: 4
582
565
  summary: A command-centric and discoverable software framework with a focus on domain
583
566
  concepts and abstracting away integration code
@@ -1,16 +0,0 @@
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__}/../..")
@@ -1,21 +0,0 @@
1
- module Foobara
2
- module BuiltinTypes
3
- module BigDecimal
4
- module Casters
5
- class Integer < Value::Caster
6
- def applicable?(value)
7
- value.is_a?(::Integer)
8
- end
9
-
10
- def applies_message
11
- "be a an Integer"
12
- end
13
-
14
- def cast(integer)
15
- BigDecimal(integer)
16
- end
17
- end
18
- end
19
- end
20
- end
21
- end
@@ -1,24 +0,0 @@
1
- module Foobara
2
- module BuiltinTypes
3
- module BigDecimal
4
- module Casters
5
- class String < Value::Caster
6
- FLOAT_REGEX = /^-?\d+(\.\d+)?([eE]-?\d+)?$/
7
-
8
- def applicable?(value)
9
- value.is_a?(::String) && value =~ FLOAT_REGEX
10
- end
11
-
12
- def applies_message
13
- "be a string of digits with one decimal point optionally amongst " \
14
- "them and optionally with a minus sign in front and optionally an exponent denoted with e"
15
- end
16
-
17
- def cast(string)
18
- BigDecimal(string)
19
- end
20
- end
21
- end
22
- end
23
- end
24
- end