rubyjs-vite 1.1.3 → 2.0.0
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/bin/rjsv +6 -2
- data/lib/option_parser.rb +6 -2
- data/lib/rjsv/cli/arguments.rb +77 -0
- data/lib/rjsv/cli/plugins.rb +71 -0
- data/lib/rjsv/cli/signals.rb +15 -0
- data/lib/rjsv/constants.rb +8 -0
- data/lib/rjsv/core/constants.rb +31 -0
- data/lib/rjsv/core/event.rb +24 -0
- data/lib/rjsv/core/files.rb +96 -0
- data/lib/rjsv/plugin.rb +55 -0
- data/lib/rjsv/translate.rb +40 -0
- data/lib/rjsv/version.rb +3 -0
- data/lib/rjsv/watch.rb +35 -0
- data/lib/rjsv.rb +105 -0
- data/plugins/scaffold/lib/init.rb +31 -0
- data/plugins/scaffold/lib/scaffold/cli/arguments.rb +43 -0
- data/plugins/scaffold/lib/scaffold/create.rb +64 -0
- data/plugins/scaffold/lib/scaffold/states.rb +40 -0
- data/plugins/scaffold/lib/scaffold/vite.rb +13 -0
- data/share/scaffold/element/element.js.rb +20 -0
- data/share/scaffold/element/init.js.rb +3 -0
- data/share/{template → scaffold/web}/.gitignore +2 -0
- data/share/{template → scaffold/web}/bin/server +1 -1
- data/share/scaffold/web/config/ruby2js.rb +10 -0
- data/share/{template → scaffold/web}/index.html +1 -1
- data/share/{template → scaffold/web}/package.json +6 -3
- data/share/scaffold/web/src/css/style.css +0 -0
- data/share/scaffold/web/src/js/env.js +1 -0
- metadata +42 -30
- data/app/arguments.rb +0 -67
- data/app/config.rb +0 -11
- data/app/main.rb +0 -75
- data/app/signals.rb +0 -4
- data/lib/description.rb +0 -10
- data/lib/ruby_js/code_join.rb +0 -153
- data/lib/ruby_js/constants.rb +0 -7
- data/lib/ruby_js/helper.rb +0 -50
- data/lib/ruby_js/scaffold.rb +0 -52
- data/lib/ruby_js/version.rb +0 -3
- data/lib/ruby_js.rb +0 -74
- data/share/template/.codejoin +0 -8
- data/share/template/bin/generate +0 -3
- data/share/template/bin/watch +0 -3
- /data/share/{template/src/css/style.css → scaffold/web/.env} +0 -0
- /data/share/{template → scaffold/web}/public/vite.svg +0 -0
- /data/share/{template/src/rjs/main.rjs → scaffold/web/src/rb/main.js.rb} +0 -0
@@ -0,0 +1,64 @@
|
|
1
|
+
module RJSV
|
2
|
+
module Plugins
|
3
|
+
module Scaffold
|
4
|
+
module Create
|
5
|
+
module_function
|
6
|
+
|
7
|
+
def web path_output
|
8
|
+
path_scaffold = File.expand_path('./share/scaffold/web', ROOT)
|
9
|
+
|
10
|
+
puts "Scaffolding project in #{path_output}..."
|
11
|
+
RJSV::Core::Files.copy(path_scaffold, path_output)
|
12
|
+
|
13
|
+
json_package = JsonParser.new File.join(path_output, "package.json")
|
14
|
+
json_package.parse :name, File.basename(path_output).downcase
|
15
|
+
end
|
16
|
+
|
17
|
+
def element(name, &block)
|
18
|
+
name_class = name.split(/[_-]/).map(&:capitalize).join
|
19
|
+
name_file = name.gsub('-', '_')
|
20
|
+
name_element = name.gsub('_', '-')
|
21
|
+
|
22
|
+
path_scaffold = File.expand_path('./share/scaffold/element', ROOT)
|
23
|
+
path_scaffold_element = File.join(path_scaffold, 'element.js.rb')
|
24
|
+
path_scaffold_init = File.join(path_scaffold, 'init.js.rb')
|
25
|
+
|
26
|
+
content_element = RJSV::Core::Files.open(path_scaffold_element)
|
27
|
+
.sub('NAME_CLASS', name_class)
|
28
|
+
content_init = RJSV::Core::Files.open(path_scaffold_init)
|
29
|
+
.gsub('NAME_CLASS', name_class)
|
30
|
+
.sub('NAME_FILE', name_file)
|
31
|
+
.sub('NAME_ELEMENT', name_element)
|
32
|
+
|
33
|
+
path_output_element = File.join(
|
34
|
+
Dir.pwd, 'src', 'rb', 'elements', "elm_#{name_file}.js.rb"
|
35
|
+
)
|
36
|
+
path_output_init = File.join(
|
37
|
+
Dir.pwd, 'src', 'rb', 'elements.js.rb'
|
38
|
+
)
|
39
|
+
|
40
|
+
files = [
|
41
|
+
{
|
42
|
+
path: path_output_element,
|
43
|
+
content: content_element,
|
44
|
+
mode: 'w+'
|
45
|
+
},
|
46
|
+
{
|
47
|
+
path: path_output_init,
|
48
|
+
content: content_init,
|
49
|
+
mode: 'a+'
|
50
|
+
}
|
51
|
+
]
|
52
|
+
|
53
|
+
files.each do |file|
|
54
|
+
RJSV::Core::Files.write_with_dir(
|
55
|
+
file[:content], file[:path], file[:mode]
|
56
|
+
)
|
57
|
+
block.call("Modified '.#{file[:path].sub(Dir.pwd, '')}'") if block
|
58
|
+
end
|
59
|
+
block.call("Element 'elm-#{name_element}'") if block
|
60
|
+
end
|
61
|
+
end#Create
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
module RJSV
|
2
|
+
module Plugins
|
3
|
+
module Scaffold
|
4
|
+
module States
|
5
|
+
module_function
|
6
|
+
|
7
|
+
def create_web_state(options)
|
8
|
+
project = options[:create_web]
|
9
|
+
if project
|
10
|
+
path_output = File.join(Dir.pwd, project)
|
11
|
+
Create.web(path_output)
|
12
|
+
is_installed = Vite.install(path_output)
|
13
|
+
|
14
|
+
if is_installed
|
15
|
+
puts "\nDone. Now run:\n\n cd #{project}\n bin/server\n\n"
|
16
|
+
else
|
17
|
+
wspaces = ' '*2
|
18
|
+
puts "\nThe Vite library installation encountered an issue.\n" +
|
19
|
+
"NodeJS is probably not installed on your machine.\n" +
|
20
|
+
"Please rerun the Vite installation after installing NodeJS.\n" +
|
21
|
+
"Use these instructions:\n\n" +
|
22
|
+
"#{wspaces}cd #{project}\n" +
|
23
|
+
"#{wspaces}npm install -D vite\n" +
|
24
|
+
"#{wspaces}bin/server"
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
def create_element_state(options)
|
30
|
+
name = options[:element]
|
31
|
+
if name
|
32
|
+
Create.element(name) do |message|
|
33
|
+
RJSV::Core::Event.print('scaffold', message)
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end#States
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
export default class ElmNAME_CLASS < HTMLElement
|
2
|
+
def initialize
|
3
|
+
super
|
4
|
+
|
5
|
+
init_elm()
|
6
|
+
end
|
7
|
+
|
8
|
+
def connectedCallback()
|
9
|
+
end
|
10
|
+
|
11
|
+
def disconnectedCallback()
|
12
|
+
end
|
13
|
+
|
14
|
+
def init_elm()
|
15
|
+
template = """
|
16
|
+
"""
|
17
|
+
|
18
|
+
self.innerHTML = template
|
19
|
+
end
|
20
|
+
end
|
@@ -1,11 +1,14 @@
|
|
1
1
|
{
|
2
|
-
"name": "
|
2
|
+
"name": "dsdsds",
|
3
3
|
"private": true,
|
4
4
|
"version": "0.0.0",
|
5
5
|
"type": "module",
|
6
6
|
"scripts": {
|
7
7
|
"dev": "vite",
|
8
|
-
"build": "vite build",
|
8
|
+
"build": "vite build --base=./",
|
9
9
|
"preview": "vite preview"
|
10
|
+
},
|
11
|
+
"devDependencies": {
|
12
|
+
"vite": "^4.3.9"
|
10
13
|
}
|
11
|
-
}
|
14
|
+
}
|
File without changes
|
@@ -0,0 +1 @@
|
|
1
|
+
export const ENV = import.meta.env
|
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:
|
4
|
+
version: 2.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Filip Vrba
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-06-
|
11
|
+
date: 2023-06-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: ruby2js
|
@@ -16,65 +16,76 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '5.
|
19
|
+
version: '5.1'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '5.
|
26
|
+
version: '5.1'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: listen
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
31
|
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: '3.
|
33
|
+
version: '3.8'
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: '3.
|
41
|
-
description:
|
42
|
-
|
40
|
+
version: '3.8'
|
41
|
+
description: This is a tool that behaves like a CLI application. The tool can track
|
42
|
+
RB files in real time and transpile them into JS files. RubyJS-Vite has its own
|
43
|
+
ecosystem and various plugins can be added. This tool can also communicate with
|
44
|
+
Vite tool for easier web development. Read the documentation for more information.
|
43
45
|
email: filipvrbaxi@gmail.com
|
44
46
|
executables:
|
45
47
|
- rjsv
|
46
48
|
extensions: []
|
47
49
|
extra_rdoc_files: []
|
48
50
|
files:
|
49
|
-
- app/arguments.rb
|
50
|
-
- app/config.rb
|
51
|
-
- app/main.rb
|
52
|
-
- app/signals.rb
|
53
51
|
- bin/rjsv
|
54
|
-
- lib/description.rb
|
55
52
|
- lib/json_parser.rb
|
56
53
|
- lib/option_parser.rb
|
57
|
-
- lib/
|
58
|
-
- lib/
|
59
|
-
- lib/
|
60
|
-
- lib/
|
61
|
-
- lib/
|
62
|
-
- lib/
|
63
|
-
-
|
64
|
-
-
|
65
|
-
-
|
66
|
-
-
|
67
|
-
-
|
68
|
-
-
|
69
|
-
-
|
70
|
-
-
|
71
|
-
-
|
72
|
-
-
|
54
|
+
- lib/rjsv.rb
|
55
|
+
- lib/rjsv/cli/arguments.rb
|
56
|
+
- lib/rjsv/cli/plugins.rb
|
57
|
+
- lib/rjsv/cli/signals.rb
|
58
|
+
- lib/rjsv/constants.rb
|
59
|
+
- lib/rjsv/core/constants.rb
|
60
|
+
- lib/rjsv/core/event.rb
|
61
|
+
- lib/rjsv/core/files.rb
|
62
|
+
- lib/rjsv/plugin.rb
|
63
|
+
- lib/rjsv/translate.rb
|
64
|
+
- lib/rjsv/version.rb
|
65
|
+
- lib/rjsv/watch.rb
|
66
|
+
- plugins/scaffold/lib/init.rb
|
67
|
+
- plugins/scaffold/lib/scaffold/cli/arguments.rb
|
68
|
+
- plugins/scaffold/lib/scaffold/create.rb
|
69
|
+
- plugins/scaffold/lib/scaffold/states.rb
|
70
|
+
- plugins/scaffold/lib/scaffold/vite.rb
|
71
|
+
- share/scaffold/element/element.js.rb
|
72
|
+
- share/scaffold/element/init.js.rb
|
73
|
+
- share/scaffold/web/.env
|
74
|
+
- share/scaffold/web/.gitignore
|
75
|
+
- share/scaffold/web/bin/server
|
76
|
+
- share/scaffold/web/config/ruby2js.rb
|
77
|
+
- share/scaffold/web/index.html
|
78
|
+
- share/scaffold/web/package.json
|
79
|
+
- share/scaffold/web/public/vite.svg
|
80
|
+
- share/scaffold/web/src/css/style.css
|
81
|
+
- share/scaffold/web/src/js/env.js
|
82
|
+
- share/scaffold/web/src/rb/main.js.rb
|
73
83
|
homepage: https://rubygems.org/gems/rubyjs-vite
|
74
84
|
licenses:
|
75
85
|
- MIT
|
76
86
|
metadata:
|
77
87
|
source_code_uri: https://github.com/filipvrba/ruby-js
|
88
|
+
documentation_uri: https://filipvrba.github.io/ruby-js/
|
78
89
|
post_install_message:
|
79
90
|
rdoc_options: []
|
80
91
|
require_paths:
|
@@ -93,5 +104,6 @@ requirements: []
|
|
93
104
|
rubygems_version: 3.4.10
|
94
105
|
signing_key:
|
95
106
|
specification_version: 4
|
96
|
-
summary:
|
107
|
+
summary: CLI application with RB file transpilation that communicates with the Vite
|
108
|
+
tool.
|
97
109
|
test_files: []
|
data/app/arguments.rb
DELETED
@@ -1,67 +0,0 @@
|
|
1
|
-
require "option_parser"
|
2
|
-
|
3
|
-
@options = {
|
4
|
-
compile: false,
|
5
|
-
generate: nil,
|
6
|
-
watch: false,
|
7
|
-
output: Dir.pwd,
|
8
|
-
output_type: RubyJS::Constants::FILE_TYPE_O,
|
9
|
-
source: Dir.pwd,
|
10
|
-
eslevel: Config::get_eslevel,
|
11
|
-
pid: nil,
|
12
|
-
}
|
13
|
-
|
14
|
-
OptionParser.parse do |parser|
|
15
|
-
parser.banner(
|
16
|
-
"Converts the syntax of ruby into javascript.\n" +
|
17
|
-
"Usage: #{RubyJS::Constants::APP_NAME} [options]\n" +
|
18
|
-
"\nOptions:"
|
19
|
-
)
|
20
|
-
parser.on( "-h", "--help", "Show help" ) do
|
21
|
-
puts parser
|
22
|
-
exit
|
23
|
-
end
|
24
|
-
parser.on( "-v", "--version", "Show version" ) do
|
25
|
-
puts "Version is #{RubyJS::VERSION}"
|
26
|
-
exit
|
27
|
-
end
|
28
|
-
parser.on( "-w", "--watch", "Watch scripts for changes and rerun commands." ) do
|
29
|
-
@options[:watch] = true
|
30
|
-
end
|
31
|
-
parser.on( "-c", "--compile", "Compile to JavaScript and save as .#{@options[:output_type]} files." ) do
|
32
|
-
@options[:compile] = true
|
33
|
-
end
|
34
|
-
parser.on( "-g PATH", "--generate PATH", "Copies every rjs file into a single rjs file." ) do |path|
|
35
|
-
if File.directory?(path)
|
36
|
-
@options[:generate] = path
|
37
|
-
else
|
38
|
-
@options[:generate] = ""
|
39
|
-
end
|
40
|
-
end
|
41
|
-
parser.on("-o DIR", "--output DIR", "Set the output path or path/filename\n" +
|
42
|
-
"for compiled JavaScript." ) do |dir|
|
43
|
-
@options[:output] = dir
|
44
|
-
end
|
45
|
-
parser.on("-ot TYPE", "--output-type TYPE", "Set the output type.\n" +
|
46
|
-
"The default: #{@options[:output_type]}" ) do |type|
|
47
|
-
@options[:output_type] = type
|
48
|
-
end
|
49
|
-
parser.on("-s DIR", "--source DIR", "Set the source path or path/filename\n" +
|
50
|
-
"for RubyJS." ) do |dir|
|
51
|
-
@options[:source] = dir
|
52
|
-
end
|
53
|
-
parser.on("-es LEVEL", "--eslevel LEVEL", "ECMAScript versions for compilation.\n" +
|
54
|
-
"The default: #{@options[:eslevel]}\n" +
|
55
|
-
"(Accepted level ranges 2015...2022.)") do |level|
|
56
|
-
|
57
|
-
@options[:eslevel] = level.to_i
|
58
|
-
end
|
59
|
-
parser.on("--pid PROCESS", "", "When the pid is set, the SIGUSR1\n" +
|
60
|
-
"signal is triggered." ) do |pid|
|
61
|
-
@options[:pid] = pid.to_i
|
62
|
-
end
|
63
|
-
parser.on("--create PROJECT", nil, "Creates a new project using scaffolding." ) do |project|
|
64
|
-
RubyJS::Scaffold.create project
|
65
|
-
exit
|
66
|
-
end
|
67
|
-
end
|
data/app/config.rb
DELETED
@@ -1,11 +0,0 @@
|
|
1
|
-
module Config
|
2
|
-
module_function
|
3
|
-
|
4
|
-
@default = JsonParser.new File.join(ROOT, 'config/default.json')
|
5
|
-
# If eslevel doesn't already exist, the default value is used to initialize it.
|
6
|
-
@default.on :eslevel, "2021"
|
7
|
-
|
8
|
-
def get_eslevel
|
9
|
-
@default.parse(:eslevel).to_i
|
10
|
-
end
|
11
|
-
end
|
data/app/main.rb
DELETED
@@ -1,75 +0,0 @@
|
|
1
|
-
require "ruby_js"
|
2
|
-
require_relative "config"
|
3
|
-
require_relative "arguments"
|
4
|
-
require_relative "signals"
|
5
|
-
|
6
|
-
def compile_fun path_f
|
7
|
-
RubyJS.compile path_f, {
|
8
|
-
eslevel: @options[:eslevel],
|
9
|
-
path_s: @options[:source],
|
10
|
-
path_o: @options[:output],
|
11
|
-
type_o: @options[:output_type],
|
12
|
-
}
|
13
|
-
end
|
14
|
-
|
15
|
-
def compile path_f
|
16
|
-
if @options[:compile]
|
17
|
-
compile_fun(path_f)
|
18
|
-
else
|
19
|
-
puts RubyJS::Helper.event_p("warning", "This '#{path_f}' file was edited, " +
|
20
|
-
"but it wasn't made into a js file.")
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
|
-
def generate
|
25
|
-
if @options[:generate]
|
26
|
-
code_j = RubyJS.generate_cj @options[:source], @options[:generate]
|
27
|
-
return code_j.get_ignore_r
|
28
|
-
end
|
29
|
-
|
30
|
-
return RubyJS::CodeJoin::TEST_N
|
31
|
-
end
|
32
|
-
ignore_cjfs = generate()
|
33
|
-
|
34
|
-
if @options[:compile]
|
35
|
-
RubyJS.get_files(@options[:source]).each do |path_f|
|
36
|
-
compile_fun(path_f)
|
37
|
-
end
|
38
|
-
end
|
39
|
-
|
40
|
-
if @options[:watch]
|
41
|
-
h_sigusr = lambda do
|
42
|
-
pid = @options[:pid]
|
43
|
-
if pid
|
44
|
-
Process.kill("USR1", pid)
|
45
|
-
end
|
46
|
-
end
|
47
|
-
|
48
|
-
puts RubyJS::Helper.event_p("message", "There is now a watch for edited files.")
|
49
|
-
h_sigusr.call()
|
50
|
-
|
51
|
-
path_s = @options[:source]
|
52
|
-
|
53
|
-
RubyJS::Helper.create_dir(path_s)
|
54
|
-
RubyJS.watch path_s, ignore_cjfs do |modified, added, removed|
|
55
|
-
generate()
|
56
|
-
|
57
|
-
unless added.empty?
|
58
|
-
compile(added.last)
|
59
|
-
end
|
60
|
-
|
61
|
-
unless modified.empty?
|
62
|
-
compile(modified.last)
|
63
|
-
end
|
64
|
-
|
65
|
-
unless removed.empty?
|
66
|
-
RubyJS.free removed.last, {
|
67
|
-
path_s: @options[:source],
|
68
|
-
path_o: @options[:output],
|
69
|
-
type_o: @options[:output_type],
|
70
|
-
}
|
71
|
-
end
|
72
|
-
|
73
|
-
h_sigusr.call()
|
74
|
-
end
|
75
|
-
end
|
data/app/signals.rb
DELETED
data/lib/description.rb
DELETED
data/lib/ruby_js/code_join.rb
DELETED
@@ -1,153 +0,0 @@
|
|
1
|
-
require "json_parser"
|
2
|
-
|
3
|
-
module RubyJS
|
4
|
-
FileS = Struct.new :path, :content, :class_rid
|
5
|
-
|
6
|
-
class CodeJoin
|
7
|
-
FILE_N = "FILE_N"
|
8
|
-
TEST_N = "test.rjs"
|
9
|
-
FILE_HN = ".codejoin"
|
10
|
-
|
11
|
-
attr_reader :json_cj
|
12
|
-
|
13
|
-
def initialize path_s
|
14
|
-
@files = []
|
15
|
-
|
16
|
-
@json_cj = JsonParser.new File.join(path_s, FILE_HN)
|
17
|
-
@json_cj.on :name, "project"
|
18
|
-
@json_cj.on :ignore, ["#{FILE_N}_.*.rjs", TEST_N, "main.rjs"]
|
19
|
-
end
|
20
|
-
|
21
|
-
def add_file path_f
|
22
|
-
content = File.open(path_f).read
|
23
|
-
i_c = content.index /class/
|
24
|
-
i_n = content.index(/\n/, i_c) if i_c
|
25
|
-
@files << FileS.new(path_f, content, [i_c, i_n])
|
26
|
-
end
|
27
|
-
|
28
|
-
def get_ignore_r
|
29
|
-
result = ""
|
30
|
-
@json_cj.parse(:ignore).each do |i|
|
31
|
-
result << i.sub(/#{FILE_N}/, @json_cj.parse(:name).downcase.gsub(' ', '_')).concat("$|")
|
32
|
-
end
|
33
|
-
return result.sub(/\|$/, '')
|
34
|
-
end
|
35
|
-
|
36
|
-
def get_pos_class
|
37
|
-
files_ch = {}
|
38
|
-
files_nc = []
|
39
|
-
@files.each do |f|
|
40
|
-
if f.class_rid[0]
|
41
|
-
r_class = f.content[f.class_rid[0], f.class_rid[1] - f.class_rid[0]]
|
42
|
-
r_class_s = r_class.split(' ')
|
43
|
-
_class = r_class_s[1]
|
44
|
-
_super = r_class_s[3]
|
45
|
-
|
46
|
-
files_ch[_class] = _super
|
47
|
-
else
|
48
|
-
files_nc << f
|
49
|
-
end
|
50
|
-
end
|
51
|
-
|
52
|
-
files_c = []
|
53
|
-
extends_pos_class(files_ch).each do |c|
|
54
|
-
@files.each do |f|
|
55
|
-
if f.class_rid[0]
|
56
|
-
r_class = f.content[f.class_rid[0], f.class_rid[1] - f.class_rid[0]]
|
57
|
-
if r_class.index("class #{c}")
|
58
|
-
files_c << f
|
59
|
-
break
|
60
|
-
end
|
61
|
-
end
|
62
|
-
end
|
63
|
-
end
|
64
|
-
|
65
|
-
return files_c + files_nc
|
66
|
-
end
|
67
|
-
|
68
|
-
def extends_pos_class hash
|
69
|
-
fe_arr = [] # Extend class
|
70
|
-
fa_arr = [] # No extend class
|
71
|
-
hash.each do |c, e|
|
72
|
-
if e
|
73
|
-
arr_c = [c, e]
|
74
|
-
def e_loop hash, key
|
75
|
-
k = hash.dig(key)
|
76
|
-
if k
|
77
|
-
yield k
|
78
|
-
e_loop(hash, k) do |kk|
|
79
|
-
yield kk
|
80
|
-
end
|
81
|
-
end
|
82
|
-
end
|
83
|
-
e_loop(hash, e) do |k|
|
84
|
-
arr_c << k
|
85
|
-
end
|
86
|
-
|
87
|
-
arr_c.pop
|
88
|
-
fe_arr << arr_c.reverse
|
89
|
-
else
|
90
|
-
fa_arr << c
|
91
|
-
end
|
92
|
-
end
|
93
|
-
|
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
|
132
|
-
end
|
133
|
-
|
134
|
-
def to_s
|
135
|
-
result = ""
|
136
|
-
# " * Module Description" +
|
137
|
-
# " *" +
|
138
|
-
# " * @version #{}" +
|
139
|
-
# " * @date #{}" +
|
140
|
-
# " * @author #{}" +
|
141
|
-
# " * @remarks #{}" +
|
142
|
-
# " * @github #{}" +
|
143
|
-
# " */"
|
144
|
-
|
145
|
-
get_pos_class.each do |f_s|
|
146
|
-
content_e = f_s.content.gsub(/import.*\n/, '').gsub('export ', '').gsub('default ', '')
|
147
|
-
content_en = content_e[content_e.length - 1] == "\n" ? content_e : content_e.concat("\n")
|
148
|
-
result << content_en
|
149
|
-
end
|
150
|
-
return result
|
151
|
-
end
|
152
|
-
end
|
153
|
-
end
|