neri 0.1.3 → 0.1.4
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 +1 -1
- data/lib/neri/ayame.rb +9 -5
- data/lib/neri/build.rb +6 -2
- data/lib/neri/dxruby.rb +39 -34
- data/lib/neri/dxruby_tiled.rb +4 -4
- data/lib/neri/runtime.rb +9 -4
- data/lib/neri/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 67233b2846e6e38f9bc09eb3a467513054dc3fb8
|
4
|
+
data.tar.gz: 50e5ccdbb4e581ec797c4e1f063f2a5f385c6788
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c63b8a5630a93aa8bd0395d215fe5d54db66f74c038d27355d410e6e782915c354886ef36d337040c451e708de2edd2fe92e8db500d91b505a0a3ee9c3c1eb71
|
7
|
+
data.tar.gz: 40e9179833af326b317641b0bc3b8aa07d32c46c8401be56a3b6032243b3a71be6a61cb4fb6b7d3183f907d4ad9e90b0e6d504c7b5972308f354c9c681ae277f
|
data/README.ja.md
CHANGED
@@ -196,7 +196,7 @@ Neri は単独では bat ファイルを作成するのみですが、Bat To Exe
|
|
196
196
|
|
197
197
|
データファイル内のスクリプトファイルは、`require` や `load` で読み込むことができます。
|
198
198
|
|
199
|
-
また、元のスクリプトファイルで `require 'neri
|
199
|
+
また、元のスクリプトファイルで `require 'neri'` しておくことで、以下のような命令でデータファイル内のデータにアクセスできます。
|
200
200
|
|
201
201
|
```ruby
|
202
202
|
Neri.file_exist?(filename) # -> bool
|
data/lib/neri/ayame.rb
CHANGED
@@ -2,17 +2,21 @@ require "neri/runtime"
|
|
2
2
|
|
3
3
|
require "ayame" unless defined? Ayame
|
4
4
|
|
5
|
-
|
6
|
-
|
7
|
-
alias :_neri_orig_new :new
|
8
|
-
|
5
|
+
module Neri
|
6
|
+
module Ayame
|
9
7
|
def new(filename)
|
10
8
|
if Neri.exist_in_datafile?(filename)
|
11
9
|
ayame = load_from_memory(Neri.file_read(path))
|
12
10
|
return ayame
|
13
11
|
else
|
14
|
-
return
|
12
|
+
return super
|
15
13
|
end
|
16
14
|
end
|
17
15
|
end
|
18
16
|
end
|
17
|
+
|
18
|
+
class Ayame
|
19
|
+
class << self
|
20
|
+
prepend Neri::Ayame
|
21
|
+
end
|
22
|
+
end
|
data/lib/neri/build.rb
CHANGED
@@ -551,10 +551,14 @@ endlocal
|
|
551
551
|
|
552
552
|
def create_datafile()
|
553
553
|
nputs "Creating data_file '#{datafile}'."
|
554
|
+
data_files = @data_files.select { |file| File.file? file }
|
555
|
+
@data_files.select { |file| File.directory? file }.each do |dir|
|
556
|
+
data_files += Dir.glob(dir + "/**/*").select { |file| File.file? file }
|
557
|
+
end
|
554
558
|
Neri.key = @encryption_key || "0" * 64
|
555
559
|
open(datafile, "wb") do |f|
|
556
560
|
pos = 0
|
557
|
-
files_str =
|
561
|
+
files_str = data_files.map{|file|
|
558
562
|
filename = File.expand_path(file)
|
559
563
|
filename = relative_path(filename, rubydir, "*neri*" + File::SEPARATOR)
|
560
564
|
filename = relative_path(filename, Dir.pwd)
|
@@ -567,7 +571,7 @@ endlocal
|
|
567
571
|
|
568
572
|
f.write(sprintf("%#{BLOCK_LENGTH}d", files_str.bytesize))
|
569
573
|
f.write(xor(files_str))
|
570
|
-
|
574
|
+
data_files.each do |file|
|
571
575
|
f.write(xor(File.binread(file)))
|
572
576
|
end
|
573
577
|
end
|
data/lib/neri/dxruby.rb
CHANGED
@@ -2,49 +2,54 @@ require "neri/runtime"
|
|
2
2
|
|
3
3
|
require "dxruby" unless defined? DXRuby
|
4
4
|
|
5
|
-
module
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
image = image.slice(x, y, width, height) if x && y && width && height
|
15
|
-
return image
|
16
|
-
else
|
17
|
-
return _neri_orig_load(path, x, y, width, height)
|
18
|
-
end
|
5
|
+
module Neri
|
6
|
+
module DXRubyImage
|
7
|
+
def load(path, x=nil, y=nil, width=nil, height=nil)
|
8
|
+
if Neri.exist_in_datafile?(path)
|
9
|
+
image = load_from_file_in_memory(Neri.file_read(path))
|
10
|
+
image = image.slice(x, y, width, height) if x && y && width && height
|
11
|
+
return image
|
12
|
+
else
|
13
|
+
return super
|
19
14
|
end
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
15
|
+
end
|
16
|
+
|
17
|
+
def load_tiles(path, xcount, ycount, share_switch=true)
|
18
|
+
if Neri.exist_in_datafile?(path) && !share_switch
|
19
|
+
image = load_from_file_in_memory(Neri.file_read(path))
|
20
|
+
return image.slice_tiles(xcount, ycount)
|
21
|
+
else
|
22
|
+
return super
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
module DXRubySound
|
28
|
+
def new(path)
|
29
|
+
if Neri.exist_in_datafile?(path)
|
30
|
+
case File.extname(path)
|
31
|
+
when ".mid"
|
32
|
+
return load_from_memory(Neri.file_read(path), DXRuby::TYPE_MIDI)
|
25
33
|
else
|
26
|
-
return
|
34
|
+
return load_from_memory(Neri.file_read(path), DXRuby::TYPE_WAV)
|
27
35
|
end
|
36
|
+
else
|
37
|
+
return super
|
28
38
|
end
|
29
39
|
end
|
30
40
|
end
|
41
|
+
end
|
42
|
+
|
43
|
+
module DXRuby
|
44
|
+
class Image
|
45
|
+
class << self
|
46
|
+
prepend Neri::DXRubyImage
|
47
|
+
end
|
48
|
+
end
|
31
49
|
|
32
50
|
class Sound
|
33
51
|
class << self
|
34
|
-
|
35
|
-
|
36
|
-
def new(path)
|
37
|
-
if Neri.exist_in_datafile?(path)
|
38
|
-
case File.extname(path)
|
39
|
-
when ".mid"
|
40
|
-
return load_from_memory(Neri.file_read(path), DXRuby::TYPE_MIDI)
|
41
|
-
else
|
42
|
-
return load_from_memory(Neri.file_read(path), DXRuby::TYPE_WAV)
|
43
|
-
end
|
44
|
-
else
|
45
|
-
return _neri_orig_new(path)
|
46
|
-
end
|
47
|
-
end
|
52
|
+
prepend Neri::DXRubySound
|
48
53
|
end
|
49
54
|
end
|
50
55
|
end
|
data/lib/neri/dxruby_tiled.rb
CHANGED
@@ -4,10 +4,10 @@ require "dxruby_tiled" unless defined? DXRuby::Tiled
|
|
4
4
|
|
5
5
|
module DXRuby
|
6
6
|
module Tiled
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
7
|
+
module_function
|
8
|
+
|
9
|
+
def read_file(file, encoding = Encoding::UTF_8)
|
10
|
+
Neri.file_read(file, encoding)
|
11
11
|
end
|
12
12
|
end
|
13
13
|
end
|
data/lib/neri/runtime.rb
CHANGED
@@ -41,10 +41,11 @@ module Neri
|
|
41
41
|
filepath = nil
|
42
42
|
load_path.each do |path|
|
43
43
|
["", ".rb"].each do |ext|
|
44
|
-
|
44
|
+
next unless exist_in_datafile?(path + feature + ext)
|
45
|
+
filepath = adjust_path(path + feature + ext)
|
45
46
|
end
|
46
47
|
end
|
47
|
-
|
48
|
+
|
48
49
|
if filepath
|
49
50
|
return false if $LOADED_FEATURES.index(filepath)
|
50
51
|
code = load_code(filepath)
|
@@ -81,7 +82,7 @@ module Neri
|
|
81
82
|
def file_read(filename, encoding = Encoding::BINARY)
|
82
83
|
str = nil
|
83
84
|
if exist_in_datafile?(filename)
|
84
|
-
length, offset = @files[filename.encode(Encoding::UTF_8)]
|
85
|
+
length, offset = @files[adjust_path(filename.encode(Encoding::UTF_8))]
|
85
86
|
str = read(length, offset)
|
86
87
|
else
|
87
88
|
str = File.binread(filename)
|
@@ -95,7 +96,7 @@ module Neri
|
|
95
96
|
end
|
96
97
|
|
97
98
|
def exist_in_datafile?(filename)
|
98
|
-
return @files.has_key?(filename.encode(Encoding::UTF_8))
|
99
|
+
return @files.has_key?(adjust_path(filename.encode(Encoding::UTF_8)))
|
99
100
|
end
|
100
101
|
|
101
102
|
private
|
@@ -114,6 +115,10 @@ module Neri
|
|
114
115
|
end
|
115
116
|
end
|
116
117
|
|
118
|
+
def adjust_path(path)
|
119
|
+
return path.sub(/^\.\//, "")
|
120
|
+
end
|
121
|
+
|
117
122
|
def read(length, offset)
|
118
123
|
if @xor
|
119
124
|
tmp_length = length
|
data/lib/neri/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: neri
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- nodai2hITC
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2018-02-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|