neri 0.9.4 → 1.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/README.ja.md +49 -69
- data/README.md +201 -61
- data/exe/neri +1 -2
- data/lib/neri/build.rb +314 -412
- data/lib/neri/runtime.rb +77 -60
- data/lib/neri/version.rb +1 -1
- data/neri.gemspec +0 -2
- metadata +4 -18
data/lib/neri/runtime.rb
CHANGED
@@ -1,79 +1,91 @@
|
|
1
1
|
require "neri/version"
|
2
|
+
require "pathname"
|
2
3
|
|
3
|
-
|
4
|
-
|
4
|
+
module Kernel
|
5
|
+
unless defined?(neri_original_require)
|
6
|
+
alias neri_original_require require
|
7
|
+
private :neri_original_require
|
8
|
+
end
|
5
9
|
|
6
|
-
|
7
|
-
|
8
|
-
|
10
|
+
unless defined?(neri_original_load)
|
11
|
+
alias neri_original_load load
|
12
|
+
private :neri_original_load
|
13
|
+
end
|
14
|
+
|
15
|
+
def require(feature)
|
16
|
+
Neri.require(feature)
|
17
|
+
end
|
9
18
|
|
10
|
-
def load(file, priv = false)
|
11
|
-
|
19
|
+
def load(file, priv = false)
|
20
|
+
Neri.load(file, priv)
|
21
|
+
end
|
12
22
|
end
|
13
23
|
|
14
24
|
module Neri
|
15
25
|
BLOCK_LENGTH = 32
|
16
26
|
@datafile = nil
|
17
|
-
@
|
18
|
-
@
|
19
|
-
@
|
20
|
-
@
|
27
|
+
@file_informations = {}
|
28
|
+
@fullpath_files = {}
|
29
|
+
@virtual_files = {}
|
30
|
+
@virtual_directory = "."
|
21
31
|
@xor = nil
|
22
32
|
|
23
33
|
class << self
|
24
34
|
def datafile=(datafile)
|
25
35
|
@datafile = datafile.encode(Encoding::UTF_8)
|
26
|
-
@system_dir = File.dirname(File.expand_path(@datafile)) + File::SEPARATOR
|
27
36
|
files_length = File.binread(@datafile, BLOCK_LENGTH).to_i
|
28
37
|
files_str = read(files_length, BLOCK_LENGTH)
|
29
38
|
pos = files_length + BLOCK_LENGTH
|
30
39
|
pos += BLOCK_LENGTH - pos % BLOCK_LENGTH unless pos % BLOCK_LENGTH == 0
|
31
40
|
files_str.force_encoding(Encoding::UTF_8)
|
32
|
-
files_str.
|
41
|
+
files_str.each_line do |line|
|
33
42
|
filename, length, offset = line.split("\t")
|
34
|
-
@
|
43
|
+
@file_informations[filename] = [length.to_i, offset.to_i + pos]
|
35
44
|
end
|
36
|
-
@
|
45
|
+
@fullpath_files = @file_informations.transform_keys { |k| File.expand_path(k) }
|
37
46
|
end
|
38
47
|
|
39
48
|
def key=(key)
|
40
|
-
@xor
|
49
|
+
@xor ||= key.scan(/../).map { |a| a.to_i(16) }.pack("c*")
|
41
50
|
end
|
42
51
|
|
43
|
-
def
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
["", ".rb"].each do |ext|
|
48
|
-
tmp_path = path + feature + ext
|
49
|
-
filepath ||= tmp_path if exist_in_datafile?(tmp_path)
|
50
|
-
end
|
51
|
-
end
|
52
|
-
|
53
|
-
return _neri_orig_require(feature) unless filepath
|
54
|
-
return false if $LOADED_FEATURES.index(filepath)
|
52
|
+
def virtual_directory=(path)
|
53
|
+
@virtual_directory = path
|
54
|
+
@virtual_files = @file_informations.transform_keys { |k| File.expand_path(k, path) }
|
55
|
+
end
|
55
56
|
|
56
|
-
|
57
|
-
|
58
|
-
|
57
|
+
def require(feature)
|
58
|
+
feature_path = Pathname.new(feature.encode(Encoding::UTF_8))
|
59
|
+
feature_path = feature_path.sub_ext(".rb") if feature_path.extname == ""
|
60
|
+
return neri_original_require(feature) if feature_path.extname == ".so"
|
61
|
+
|
62
|
+
path_str = if feature_path.absolute? || feature.start_with?(".")
|
63
|
+
path_in_datafile(feature_path)
|
64
|
+
else
|
65
|
+
search_in_load_path(feature_path)
|
66
|
+
end
|
67
|
+
|
68
|
+
return neri_original_require(feature) unless path_str
|
69
|
+
return false if $LOADED_FEATURES.index(path_str)
|
70
|
+
|
71
|
+
code = load_code(path_str)
|
72
|
+
eval(code, TOPLEVEL_BINDING, path_str)
|
73
|
+
$LOADED_FEATURES.push(path_str)
|
59
74
|
true
|
60
75
|
end
|
61
76
|
|
62
77
|
def load(file, priv = false)
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
paths.each do |path|
|
67
|
-
filepath ||= path + file if exist_in_datafile?(path + file)
|
68
|
-
end
|
78
|
+
file_path = Pathname.new(file.encode(Encoding::UTF_8))
|
79
|
+
path_str = search_in_load_path(file_path) if file_path.relative? && !file.start_with?(".")
|
80
|
+
path_str ||= path_in_datafile(file_path)
|
69
81
|
|
70
|
-
return
|
82
|
+
return neri_original_load(file, priv) unless path_str
|
71
83
|
|
72
|
-
code = load_code(
|
84
|
+
code = load_code(path_str)
|
73
85
|
if priv
|
74
|
-
Module.new.module_eval(code,
|
86
|
+
Module.new.module_eval(code, path_str)
|
75
87
|
else
|
76
|
-
eval(code, TOPLEVEL_BINDING,
|
88
|
+
eval(code, TOPLEVEL_BINDING, path_str)
|
77
89
|
end
|
78
90
|
true
|
79
91
|
end
|
@@ -84,32 +96,26 @@ module Neri
|
|
84
96
|
|
85
97
|
def file_read(filename, encoding = Encoding::BINARY)
|
86
98
|
filename = filename.encode(Encoding::UTF_8)
|
87
|
-
|
88
|
-
|
89
|
-
length, offset = fullpath_files[File.expand_path(filename)]
|
90
|
-
str = read(length, offset)
|
91
|
-
else
|
92
|
-
str = File.binread(filename)
|
93
|
-
end
|
99
|
+
length, offset = file_information(filename)
|
100
|
+
str = length ? read(length, offset) : File.binread(filename)
|
94
101
|
str.force_encoding(encoding)
|
95
102
|
end
|
96
103
|
|
97
104
|
def files
|
98
|
-
@
|
105
|
+
@file_informations.keys
|
99
106
|
end
|
100
107
|
|
101
108
|
def exist_in_datafile?(filename)
|
102
|
-
|
109
|
+
file_information(filename) != nil
|
103
110
|
end
|
104
111
|
|
105
112
|
private
|
106
113
|
|
107
|
-
def
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
@fullpath_files
|
114
|
+
def file_information(filename)
|
115
|
+
fullpath = File.expand_path(filename)
|
116
|
+
return @fullpath_files[fullpath] if @fullpath_files.key?(fullpath)
|
117
|
+
|
118
|
+
@virtual_files[File.expand_path(filename, @virtual_directory)]
|
113
119
|
end
|
114
120
|
|
115
121
|
def xor(str)
|
@@ -131,11 +137,22 @@ module Neri
|
|
131
137
|
xor(File.binread(@datafile, tmp_length, offset))[0, length]
|
132
138
|
end
|
133
139
|
|
134
|
-
def
|
135
|
-
|
136
|
-
|
140
|
+
def search_in_load_path(file_path)
|
141
|
+
$LOAD_PATH.each do |path_str|
|
142
|
+
path_str = path_str.dup.force_encoding(Encoding::UTF_8) if path_str.encoding == Encoding::BINARY
|
143
|
+
load_path = Pathname.new(path_str.encode(Encoding::UTF_8))
|
144
|
+
candidate_path_str = path_in_datafile(load_path + file_path)
|
145
|
+
return candidate_path_str if candidate_path_str
|
146
|
+
end
|
147
|
+
nil
|
148
|
+
end
|
149
|
+
|
150
|
+
def path_in_datafile(file_path)
|
151
|
+
fullpath = File.expand_path(file_path.to_s)
|
152
|
+
return fullpath if exist_in_datafile?(fullpath)
|
137
153
|
|
138
|
-
|
154
|
+
virtual_path = File.expand_path(file_path.to_s, @virtual_directory)
|
155
|
+
exist_in_datafile?(virtual_path) ? virtual_path : nil
|
139
156
|
end
|
140
157
|
|
141
158
|
def load_code(file)
|
data/lib/neri/version.rb
CHANGED
data/neri.gemspec
CHANGED
metadata
CHANGED
@@ -1,29 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: neri
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- nodai2hITC
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
12
|
-
dependencies:
|
13
|
-
- !ruby/object:Gem::Dependency
|
14
|
-
name: win32api
|
15
|
-
requirement: !ruby/object:Gem::Requirement
|
16
|
-
requirements:
|
17
|
-
- - ">="
|
18
|
-
- !ruby/object:Gem::Version
|
19
|
-
version: '0'
|
20
|
-
type: :runtime
|
21
|
-
prerelease: false
|
22
|
-
version_requirements: !ruby/object:Gem::Requirement
|
23
|
-
requirements:
|
24
|
-
- - ">="
|
25
|
-
- !ruby/object:Gem::Version
|
26
|
-
version: '0'
|
11
|
+
date: 2022-01-08 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
27
13
|
description: Neri builds Windows batfile or exefile from Ruby script.
|
28
14
|
email:
|
29
15
|
- nodai2h.itc@gmail.com
|
@@ -70,7 +56,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
70
56
|
- !ruby/object:Gem::Version
|
71
57
|
version: '0'
|
72
58
|
requirements: []
|
73
|
-
rubygems_version: 3.
|
59
|
+
rubygems_version: 3.3.3
|
74
60
|
signing_key:
|
75
61
|
specification_version: 4
|
76
62
|
summary: One-Click Ruby Application Builder
|