hecks 1.5.0 → 1.5.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.
@@ -31,11 +31,13 @@ module Hecks
31
31
  #
32
32
  # an export takes a declaration and its bindings and answers
33
33
  # something that is the domain, running elsewhere — rust/project.rb's
34
- # generated crate, the WASM artifact, the SAM template
35
- # bin/project_deploy renders. It needs the `.world`/`.hecksagon` a
36
- # projection never looks at, because a running system has to know how
37
- # it is wired. That is the whole reason bin/project_deploy cannot use
38
- # this protocol: `call(bluebook:, options:)` has no channel for it.
34
+ # generated crate, the WASM artifact, the CloudFormation template
35
+ # `lib/hecks/projections/deploy` renders. It needs the
36
+ # `.world`/`.hecksagon` a projection never looks at, because a
37
+ # running system has to know how it is wired. A target that needs
38
+ # this declares `needs_world: true` (`Target#projects_as`) and reads
39
+ # `options.fetch(:world)`; `Projector.call`'s own `world:` keyword is
40
+ # what carries it, merged into `options` before the target ever runs.
39
41
  #
40
42
  # a state projection takes records — a domain after dispatch — and is
41
43
  # a read-model question wearing the same word.
@@ -88,17 +90,21 @@ module Hecks
88
90
  # @param bluebook [Bluebook::Behaviour::Chapter, Hecks::IR] the chapter or
89
91
  # IR-emitting construct to project
90
92
  # @param options [Hash] projector-specific options, passed through unchanged
93
+ # @param world [Bluebook::World, nil] the domain's `.world`/`.hecksagon` bindings,
94
+ # required by an export (`needs_world: true`); nil for an ordinary projection.
95
+ # Merged into `options[:world]` before the target runs — the target never
96
+ # receives it as a separate argument.
91
97
  # @return [Object] whatever the projector's own `call` returns: typically a
92
98
  # `Hash`/`String` artifact, or a `Hash{String => String}` file tree
93
99
  # @raise [UnknownProjector] if no projector is registered under `name`
94
100
  # @raise [WrongConstruct] if `bluebook` lacks a capability or aggregate the
95
- # projector requires
96
- def call(name, bluebook:, options: {})
101
+ # projector requires, or if the projector needs `world:` and none is given
102
+ def call(name, bluebook:, options: {}, world: nil)
97
103
  projector = registry.fetch(name.to_sym) do
98
104
  raise UnknownProjector, "no projector registered for #{name.inspect} — registered: #{registered.sort.inspect}"
99
105
  end
100
- admits!(name, projector, bluebook)
101
- projector.call(bluebook: bluebook, options: options)
106
+ admits!(name, projector, bluebook, world)
107
+ projector.call(bluebook: bluebook, options: world ? options.merge(world: world) : options)
102
108
  end
103
109
 
104
110
  # Refuses `construct` if it lacks a capability or declared aggregate
@@ -116,13 +122,17 @@ module Hecks
116
122
  # @param name [String, Symbol] the projector's registered key, used in the message
117
123
  # when refusing
118
124
  # @param projector [Module, Class, #call] the target being checked; consulted for
119
- # `projection_requires` and `projection_declares` when it answers them
125
+ # `projection_requires`, `projection_declares`, and `projection_needs_world?` when
126
+ # it answers them
120
127
  # @param construct [Bluebook::Behaviour::Chapter, Hecks::IR] the chapter or
121
128
  # IR-emitting construct offered to the projector
129
+ # @param world [Bluebook::World, nil] the `world:` given to `Projector.call`, checked
130
+ # against the target's own `needs_world:` declaration
122
131
  # @return [void]
123
- # @raise [WrongConstruct] if `construct` lacks a required capability, or the
124
- # chapter it is declares no aggregate the projector needs
125
- def admits!(name, projector, construct)
132
+ # @raise [WrongConstruct] if `construct` lacks a required capability, the chapter it
133
+ # is declares no aggregate the projector needs, or the projector needs `world:`
134
+ # and `world` is nil
135
+ def admits!(name, projector, construct, world = nil)
126
136
  needed = projector.respond_to?(:projection_requires) ? projector.projection_requires : []
127
137
  missing = needed.reject { |capability| capable?(construct, capability) }
128
138
  unless missing.empty?
@@ -133,11 +143,15 @@ module Hecks
133
143
 
134
144
  declared = projector.respond_to?(:projection_declares) ? projector.projection_declares : []
135
145
  absent = declared.reject { |named| construct.aggregate(named) }
136
- return if absent.empty?
146
+ unless absent.empty?
147
+ raise WrongConstruct,
148
+ "#{name.inspect} needs a chapter declaring #{absent.join(' and ')}; " \
149
+ "#{construct.name} declares no such aggregate."
150
+ end
151
+
152
+ return unless projector.respond_to?(:projection_needs_world?) && projector.projection_needs_world? && world.nil?
137
153
 
138
- raise WrongConstruct,
139
- "#{name.inspect} needs a chapter declaring #{absent.join(' and ')}; " \
140
- "#{construct.name} declares no such aggregate."
154
+ raise WrongConstruct, "#{name.inspect} needs .world/.hecksagon bindings — pass world: to Projector.call."
141
155
  end
142
156
 
143
157
  # Tells whether `construct` has the capability `admits!` requires of it.
data/lib/hecks/version.rb CHANGED
@@ -12,5 +12,5 @@ module Hecks
12
12
  # it there, or even in the consuming Gemfile, never closed the gap,
13
13
  # because gemspec evaluation happens before anything Bundler
14
14
  # resolves is actually loadable yet.
15
- VERSION = "1.5.0".freeze
15
+ VERSION = "1.5.1".freeze
16
16
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hecks
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.5.0
4
+ version: 1.5.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chris Young
@@ -378,6 +378,9 @@ files:
378
378
  - lib/hecks/ports/query/ordering.rb
379
379
  - lib/hecks/projections.rb
380
380
  - lib/hecks/projections/bootstrap_table.rb
381
+ - lib/hecks/projections/deploy/fargate.rb
382
+ - lib/hecks/projections/deploy/lambda.rb
383
+ - lib/hecks/projections/deploy/shared.rb
381
384
  - lib/hecks/projections/diagrams.rb
382
385
  - lib/hecks/projections/glossary.rb
383
386
  - lib/hecks/projections/glossary/html.rb
@@ -1 +0,0 @@
1
- ../../../../examples/compliance/bluebook/compliance.bluebook