rubyjs-vite 1.0.6 → 1.0.8

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b9849d181ab8eeb5a8dd4f15d860a3ae2fde08b23de946679212b82657aea889
4
- data.tar.gz: 5483e31adbcf1a6533222c0a110fc3c5c31c3735e8b3713db8932a49a904e154
3
+ metadata.gz: e74e719ed6b734bda5a6a351f5dd2c6ae7c88b9b6b8454504e52ec3344162c08
4
+ data.tar.gz: 8c5b53516bd6d61ad97373e87148353c70c11cb68d2923baf9c671ad358acde6
5
5
  SHA512:
6
- metadata.gz: b9ae171e632c80e2ec60058a4041631244ca95fab2cfacb111733aebb9d760b66e40d011e2f624dd4aa9a1e7c79e8af3c486d5c6a767880b2a8acc87ad70118f
7
- data.tar.gz: 2e8e7c0cdc05ba2e5d6fe42cf661130f7477153857687cf969cacf95473357db4b30a6a900dcf2d5714bacfb40cfa1ba0c35d1366239b81a185a473e86629502
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: false,
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 .js files." ) do
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
- @options[:generate] = true
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
- path_s = @options[:source]
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
@@ -1,4 +1,4 @@
1
1
  Signal.trap("INT") do
2
- puts "\nExiting"
2
+ puts "\n" + RubyJS::Helper.event_p("exiting")
3
3
  exit
4
4
  end
data/lib/option_parser.rb CHANGED
@@ -1,7 +1,7 @@
1
1
  class OptionParser
2
2
 
3
3
  LEFT = 2
4
- MIDDLE = 28
4
+ MIDDLE = 30
5
5
 
6
6
  attr_reader :args
7
7
 
@@ -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
- fe_arr_u = fe_arr.group_by{|x|x[1]}.values.map(&:last).reverse
95
- return fa_arr.clone.concat(fe_arr_u).to_s.gsub(/[\[\]\"]/, '').split(', ')
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
@@ -1,6 +1,7 @@
1
1
  module RubyJS
2
2
  module Constants
3
3
  FILE_TYPE = 'rjs'
4
+ FILE_TYPE_O = 'js'
4
5
  APP_NAME = 'rjsv'
5
6
  end
6
7
  end
@@ -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 = "js"
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
@@ -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.copy_entry path_as, path_ao
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
@@ -1,3 +1,3 @@
1
1
  module RubyJS
2
- VERSION = "1.0.6"
2
+ VERSION = "1.0.8"
3
3
  end
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 path_f, { path_s: options[:path_s], path_o: options[:path_o] }
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
- path_f = File.join(path_s, name_f)
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.6
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: 2022-11-28 00:00:00.000000000 Z
11
+ date: 2023-02-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: ruby2js