neri 0.1.7 → 0.9.3
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 +5 -5
- data/README.ja.md +17 -14
- data/README.md +1 -0
- data/Rakefile +3 -1
- data/lib/neri/ayame.rb +3 -6
- data/lib/neri/build.rb +464 -294
- data/lib/neri/dxruby.rb +18 -28
- data/lib/neri/dxruby_tiled.rb +1 -1
- data/lib/neri/runtime.rb +77 -74
- data/lib/neri/version.rb +1 -1
- data/neri.gemspec +23 -24
- metadata +12 -40
- data/.gitignore +0 -9
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,7 +1,7 @@
|
|
1
1
|
require "neri/version"
|
2
2
|
|
3
|
-
alias
|
4
|
-
alias
|
3
|
+
alias _neri_orig_require require
|
4
|
+
alias _neri_orig_load load
|
5
5
|
|
6
6
|
def require(feature)
|
7
7
|
Neri.require(feature)
|
@@ -16,12 +16,14 @@ module Neri
|
|
16
16
|
@datafile = nil
|
17
17
|
@system_dir = nil
|
18
18
|
@files = {}
|
19
|
+
@fullpath_files = nil
|
20
|
+
@current_directory = nil
|
19
21
|
@xor = nil
|
20
|
-
|
22
|
+
|
21
23
|
class << self
|
22
24
|
def datafile=(datafile)
|
23
|
-
@datafile = datafile
|
24
|
-
@system_dir = File.dirname(File.expand_path(datafile)) + File::SEPARATOR
|
25
|
+
@datafile = datafile.encode(Encoding::UTF_8)
|
26
|
+
@system_dir = File.dirname(File.expand_path(@datafile)) + File::SEPARATOR
|
25
27
|
files_length = File.binread(@datafile, BLOCK_LENGTH).to_i
|
26
28
|
files_str = read(files_length, BLOCK_LENGTH)
|
27
29
|
pos = files_length + BLOCK_LENGTH
|
@@ -31,115 +33,116 @@ module Neri
|
|
31
33
|
filename, length, offset = line.split("\t")
|
32
34
|
@files[filename] = [length.to_i, offset.to_i + pos]
|
33
35
|
end
|
36
|
+
@current_directory = nil
|
34
37
|
end
|
35
|
-
|
38
|
+
|
36
39
|
def key=(key)
|
37
|
-
@xor = key.scan(/../).map{|a| a.to_i(16)}.pack("c*")
|
40
|
+
@xor = key.scan(/../).map { |a| a.to_i(16) }.pack("c*")
|
38
41
|
end
|
39
|
-
|
42
|
+
|
40
43
|
def require(feature)
|
44
|
+
feature = feature.encode(Encoding::UTF_8)
|
41
45
|
filepath = nil
|
42
|
-
load_path.each do |path|
|
46
|
+
(feature.start_with?(/[a-z]:/i, "\\", "/", ".") ? [""] : load_path).each do |path|
|
43
47
|
["", ".rb"].each do |ext|
|
44
|
-
|
45
|
-
filepath
|
48
|
+
tmp_path = path + feature + ext
|
49
|
+
filepath ||= tmp_path if exist_in_datafile?(tmp_path)
|
46
50
|
end
|
47
51
|
end
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
return _neri_orig_require(feature)
|
57
|
-
end
|
52
|
+
|
53
|
+
return _neri_orig_require(feature) unless filepath
|
54
|
+
return false if $LOADED_FEATURES.index(filepath)
|
55
|
+
|
56
|
+
code = load_code(filepath)
|
57
|
+
eval(code, TOPLEVEL_BINDING, filepath)
|
58
|
+
$LOADED_FEATURES.push(filepath)
|
59
|
+
true
|
58
60
|
end
|
59
|
-
|
61
|
+
|
60
62
|
def load(file, priv = false)
|
63
|
+
file = file.encode(Encoding::UTF_8)
|
61
64
|
filepath = nil
|
62
|
-
(load_path + [""]
|
63
|
-
|
65
|
+
paths = file.start_with?(/[a-z]:/i, "\\", "/", ".") ? [""] : load_path + [""]
|
66
|
+
paths.each do |path|
|
67
|
+
filepath ||= path + file if exist_in_datafile?(path + file)
|
64
68
|
end
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
Module.new.module_eval(code, filepath)
|
72
|
-
end
|
69
|
+
|
70
|
+
return _neri_orig_load(file, priv) unless filepath
|
71
|
+
|
72
|
+
code = load_code(filepath)
|
73
|
+
if priv
|
74
|
+
Module.new.module_eval(code, filepath)
|
73
75
|
else
|
74
|
-
|
76
|
+
eval(code, TOPLEVEL_BINDING, filepath)
|
75
77
|
end
|
78
|
+
true
|
76
79
|
end
|
77
|
-
|
80
|
+
|
78
81
|
def file_exist?(filename)
|
79
|
-
|
82
|
+
exist_in_datafile?(filename) || File.exist?(filename)
|
80
83
|
end
|
81
|
-
|
84
|
+
|
82
85
|
def file_read(filename, encoding = Encoding::BINARY)
|
86
|
+
filename = filename.encode(Encoding::UTF_8)
|
83
87
|
str = nil
|
84
88
|
if exist_in_datafile?(filename)
|
85
|
-
length, offset =
|
89
|
+
length, offset = fullpath_files[File.expand_path(filename)]
|
86
90
|
str = read(length, offset)
|
87
91
|
else
|
88
92
|
str = File.binread(filename)
|
89
93
|
end
|
90
94
|
str.force_encoding(encoding)
|
91
|
-
return str
|
92
95
|
end
|
93
|
-
|
94
|
-
def files
|
95
|
-
|
96
|
+
|
97
|
+
def files
|
98
|
+
@files.keys
|
96
99
|
end
|
97
|
-
|
100
|
+
|
98
101
|
def exist_in_datafile?(filename)
|
99
|
-
|
102
|
+
fullpath_files.key?(File.expand_path(filename.encode(Encoding::UTF_8)))
|
100
103
|
end
|
101
|
-
|
104
|
+
|
102
105
|
private
|
103
|
-
|
104
|
-
def
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
end
|
109
|
-
if defined?(Xorcist)
|
110
|
-
return Xorcist.xor!(str, @xor * (str.bytesize / BLOCK_LENGTH))
|
111
|
-
else
|
112
|
-
s = []
|
113
|
-
str.unpack("Q*").zip((@xor * (str.bytesize / BLOCK_LENGTH)).unpack("Q*")){|a, b| s.push(a ^ b)}
|
114
|
-
return s.pack("Q*")
|
106
|
+
|
107
|
+
def fullpath_files
|
108
|
+
if @current_directory != Dir.pwd
|
109
|
+
@current_directory = Dir.pwd
|
110
|
+
@fullpath_files = @files.transform_keys { |k| File.expand_path(k) }
|
115
111
|
end
|
112
|
+
@fullpath_files
|
116
113
|
end
|
117
|
-
|
118
|
-
def
|
119
|
-
|
114
|
+
|
115
|
+
def xor(str)
|
116
|
+
str.force_encoding(Encoding::BINARY)
|
117
|
+
str << rand(256).chr while str.bytesize % BLOCK_LENGTH != 0
|
118
|
+
xor_str = @xor * (str.bytesize / BLOCK_LENGTH)
|
119
|
+
return Xorcist.xor!(str, xor_str) if defined?(Xorcist)
|
120
|
+
|
121
|
+
s = []
|
122
|
+
str.unpack("Q*").zip((xor_str).unpack("Q*")) { |a, b| s.push(a ^ b) }
|
123
|
+
s.pack("Q*")
|
120
124
|
end
|
121
|
-
|
125
|
+
|
122
126
|
def read(length, offset)
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
return File.binread(@datafile, length, offset)
|
129
|
-
end
|
127
|
+
return File.binread(@datafile, length, offset) unless @xor
|
128
|
+
|
129
|
+
tmp_length = length
|
130
|
+
tmp_length += BLOCK_LENGTH - length % BLOCK_LENGTH unless length % BLOCK_LENGTH == 0
|
131
|
+
xor(File.binread(@datafile, tmp_length, offset))[0, length]
|
130
132
|
end
|
131
|
-
|
132
|
-
def load_path
|
133
|
-
|
134
|
-
return
|
133
|
+
|
134
|
+
def load_path
|
135
|
+
paths = $LOAD_PATH.map { |path| path.encode(Encoding::UTF_8) }
|
136
|
+
return paths unless @system_dir
|
137
|
+
|
138
|
+
paths.map { |path| path.sub(@system_dir, "*neri*#{File::SEPARATOR}") + File::SEPARATOR }
|
135
139
|
end
|
136
|
-
|
140
|
+
|
137
141
|
def load_code(file)
|
138
142
|
code = file_read(file)
|
139
143
|
encoding = "UTF-8"
|
140
|
-
encoding =
|
144
|
+
encoding = Regexp.last_match(1) if code.lines[0..2].join("\n").match(/coding:\s*(\S+)/)
|
141
145
|
code.force_encoding(encoding)
|
142
|
-
return code
|
143
146
|
end
|
144
147
|
end
|
145
148
|
end
|
data/lib/neri/version.rb
CHANGED
data/neri.gemspec
CHANGED
@@ -1,36 +1,35 @@
|
|
1
|
-
#
|
2
|
-
|
3
|
-
|
4
|
-
require "neri/version"
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative "lib/neri/version"
|
5
4
|
|
6
5
|
Gem::Specification.new do |spec|
|
7
6
|
spec.name = "neri"
|
8
7
|
spec.version = Neri::VERSION
|
9
8
|
spec.authors = ["nodai2hITC"]
|
10
9
|
spec.email = ["nodai2h.itc@gmail.com"]
|
11
|
-
|
12
|
-
spec.summary =
|
13
|
-
spec.description =
|
10
|
+
|
11
|
+
spec.summary = "One-Click Ruby Application Builder"
|
12
|
+
spec.description = "Neri builds Windows batfile or exefile from Ruby script."
|
14
13
|
spec.homepage = "https://github.com/nodai2hITC/neri"
|
15
14
|
spec.license = "MIT"
|
16
|
-
|
17
|
-
|
18
|
-
#
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
spec.files
|
27
|
-
|
15
|
+
spec.required_ruby_version = ">= 2.5.0"
|
16
|
+
|
17
|
+
# spec.metadata["allowed_push_host"] = "TODO: Set to 'https://mygemserver.com'"
|
18
|
+
|
19
|
+
spec.metadata["homepage_uri"] = spec.homepage
|
20
|
+
spec.metadata["source_code_uri"] = spec.homepage
|
21
|
+
# spec.metadata["changelog_uri"] = "TODO: Put your gem's CHANGELOG.md URL here."
|
22
|
+
|
23
|
+
# Specify which files should be added to the gem when it is released.
|
24
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
25
|
+
spec.files = Dir.chdir(File.expand_path(__dir__)) do
|
26
|
+
`git ls-files -z`.split("\x0").reject do |f|
|
27
|
+
(f == __FILE__) || f.match(%r{\A(?:(?:test|spec|features)/|\.(?:git|travis|circleci)|appveyor)})
|
28
|
+
end
|
28
29
|
end
|
29
30
|
spec.bindir = "exe"
|
30
|
-
spec.executables = spec.files.grep(%r{
|
31
|
+
spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
|
31
32
|
spec.require_paths = ["lib"]
|
32
|
-
|
33
|
-
spec.
|
34
|
-
spec.add_development_dependency "rake", "~> 10.0"
|
35
|
-
spec.add_development_dependency "pry"
|
33
|
+
|
34
|
+
spec.add_dependency "win32api"
|
36
35
|
end
|
metadata
CHANGED
@@ -1,51 +1,23 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: neri
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.9.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- nodai2hITC
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-11-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
|
-
name:
|
15
|
-
requirement: !ruby/object:Gem::Requirement
|
16
|
-
requirements:
|
17
|
-
- - "~>"
|
18
|
-
- !ruby/object:Gem::Version
|
19
|
-
version: '1.15'
|
20
|
-
type: :development
|
21
|
-
prerelease: false
|
22
|
-
version_requirements: !ruby/object:Gem::Requirement
|
23
|
-
requirements:
|
24
|
-
- - "~>"
|
25
|
-
- !ruby/object:Gem::Version
|
26
|
-
version: '1.15'
|
27
|
-
- !ruby/object:Gem::Dependency
|
28
|
-
name: rake
|
29
|
-
requirement: !ruby/object:Gem::Requirement
|
30
|
-
requirements:
|
31
|
-
- - "~>"
|
32
|
-
- !ruby/object:Gem::Version
|
33
|
-
version: '10.0'
|
34
|
-
type: :development
|
35
|
-
prerelease: false
|
36
|
-
version_requirements: !ruby/object:Gem::Requirement
|
37
|
-
requirements:
|
38
|
-
- - "~>"
|
39
|
-
- !ruby/object:Gem::Version
|
40
|
-
version: '10.0'
|
41
|
-
- !ruby/object:Gem::Dependency
|
42
|
-
name: pry
|
14
|
+
name: win32api
|
43
15
|
requirement: !ruby/object:Gem::Requirement
|
44
16
|
requirements:
|
45
17
|
- - ">="
|
46
18
|
- !ruby/object:Gem::Version
|
47
19
|
version: '0'
|
48
|
-
type: :
|
20
|
+
type: :runtime
|
49
21
|
prerelease: false
|
50
22
|
version_requirements: !ruby/object:Gem::Requirement
|
51
23
|
requirements:
|
@@ -60,7 +32,6 @@ executables:
|
|
60
32
|
extensions: []
|
61
33
|
extra_rdoc_files: []
|
62
34
|
files:
|
63
|
-
- ".gitignore"
|
64
35
|
- Gemfile
|
65
36
|
- LICENSE.txt
|
66
37
|
- README.ja.md
|
@@ -81,8 +52,10 @@ files:
|
|
81
52
|
homepage: https://github.com/nodai2hITC/neri
|
82
53
|
licenses:
|
83
54
|
- MIT
|
84
|
-
metadata:
|
85
|
-
|
55
|
+
metadata:
|
56
|
+
homepage_uri: https://github.com/nodai2hITC/neri
|
57
|
+
source_code_uri: https://github.com/nodai2hITC/neri
|
58
|
+
post_install_message:
|
86
59
|
rdoc_options: []
|
87
60
|
require_paths:
|
88
61
|
- lib
|
@@ -90,16 +63,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
90
63
|
requirements:
|
91
64
|
- - ">="
|
92
65
|
- !ruby/object:Gem::Version
|
93
|
-
version:
|
66
|
+
version: 2.5.0
|
94
67
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
95
68
|
requirements:
|
96
69
|
- - ">="
|
97
70
|
- !ruby/object:Gem::Version
|
98
71
|
version: '0'
|
99
72
|
requirements: []
|
100
|
-
|
101
|
-
|
102
|
-
signing_key:
|
73
|
+
rubygems_version: 3.2.30
|
74
|
+
signing_key:
|
103
75
|
specification_version: 4
|
104
76
|
summary: One-Click Ruby Application Builder
|
105
77
|
test_files: []
|