Class: Ruflet::Rails::Configuration
- Inherits:
-
Object
- Object
- Ruflet::Rails::Configuration
- Defined in:
- lib/ruflet/rails/configuration.rb
Overview
Central configuration for ruflet_rails.
Mirrors the full ruflet.yaml schema so a Rails app needs only config/initializers/ruflet.rb — no ruflet.yaml on disk.
Set in config/initializers/ruflet.rb:
Ruflet::Rails.configure do |config|
# Runtime / server
config.app_file = Rails.root.join("app/views/ruflet/main.rb")
config.ws_path = "/ws"
config.backend_url = Rails.env.production? ? "https://example.com" : "http://localhost:3000"
# Flutter web build output directory
config.web_build_dir = Rails.root.join("public/app")
# App metadata (ruflet.yaml → app:)
config.app_name = "My App"
# Services (ruflet.yaml → services:)
config.services = []
# Assets (ruflet.yaml → assets:)
config.splash_screen = Rails.root.join("app/assets/images/splash.png")
config.splash_dark = Rails.root.join("app/assets/images/splash_dark.png")
config.icon_launcher = Rails.root.join("app/assets/images/icon.png")
config.icon_android = Rails.root.join("app/assets/images/icon_android.png")
config.icon_ios = Rails.root.join("app/assets/images/icon_ios.png")
config.icon_web = Rails.root.join("app/assets/images/icon_web.png")
config.icon_windows = Rails.root.join("app/assets/images/icon_windows.png")
config.icon_macos = Rails.root.join("app/assets/images/icon_macos.png")
# Build options (ruflet.yaml → build:)
config.splash_color = "#FFFFFF"
config.splash_dark_color = "#000000"
config.icon_background = "#FFFFFF"
config.theme_color = "#FFFFFF"
end
Instance Attribute Summary collapse
-
#app_file ⇒ Object
Absolute path to the Ruflet app entry-point.
-
#app_name ⇒ Object
— App metadata (ruflet.yaml → app:) —.
-
#backend_url ⇒ Object
Backend base URL.
-
#icon_android ⇒ Object
Returns the value of attribute icon_android.
-
#icon_background ⇒ Object
Returns the value of attribute icon_background.
-
#icon_ios ⇒ Object
Returns the value of attribute icon_ios.
-
#icon_launcher ⇒ Object
Returns the value of attribute icon_launcher.
-
#icon_macos ⇒ Object
Returns the value of attribute icon_macos.
-
#icon_web ⇒ Object
Returns the value of attribute icon_web.
-
#icon_windows ⇒ Object
Returns the value of attribute icon_windows.
-
#services ⇒ Object
— Services (ruflet.yaml → services:) —.
-
#splash_color ⇒ Object
— Build options (ruflet.yaml → build:) —.
-
#splash_dark ⇒ Object
Returns the value of attribute splash_dark.
-
#splash_dark_color ⇒ Object
Returns the value of attribute splash_dark_color.
-
#splash_screen ⇒ Object
— Assets (ruflet.yaml → assets:) —.
-
#theme_color ⇒ Object
Returns the value of attribute theme_color.
-
#web_build_dir ⇒ Object
Absolute directory containing the Flutter web build (index.html + assets).
-
#ws_path ⇒ Object
URL path the WebSocket endpoint listens on.
Instance Method Summary collapse
-
#initialize ⇒ Configuration
constructor
A new instance of Configuration.
-
#to_ruflet_yaml_hash ⇒ Object
Serialises config to the ruflet.yaml hash structure so the CLI can consume it without a yaml file on disk (written to a temp file by the Railtie’s build task).
Constructor Details
#initialize ⇒ Configuration
Returns a new instance of Configuration.
85 86 87 88 89 90 91 92 |
# File 'lib/ruflet/rails/configuration.rb', line 85 def initialize @ws_path = "/ws" @app_file = nil @backend_url = nil @web_build_dir = nil @app_name = nil @services = [] end |
Instance Attribute Details
#app_file ⇒ Object
Absolute path to the Ruflet app entry-point.
47 48 49 |
# File 'lib/ruflet/rails/configuration.rb', line 47 def app_file @app_file end |
#app_name ⇒ Object
— App metadata (ruflet.yaml → app:) —
61 62 63 |
# File 'lib/ruflet/rails/configuration.rb', line 61 def app_name @app_name end |
#backend_url ⇒ Object
Backend base URL. Used as –dart-define=RUFLET_URL at build time and by the desktop launcher. Replaces ruflet.yaml → app.backend_url.
54 55 56 |
# File 'lib/ruflet/rails/configuration.rb', line 54 def backend_url @backend_url end |
#icon_android ⇒ Object
Returns the value of attribute icon_android.
72 73 74 |
# File 'lib/ruflet/rails/configuration.rb', line 72 def icon_android @icon_android end |
#icon_background ⇒ Object
Returns the value of attribute icon_background.
82 83 84 |
# File 'lib/ruflet/rails/configuration.rb', line 82 def icon_background @icon_background end |
#icon_ios ⇒ Object
Returns the value of attribute icon_ios.
73 74 75 |
# File 'lib/ruflet/rails/configuration.rb', line 73 def icon_ios @icon_ios end |
#icon_launcher ⇒ Object
Returns the value of attribute icon_launcher.
71 72 73 |
# File 'lib/ruflet/rails/configuration.rb', line 71 def icon_launcher @icon_launcher end |
#icon_macos ⇒ Object
Returns the value of attribute icon_macos.
76 77 78 |
# File 'lib/ruflet/rails/configuration.rb', line 76 def icon_macos @icon_macos end |
#icon_web ⇒ Object
Returns the value of attribute icon_web.
74 75 76 |
# File 'lib/ruflet/rails/configuration.rb', line 74 def icon_web @icon_web end |
#icon_windows ⇒ Object
Returns the value of attribute icon_windows.
75 76 77 |
# File 'lib/ruflet/rails/configuration.rb', line 75 def icon_windows @icon_windows end |
#services ⇒ Object
— Services (ruflet.yaml → services:) —
65 66 67 |
# File 'lib/ruflet/rails/configuration.rb', line 65 def services @services end |
#splash_color ⇒ Object
— Build options (ruflet.yaml → build:) —
80 81 82 |
# File 'lib/ruflet/rails/configuration.rb', line 80 def splash_color @splash_color end |
#splash_dark ⇒ Object
Returns the value of attribute splash_dark.
70 71 72 |
# File 'lib/ruflet/rails/configuration.rb', line 70 def splash_dark @splash_dark end |
#splash_dark_color ⇒ Object
Returns the value of attribute splash_dark_color.
81 82 83 |
# File 'lib/ruflet/rails/configuration.rb', line 81 def splash_dark_color @splash_dark_color end |
#splash_screen ⇒ Object
— Assets (ruflet.yaml → assets:) —
69 70 71 |
# File 'lib/ruflet/rails/configuration.rb', line 69 def splash_screen @splash_screen end |
#theme_color ⇒ Object
Returns the value of attribute theme_color.
83 84 85 |
# File 'lib/ruflet/rails/configuration.rb', line 83 def theme_color @theme_color end |
#web_build_dir ⇒ Object
Absolute directory containing the Flutter web build (index.html + assets).
57 58 59 |
# File 'lib/ruflet/rails/configuration.rb', line 57 def web_build_dir @web_build_dir end |
#ws_path ⇒ Object
URL path the WebSocket endpoint listens on. Defaults to “/ws”.
50 51 52 |
# File 'lib/ruflet/rails/configuration.rb', line 50 def ws_path @ws_path end |
Instance Method Details
#to_ruflet_yaml_hash ⇒ Object
Serialises config to the ruflet.yaml hash structure so the CLI can consume it without a yaml file on disk (written to a temp file by the Railtie’s build task).
97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 |
# File 'lib/ruflet/rails/configuration.rb', line 97 def to_ruflet_yaml_hash hash = {} app = {} app["name"] = @app_name if @app_name app["backend_url"] = @backend_url if @backend_url hash["app"] = app unless app.empty? hash["services"] = Array(@services) assets = {} assets["splash_screen"] = @splash_screen.to_s if @splash_screen assets["splash_dark"] = @splash_dark.to_s if @splash_dark assets["icon_launcher"] = @icon_launcher.to_s if @icon_launcher assets["icon_android"] = @icon_android.to_s if @icon_android assets["icon_ios"] = @icon_ios.to_s if @icon_ios assets["icon_web"] = @icon_web.to_s if @icon_web assets["icon_windows"] = @icon_windows.to_s if @icon_windows assets["icon_macos"] = @icon_macos.to_s if @icon_macos hash["assets"] = assets unless assets.empty? build = {} build["splash_color"] = @splash_color if @splash_color build["splash_dark_color"] = @splash_dark_color if @splash_dark_color build["icon_background"] = @icon_background if @icon_background build["theme_color"] = @theme_color if @theme_color hash["build"] = build unless build.empty? hash end |