neri 0.9.2 → 0.9.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/neri/ayame.rb +3 -6
- data/lib/neri/build.rb +279 -243
- data/lib/neri/dxruby.rb +18 -28
- data/lib/neri/dxruby_tiled.rb +1 -1
- data/lib/neri/runtime.rb +113 -95
- data/lib/neri/version.rb +1 -1
- data/neri.gemspec +3 -5
- metadata +5 -19
data/lib/neri/dxruby.rb
CHANGED
@@ -4,38 +4,28 @@ require "dxruby" unless defined? DXRuby
|
|
4
4
|
|
5
5
|
module Neri
|
6
6
|
module DXRubyImage
|
7
|
-
def load(path, x=nil, y=nil, width=nil, height=nil)
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
return super
|
14
|
-
end
|
7
|
+
def load(path, x = nil, y = nil, width = nil, height = nil)
|
8
|
+
return super unless Neri.exist_in_datafile?(path)
|
9
|
+
|
10
|
+
image = load_from_file_in_memory(Neri.file_read(path))
|
11
|
+
image = image.slice(x, y, width, height) if x && y && width && height
|
12
|
+
image
|
15
13
|
end
|
16
|
-
|
17
|
-
def load_tiles(path, xcount, ycount, share_switch=true)
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
return super
|
23
|
-
end
|
14
|
+
|
15
|
+
def load_tiles(path, xcount, ycount, share_switch = true)
|
16
|
+
return super unless Neri.exist_in_datafile?(path) && !share_switch
|
17
|
+
|
18
|
+
image = load_from_file_in_memory(Neri.file_read(path))
|
19
|
+
image.slice_tiles(xcount, ycount)
|
24
20
|
end
|
25
21
|
end
|
26
|
-
|
22
|
+
|
27
23
|
module DXRubySound
|
28
24
|
def new(path)
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
else
|
34
|
-
return load_from_memory(Neri.file_read(path), DXRuby::TYPE_WAV)
|
35
|
-
end
|
36
|
-
else
|
37
|
-
return super
|
38
|
-
end
|
25
|
+
return super unless Neri.exist_in_datafile?(path)
|
26
|
+
|
27
|
+
load_from_memory(Neri.file_read(path),
|
28
|
+
File.extname(path) == ".mid" ? DXRuby::TYPE_MIDI : DXRuby::TYPE_WAV)
|
39
29
|
end
|
40
30
|
end
|
41
31
|
end
|
@@ -46,7 +36,7 @@ module DXRuby
|
|
46
36
|
prepend Neri::DXRubyImage
|
47
37
|
end
|
48
38
|
end
|
49
|
-
|
39
|
+
|
50
40
|
class Sound
|
51
41
|
class << self
|
52
42
|
prepend Neri::DXRubySound
|
data/lib/neri/dxruby_tiled.rb
CHANGED
data/lib/neri/runtime.rb
CHANGED
@@ -1,146 +1,164 @@
|
|
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
|
9
14
|
|
10
|
-
def
|
11
|
-
|
15
|
+
def require(feature)
|
16
|
+
Neri.require(feature)
|
17
|
+
end
|
18
|
+
|
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
|
-
@
|
27
|
+
@file_informations = {}
|
28
|
+
@fullpath_files = {}
|
29
|
+
@virtual_files = {}
|
30
|
+
@virtual_directory = "."
|
19
31
|
@xor = nil
|
20
|
-
|
32
|
+
|
21
33
|
class << self
|
22
34
|
def datafile=(datafile)
|
23
|
-
@datafile = datafile
|
24
|
-
@system_dir = File.dirname(File.expand_path(datafile)) + File::SEPARATOR
|
35
|
+
@datafile = datafile.encode(Encoding::UTF_8)
|
25
36
|
files_length = File.binread(@datafile, BLOCK_LENGTH).to_i
|
26
37
|
files_str = read(files_length, BLOCK_LENGTH)
|
27
38
|
pos = files_length + BLOCK_LENGTH
|
28
39
|
pos += BLOCK_LENGTH - pos % BLOCK_LENGTH unless pos % BLOCK_LENGTH == 0
|
29
40
|
files_str.force_encoding(Encoding::UTF_8)
|
30
|
-
files_str.
|
41
|
+
files_str.each_line do |line|
|
31
42
|
filename, length, offset = line.split("\t")
|
32
|
-
@
|
43
|
+
@file_informations[filename] = [length.to_i, offset.to_i + pos]
|
33
44
|
end
|
45
|
+
@fullpath_files = @file_informations.transform_keys { |k| File.expand_path(k) }
|
34
46
|
end
|
35
|
-
|
47
|
+
|
36
48
|
def key=(key)
|
37
|
-
@xor
|
49
|
+
@xor ||= key.scan(/../).map { |a| a.to_i(16) }.pack("c*")
|
50
|
+
end
|
51
|
+
|
52
|
+
def virtual_directory=(path)
|
53
|
+
@virtual_directory = path
|
54
|
+
@virtual_files = @file_informations.transform_keys { |k| File.expand_path(k, path) }
|
38
55
|
end
|
39
|
-
|
56
|
+
|
40
57
|
def require(feature)
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
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)
|
74
|
+
true
|
58
75
|
end
|
59
|
-
|
76
|
+
|
60
77
|
def load(file, priv = false)
|
61
|
-
|
62
|
-
(
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
else
|
71
|
-
eval(code, TOPLEVEL_BINDING, filepath)
|
72
|
-
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)
|
81
|
+
|
82
|
+
return neri_original_load(file, priv) unless path_str
|
83
|
+
|
84
|
+
code = load_code(path_str)
|
85
|
+
if priv
|
86
|
+
Module.new.module_eval(code, path_str)
|
73
87
|
else
|
74
|
-
|
88
|
+
eval(code, TOPLEVEL_BINDING, path_str)
|
75
89
|
end
|
90
|
+
true
|
76
91
|
end
|
77
|
-
|
92
|
+
|
78
93
|
def file_exist?(filename)
|
79
|
-
|
94
|
+
exist_in_datafile?(filename) || File.exist?(filename)
|
80
95
|
end
|
81
|
-
|
96
|
+
|
82
97
|
def file_read(filename, encoding = Encoding::BINARY)
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
str = read(length, offset)
|
87
|
-
else
|
88
|
-
str = File.binread(filename)
|
89
|
-
end
|
98
|
+
filename = filename.encode(Encoding::UTF_8)
|
99
|
+
length, offset = file_information(filename)
|
100
|
+
str = length ? read(length, offset) : File.binread(filename)
|
90
101
|
str.force_encoding(encoding)
|
91
|
-
return str
|
92
102
|
end
|
93
|
-
|
94
|
-
def files
|
95
|
-
|
103
|
+
|
104
|
+
def files
|
105
|
+
@file_informations.keys
|
96
106
|
end
|
97
|
-
|
107
|
+
|
98
108
|
def exist_in_datafile?(filename)
|
99
|
-
|
109
|
+
file_information(filename) != nil
|
100
110
|
end
|
101
|
-
|
111
|
+
|
102
112
|
private
|
103
|
-
|
113
|
+
|
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)]
|
119
|
+
end
|
120
|
+
|
104
121
|
def xor(str)
|
105
122
|
str.force_encoding(Encoding::BINARY)
|
106
|
-
while str.bytesize % BLOCK_LENGTH != 0
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
str.unpack("Q*").zip((@xor * (str.bytesize / BLOCK_LENGTH)).unpack("Q*")){|a, b| s.push(a ^ b)}
|
114
|
-
return s.pack("Q*")
|
115
|
-
end
|
116
|
-
end
|
117
|
-
|
118
|
-
def adjust_path(path)
|
119
|
-
return path.sub(/^\.\//, "")
|
123
|
+
str << rand(256).chr while str.bytesize % BLOCK_LENGTH != 0
|
124
|
+
xor_str = @xor * (str.bytesize / BLOCK_LENGTH)
|
125
|
+
return Xorcist.xor!(str, xor_str) if defined?(Xorcist)
|
126
|
+
|
127
|
+
s = []
|
128
|
+
str.unpack("Q*").zip((xor_str).unpack("Q*")) { |a, b| s.push(a ^ b) }
|
129
|
+
s.pack("Q*")
|
120
130
|
end
|
121
|
-
|
131
|
+
|
122
132
|
def read(length, offset)
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
133
|
+
return File.binread(@datafile, length, offset) unless @xor
|
134
|
+
|
135
|
+
tmp_length = length
|
136
|
+
tmp_length += BLOCK_LENGTH - length % BLOCK_LENGTH unless length % BLOCK_LENGTH == 0
|
137
|
+
xor(File.binread(@datafile, tmp_length, offset))[0, length]
|
138
|
+
end
|
139
|
+
|
140
|
+
def search_in_load_path(file_path)
|
141
|
+
$LOAD_PATH.each do |path_str|
|
142
|
+
load_path = Pathname.new(path_str.encode(Encoding::UTF_8))
|
143
|
+
candidate_path_str = path_in_datafile(load_path + file_path)
|
144
|
+
return candidate_path_str if candidate_path_str
|
129
145
|
end
|
146
|
+
nil
|
130
147
|
end
|
131
|
-
|
132
|
-
def
|
133
|
-
|
134
|
-
return
|
135
|
-
|
148
|
+
|
149
|
+
def path_in_datafile(file_path)
|
150
|
+
fullpath = File.expand_path(file_path.to_s)
|
151
|
+
return fullpath if exist_in_datafile?(fullpath)
|
152
|
+
|
153
|
+
virtual_path = File.expand_path(file_path.to_s, @virtual_directory)
|
154
|
+
exist_in_datafile?(virtual_path) ? virtual_path : nil
|
136
155
|
end
|
137
|
-
|
156
|
+
|
138
157
|
def load_code(file)
|
139
158
|
code = file_read(file)
|
140
159
|
encoding = "UTF-8"
|
141
|
-
encoding =
|
160
|
+
encoding = Regexp.last_match(1) if code.lines[0..2].join("\n").match(/coding:\s*(\S+)/)
|
142
161
|
code.force_encoding(encoding)
|
143
|
-
return code
|
144
162
|
end
|
145
163
|
end
|
146
164
|
end
|
data/lib/neri/version.rb
CHANGED
data/neri.gemspec
CHANGED
@@ -8,11 +8,11 @@ Gem::Specification.new do |spec|
|
|
8
8
|
spec.authors = ["nodai2hITC"]
|
9
9
|
spec.email = ["nodai2h.itc@gmail.com"]
|
10
10
|
|
11
|
-
spec.summary =
|
12
|
-
spec.description =
|
11
|
+
spec.summary = "One-Click Ruby Application Builder"
|
12
|
+
spec.description = "Neri builds Windows batfile or exefile from Ruby script."
|
13
13
|
spec.homepage = "https://github.com/nodai2hITC/neri"
|
14
14
|
spec.license = "MIT"
|
15
|
-
spec.required_ruby_version = ">= 2.
|
15
|
+
spec.required_ruby_version = ">= 2.5.0"
|
16
16
|
|
17
17
|
# spec.metadata["allowed_push_host"] = "TODO: Set to 'https://mygemserver.com'"
|
18
18
|
|
@@ -30,6 +30,4 @@ Gem::Specification.new do |spec|
|
|
30
30
|
spec.bindir = "exe"
|
31
31
|
spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
|
32
32
|
spec.require_paths = ["lib"]
|
33
|
-
|
34
|
-
spec.add_dependency "win32api"
|
35
33
|
end
|
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.9.
|
4
|
+
version: 0.9.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- nodai2hITC
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
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: 2021-12-29 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
|
@@ -63,14 +49,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
63
49
|
requirements:
|
64
50
|
- - ">="
|
65
51
|
- !ruby/object:Gem::Version
|
66
|
-
version: 2.
|
52
|
+
version: 2.5.0
|
67
53
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
68
54
|
requirements:
|
69
55
|
- - ">="
|
70
56
|
- !ruby/object:Gem::Version
|
71
57
|
version: '0'
|
72
58
|
requirements: []
|
73
|
-
rubygems_version: 3.2.
|
59
|
+
rubygems_version: 3.2.30
|
74
60
|
signing_key:
|
75
61
|
specification_version: 4
|
76
62
|
summary: One-Click Ruby Application Builder
|