foobara 0.7.0 → 0.7.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: 55727f8ba357338d057069b782e94dc171a87ce95ae4d1865c5df1e46252559a
4
- data.tar.gz: 5aa4e8a6535fdaf3bc1b3dd968b5b00348ef00c723d4728e313f9076b4a02b5c
3
+ metadata.gz: 64b471d0d0bf93acf6326e484b67d1be35f7c0c883bc315738f680e4c8119613
4
+ data.tar.gz: 9477f64763952ea8d819576545d6f9d06d7bb1ad562ea6dca83532297331859a
5
5
  SHA512:
6
- metadata.gz: 239417815a5ead7dd367120cb67b50fb20d0750dacdd3f8519d76f2bc1e69f565f6217d7dd8d194bd199e6dbf9e7f1d2fd8783e081461da8888ee675f1fc9e7a
7
- data.tar.gz: c06a234449b4ee52855f153277fe2440111f14873cc03dc9cc8c4c3a2fe558f811800ca6db8b0714d1e1fc2a54223290fb278c13c854b49dc2b708a5687f5ca2
6
+ metadata.gz: 941279f67447a52f9632f620637f011f21bae87766b4a8040846744751e17ba779a21db495cd0ef010152f908af015f8aad87246ab0215a9cd684673bb2c8793
7
+ data.tar.gz: de42b7abaff5512bdc00eba73d862778866034dd1a5d9b354649648a27b2ba2208062550e99ae4c91df8f51456f96bad4f7b4b89d2e263e13cc87c6d1daed231
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ # [0.7.1] - 2026-10-09
2
+
3
+ - Fix bug that removes Foobara::RuntimeError from GlobalDomain during type declaration init
4
+
1
5
  # [0.7.0] - 2026-10-09
2
6
 
3
7
  - Do not allow anything but domains (and orgs as a hack) to be children of orgs
@@ -57,6 +57,8 @@ module Foobara
57
57
  if result_type
58
58
  result result_type.reference_or_declaration_data
59
59
  end
60
+
61
+ # TODO: We don't have to clear out possible error types??
60
62
  end
61
63
  end
62
64
  end
@@ -62,6 +62,11 @@ module Foobara
62
62
  associative_array = build_and_register!(:associative_array, duckture, ::Hash)
63
63
  # TODO: uh oh... we do some translations in the casting here...
64
64
  build_and_register!(:attributes, associative_array, nil)
65
+
66
+ if needs_to_handle_reregistered_types
67
+ GlobalDomain.foobara_each_command(&:handle_reregistered_types!)
68
+ self.needs_to_handle_reregistered_types = false
69
+ end
65
70
  end
66
71
 
67
72
  def reset_all
@@ -5,6 +5,8 @@ module Foobara
5
5
 
6
6
  module BuiltinTypes
7
7
  class << self
8
+ attr_accessor :needs_to_handle_reregistered_types
9
+
8
10
  # TODO: break this up
9
11
  # TODO: much of this behavior is helpful to non-builtin types as well.
