Module: Studio::EnvironmentBanner
- Defined in:
- lib/studio/environment_banner.rb
Overview
The shared dev/QA environment banner's decisions, as pure Ruby.
Every Studio app used to hand-roll its own yellow "studio/banners/_environment
renders them, so a host adopts the standard with one render call.
Dependency-free on purpose: the unit suite requires this file directly, so the tests exercise the SHIPPED rules rather than a copy of them.
Constant Summary collapse
- QA_ENV_VAR =
"QA_ENV"- INBOX_PATH =
The engine's local email inbox (Studio::LocalEmailsController).
"/_studio/local_emails"
Class Method Summary collapse
-
.message(rails_env:, qa_environment: qa_environment?, , extra: []) ⇒ Object
"Development Environment" · "QA Environment · Non-production", plus any app-supplied suffix ("Devnet", ...).
- .present_parts(extra) ⇒ Object
-
.qa_environment?(env = ENV) ⇒ Boolean
True for stable QA apps.
-
.show?(rails_env:, qa_environment: qa_environment?) ) ⇒ Boolean
Show the banner in every environment EXCEPT real production.
- .truthy?(value) ⇒ Boolean
Class Method Details
.message(rails_env:, qa_environment: qa_environment?, , extra: []) ⇒ Object
"Development Environment" · "QA Environment · Non-production", plus any app-supplied suffix ("Devnet", ...).
38 39 40 41 42 43 44 45 46 |
# File 'lib/studio/environment_banner.rb', line 38 def (rails_env:, qa_environment: qa_environment?, extra: []) head = if qa_environment ["QA Environment", "Non-production"] else ["#{rails_env.to_s.capitalize} Environment"] end (head + present_parts(extra)).join(" · ") end |
.present_parts(extra) ⇒ Object
48 49 50 |
# File 'lib/studio/environment_banner.rb', line 48 def present_parts(extra) Array(extra).map(&:to_s).reject { |part| part.strip.empty? } end |
.qa_environment?(env = ENV) ⇒ Boolean
True for stable QA apps. They run Rails in production mode but are non-production REVIEW targets and must say so. The release conductor sets QA_ENV=true on every QA app (mcritchie-studio/config/qa_environments.yml).
24 25 26 |
# File 'lib/studio/environment_banner.rb', line 24 def qa_environment?(env = ENV) truthy?(env[QA_ENV_VAR]) end |
.show?(rails_env:, qa_environment: qa_environment?) ) ⇒ Boolean
Show the banner in every environment EXCEPT real production. A QA app is Rails-production but not real production, so QA_ENV re-opens it there.
30 31 32 33 34 |
# File 'lib/studio/environment_banner.rb', line 30 def show?(rails_env:, qa_environment: qa_environment?) return true unless rails_env.to_s == "production" qa_environment end |
.truthy?(value) ⇒ Boolean
52 53 54 |
# File 'lib/studio/environment_banner.rb', line 52 def truthy?(value) %w[1 true yes on].include?(value.to_s.strip.downcase) end |