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