foobara 0.0.122 → 0.0.123

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: 58d1193f368aef3f0903e67152b0b7a3a1a84370a319a0f046d2d328249897be
4
- data.tar.gz: 27617857c8d1ce1fd392fdfdad9348206fea4dad29f2ca8f68fa712abc52c048
3
+ metadata.gz: 604089ac36c58dbd5640d75018baabab9510df8ef2c358318af660c0fa1db12a
4
+ data.tar.gz: e87264b5380e66ab05985092f370c4c00c668b0d860e91df86d6f9044738fc0f
5
5
  SHA512:
6
- metadata.gz: daf5f6327e44917051a5c00a53d2e875dc744b20af07b84801c1fea3f3b581e0afa3d38636b77b2e044ee85b25c280461fb78e1f9d0150a2e7023f39749d91e4
7
- data.tar.gz: 5cdc61d92d02180c083bb764ae52b6ae903f08bb186b6a60f66af4b47e8c32b90b950ba50a613409eda941ed1fb95d66b6751a9b580841102cffcf3b99e7d34e
6
+ metadata.gz: f47aab9fd3411f3999d07dd3ba07d29fc6512b5efcf0eb2d1059f6f8d49b64edc3a38a4f9831d9b277844d80497600384902e7092c9c7237b74db6b6b92eaa69
7
+ data.tar.gz: dd0f28a582d9deb6429c4419d3b715836566d19c14ccb4791408d3b3d8015b9694b48041f697f972934a9a013490bc6df3309ea75d2b414f3b4ff69de4d1f855
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ # [0.0.123] - 2025-05-14
2
+
3
+ - Allow type name strings as type declarations as a fallback instead of only symbols
4
+
1
5
  # [0.0.122] - 2025-05-13
2
6
 
3
7
  - Add command connector sugar features and implement several command connector sugars
@@ -7,13 +7,17 @@ module Foobara
7
7
  # TODO: make a quick way to convert a couple simple procs into a transformer
8
8
  class SymbolDesugarizer < TypeDeclarations::Desugarizer
9
9
  def applicable?(sugary_type_declaration)
10
- sugary_type_declaration.is_a?(Symbol) && type_registered?(sugary_type_declaration)
10
+ if sugary_type_declaration.is_a?(::Symbol)
11
+ type_registered?(sugary_type_declaration)
12
+ elsif sugary_type_declaration.is_a?(::String) && TypeDeclarations.stringified?
13
+ applicable?(sugary_type_declaration.to_sym)
14
+ end
11
15
  end
12
16
 
13
17
  def desugarize(symbol)
14
18
  # TODO: just use the symbol and nothing else??
15
19
  # maybe confusing in languages with no distinction between symbol and string?
16
- { type: symbol }
20
+ { type: symbol.to_sym }
17
21
  end
18
22
 
19
23
  def priority
@@ -108,6 +108,14 @@ module Foobara
108
108
  lru_cache.cached([type_declaration_bits, block]) do
109
109
  type_for_declaration_without_cache(*type_declaration_bits, &block)
110
110
  end
111
+ rescue NoTypeDeclarationHandlerFoundError
112
+ raise if TypeDeclarations.strict_stringified?
113
+ raise if TypeDeclarations.stringified?
114
+ raise if TypeDeclarations.strict?
115
+
116
+ TypeDeclarations.stringified do
117
+ type_for_declaration(*type_declaration_bits, &block)
118
+ end
111
119
  end
112
120
 
113
121
  def type_for_declaration_without_cache(*type_declaration_bits, &)
@@ -8,6 +8,7 @@ module Foobara
8
8
  module Mode
9
9
  STRICT = :strict
10
10
  STRICT_STRINGIFIED = :strict_stringified
11
+ STRINGIFIED = :stringified
11
12
  end
12
13
 
13
14
  class << self
@@ -70,6 +71,10 @@ module Foobara
70
71
  using_mode(Mode::STRICT_STRINGIFIED, &)
71
72
  end
72
73
 
74
+ def stringified(&)
75
+ using_mode(Mode::STRINGIFIED, &)
76
+ end
77
+
73
78
  # TODO: use manifest context instead
74
79
  def using_mode(new_mode, &)
75
80
  with_manifest_context(mode: new_mode, &)
@@ -83,6 +88,10 @@ module Foobara
83
88
  foobara_manifest_context_mode == Mode::STRICT_STRINGIFIED
84
89
  end
85
90
 
91
+ def stringified?
92
+ foobara_manifest_context_mode == Mode::STRINGIFIED
93
+ end
94
+
86
95
  # TODO: we should desugarize these but can't because of a bug where desugarizing entities results in creating the
87
96
  # entity class in memory, whoops.
88
97
  def declarations_equal?(declaration1, declaration2)
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: foobara
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.122
4
+ version: 0.0.123
5
5
  platform: ruby
6
6
  authors:
7
7
  - Miles Georgi
8
8
  bindir: bin
9
9
  cert_chain: []
10
- date: 2025-05-13 00:00:00.000000000 Z
10
+ date: 2025-05-14 00:00:00.000000000 Z
11
11
  dependencies:
12
12
  - !ruby/object:Gem::Dependency
13
13
  name: bigdecimal