inquirex 0.3.0 → 0.4.0
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 +4 -4
- data/.ruby-version +1 -1
- data/README.md +37 -3
- data/docs/badges/coverage_badge.svg +2 -2
- data/justfile +47 -16
- data/lib/inquirex/engine.rb +27 -0
- data/lib/inquirex/version.rb +1 -1
- metadata +3 -5
- data/exe/inquirex +0 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: a59215d626aa41651ff87814be16abcbdb802f208151ffe0911111ab252f89b0
|
|
4
|
+
data.tar.gz: f6178810008d8800b4ada40ed83bb2b161653ef9f469acd09eee64607e1bec4a
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 94d4312b92047971aca5cd95ed99731c927515954b662c15c43f67034523d6e5a5827829f991161b65d7df7e998b29163a0f7930e531cf6b130c558b3febb80b
|
|
7
|
+
data.tar.gz: 5b5fce185e6c80c33ab289e1403c6db89c92e3c4c8e270e098c1ff22f1a697e39f4a59ac55a4818b88f711e1474e51dc95ffe9d9c76b910902deec9424b42d0c
|
data/.ruby-version
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
4.0.
|
|
1
|
+
4.0.5
|
data/README.md
CHANGED
|
@@ -4,6 +4,19 @@
|
|
|
4
4
|
|
|
5
5
|
`inquirex` is a pure Ruby, declarative, rules-driven questionnaire engine for building conditional intake forms, qualification wizards, and branching surveys.
|
|
6
6
|
|
|
7
|
+
> [!IMPORTANT]
|
|
8
|
+
>
|
|
9
|
+
> Note that `inquirex` is the base gem of the ecosystem that contains:
|
|
10
|
+
>
|
|
11
|
+
> - [`inquirex`](https://github.com/inquirex/inquirex)
|
|
12
|
+
> - [`inquirex-llm`](https://github.com/inquirex/inquirex-llm)
|
|
13
|
+
> - [`inquirex-tty`](https://github.com/inquirex/inquirex-)
|
|
14
|
+
> - [`inquirex-js`](https://github.com/inquirex/inquirex-js)
|
|
15
|
+
>
|
|
16
|
+
> For a presentation on these gems and what they do please watch the [RubySF presentation](https://www.youtube.com/watch?v=iaoKW7Ap3_M&t=1s) and you can also [view the slides form the presentation](https://reinvent.one/images/talks/pdfs/2026.inquirex.pdf).
|
|
17
|
+
|
|
18
|
+
## Summary
|
|
19
|
+
|
|
7
20
|
It is the core gem in the Inquirex ecosystem and focuses on:
|
|
8
21
|
|
|
9
22
|
- A conversational DSL (`ask`, `say`, `header`, `btw`, `warning`, `confirm`)
|
|
@@ -17,8 +30,8 @@ It is the core gem in the Inquirex ecosystem and focuses on:
|
|
|
17
30
|
|
|
18
31
|
## Status
|
|
19
32
|
|
|
20
|
-
- Version: `0.
|
|
21
|
-
- Ruby: `>= 4.0.0` (project currently uses `4.0.
|
|
33
|
+
- Version: `0.4.0`
|
|
34
|
+
- Ruby: `>= 4.0.0` (project currently uses `4.0.5`)
|
|
22
35
|
- Test suite: `220 examples, 0 failures`
|
|
23
36
|
- Coverage: ~`94%` line coverage
|
|
24
37
|
|
|
@@ -282,7 +295,11 @@ engine.totals # => { price: 700.0, complexity: 4 }
|
|
|
282
295
|
|
|
283
296
|
### JSON wire format
|
|
284
297
|
|
|
285
|
-
Accumulators serialize predictably, keeping the contract with `inquirex-js` explicit
|
|
298
|
+
Accumulators serialize predictably, keeping the contract with `inquirex-js` explicit.
|
|
299
|
+
|
|
300
|
+
> [!NOTE]
|
|
301
|
+
>
|
|
302
|
+
> You can convert between Ruby DSL and JSON using the [`inquirex-tty`](https://github.com/inquirex/inquirex-tty) gem.
|
|
286
303
|
|
|
287
304
|
```json
|
|
288
305
|
{
|
|
@@ -381,6 +398,23 @@ Behavior:
|
|
|
381
398
|
- Use `finished?` to detect completion
|
|
382
399
|
- Use `total(:price)` / `totals` to read running totals
|
|
383
400
|
- Use `to_state` / `.from_state` for persistence/resume (totals included)
|
|
401
|
+
- Use `prefill!(hash)` to merge externally-supplied answers into the state,
|
|
402
|
+
e.g. fields extracted by an LLM from a free-text answer (see
|
|
403
|
+
[inquirex-llm](#extension-gems)). Existing answers are preserved; `nil`
|
|
404
|
+
and empty values are ignored so they don't spuriously satisfy
|
|
405
|
+
`not_empty` rules. The engine auto-advances past any newly-skippable step.
|
|
406
|
+
|
|
407
|
+
```ruby
|
|
408
|
+
engine = Inquirex::Engine.new(definition)
|
|
409
|
+
engine.answer("I'm MFJ with two kids in California.") # free-text :describe
|
|
410
|
+
|
|
411
|
+
# Step is now :extracted (a clarify node); adapter returns a Hash.
|
|
412
|
+
result = adapter.call(engine.current_step, engine.answers)
|
|
413
|
+
engine.answer(result) # store under the clarify step's id
|
|
414
|
+
engine.prefill!(result) # splat into top-level answers
|
|
415
|
+
# Downstream :filing_status, :dependents, :state are now auto-skipped by
|
|
416
|
+
# `skip_if not_empty(:filing_status)` etc.
|
|
417
|
+
```
|
|
384
418
|
|
|
385
419
|
### Validation Adapter
|
|
386
420
|
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
<g fill="#fff" text-anchor="middle" font-family="DejaVu Sans,Verdana,Geneva,sans-serif" font-size="11">
|
|
16
16
|
<text x="31.5" y="15" fill="#010101" fill-opacity=".3">coverage</text>
|
|
17
17
|
<text x="31.5" y="14">coverage</text>
|
|
18
|
-
<text x="80" y="15" fill="#010101" fill-opacity=".3">
|
|
19
|
-
<text x="80" y="14">
|
|
18
|
+
<text x="80" y="15" fill="#010101" fill-opacity=".3">95%</text>
|
|
19
|
+
<text x="80" y="14">95%</text>
|
|
20
20
|
</g>
|
|
21
21
|
</svg>
|
data/justfile
CHANGED
|
@@ -1,38 +1,69 @@
|
|
|
1
|
-
|
|
1
|
+
# Tell 'just' to run bash, source our setup script, then execute the recipe
|
|
2
|
+
set shell := ["bash", "-c"]
|
|
2
3
|
|
|
3
|
-
|
|
4
|
+
version := `grep VERSION lib/inquirex/version.rb | awk '{print $3}' | tr -d '"' | tr -d '\n'`
|
|
5
|
+
rbenv := 'eval "$(rbenv init bash)"; bundle exec '
|
|
6
|
+
repo := 'git@github.com:inquirex/inquirex.git'
|
|
4
7
|
|
|
5
8
|
[no-exit-message]
|
|
6
9
|
recipes:
|
|
7
|
-
|
|
10
|
+
just --choose
|
|
8
11
|
|
|
9
12
|
# Sync all dependencies
|
|
10
13
|
install:
|
|
11
|
-
|
|
14
|
+
bin/setup
|
|
12
15
|
|
|
13
|
-
|
|
14
|
-
lint-fix *args:
|
|
15
|
-
{{rbenv}} && bundle exec rubocop -a
|
|
16
|
-
|
|
17
|
-
alias format := lint-fix
|
|
16
|
+
build: install
|
|
18
17
|
|
|
19
18
|
# Lint and reformat files
|
|
20
19
|
lint:
|
|
21
|
-
{{rbenv}}
|
|
20
|
+
{{ rbenv }} rubocop
|
|
21
|
+
|
|
22
|
+
# Lint and reformat files (-a) — pass -A as an argument
|
|
23
|
+
format *args:
|
|
24
|
+
{{ rbenv }} rubocop -a {{ args }}
|
|
22
25
|
|
|
23
26
|
# Run all the tests
|
|
24
27
|
test *args:
|
|
25
|
-
|
|
28
|
+
export ENVIRONMENT=test; {{ rbenv }} rspec {{args}}
|
|
26
29
|
|
|
27
30
|
# Run tests with coverage
|
|
28
31
|
test-coverage *args:
|
|
29
|
-
ENVIRONMENT=test COVERAGE=true
|
|
32
|
+
export ENVIRONMENT=test; export COVERAGE=true; {{ rbenv }} rspec {{ args }}
|
|
33
|
+
|
|
34
|
+
check-all: lint test-coverage
|
|
30
35
|
|
|
31
36
|
clean:
|
|
32
37
|
#!/usr/bin/env bash
|
|
33
|
-
find . -name .DS_Store -delete -print || true
|
|
34
|
-
rm -rf tmp/*
|
|
38
|
+
@find . -name .DS_Store -delete -print || true
|
|
39
|
+
@rm -rf tmp/*
|
|
35
40
|
|
|
36
41
|
# Run all lefthook pre-commit hooks
|
|
37
|
-
|
|
38
|
-
{{rbenv}}
|
|
42
|
+
lefthook:
|
|
43
|
+
{{ rbenv }} lefthook run pre-commit --all-files
|
|
44
|
+
|
|
45
|
+
# Print current gem version
|
|
46
|
+
version:
|
|
47
|
+
@echo "{{ version }}"
|
|
48
|
+
|
|
49
|
+
# Clobber
|
|
50
|
+
clobber:
|
|
51
|
+
{{ rbenv }} rake clobber
|
|
52
|
+
|
|
53
|
+
# Generate documentation
|
|
54
|
+
doc:
|
|
55
|
+
#!/usr/bin/env bash
|
|
56
|
+
{{ rbenv }} rake doc
|
|
57
|
+
|
|
58
|
+
# Create
|
|
59
|
+
publish: build
|
|
60
|
+
{{ rbenv }} rake release[remote]
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
# Tag v{{ version }}, publish the GH release, & refresh the Homebrew tap.
|
|
64
|
+
release:
|
|
65
|
+
git fetch --tags
|
|
66
|
+
git tag -f "v{{ version }}"
|
|
67
|
+
git push -f --tags
|
|
68
|
+
gh release delete -y "v{{ version }}" --repo {{ repo }} 2>/dev/null || true
|
|
69
|
+
gh release create "v{{ version }}" --generate-notes --repo {{ repo }}
|
data/lib/inquirex/engine.rb
CHANGED
|
@@ -74,6 +74,33 @@ module Inquirex
|
|
|
74
74
|
advance_step
|
|
75
75
|
end
|
|
76
76
|
|
|
77
|
+
# Merges a hash of { step_id => value } into the top-level answers without
|
|
78
|
+
# clobbering answers the user has already provided. Used by LLM clarify
|
|
79
|
+
# steps to populate downstream answers from free-text extraction so that
|
|
80
|
+
# `skip_if not_empty(:id)` rules on later steps will fire.
|
|
81
|
+
#
|
|
82
|
+
# Nil/empty values in the hash are ignored so that "unknown" LLM outputs
|
|
83
|
+
# don't spuriously satisfy `not_empty` rules.
|
|
84
|
+
#
|
|
85
|
+
# If the engine's current step becomes skippable as a result of the prefill,
|
|
86
|
+
# it auto-advances past it.
|
|
87
|
+
#
|
|
88
|
+
# @param hash [Hash] answers keyed by step id
|
|
89
|
+
# @return [Hash] the updated answers
|
|
90
|
+
def prefill!(hash)
|
|
91
|
+
return @answers unless hash.is_a?(Hash)
|
|
92
|
+
|
|
93
|
+
hash.each do |key, value|
|
|
94
|
+
next if value.nil?
|
|
95
|
+
next if value.respond_to?(:empty?) && value.empty?
|
|
96
|
+
|
|
97
|
+
sym = key.to_sym
|
|
98
|
+
@answers[sym] = value unless @answers.key?(sym)
|
|
99
|
+
end
|
|
100
|
+
skip_if_needed unless finished?
|
|
101
|
+
@answers
|
|
102
|
+
end
|
|
103
|
+
|
|
77
104
|
# Serializable state snapshot for persistence or resumption.
|
|
78
105
|
#
|
|
79
106
|
# @return [Hash]
|
data/lib/inquirex/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: inquirex
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.4.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Konstantin Gredeskoul
|
|
8
|
-
bindir:
|
|
8
|
+
bindir: bin
|
|
9
9
|
cert_chain: []
|
|
10
10
|
date: 1980-01-02 00:00:00.000000000 Z
|
|
11
11
|
dependencies: []
|
|
@@ -18,8 +18,7 @@ description: Inquirex lets you define multi-step questionnaires as directed grap
|
|
|
18
18
|
immutable definitions.
|
|
19
19
|
email:
|
|
20
20
|
- kigster@gmail.com
|
|
21
|
-
executables:
|
|
22
|
-
- inquirex
|
|
21
|
+
executables: []
|
|
23
22
|
extensions: []
|
|
24
23
|
extra_rdoc_files: []
|
|
25
24
|
files:
|
|
@@ -33,7 +32,6 @@ files:
|
|
|
33
32
|
- README.md
|
|
34
33
|
- Rakefile
|
|
35
34
|
- docs/badges/coverage_badge.svg
|
|
36
|
-
- exe/inquirex
|
|
37
35
|
- justfile
|
|
38
36
|
- lefthook.yml
|
|
39
37
|
- lib/inquirex.rb
|
data/exe/inquirex
DELETED