rubyjs-vite 2.0.0 → 2.0.1

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: be5d3678617c35c3ed3a02eb1e9822bb725055fed392f18742262757f0ce9064
4
- data.tar.gz: 3e0e450c8464c82f8b4795e39c85ee92a3f5c25316ee1a0d63dd3703061e3e1c
3
+ metadata.gz: 0e448860a7ddcb9e6dafe089169a1540b2e02d7b8e579b8ea0c0ff665f9f3970
4
+ data.tar.gz: 07332aaa9d963717b44db9204817dcc24a9ea59dc8024aa818b5cc5edbfa37ba
5
5
  SHA512:
6
- metadata.gz: fa91c0766b29943444a4c872f59306c527b4b27f60fdc4c17793469a6e2ae9cf404a76c9d0a503b150002664279810516befc50bafa13277d567d4a5aee5bbf8
7
- data.tar.gz: d88354c19f850192b3b77cf6fa80dcafe2401795bc2eeabc9c34bb3cdfbbbd16f6c43ea70f2559032fdaa717a210f292288cf853faf6bec6a5d2beea3a882582
6
+ metadata.gz: aec8b571b7827c6e7414500e61e89ab4ea01a6d9089a26e0bc0fbfb5207e0170c1cf305fa2e690e3d1874d54dd8c0808e0891c5338e88616078a28c49c2dfed3
7
+ data.tar.gz: 48fefe6f420e47046f03cc2d11c75949840b21b460b613a9a0c4367811f8514e90169e9f78f552f856c785b551188f7dd123214bcedc47365e6a34e21f9adf06
@@ -18,7 +18,8 @@ module RJSV
18
18
  l_path = lambda { |p| File.join(p, 'plugins', '**', 'init.rb') }
19
19
  Dir.glob [
20
20
  l_path.call(path),
21
- l_path.call(ROOT)
21
+ l_path.call(ROOT),
22
+ l_path.call(File.join(Dir.home, '.rjsv'))
22
23
  ]
23
24
  end
24
25
 
@@ -0,0 +1,68 @@
1
+ module RJSV
2
+ module CLI
3
+ ##
4
+ # Here are the code blocks that are activated when
5
+ # the main function is triggered.
6
+ # Functions communicate using arguments passed via
7
+ # the command line, which are passed as options_cli.
8
+ # These functions include translate and watch,
9
+ # which can be reused when creating custom plugins.
10
+
11
+ module States
12
+ module_function
13
+
14
+ ##
15
+ # Block of code that handles the transpilation of script.
16
+ # This is opening a Ruby script container file,
17
+ # which is then converted into a JavaScript file.
18
+ # The file is saved to the output path.
19
+
20
+ def translate_state(path, options_cli)
21
+ if options_cli[:translate]
22
+ content_ruby = Core::Files.open(path)
23
+ if content_ruby && path
24
+ path_output = Core::Files.change_path_to_output(path, options_cli)
25
+ RJSV::Translate.ruby_to_js_with_write(content_ruby, path_output) do |err|
26
+ Core::Event.print('error', "#{path.sub(File.join(Dir.pwd, ''), '')} #{err}")
27
+ return
28
+ end
29
+ Core::Event.print('translated', path_output)
30
+ end
31
+ end
32
+ end
33
+
34
+ ##
35
+ # Block of code that tracks files under the input path.
36
+ # If a file has been logged, several events are performed
37
+ # such as to add, modify and remove logged files.
38
+ # These then trigger procedural methods to process the requests.
39
+
40
+ def watch_state(options_cli)
41
+ if options_cli[:watch]
42
+ Core::Event.print('message', 'There is now a watch for edited files.')
43
+ RJSV::Watch.modified_files(options_cli[:source]) do |modified, added, removed|
44
+ unless added.empty?
45
+ added.each do |path|
46
+ translate_state(path, options_cli)
47
+ end
48
+ end
49
+
50
+ unless modified.empty?
51
+ modified.each do |path|
52
+ translate_state(path, options_cli)
53
+ end
54
+ end
55
+
56
+ unless removed.empty?
57
+ removed.each do |path|
58
+ path_output = Core::Files.change_path_to_output(path, options_cli)
59
+ Core::Files.remove(path_output)
60
+ Core::Event.print('deleted', path_output)
61
+ end
62
+ end
63
+ end
64
+ end
65
+ end#watch_state
66
+ end#States
67
+ end
68
+ end
@@ -61,10 +61,9 @@ module RJSV
61
61
  # path for the output path.
62
62
 