10
12
  def build_and_register!(
@@ -86,7 +88,17 @@ module Foobara
86
88
 
87
89
  # TODO: really need to encapsulate this somehow...
88
90
  type.type_symbol = type_symbol
89
- (type.foobara_parent_namespace || GlobalDomain).foobara_register(type)
91
+
92
+ domain = type.foobara_parent_namespace || GlobalDomain
93
+ mode = Namespace::LookupMode::DIRECT
94
+
95
+ exists = domain.foobara_registered?(type_symbol, mode:)
96
+ if exists
97
+ domain.foobara_unregister(domain.foobara_lookup_type(type_symbol, mode:))
98
+ self.needs_to_handle_reregistered_types = true
99
+ end
100
+
101
+ domain.foobara_register(type)
90
102
 
91
103
  supported_casters_module = Util.constant_value(builtin_type_module, :SupportedCasters)
92
104
  supported_caster_classes = if supported_casters_module
@@ -7,7 +7,6 @@ module Foobara
7
7
 
8
8
  def scoped_path
9
9
  if scoped_unregistered?
10
- # TODO: can probably delete this defensive check
11
10
  # simplecov:disable
12
11
  raise "Cannot use unregistered Scoped object"
13
12
  # simplecov:enable
@@ -17,35 +17,56 @@ module Foobara
17
17
  [
18
18
  :@foobara_children,
19
19
  :@foobara_registry,
20
- :@foobara_type_builder
20
+ :@foobara_type_builder,
21
+ :@lru_cache
21
22
  ].each do |var_name|
22
- # Don't we only have to do this for Foobara and not all of these??
23
- [
24
- Namespace.global,
25
- Foobara::GlobalOrganization,
26
- Foobara::GlobalDomain,
27
- Domain,
28
- Types::Type,
29
- Value::Processor,
30
- Error
31
- ].each do |klass|
23
+ namespaces_to_reset.each do |klass|
32
24
  if klass.instance_variable_defined?(var_name)
33
25
  klass.remove_instance_variable(var_name)
34
26
  end
35
27
  end
36
28
  end
37
29
 
38
- @original_scoped.each do |scoped|
39
- Namespace.global.foobara_register(scoped)
40
- end
30
+ Namespace.clear_lru_cache!
31
+
32
+ @original_scoped.each_key do |namespace|
33
+ scoped = @original_scoped[namespace]
34
+ to_remove = []
35
+
36
+ scoped.each do |child|
37
+ if child.scoped_unregistered?
38
+ to_remove << child
39
+ next
40
+ end
41
41
 
42
- children = Namespace.global.foobara_children
42
+ unless namespace.foobara_registered?(child, mode: Namespace::LookupMode::DIRECT)
43
+ namespace.foobara_register(child)
44
+ end
45
+ end
43
46
 
44
- @original_children.each do |child|
45
- children.foobara_children << child unless children.include?(child)
47
+ children = namespace.foobara_children
48
+
49
+ to_remove.each do |child|
50
+ children.delete(child)
51
+ scoped.delete(child)
52
+ end
53
+
54
+ to_remove.clear
55
+
56
+ @original_children[namespace].each do |child|
57
+ if child.scoped_unregistered?
58
+ to_remove << child
59
+ next
60
+ end
61
+ children << child unless children.include?(child)
62
+ end
63
+
64
+ to_remove.each do |child|
65
+ @original_children[namespace].delete(child)
66
+ end
46
67
  end
47
68
 
48
- GlobalOrganization.foobara_register(GlobalDomain)
69
+ Namespace.clear_lru_cache!
49
70
 
50
71
  register_type_declaration(Handlers::RegisteredTypeDeclaration.new)
51
72
  register_type_declaration(Handlers::ExtendRegisteredTypeDeclaration.new)
@@ -117,11 +138,33 @@ module Foobara
117
138
  capture_current_namespaces
118
139
  end
119
140
 
141
+ private
142
+
120
143
  def capture_current_namespaces
121
144
  # TODO: this feels like the wrong place to do this but doing it here for now to make sure it's done when
122
145
  # most important
123
- @original_scoped = Namespace.global.foobara_registry.all_scoped.dup
124
- @original_children = Namespace.global.foobara_children.dup
146
+ @original_scoped = {}
147
+ @original_children = {}
148
+
149
+ namespaces_to_reset.each do |namespace|
150
+ next unless namespace.is_a?(Namespace::IsNamespace)
151
+
152
+ @original_scoped[namespace] = namespace.foobara_registry.all_scoped.dup
153
+ @original_children[namespace] = namespace.foobara_children.dup
154
+ end
155
+ end
156
+
157
+ def namespaces_to_reset
158
+ [
159
+ Foobara::GlobalDomain,
160
+ Foobara::GlobalOrganization,
161
+ Value::Processor,
162
+ Types::Type,
163
+ Domain,
164
+ Error,
165
+ Foobara,
166
+ Namespace.global
167
+ ]
125
168
  end
126
169
  end
127
170
  end
data/version.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  module Foobara
2
2
  module Version
3
- VERSION = "0.7.0".freeze
3
+ VERSION = "0.7.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.0
4
+ version: 0.7.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Miles Georgi