Class: Ruflet::Rails::Configuration
- Inherits:
-
Object
- Object
- Ruflet::Rails::Configuration
- Defined in:
- lib/ruflet/rails/configuration.rb
Overview
Central configuration for ruflet_rails.
An install needs no config/initializers/ruflet.rb: routes mount app/views/ruflet/main.rb explicitly and build metadata is read from ruflet.yaml. Add an initializer only to override these settings:
Ruflet::Rails.configure do |config|
# Runtime / server
config.backend_url = Rails.env.production? ? "https://example.com" : "http://localhost:3000"
# 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_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.
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.
70 71 72 73 74 |
# File 'lib/ruflet/rails/configuration.rb', line 70 def initialize @backend_url = nil @app_name = nil @services = [] end |
Instance Attribute Details
#app_name ⇒ Object
— App metadata (ruflet.yaml → app:) —
46 47 48 |
# File 'lib/ruflet/rails/configuration.rb', line 46 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.
42 43 44 |
# File 'lib/ruflet/rails/configuration.rb', line 42 def backend_url @backend_url end |
#icon_android ⇒ Object
Returns the value of attribute icon_android.
57 58 59 |
# File 'lib/ruflet/rails/configuration.rb', line 57 def icon_android @icon_android end |
#icon_background ⇒ Object
Returns the value of attribute icon_background.
67 68 69 |
# File 'lib/ruflet/rails/configuration.rb', line 67 def icon_background @icon_background end |
#icon_ios ⇒ Object
Returns the value of attribute icon_ios.
58 59 60 |
# File 'lib/ruflet/rails/configuration.rb', line 58 def icon_ios @icon_ios end |
#icon_launcher ⇒ Object
Returns the value of attribute icon_launcher.
56 57 58 |
# File 'lib/ruflet/rails/configuration.rb', line 56 def icon_launcher @icon_launcher end |
#icon_macos ⇒ Object
Returns the value of attribute icon_macos.
61 62 63 |
# File 'lib/ruflet/rails/configuration.rb', line 61 def icon_macos @icon_macos end |
#icon_web ⇒ Object
Returns the value of attribute icon_web.
59 60 61 |
# File 'lib/ruflet/rails/configuration.rb', line 59 def icon_web @icon_web end |
#icon_windows ⇒ Object
Returns the value of attribute icon_windows.
60 61 62 |
# File 'lib/ruflet/rails/configuration.rb', line 60 def icon_windows @icon_windows end |
#services ⇒ Object
— Services (ruflet.yaml → services:) —
50 51 52 |
# File 'lib/ruflet/rails/configuration.rb', line 50 def services @services end |
#splash_color ⇒ Object
— Build options (ruflet.yaml → build:) —
65 66 67 |
# File 'lib/ruflet/rails/configuration.rb', line 65 def splash_color @splash_color end |
#splash_dark ⇒ Object
Returns the value of attribute splash_dark.
55 56 57 |
# File 'lib/ruflet/rails/configuration.rb', line 55 def splash_dark @splash_dark end |
#splash_dark_color ⇒ Object
Returns the value of attribute splash_dark_color.
66 67 68 |
# File 'lib/ruflet/rails/configuration.rb', line 66 def splash_dark_color @splash_dark_color end |
#splash_screen ⇒ Object
— Assets (ruflet.yaml → assets:) —
54 55 56 |
# File 'lib/ruflet/rails/configuration.rb', line 54 def splash_screen @splash_screen end |
#theme_color ⇒ Object
Returns the value of attribute theme_color.
68 69 70 |
# File 'lib/ruflet/rails/configuration.rb', line 68 def theme_color @theme_color 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).
79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 |
# File 'lib/ruflet/rails/configuration.rb', line 79 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 |