|
|
@ -12,7 +12,7 @@ module Live |
|
|
|
def string(default = '') = define_type_from_callee(caller[0], :string, default) |
|
|
|
|
|
|
|
def reload_from_env |
|
|
|
logger.debug('reload from env') |
|
|
|
# logger.debug('reload from env') |
|
|
|
|
|
|
|
changes = [] |
|
|
|
new_env_values = env_values(cached: false) |
|
|
@ -28,6 +28,15 @@ module Live |
|
|
|
private |
|
|
|
|
|
|
|
def trigger_rolling_event(changes) |
|
|
|
logger.info ' ', dimensions: Semantic::FancyDimensions.new(rails: '╔═╗', before: 1) |
|
|
|
changes.each do |change| |
|
|
|
kind = change[:kind] |
|
|
|
constant = change[:constant] |
|
|
|
value = change[:new_value] |
|
|
|
logger.warn "Constant #{kind}:#{Semantic::AnsiColors::CLEAR} #{constant} = #{value.ai}" |
|
|
|
end |
|
|
|
logger.info ' ', dimensions: Semantic::FancyDimensions.new(rails: '╚═╝') |
|
|
|
|
|
|
|
ActiveSupport::Notifications.instrument('rolling.live_constant', changes:) |
|
|
|
FileUtils.touch(MAIN_CSS) if defined?(RailsLiveReload) # triggering RailsLiveReload |
|
|
|
rescue StandardError => e |
|
|
@ -43,7 +52,6 @@ module Live |
|
|
|
return if new_value == old_value |
|
|
|
|
|
|
|
define_value(constant, new_value) |
|
|
|
logger.warn "Constant overriden from environment:#{Semantic::AnsiColors::CLEAR} #{constant} = #{new_value.ai}" |
|
|
|
{ kind: :overriden, constant:, type:, old_value:, new_value: } |
|
|
|
end |
|
|
|
|
|
|
@ -54,7 +62,6 @@ module Live |
|
|
|
|
|
|
|
type = definition[:type] |
|
|
|
define_value(constant, new_value) |
|
|
|
logger.warn "Constant restored:#{Semantic::AnsiColors::CLEAR} #{constant} = #{new_value.ai}" |
|
|
|
{ kind: :restored, constant:, type:, old_value:, new_value: } |
|
|
|
end |
|
|
|
|
|
|
@ -64,7 +71,7 @@ module Live |
|
|
|
@env_values = Dotenv.parse(*Dotenv::Rails.files) |
|
|
|
end |
|
|
|
|
|
|
|
def logger = @logger ||= SemanticLogger[self] |
|
|
|
def logger = @logger ||= SemanticLogger[to_s.underscore] |
|
|
|
def definitions = @definitions ||= {} |
|
|
|
|
|
|
|
def define_value(constant, value) |
|
|
|