63
63
  def change_path_to_output(path, options_cli)
64
- path.sub(File.join(Dir.pwd, ''), '')
65
- .sub(options_cli[:source], '')
64
+ path.sub(options_cli[:source], options_cli[:output])
66
65
  .sub(/\.#{RJSV::Constants::SUFFIX_RB}$/, '')
67
- .prepend(options_cli[:output])
66
+ .sub(File.join(Dir.pwd(), ''), '')
68
67
  end
69
68
 
70
69
  ##
data/lib/rjsv/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module RJSV
2
- VERSION = '2.0.0'
2
+ VERSION = '2.0.1'
3
3
  end
data/lib/rjsv.rb CHANGED
@@ -9,13 +9,14 @@ require 'rjsv/core/event'
9
9
  require 'rjsv/core/files'
10
10
  require 'rjsv/core/constants'
11
11
 
12
+ require 'rjsv/translate'
13
+ require 'rjsv/watch'
14
+
15
+ require 'rjsv/cli/states'
12
16
  require 'rjsv/cli/signals'
13
17
  require 'rjsv/cli/plugins'
14
18
  require 'rjsv/cli/arguments'
15
19
 
16
- require 'rjsv/translate'
17
- require 'rjsv/watch'
18
-
19
20
  ##
20
21
  # This is the main initialization module of
21
22
  # all modules that are needed for the functionality
@@ -28,59 +29,6 @@ module RJSV
28
29
 
29
30
  module_function
30
31
 
31
- ##
32
- # Block of code that handles the transpilation of script.
33
- # This is opening a Ruby script container file,
34
- # which is then converted into a JavaScript file.
35
- # The file is saved to the output path.
36
-
37
- def translate_state(path)
38
- if @options_cli[:translate]
39
- content_ruby = Core::Files.open(path)
40
- if content_ruby && path
41
- path_output = Core::Files.change_path_to_output(path, @options_cli)
42
- Translate.ruby_to_js_with_write(content_ruby, path_output) do |err|
43
- Core::Event.print('error', "#{path.sub(File.join(Dir.pwd, ''), '')} #{err}")
44
- return
45
- end
46
- Core::Event.print('translated', path_output)
47
- end
48
- end
49
- end
50
-
51
- ##
52
- # Block of code that tracks files under the input path.
53
- # If a file has been logged, several events are performed
54
- # such as to add, modify and remove logged files.
55
- # These then trigger procedural methods to process the requests.
56
-
57
- def watch_state()
58
- if @options_cli[:watch]
59
- Core::Event.print('message', 'There is now a watch for edited files.')
60
- Watch.modified_files(@options_cli[:source]) do |modified, added, removed|
61
- unless added.empty?
62
- added.each do |path|
63
- translate_state(path)
64
- end
65
- end
66
-
67
- unless modified.empty?
68
- modified.each do |path|
69
- translate_state(path)
70
- end
71
- end
72
-
73
- unless removed.empty?
74
- removed.each do |path|
75
- path_output = Core::Files.change_path_to_output(path, @options_cli)
76
- Core::Files.remove(path_output)
77
- Core::Event.print('deleted', path_output)
78
- end
79
- end
80
- end
81
- end
82
- end#watch_state
83
-
84
32
  ##
85
33
  # This is the main function to run the desired
86
34
  # block function scenarios. In order to arm itself
@@ -95,11 +43,11 @@ module RJSV
95
43
  if @options_cli[:translate]
96
44
  files_rb = Core::Files.find_all(@options_cli[:source])
97
45
  files_rb.each do |path|
98
- translate_state(path)
46
+ CLI::States.translate_state(path, @options_cli)
99
47
  end
100
48
  end
101
49
 
102
- watch_state()
50
+ CLI::States.watch_state(@options_cli)
103
51
  end
104
52
  end#main
105
53
  end
@@ -20,7 +20,7 @@ module RJSV
20
20
  "Please rerun the Vite installation after installing NodeJS.\n" +
21
21
  "Use these instructions:\n\n" +
22
22
  "#{wspaces}cd #{project}\n" +
23
- "#{wspaces}npm install -D vite\n" +
23
+ "#{wspaces}npm install\n" +
24
24
  "#{wspaces}bin/server"
25
25
  end
26
26
  end
@@ -5,10 +5,10 @@ export default class ElmNAME_CLASS < HTMLElement
5
5
  init_elm()
6
6
  end
7
7
 
8
- def connectedCallback()
8
+ def connected_callback()
9
9
  end
10
10
 
11
- def disconnectedCallback()
11
+ def disconnected_callback()
12
12
  end
13
13
 
14
14
  def init_elm()
@@ -1,3 +1,3 @@
1
1
 
2
2
  import 'ElmNAME_CLASS', './elements/elm_NAME_FILE'
3
- window.customElements.define('elm-NAME_ELEMENT', ElmNAME_CLASS)
3
+ window.custom_elements.define('elm-NAME_ELEMENT', ElmNAME_CLASS)
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "dsdsds",
3
3
  "private": true,
4
- "version": "0.0.0",
4
+ "version": "0.1.0",
5
5
  "type": "module",
6
6
  "scripts": {
7
7
  "dev": "vite",
@@ -0,0 +1,20 @@
1
+ export default class Events
2
+ def self.emit(dom, event, values = nil)
3
+ custom_event = new CustomEvent(event, {
4
+ detail: {
5
+ value: values
6
+ }
7
+ })
8
+
9
+ document.query_selector(dom).dispatch_event(custom_event)
10
+ end
11
+
12
+ def self.connect(dom, event, &callback)
13
+ document.query_selector(dom).add_event_listener(event, callback) if callback
14
+ end
15
+
16
+ def self.disconnect(dom, event, &callback)
17
+ document.query_selector(dom).remove_event_listener(event, callback) if callback
18
+ end
19
+ end
20
+ window.Events = Events
@@ -0,0 +1,12 @@
1
+ export default class Net
2
+ def self.curl(url, &callback)
3
+ fetch(url)
4
+ .then(lambda do |response|
5
+ response.text()
6
+ end)
7
+ .then(lambda do |text|
8
+ callback(text) if callback
9
+ end)
10
+ end
11
+ end
12
+ window.Net = Net
@@ -0,0 +1,2 @@
1
+ import './core/events'
2
+ import './core/net'
@@ -1,3 +1,5 @@
1
1
  import '../css/style.css'
2
2
 
3
+ import './core'
4
+
3
5
  document.querySelector('#app').innerHTML = "<h1>Hello RubyJS</h1>"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rubyjs-vite
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.0
4
+ version: 2.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Filip Vrba
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-06-22 00:00:00.000000000 Z
11
+ date: 2024-03-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: ruby2js
@@ -55,6 +55,7 @@ files:
55
55
  - lib/rjsv/cli/arguments.rb
56
56
  - lib/rjsv/cli/plugins.rb
57
57
  - lib/rjsv/cli/signals.rb
58
+ - lib/rjsv/cli/states.rb
58
59
  - lib/rjsv/constants.rb
59
60
  - lib/rjsv/core/constants.rb
60
61
  - lib/rjsv/core/event.rb
@@ -70,7 +71,6 @@ files:
70
71
  - plugins/scaffold/lib/scaffold/vite.rb
71
72
  - share/scaffold/element/element.js.rb
72
73
  - share/scaffold/element/init.js.rb
73
- - share/scaffold/web/.env
74
74
  - share/scaffold/web/.gitignore
75
75
  - share/scaffold/web/bin/server
76
76
  - share/scaffold/web/config/ruby2js.rb
@@ -79,6 +79,9 @@ files:
79
79
  - share/scaffold/web/public/vite.svg
80
80
  - share/scaffold/web/src/css/style.css
81
81
  - share/scaffold/web/src/js/env.js
82
+ - share/scaffold/web/src/rb/core.js.rb
83
+ - share/scaffold/web/src/rb/core/events.js.rb
84
+ - share/scaffold/web/src/rb/core/net.js.rb
82
85
  - share/scaffold/web/src/rb/main.js.rb
83
86
  homepage: https://rubygems.org/gems/rubyjs-vite
84
87
  licenses:
@@ -86,7 +89,7 @@ licenses:
86
89
  metadata:
87
90
  source_code_uri: https://github.com/filipvrba/ruby-js
88
91
  documentation_uri: https://filipvrba.github.io/ruby-js/
89
- post_install_message:
92
+ post_install_message:
90
93
  rdoc_options: []
91
94
  require_paths:
92
95
  - lib
@@ -101,8 +104,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
101
104
  - !ruby/object:Gem::Version
102
105
  version: '0'
103
106
  requirements: []
104
- rubygems_version: 3.4.10
105
- signing_key:
107
+ rubygems_version: 3.5.3
108
+ signing_key:
106
109
  specification_version: 4
107
110
  summary: CLI application with RB file transpilation that communicates with the Vite
108
111
  tool.
File without changes