svelte-on-rails 22.1.1 → 22.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e4321bcf9f02af3beafeef6f841ae2b428415633b3554b67c03b95c7841fcf8c
4
- data.tar.gz: d39b7db4a9ae20f6edc43ff5615ac2547d98d1dbff9c764c1424ac702701de5e
3
+ metadata.gz: a32126c57f42015b2fae36849a77266d174dfc6234a5958c924b490e4c1efc47
4
+ data.tar.gz: b264887e056b7d3aeb763923d1f20eccdab81000bc1c7dae63b7c909397157c0
5
5
  SHA512:
6
- metadata.gz: dbadd0e2a4d1b92288edbaaa38b83bb297294610df6fe39dfa9ed59ded3b05aa9d039ac9416038cb54ddb920fd413f4d2a043f1398a9cc4e7efcc71cd30854b7
7
- data.tar.gz: 3a22b355a4be460ca6a0262442959c2f778f2d0f7b11a6a70b79b47b8070de438efb13621c50c4118a58c492f5a1a3c4879c76a5e7df6c5b1f007c5dceb9593d
6
+ metadata.gz: ec6ad182cd5a2f06c654017f2ddbc81fe07b07498339262b0ec145d7fbaa815d12abef5a681930080d8edaee57e536f036399e5df011c8e3d3413ecea9b0a5f7
7
+ data.tar.gz: e67beb89b3a4ed77bdb3d7cc39f54596769c1b9cd25d12b7db7341cf860176d0b9a633b6fba4e4703a2a48d42509a1b18a977345b0a91214cefe556c760766b2
@@ -179,7 +179,7 @@ module SvelteOnRails
179
179
 
180
180
  def redis_cache_store_configs
181
181
  if defined?(Rails.application) && Rails.application.config.cache_store.is_a?(Array) && Rails.application.config.cache_store.first == :redis_cache_store
182
- { 'redis_cache_store' => Rails.application.config.cache_store.second.stringify_keys }
182
+ { redis_cache_store: Rails.application.config.cache_store.second.stringify_keys }
183
183
  else
184
184
  {}
185
185
  end
@@ -24,24 +24,38 @@ module SvelteOnRails
24
24
 
25
25
  # Defining methods to log errors and warnings using Rails logger
26
26
  def self.puts_error(text)
27
- # Using Rails logger to log error with custom formatting
28
- caller_info = caller[1] =~ /`([^']*)'/ ? $1 : "unknown"
29
- Rails.logger.error(" => [SOR] #{caller_info} ERROR")
30
- text.split("\n").each do |line|
31
- Rails.logger.error(" => #{line}")
32
- end
27
+ log_with_severity(:error, text, "ERROR", "\e[31m") # red
33
28
  end
34
29
 
35
30
  # Defining method to log warnings using Rails logger
36
31
  def self.puts_warning(text)
37
- # Using Rails logger to log warning with custom formatting
38
- caller_info = caller[1] =~ /`([^']*)'/ ? $1 : "unknown"
39
- Rails.logger.warn(" => [SOR] #{caller_info} WARNING \e[0m")
40
- text.split("\n").each do |line|
41
- Rails.logger.warn(" => #{line}")
32
+ log_with_severity(:warn, text, "WARNING", "\e[33m")
33
+ end
34
+
35
+ # Internal: emits a tagged, colored block via Rails.logger.
36
+ # ANSI colors are always included; modern terminals + the Rails
37
+ # dev logger render them. In production the logger strips them
38
+ # or they pass through harmlessly to aggregators.
39
+ def self.log_with_severity(level, text, label, color_code)
40
+
41
+ clear = "\e[0m"
42
+ bold = "\e[1m"
43
+
44
+ header = "#{color_code}#{bold}[SOR] #{label}#{clear}"
45
+ Rails.logger.public_send(level, header)
46
+ text.to_s.split("\n").each do |line|
47
+ Rails.logger.public_send(level, "#{color_code} => #{line}#{clear}")
42
48
  end
43
49
  end
44
50
 
51
+ def self.color_supported?
52
+ return false if Rails.env.production?
53
+ # Rails dev logger writes to STDOUT; check that it's a TTY.
54
+ $stdout.tty?
55
+ rescue
56
+ false
57
+ end
58
+
45
59
  def self.component_paths_uncached(component, current_controller_path)
46
60
 
47
61
  file_basename = File.basename(component, ".svelte")
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: svelte-on-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 22.1.1
4
+ version: 22.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Christian Sedlmair