hot_constants first attempt
This commit is contained in:
+8
-5
@@ -1,11 +1,11 @@
|
||||
# STATIC: restart server when changes!
|
||||
#-------------------------------------
|
||||
RAILS_PORT=7500
|
||||
# RAILS_PORT=7500
|
||||
|
||||
DATABASE_HOST=localhost
|
||||
DATABASE_NAME=easy-going-rails
|
||||
DATABASE_USER=$DATABASE_NAME
|
||||
DATABASE_PASSWORD=$DATABASE_NAME
|
||||
# DATABASE_HOST=localhost
|
||||
# DATABASE_NAME=easy-going-rails
|
||||
# DATABASE_USER=$DATABASE_NAME
|
||||
# DATABASE_PASSWORD=$DATABASE_NAME
|
||||
|
||||
# HOT CONSTANTS
|
||||
#--------------
|
||||
@@ -13,3 +13,6 @@ STIMULUS_DEBUG=false
|
||||
LOG_ACTIVE_RECORD=false
|
||||
LOG_ACTION_VIEW=false
|
||||
|
||||
INTEGER=1
|
||||
STRING=""
|
||||
BOOLEAN=true
|
||||
|
||||
@@ -32,8 +32,9 @@ New Notes
|
||||
|
||||
* [x] Use hotwire_livereload instead of rails_live_reload
|
||||
* [x] nope, because rails_live_reload is more clever (and sooner) than hotwire_livereload
|
||||
* [x] LiveConstants
|
||||
* [x] HotConstants
|
||||
* [x] monkeypatch rails-live-reload
|
||||
* [ ] meta-programming
|
||||
* [x] Flash message
|
||||
* [x] https://reinteractive.com/articles/how-to-create-flash-messages-in-Rails-7
|
||||
* [x] Minitest
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
<%= tag :meta, name: :viewport, content: 'width=device-width,initial-scale=1' %>
|
||||
<% if Rails.env.development? %>
|
||||
<%= tag :meta, name: 'turbo-prefetch', content: false %>
|
||||
<%= tag :meta, name: 'stimulus-debug', content: LiveConstants.stimulus_debug %>
|
||||
<%= tag :meta, name: 'stimulus-debug', content: HotConstants.stimulus_debug %>
|
||||
<% end%>
|
||||
|
||||
<!-- LINK-->
|
||||
|
||||
@@ -78,8 +78,8 @@ Rails.application.configure do # rubocop:disable Metrics/BlockLength
|
||||
routes.default_url_options[:host] = '127.0.0.1'
|
||||
|
||||
config.after_initialize do
|
||||
require Rails.root.join('lib', 'hot_constants', 'live_constants')
|
||||
LiveConstants.reload!
|
||||
require Rails.root.join('lib', 'hot_constants', 'hot_constants')
|
||||
HotConstants.reload!
|
||||
end
|
||||
|
||||
require Rails.root.join('lib', 'formatters', 'ansi_formatter')
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
Developer documentation
|
||||
======================
|
||||
|
||||
Hint
|
||||
----
|
||||
* Do not use AlpineJs bind:class onto a fontawesome i element, it hangs due to the SVG convert of the i element happening concurrently
|
||||
@@ -1,11 +1,15 @@
|
||||
require 'dotenv'
|
||||
|
||||
# Hot Live Constants
|
||||
module LiveConstants
|
||||
module HotConstants
|
||||
HOTENV = {} # rubocop:disable Style/MutableConstant
|
||||
LOGGER = SemanticLogger[to_s]
|
||||
|
||||
class << self
|
||||
def initialize
|
||||
LOGGER.info('initializing')
|
||||
end
|
||||
|
||||
def stimulus_debug = load_boolean('STIMULUS_DEBUG', false)
|
||||
def log_active_record = load_boolean('LOG_ACTIVE_RECORD', true)
|
||||
def log_action_view = load_boolean('LOG_ACTION_VIEW', true)
|
||||
@@ -1,7 +1,6 @@
|
||||
module RailsLiveReload
|
||||
# MonkeyPath Watcher
|
||||
class Watcher
|
||||
ENV_FILE = Rails.root.join('.env').to_s
|
||||
def reload_all
|
||||
before_reload(files)
|
||||
data = { event: RailsLiveReload::INTERNAL[:socket_events][:reload], files: }.to_json
|
||||
@@ -10,8 +9,10 @@ module RailsLiveReload
|
||||
|
||||
private
|
||||
|
||||
ENV_FILE = Rails.root.join('.env').to_s
|
||||
|
||||
def before_reload(files)
|
||||
LiveConstants.reload! if files.find { |change| change[0] == ENV_FILE }
|
||||
HotConstants.reload! if files.find { |change| change[0] == ENV_FILE }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user