Class: Ruflet::Rails::Configuration
- Inherits:
-
Object
- Object
- Ruflet::Rails::Configuration
- Defined in:
- lib/ruflet/rails/configuration.rb
Overview
Central configuration for ruflet_rails.
Rails apps keep Ruflet build metadata in config/initializers/ruflet.rb. The build task serializes this object to the ruflet.yaml structure the Ruflet CLI consumes, so Rails remains the source of truth:
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 / extensions (ruflet.yaml → services: / extensions:)
config.services = []
config.extensions = %w[webview]
# 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.
-
#extensions ⇒ Object
Returns the value of attribute extensions.
-
#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 / extensions (ruflet.yaml → services: / extensions:) ---.
-
#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.
72 73 74 75 76 77 |
# File 'lib/ruflet/rails/configuration.rb', line 72 def initialize @backend_url = nil @app_name = nil @services = [] @extensions = [] end |
Instance Attribute Details
#app_name ⇒ Object
--- App metadata (ruflet.yaml → app:) ---
47 48 49 |
# File 'lib/ruflet/rails/configuration.rb', line 47 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.
43 44 45 |
# File 'lib/ruflet/rails/configuration.rb', line 43 def backend_url @backend_url end |
#extensions ⇒ Object
Returns the value of attribute extensions.
52 53 54 |
# File 'lib/ruflet/rails/configuration.rb', line 52 def extensions @extensions end |
#icon_android ⇒ Object
Returns the value of attribute icon_android.
59 60 61 |
# File 'lib/ruflet/rails/configuration.rb', line 59 def icon_android @icon_android end |
#icon_background ⇒ Object
Returns the value of attribute icon_background.
69 70 71 |
# File 'lib/ruflet/rails/configuration.rb', line 69 def icon_background @icon_background end |
#icon_ios ⇒ Object
Returns the value of attribute icon_ios.
60 61 62 |
# File 'lib/ruflet/rails/configuration.rb', line 60 def icon_ios @icon_ios end |
#icon_launcher ⇒ Object
Returns the value of attribute icon_launcher.
58 59 60 |
# File 'lib/ruflet/rails/configuration.rb', line 58 def icon_launcher @icon_launcher end |
#icon_macos ⇒ Object
Returns the value of attribute icon_macos.
63 64 65 |
# File 'lib/ruflet/rails/configuration.rb', line 63 def icon_macos @icon_macos end |
#icon_web ⇒ Object
Returns the value of attribute icon_web.
61 62 63 |
# File 'lib/ruflet/rails/configuration.rb', line 61 def icon_web @icon_web end |
#icon_windows ⇒ Object
Returns the value of attribute icon_windows.
62 63 64 |
# File 'lib/ruflet/rails/configuration.rb', line 62 def icon_windows @icon_windows end |
#services ⇒ Object
--- Services / extensions (ruflet.yaml → services: / extensions:) ---
51 52 53 |
# File 'lib/ruflet/rails/configuration.rb', line 51 def services @services end |
#splash_color ⇒ Object
--- Build options (ruflet.yaml → build:) ---
67 68 69 |
# File 'lib/ruflet/rails/configuration.rb', line 67 def splash_color @splash_color end |
#splash_dark ⇒ Object
Returns the value of attribute splash_dark.
57 58 59 |
# File 'lib/ruflet/rails/configuration.rb', line 57 def splash_dark @splash_dark end |
#splash_dark_color ⇒ Object
Returns the value of attribute splash_dark_color.
68 69 70 |
# File 'lib/ruflet/rails/configuration.rb', line 68 def splash_dark_color @splash_dark_color end |
#splash_screen ⇒ Object
--- Assets (ruflet.yaml → assets:) ---
56 57 58 |
# File 'lib/ruflet/rails/configuration.rb', line 56 def splash_screen @splash_screen end |
#theme_color ⇒ Object
Returns the value of attribute theme_color.
70 71 72 |
# File 'lib/ruflet/rails/configuration.rb', line 70 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).
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 109 110 111 112 113 114 |
# File 'lib/ruflet/rails/configuration.rb', line 82 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? services = Array(@services) extensions = Array(@extensions) hash["services"] = services unless services.empty? hash["extensions"] = extensions unless extensions.empty? 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 |