rubyjs-vite 1.0.6 → 1.0.8
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/app/arguments.rb +13 -4
- data/app/main.rb +3 -3
- data/app/signals.rb +1 -1
- data/lib/option_parser.rb +1 -1
- data/lib/ruby_js/code_join.rb +42 -6
- data/lib/ruby_js/constants.rb +1 -0
- data/lib/ruby_js/helper.rb +2 -2
- data/lib/ruby_js/scaffold.rb +1 -1
- data/lib/ruby_js/version.rb +1 -1
- data/lib/ruby_js.rb +5 -3
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e74e719ed6b734bda5a6a351f5dd2c6ae7c88b9b6b8454504e52ec3344162c08
|
4
|
+
data.tar.gz: 8c5b53516bd6d61ad97373e87148353c70c11cb68d2923baf9c671ad358acde6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d090f6c832663cb4f268eb866b9a4c1e4990f0abf96eb44e8d711da35e2c3ab16f21878e6947fa8e93fae45003040a8c691c8630c2c952b835d22f10c714a9b4
|
7
|
+
data.tar.gz: 927824b334eb77253a20cc58c34b2a21b9be5dc5082248efbe0a8bb02d1f74fe563d316717df902fe3a79a35834e854bfbe980882c16867f36f8e7be637aa54f
|
data/app/arguments.rb
CHANGED
@@ -2,9 +2,10 @@ require "option_parser"
|
|
2
2
|
|
3
3
|
@options = {
|
4
4
|
compile: false,
|
5
|
-
generate:
|
5
|
+
generate: nil,
|
6
6
|
watch: false,
|
7
7
|
output: Dir.pwd,
|
8
|
+
output_type: RubyJS::Constants::FILE_TYPE_O,
|
8
9
|
source: Dir.pwd,
|
9
10
|
eslevel: Config::get_eslevel
|
10
11
|
}
|
@@ -26,16 +27,24 @@ OptionParser.parse do |parser|
|
|
26
27
|
parser.on( "-w", "--watch", "Watch scripts for changes and rerun commands." ) do
|
27
28
|
@options[:watch] = true
|
28
29
|
end
|
29
|
-
parser.on( "-c", "--compile", "Compile to JavaScript and save as
|
30
|
+
parser.on( "-c", "--compile", "Compile to JavaScript and save as .#{@options[:output_type]} files." ) do
|
30
31
|
@options[:compile] = true
|
31
32
|
end
|
32
|
-
parser.on( "-g", "--generate", "Copies every rjs file into a single rjs file." ) do
|
33
|
-
|
33
|
+
parser.on( "-g PATH", "--generate PATH", "Copies every rjs file into a single rjs file." ) do |path|
|
34
|
+
if File.directory?(path)
|
35
|
+
@options[:generate] = path
|
36
|
+
else
|
37
|
+
@options[:generate] = ""
|
38
|
+
end
|
34
39
|
end
|
35
40
|
parser.on("-o DIR", "--output DIR", "Set the output path or path/filename\n" +
|
36
41
|
"for compiled JavaScript." ) do |dir|
|
37
42
|
@options[:output] = dir
|
38
43
|
end
|
44
|
+
parser.on("-ot TYPE", "--output-type TYPE", "Set the output type.\n" +
|
45
|
+
"The default: #{@options[:output_type]}" ) do |type|
|
46
|
+
@options[:output_type] = type
|
47
|
+
end
|
39
48
|
parser.on("-s DIR", "--source DIR", "Set the source path or path/filename\n" +
|
40
49
|
"for RubyJS." ) do |dir|
|
41
50
|
@options[:source] = dir
|
data/app/main.rb
CHANGED
@@ -7,7 +7,8 @@ def compile_fun path_f
|
|
7
7
|
RubyJS.compile path_f, {
|
8
8
|
eslevel: @options[:eslevel],
|
9
9
|
path_s: @options[:source],
|
10
|
-
path_o: @options[:output]
|
10
|
+
path_o: @options[:output],
|
11
|
+
type_o: @options[:output_type],
|
11
12
|
}
|
12
13
|
end
|
13
14
|
|
@@ -22,8 +23,7 @@ end
|
|
22
23
|
|
23
24
|
def generate
|
24
25
|
if @options[:generate]
|
25
|
-
|
26
|
-
code_j = RubyJS.generate_cj path_s
|
26
|
+
code_j = RubyJS.generate_cj @options[:source], @options[:generate]
|
27
27
|
return code_j.get_ignore_r
|
28
28
|
end
|
29
29
|
|
data/app/signals.rb
CHANGED
data/lib/option_parser.rb
CHANGED
data/lib/ruby_js/code_join.rb
CHANGED
@@ -15,7 +15,7 @@ module RubyJS
|
|
15
15
|
|
16
16
|
@json_cj = JsonParser.new File.join(path_s, FILE_HN)
|
17
17
|
@json_cj.on :name, "project"
|
18
|
-
@json_cj.on :ignore, ["#{FILE_N}_.*.rjs", TEST_N]
|
18
|
+
@json_cj.on :ignore, ["#{FILE_N}_.*.rjs", TEST_N, "main.rjs"]
|
19
19
|
end
|
20
20
|
|
21
21
|
def add_file path_f
|
@@ -61,13 +61,13 @@ module RubyJS
|
|
61
61
|
end
|
62
62
|
end
|
63
63
|
end
|
64
|
-
|
64
|
+
|
65
65
|
return files_c + files_nc
|
66
66
|
end
|
67
67
|
|
68
68
|
def extends_pos_class hash
|
69
|
-
fe_arr = []
|
70
|
-
fa_arr = []
|
69
|
+
fe_arr = [] # Extend class
|
70
|
+
fa_arr = [] # No extend class
|
71
71
|
hash.each do |c, e|
|
72
72
|
if e
|
73
73
|
arr_c = [c, e]
|
@@ -91,8 +91,44 @@ module RubyJS
|
|
91
91
|
end
|
92
92
|
end
|
93
93
|
|
94
|
-
|
95
|
-
|
94
|
+
last_class = check_last_extend_class(fe_arr)
|
95
|
+
|
96
|
+
fe_arr_ue = []
|
97
|
+
fe_arr.each do |cs|
|
98
|
+
cs.each do |c|
|
99
|
+
fe_arr_ue << c
|
100
|
+
end
|
101
|
+
end
|
102
|
+
fe_arr_uniq = change_extend_class_position(last_class, fe_arr_ue.uniq)
|
103
|
+
|
104
|
+
return fa_arr.clone.concat(fe_arr_uniq)
|
105
|
+
end
|
106
|
+
|
107
|
+
def change_extend_class_position last_class, fe_arr_uniq
|
108
|
+
last_class.each do |c|
|
109
|
+
i_c = fe_arr_uniq.delete c
|
110
|
+
fe_arr_uniq.push c
|
111
|
+
end
|
112
|
+
return fe_arr_uniq
|
113
|
+
end
|
114
|
+
|
115
|
+
def check_last_extend_class fe_arr
|
116
|
+
last_class = []
|
117
|
+
fe_arr.each do |cs|
|
118
|
+
unless last_class.empty?
|
119
|
+
last_class.each do |c|
|
120
|
+
is_exist = cs.find_index(c)
|
121
|
+
if is_exist
|
122
|
+
last_class.delete(c)
|
123
|
+
end
|
124
|
+
end
|
125
|
+
end
|
126
|
+
|
127
|
+
if cs.length == 1
|
128
|
+
last_class << cs[0]
|
129
|
+
end
|
130
|
+
end
|
131
|
+
return last_class
|
96
132
|
end
|
97
133
|
|
98
134
|
def to_s
|
data/lib/ruby_js/constants.rb
CHANGED
data/lib/ruby_js/helper.rb
CHANGED
@@ -31,11 +31,11 @@ module RubyJS
|
|
31
31
|
Dir.delete(path_dro) if Dir.empty? path_dro
|
32
32
|
end
|
33
33
|
|
34
|
-
def self.event_p event, path_f
|
34
|
+
def self.event_p event, path_f = ""
|
35
35
|
"#{Time.now.strftime("%l:%M:%S %p").lstrip} [#{Constants::APP_NAME}] #{event} #{path_f}"
|
36
36
|
end
|
37
37
|
|
38
|
-
def self.absolute_path path_f, path_options, prefix
|
38
|
+
def self.absolute_path path_f, path_options, prefix
|
39
39
|
path_ffr = path_f.sub("#{Dir.pwd}/", '').sub(path_options[:path_s], '').sub(Constants::FILE_TYPE, prefix)
|
40
40
|
path_ffa = File.join(path_options[:path_o], path_ffr)
|
41
41
|
path_ffa
|
data/lib/ruby_js/scaffold.rb
CHANGED
@@ -7,7 +7,7 @@ module RubyJS
|
|
7
7
|
path_ao = File.join(Dir.pwd, project)
|
8
8
|
|
9
9
|
puts "Scaffolding project in #{path_ao}..."
|
10
|
-
FileUtils.
|
10
|
+
FileUtils.cp_r path_as, path_ao
|
11
11
|
|
12
12
|
json_oc = JsonParser.new File.join(path_ao, "package.json")
|
13
13
|
json_oc.parse :name, project.downcase
|
data/lib/ruby_js/version.rb
CHANGED
data/lib/ruby_js.rb
CHANGED
@@ -19,7 +19,8 @@ module RubyJS
|
|
19
19
|
end
|
20
20
|
|
21
21
|
def self.compile path_f, options
|
22
|
-
path_o = Helper.absolute_path
|
22
|
+
path_o = Helper.absolute_path(path_f,
|
23
|
+
{ path_s: options[:path_s], path_o: options[:path_o] }, options[:type_o])
|
23
24
|
|
24
25
|
begin
|
25
26
|
content_rb = Helper.open(path_f)
|
@@ -33,7 +34,7 @@ module RubyJS
|
|
33
34
|
end
|
34
35
|
end
|
35
36
|
|
36
|
-
def self.generate_cj path_s
|
37
|
+
def self.generate_cj path_s, path_g
|
37
38
|
path_hfd = path_s
|
38
39
|
unless File.exist?(File.join(path_s, CodeJoin::FILE_HN))
|
39
40
|
path_hfd = Dir.pwd
|
@@ -50,7 +51,8 @@ module RubyJS
|
|
50
51
|
|
51
52
|
name_f = "#{code_join.json_cj.parse(:name).downcase.gsub(' ', '_')}_" +
|
52
53
|
"#{Time.now.strftime("%ya%m%d")}.#{Constants::FILE_TYPE}"
|
53
|
-
|
54
|
+
path_w = path_g.empty? ? path_s : path_g
|
55
|
+
path_f = File.join(path_w, name_f)
|
54
56
|
RubyJS::Helper.write(path_f, content_join)
|
55
57
|
puts Helper.event_p("generated", path_f)
|
56
58
|
|
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: 1.0.
|
4
|
+
version: 1.0.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Filip Vrba
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2023-02-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: ruby2js
|