Module: Hibiki::Rails::Generators::NestedInjections

Included in:
NestedGenerator
Defined in:
lib/generators/hibiki/rails/nested_injections.rb

Overview

What hibiki:rails:nested writes into files the app already owns. Every injection is guarded by a wired? probe, so a re-run is a no-op, and every missing anchor downgrades to a manual_wiring notice rather than a half-edit. Anchors that could collide are line-anchored regexes matching exactly once (Thor's insert_into_file replaces EVERY match, and a bare-string anchor also matches as a substring — the 0.7.0 trap).

Constant Summary collapse

CHANNEL_ANCHOR =
"  include Hibiki::Rails::Channel\n"
FORM_ANCHOR =

The whole reactive_attributes statement, continuation lines included: minimal lines up to the first blank one.

/^[ \t]*reactive_attributes\b(?:.*\n)+?\n/
FILE_END =

The class's own closing end — the only end at column zero.

/^end\n\z/
REMAINING_ANCHOR =
/^    @remaining = Hibiki::Derived\.new [^\n]*\n/
URL_PARAMS_ANCHOR =
/^      url_params: query_url_params/
ERB_FIELDSET_CLOSE =

The fieldset's close in the ERB row form: the one "

" a blank line follows.

%r{^  </div>\n\n}
ERB_FIELDS_CLOSE =

The fields partial's own outer close — column zero by construction.

%r{^</div>\n\z}
ERB_SUBMIT_DIV =
/^  <div>\n    <%= form\.submit/
PHLEX_FORM_ACTIONS_CALL =
/^      form_actions\n/
PHLEX_FORM_ACTIONS_DEF =
/^  def form_actions\n/
PHLEX_CONTROLS_CALL =
/^      controls\n/
PHLEX_CONTROLS_DEF =
/^  def controls\n/
PHLEX_PAGE_FIELDS_CALL =
/^      fields\(form\)\n/