Class: Binpacker::ProjectState
- Inherits:
-
Object
- Object
- Binpacker::ProjectState
- Defined in:
- lib/binpacker/project_state.rb,
sig/binpacker/project_state.rbs
Overview
Inspects the working directory to report binpacker's setup state and
recommend the next skill. Backs binpacker describe.
See docs/design/agent-workflows.md.
Constant Summary collapse
- CONFIG_FILE =
"binpacker.yml"- DEFAULT_TIMING_FILE =
"binpacker.timings"- SUPPORTED_FRAMEWORKS =
%w[rspec minitest].freeze
- TESTUNIT_HINT =
%r{test-unit|test/unit}
Instance Method Summary collapse
- #ci_wired? ⇒ Boolean
- #config_present? ⇒ Boolean
-
#framework ⇒ String?
"rspec", "minitest", "test-unit", or nil.
-
#recommendation ⇒ String
The skill the agent should run next.
-
#supported_framework? ⇒ Boolean
binpacker ships runners for rspec and minitest only.
- #timing_present? ⇒ Boolean
- #to_h ⇒ Hash[Symbol, untyped]
Instance Method Details
#ci_wired? ⇒ Boolean
36 37 38 39 40 |
# File 'lib/binpacker/project_state.rb', line 36 def ci_wired? Dir.glob(".github/workflows/*.{yml,yaml}").any? do |wf| File.read(wf).include?("binpacker run") end end |
#config_present? ⇒ Boolean
13 14 15 |
# File 'lib/binpacker/project_state.rb', line 13 def config_present? File.exist?(CONFIG_FILE) end |
#framework ⇒ String?
"rspec", "minitest", "test-unit", or nil. Minitest and test-unit share the *_test.rb convention, so they are told apart by dependency hints.
23 24 25 26 27 |
# File 'lib/binpacker/project_state.rb', line 23 def framework return minitest_family if minitest_globs? return "rspec" if Dir.glob("spec/**/*_spec.rb").any? nil end |
#recommendation ⇒ String
The skill the agent should run next.
43 44 45 46 |
# File 'lib/binpacker/project_state.rb', line 43 def recommendation return "binpacker-setup" unless config_present? && timing_present? "binpacker-improve" end |
#supported_framework? ⇒ Boolean
binpacker ships runners for rspec and minitest only. A detected framework outside that set (e.g. test-unit) is unsupported; nil is merely unknown.
31 32 33 34 |
# File 'lib/binpacker/project_state.rb', line 31 def supported_framework? fw = framework fw.nil? || SUPPORTED_FRAMEWORKS.include?(fw) end |
#timing_present? ⇒ Boolean
17 18 19 |
# File 'lib/binpacker/project_state.rb', line 17 def timing_present? File.exist?(timing_file) end |
#to_h ⇒ Hash[Symbol, untyped]
48 49 50 51 52 53 54 55 56 |
# File 'lib/binpacker/project_state.rb', line 48 def to_h { config_present: config_present?, timing_present: timing_present?, framework: framework, ci_wired: ci_wired?, recommendation: recommendation } end |