svelte-on-rails 0.0.9 → 0.0.12

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: 21cc2327494c663a2040c3775ec40e5fd4e3612a28e51eba172c13da07440ad0
4
- data.tar.gz: 9773b7346d542202ae0670e2c79d03faca86164b513e398df0c0bf6c265efd87
3
+ metadata.gz: 202f1fbacaa78ff38947e7665f87e21a904f6cb25fdab0e2c3280f8cd8d47c8c
4
+ data.tar.gz: 18024b88f324f8e6a2e95832b6bec156154ff00692ad849952dc5739d6875634
5
5
  SHA512:
6
- metadata.gz: 8d252352dcadea7d3fe44d937cff9b2e5a9376a7d6bdb8087cb19b9c15ad0084fe0d93c323ddad9cbc0ab5b82443cc3b023e61beb1b724405d0b9c8c6748dc55
7
- data.tar.gz: 7b8be4d43e13f0bafe356a6dbc3b3052b44627b30fdb56509313993e14fb6bed039f411f4d9b0b045d53cb697f2b101b73488e4e136de4c433ad83621bccc92a
6
+ metadata.gz: dc2bd126266183b839b66a9f42febc0f72b1a75f9d104b3b00cd8f15d80aa92345aa47060444cca49190fd9d6317517560e2d648d5680f6f732aee1ecafe950a
7
+ data.tar.gz: 405093ef539c984afe97a78dca95e70c43c920da0cce9b01c12e1c5e3a75bb91139a74cb8fb6df9384d506eeecb36a510cda8014a2fca700d1a06d487ab3805e
data/README.md CHANGED
@@ -82,6 +82,9 @@ Within the `components_folder` (configs above) a component like `myComponent.sve
82
82
 
83
83
  And you should see «Greetings from svelte» on the browser.
84
84
 
85
+ I inserted very detailed error messages on rails and on the
86
+ npm package, so please check the logs on your browser.
87
+
85
88
  ### Import statements
86
89
 
87
90
  For check which statements are working and actively tested, please check the
@@ -21,7 +21,7 @@ module SvelteOnRails
21
21
  load_yaml_config if defined?(Rails)
22
22
  end
23
23
 
24
- def watch_changes
24
+ def watch_changes?
25
25
  if @configs[Rails.env]
26
26
  @configs[Rails.env]['watch_changes'] == true
27
27
  else
@@ -34,11 +34,19 @@ module SvelteOnRails
34
34
  end
35
35
 
36
36
  def frontend_folder
37
+ @configs['frontend_folder']
38
+ end
39
+
40
+ def frontend_folder_full
37
41
  rails_root.join(@configs['frontend_folder'].to_s)
38
42
  end
39
43
 
44
+ def components_folder_full
45
+ Pathname.new(frontend_folder_full).join(components_folder.to_s)
46
+ end
47
+
40
48
  def components_folder
41
- frontend_folder.join(@configs['components_folder'].to_s)
49
+ @configs['components_folder']
42
50
  end
43
51
 
44
52
  def render_server_side
@@ -5,7 +5,7 @@ module SvelteOnRails
5
5
 
6
6
  def initialize(filename)
7
7
 
8
- @svelte_file = SvelteOnRails::Configuration.instance.components_folder + filename
8
+ @svelte_file = SvelteOnRails::Configuration.instance.components_folder_full + filename
9
9
  @svelte_filename = filename
10
10
  @compiled_file = "#{SvelteOnRails::Configuration.instance.dist_folder}/#{(filename.match(/\.svelte$/) ? filename[0..-8] : filename)}"
11
11
 
@@ -15,7 +15,7 @@ module SvelteOnRails
15
15
 
16
16
  # letzte Änderung innerhalb des ordners ermitteln
17
17
 
18
- watch_changes = SvelteOnRails::Configuration.instance.watch_changes
18
+ watch_changes = SvelteOnRails::Configuration.instance.watch_changes?
19
19
  ts_file = SvelteOnRails::Configuration.instance.dist_folder.join('reset_timestamp')
20
20
 
21
21
  have_changes = if watch_changes && File.exist?(ts_file)
@@ -120,5 +120,14 @@ module SvelteOnRails
120
120
  FileUtils.touch SvelteOnRails::Configuration.instance.dist_folder.join('reset_timestamp')
121
121
  end
122
122
 
123
+ def self.file_exist_case_sensitive?(containing_dir, filename)
124
+ # Combine the directory path and filename
125
+ full_path = File.join(containing_dir, filename)
126
+
127
+ # Check if the file exists and the path matches case-sensitively
128
+ File.exist?(full_path) && Dir[File.join(containing_dir, "*")].any? { |f| f == full_path }
129
+ end
130
+
131
+
123
132
  end
124
133
  end
@@ -4,15 +4,22 @@ module SvelteOnRails
4
4
  def svelte_component(filename, props = {})
5
5
 
6
6
  # check filename
7
- file_path = SvelteOnRails::Configuration.instance.components_folder + "#{filename}.svelte"
8
- raise "File not found: #{file_path}" unless File.exist?(file_path)
7
+ conf = SvelteOnRails::Configuration.instance
8
+ cff = conf.components_folder_full
9
+ file_path = cff + "#{filename}.svelte"
10
+ found = (conf.watch_changes? ? SvelteOnRails::RenderServerSide.file_exist_case_sensitive?(cff, filename + '.svelte') : File.exist?(file_path))
11
+ unless found
12
+ ff = conf.frontend_folder
13
+ cf = conf.components_folder
14
+ raise "File not found: #{file_path}\nsvelte-on-rails gem, view helper #svelte_component\n\nYour configurations are:\nfrontend_folder: «#{ff}»\ncomponents_folder: «#{cf}»\n.. and the filename attribute for the view helper: «#{filename}»\n"
15
+ end
9
16
 
10
17
  # check what to do
11
18
 
12
19
  rss = if props.key?(:render_server_side)
13
20
  props.delete(:render_server_side)
14
21
  else
15
- SvelteOnRails::Configuration.instance.render_server_side
22
+ conf.render_server_side
16
23
  end
17
24
  unless [true, false, :auto].include?(rss)
18
25
  raise "Only true, false or auto are allowed for the argument #render_server_side"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: svelte-on-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.9
4
+ version: 0.0.12
5
5
  platform: ruby
6
6
  authors:
7
7
  - Christian Sedlmair
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2025-04-16 00:00:00.000000000 Z
11
+ date: 2025-04-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: railties