rubyjs-vite 2.0.1 → 2.0.2
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 +4 -4
- data/lib/rjsv/cli/arguments.rb +9 -7
- data/lib/rjsv/cli/states.rb +6 -5
- data/lib/rjsv/constants.rb +2 -1
- data/lib/rjsv/core/files.rb +25 -7
- data/lib/rjsv/version.rb +1 -1
- data/lib/rjsv/watch.rb +11 -11
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c3baf7c830c6ab5d908f949113abc8a4ad9fe322b01e452f152387dc4045dfbb
|
4
|
+
data.tar.gz: b99b607fc01cfb132b2db97c19a8f4f69e6ec1594531f6c08949e43b240e4677
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c51615a4a21a4ed84b73eaba45ef9dec248a9cea20c1ec6bef66fb7d4c43018897e2173a8dc2eb0c5f58eb628495a24e5d8e051d425a4b34a723d19818addff5
|
7
|
+
data.tar.gz: 4621c5d09324f795801cc902f54039225cab4f6c70b538a4c02cef350671ff73a66012b30938ab33d5da1cb5b0aeaae015fe941628f1cb3cbf6610ec6895255a
|
data/lib/rjsv/cli/arguments.rb
CHANGED
@@ -32,17 +32,19 @@ module RJSV
|
|
32
32
|
end
|
33
33
|
parser.on( "-t", "--translate", "It translates all loaded RB files\n" +
|
34
34
|
"into JavaScript code and stores them\n" +
|
35
|
-
"in certain type files
|
35
|
+
"in certain type files.\n" ) do
|
36
36
|
@options[:translate] = true
|
37
37
|
end
|
38
|
-
parser.on("-s DIR", "--source DIR", "The path of the source folder
|
39
|
-
"all RB files are found
|
40
|
-
"ending
|
38
|
+
parser.on("-s DIR", "--source DIR", "The path or paths of the source folder(s)\n" +
|
39
|
+
"where all RB files are found\n" +
|
40
|
+
"(e.g., files ending in *.js.#{RJSV::Constants::SUFFIX_RB}).") do |dir|
|
41
|
+
|
41
42
|
@options[:source] = dir
|
42
43
|
end
|
43
|
-
parser.on("-o DIR", "--output DIR", "The path of the output folder
|
44
|
-
"all Ruby
|
45
|
-
"JavaScript with the prepared file type
|
44
|
+
parser.on("-o DIR", "--output DIR", "The path or paths of the output folder(s)\n" +
|
45
|
+
"where all Ruby code will be translated into\n" +
|
46
|
+
"JavaScript with the prepared file type.\n" ) do |dir|
|
47
|
+
|
46
48
|
@options[:output] = dir
|
47
49
|
end
|
48
50
|
|
data/lib/rjsv/cli/states.rb
CHANGED
@@ -32,15 +32,16 @@ module RJSV
|
|
32
32
|
end
|
33
33
|
|
34
34
|
##
|
35
|
-
# Block of code that tracks files under the input
|
36
|
-
# If a file has been logged, several events are performed
|
37
|
-
# such as
|
38
|
-
# These then trigger procedural methods to process the requests.
|
35
|
+
# Block of code that tracks files under the input paths.
|
36
|
+
# If a file has been logged, several events are performed,
|
37
|
+
# such as adding, modifying, and removing logged files.
|
38
|
+
# These events then trigger procedural methods to process the requests.
|
39
39
|
|
40
40
|
def watch_state(options_cli)
|
41
41
|
if options_cli[:watch]
|
42
42
|
Core::Event.print('message', 'There is now a watch for edited files.')
|
43
|
-
|
43
|
+
paths = options_cli[:source].split(RJSV::Constants::PATH_SPLIT)
|
44
|
+
RJSV::Watch.modified_files(*paths) do |modified, added, removed|
|
44
45
|
unless added.empty?
|
45
46
|
added.each do |path|
|
46
47
|
translate_state(path, options_cli)
|
data/lib/rjsv/constants.rb
CHANGED
data/lib/rjsv/core/files.rb
CHANGED
@@ -61,18 +61,36 @@ module RJSV
|
|
61
61
|
# path for the output path.
|
62
62
|
|
63
63
|
def change_path_to_output(path, options_cli)
|
64
|
-
|
65
|
-
|
66
|
-
|
64
|
+
find_output_path = lambda do
|
65
|
+
index_s_path = options_cli[:source].split(RJSV::Constants::PATH_SPLIT)
|
66
|
+
.index {|e| path.index(e) != nil }
|
67
|
+
s_path = options_cli[:source].split(RJSV::Constants::PATH_SPLIT)[index_s_path]
|
68
|
+
mo_path = options_cli[:output].split(RJSV::Constants::PATH_SPLIT)[index_s_path]
|
69
|
+
|
70
|
+
unless mo_path
|
71
|
+
mo_path = options_cli[:output].split(RJSV::Constants::PATH_SPLIT)[0]
|
72
|
+
Core::Event.print('warning', "Output path not found for '#{s_path}'.")
|
73
|
+
end
|
74
|
+
|
75
|
+
return path.sub(s_path, mo_path)
|
76
|
+
end
|
77
|
+
|
78
|
+
find_output_path.call()
|
79
|
+
.sub(/\.#{RJSV::Constants::SUFFIX_RB}$/, '')
|
80
|
+
.sub(File.join(Dir.pwd(), ''), '')
|
67
81
|
end
|
68
82
|
|
69
83
|
##
|
70
84
|
# Finds all files with the extension '.*.rb'
|
71
|
-
# from the defined
|
85
|
+
# from the defined paths.
|
86
|
+
|
87
|
+
def find_all(paths)
|
88
|
+
path_all = []
|
89
|
+
paths.split(RJSV::Constants::PATH_SPLIT).each do |path|
|
90
|
+
path_all << File.join(path, '**', '*') + ".*.#{RJSV::Constants::SUFFIX_RB}"
|
91
|
+
end
|
72
92
|
|
73
|
-
|
74
|
-
path_all = File.join(path, '**', '*')
|
75
|
-
Dir.glob("#{path_all}.*.#{RJSV::Constants::SUFFIX_RB}")
|
93
|
+
Dir.glob(path_all)
|
76
94
|
end
|
77
95
|
|
78
96
|
##
|
data/lib/rjsv/version.rb
CHANGED
data/lib/rjsv/watch.rb
CHANGED
@@ -11,18 +11,18 @@ module RJSV
|
|
11
11
|
module_function
|
12
12
|
|
13
13
|
##
|
14
|
-
# Tracks modified files in the
|
15
|
-
# defined as the source
|
16
|
-
# function is called, the event listener is
|
17
|
-
# for events such as modified, added,
|
18
|
-
# file events. Therefore, the method
|
19
|
-
# the application to sleep and silently
|
20
|
-
# the event process. It watches all
|
21
|
-
# extension '.*.rb',
|
22
|
-
# any sub
|
14
|
+
# Tracks modified files in the paths that are
|
15
|
+
# defined as the source directories. When this
|
16
|
+
# function is called, the event listener is
|
17
|
+
# triggered for events such as modified, added,
|
18
|
+
# and deleted file events. Therefore, the method
|
19
|
+
# can put the application to sleep and silently
|
20
|
+
# monitor the event process. It watches all
|
21
|
+
# files with the extension '.*.rb', where
|
22
|
+
# the asterisk means any sub-extension such as '.js'.
|
23
23
|
|
24
|
-
def modified_files(
|
25
|
-
listener = Listen.to(
|
24
|
+
def modified_files(*paths, &block)
|
25
|
+
listener = Listen.to(*paths,
|
26
26
|
only: /\..*\.#{Constants::SUFFIX_RB}$/
|
27
27
|
) do |m, a, r|
|
28
28
|
|
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.
|
4
|
+
version: 2.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Filip Vrba
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-
|
11
|
+
date: 2024-10-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: ruby2js
|
@@ -104,7 +104,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
104
104
|
- !ruby/object:Gem::Version
|
105
105
|
version: '0'
|
106
106
|
requirements: []
|
107
|
-
rubygems_version: 3.5.
|
107
|
+
rubygems_version: 3.5.16
|
108
108
|
signing_key:
|
109
109
|
specification_version: 4
|
110
110
|
summary: CLI application with RB file transpilation that communicates with the Vite
|