Module: AsyncapiCable::Generator::RakeTaskSupport
- Defined in:
- lib/asyncapi_cable/generator/rake_task_support.rb
Overview
Helpers backing the asyncapi_cable:generate rake task. Framework
detection and the subprocess environment are openapi-ruby's: the two
generators run against the same host, and a second copy of that logic
would drift from the one the OpenAPI schema is generated with.
Class Method Summary collapse
- .default_pattern_for(framework) ⇒ Object
- .detect_test_framework ⇒ Object
- .generate_script(framework, pattern) ⇒ Object
-
.subprocess_env ⇒ Object
OPENAPI_RUBY_GENERATINGcomes along on purpose: host test helpers guard their test-framework requires withunless OpenapiRuby.schema_generating?, and a cable generation run is the same kind of run — files are loaded for their declarations, never executed — so that guard has to fire here too.
Class Method Details
.default_pattern_for(framework) ⇒ Object
18 19 20 21 22 23 24 25 26 |
# File 'lib/asyncapi_cable/generator/rake_task_support.rb', line 18 def default_pattern_for(framework) DeclarationLoader.validate_framework!(framework) case framework when "rspec" then "spec/**/*_spec.rb" when "minitest" then "test/**/*_test.rb" when "hybrid" then "spec/**/*_spec.rb,test/**/*_test.rb" end end |
.detect_test_framework ⇒ Object
14 15 16 |
# File 'lib/asyncapi_cable/generator/rake_task_support.rb', line 14 def detect_test_framework OpenapiRuby::Generator::RakeTaskSupport.detect_test_framework end |
.generate_script(framework, pattern) ⇒ Object
39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/asyncapi_cable/generator/rake_task_support.rb', line 39 def generate_script(framework, pattern) DeclarationLoader.validate_framework!(framework) <<~RUBY require "asyncapi_cable/generator/runner" AsyncapiCable::Generator::Runner.call( framework: #{framework.inspect}, pattern: #{pattern.inspect} ) RUBY end |
.subprocess_env ⇒ Object
OPENAPI_RUBY_GENERATING comes along on purpose: host test helpers
guard their test-framework requires with
unless OpenapiRuby.schema_generating?, and a cable generation run is
the same kind of run — files are loaded for their declarations, never
executed — so that guard has to fire here too.
33 34 35 36 37 |
# File 'lib/asyncapi_cable/generator/rake_task_support.rb', line 33 def subprocess_env OpenapiRuby::Generator::RakeTaskSupport .subprocess_env .merge("ASYNCAPI_CABLE_GENERATING" => "true") end |