foobara 0.0.68 → 0.0.70

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: 790ae183ee74af5880496317c73fd548aefe37167a38b4591dedb46b67a2bf79
4
- data.tar.gz: c057c7557d53dff6efef1ae9506b57a0fbdc0249f48cb10040de808697b7e495
3
+ metadata.gz: 9fa42ccdb3430fea47bc5de7590f08ef9c640e87d747eec8d4a594d4fd8d8a91
4
+ data.tar.gz: 797a5cef37a8478295bc5c887766ec69819fa150c005bd49e7501d3609337ff5
5
5
  SHA512:
6
- metadata.gz: b7b5571c2174ae0022efeccdbdcf053e8c2fcfa9cd152a4caf31d4f1313dd9f4ec32d0a249a88b4c59b271685e1676d0ba8537da77dd7c7e6b6a119838d40622
7
- data.tar.gz: 243e81f88a9456cb93ded173519f79eb863779ce8957fc51fc3ba808acc24b0ad59090310b4671bfa4034adfc676bc1733c43a3e60b615b7439eb7ec414fb53d
6
+ metadata.gz: 771d25f93db9d12e31a9f74143840375bf1cd702f7b02f394c44411c12f50d37ce210213737794778dca08e6264ac4166b094930edb6969f20117f2b888d7e49
7
+ data.tar.gz: c565ae11e35f1a767761823655e2294a70cd07fa02acb403bb6f37d43a3f471bb909d4b315e7defaaadb56b999e9778466092238f2f89af3722aa169666eee11
data/CHANGELOG.md CHANGED
@@ -1,3 +1,11 @@
1
+ # [0.0.70] - 2025-03-06
2
+
3
+ - Make sure Foobara::Command.depends_on is inherited
4
+
5
+ ## [0.0.69] - 2025-03-03
6
+
7
+ - Allow StateMachine to use an attribute on another object as its current state for convenience
8
+
1
9
  ## [0.0.68] - 2025-02-28
2
10
 
3
11
  - Make use of LruCache for performance boost when converting type declarations to types
@@ -56,7 +56,15 @@ module Foobara
56
56
  end
57
57
 
58
58
  def depends_on(*subcommand_classes)
59
- return @depends_on ||= Set.new if subcommand_classes.empty?
59
+ if subcommand_classes.empty?
60
+ return @depends_on if defined?(@depends_on)
61
+
62
+ @depends_on = if self == Foobara::Command
63
+ Set.new
64
+ else
65
+ superclass.depends_on.dup
66
+ end
67
+ end
60
68
 
61
69
  if subcommand_classes.length == 1
62
70
  subcommand_classes = Util.array(subcommand_classes.first)
@@ -3,11 +3,9 @@ module Foobara
3
3
  module Callbacks
4
4
  include Concern
5
5
 
6
- # owner helps with determining the relevant object when running class-registered state transition callbacks
7
- attr_accessor :callback_registry, :owner
6
+ attr_accessor :callback_registry
8
7
 
9
- def initialize(owner: nil)
10
- self.owner = owner
8
+ def initialize(...)
11
9
  self.callback_registry = Callback::Registry::ChainedConditioned.new(self.class.class_callback_registry)
12
10
  end
13
11
 
@@ -34,12 +34,36 @@ module Foobara
34
34
  end
35
35
  end
36
36
 
37
- attr_accessor :current_state
37
+ attr_accessor :target_attribute, :owner
38
+
39
+ # owner is optional. It can help with certain callbacks. It's also required if planning to use the target_attribute
40
+ # feature
41
+ def initialize(*args, owner: nil, target_attribute: nil, **options)
42
+ self.owner = owner
38
43
 
39
- def initialize(*args, **options)
40
44
  super
41
45
 
42
- self.current_state = self.class.initial_state
46
+ if target_attribute
47
+ self.target_attribute = target_attribute
48
+ else
49
+ self.current_state = self.class.initial_state
50
+ end
51
+ end
52
+
53
+ def current_state
54
+ if target_attribute
55
+ owner.send(target_attribute) || self.class.initial_state
56
+ else
57
+ @current_state
58
+ end
59
+ end
60
+
61
+ def current_state=(state)
62
+ if target_attribute
63
+ owner.send("#{target_attribute}=", state)
64
+ else
65
+ @current_state = state
66
+ end
43
67
  end
44
68
 
45
69
  def perform_transition!(transition, &block)
@@ -5,7 +5,7 @@ module Foobara
5
5
 
6
6
  attr_accessor :log
7
7
 
8
- def initialize(*args, **options)
8
+ def initialize(...)
9
9
  super
10
10
 
11
11
  self.log = []
@@ -111,8 +111,6 @@ module Foobara
111
111
  capture_current_namespaces
112
112
  end
113
113
 
114
- private
115
-
116
114
  def capture_current_namespaces
117
115
  # TODO: this feels like the wrong place to do this but doing it here for now to make sure it's done when
118
116
  # most important
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.68
4
+ version: 0.0.70
5
5
  platform: ruby
6
6
  authors:
7
7
  - Miles Georgi
8
8
  bindir: bin
9
9
  cert_chain: []
10
- date: 2025-02-28 00:00:00.000000000 Z
10
+ date: 2025-03-06 00:00:00.000000000 Z
11
11
  dependencies:
12
12
  - !ruby/object:Gem::Dependency
13
13
  name: bigdecimal
@@ -460,7 +460,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
460
460
  - !ruby/object:Gem::Version
461
461
  version: '0'
462
462
  requirements: []
463
- rubygems_version: 3.6.3
463
+ rubygems_version: 3.6.5
464
464
  specification_version: 4
465
465
  summary: A command-centric and discoverable software framework with a focus on domain
466
466
  concepts and abstracting away integration code