neri 0.1.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 +7 -0
- data/.gitignore +9 -0
- data/Gemfile +6 -0
- data/LICENSE.txt +21 -0
- data/README.ja.md +230 -0
- data/README.md +75 -0
- data/Rakefile +2 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/exe/neri +6 -0
- data/lib/neri/ayame.rb +18 -0
- data/lib/neri/dxruby.rb +50 -0
- data/lib/neri/dxruby_tiled.rb +13 -0
- data/lib/neri/runtime.rb +140 -0
- data/lib/neri/version.rb +3 -0
- data/lib/neri.rb +2 -0
- data/neri.gemspec +36 -0
- data/share/default.ico +0 -0
- metadata +104 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 5245bae62328239fdc0721d966a981de0a8ce408
|
4
|
+
data.tar.gz: e19a7a09fdec97002d91eab16cedd90a4ea66209
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: ff1777b644bc6ab6eb474d55891079e2e719bb9fb2e3964b70a09d9e676808582d4cec0e24daea6d9d7ca8bc93dc42f9ef880f9d8b8d2e9e6c6f15b90e70fb7b
|
7
|
+
data.tar.gz: 2bd549b4f641fd1d8150113ed1a08d41176f00e4e9e8a6743bf4b00a8f8ea5f41012509508f743189f70e385e3959914a39b663a1a2a3edfd3871846269e1c43
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2017 nodai2hITC
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.ja.md
ADDED
@@ -0,0 +1,230 @@
|
|
1
|
+
# Neri
|
2
|
+
|
3
|
+
Neri は、Ruby スクリプトを Ruby 未インストール環境向けに配布するためのパッケージングシステムです。
|
4
|
+
|
5
|
+
同種の gem としては [OCRA](https://github.com/larsch/ocra) がありますが、以下のような違いがあります。
|
6
|
+
|
7
|
+
- OCRA に比べての長所
|
8
|
+
- 展開しない分、起動が速い。
|
9
|
+
- OCRA には「日本語を含むユーザー名の環境では起動できない」という問題があるが、Neri にはない。
|
10
|
+
- ただし Ruby のバージョンによっては、日本語を含むパス上では起動できない。(OCRA も同様。)
|
11
|
+
- OCRA に比べての短所
|
12
|
+
- Neri 単独では、bat ファイルを作成することしかできない。
|
13
|
+
- ただし、後述する [Bat To Exe Converter](http://www.f2ko.de/en/b2e.php) を導入すれば、exe ファイルを自動で作成します。
|
14
|
+
|
15
|
+
## インストール
|
16
|
+
|
17
|
+
$ gem install neri
|
18
|
+
|
19
|
+
## 使い方
|
20
|
+
|
21
|
+
$ neri [options] script.rb (other_files...) -- script_arguments
|
22
|
+
|
23
|
+
上の例では、一度 "script.rb" を依存ファイルチェックのために実行し、
|
24
|
+
その際に必要としたファイルを依存ファイルとして出力先にコピーした上で、
|
25
|
+
実行ファイルを作成します。
|
26
|
+
|
27
|
+
出力先フォルダを丸ごとコピーすれば、Ruby 未インストール環境でもスクリプトを実行できます。
|
28
|
+
|
29
|
+
### options:
|
30
|
+
|
31
|
+
#### 基本オプション
|
32
|
+
|
33
|
+
<dl>
|
34
|
+
<dt>--help or -h</dt>
|
35
|
+
<dd>ヘルプを表示します。</dd>
|
36
|
+
<dt>--version or -v</dt>
|
37
|
+
<dd>バージョンを表示します。</dd>
|
38
|
+
<dt>--quiet</dt>
|
39
|
+
<dd>実行中に途中経過等を表示しなくなります。</dd>
|
40
|
+
<dt>--verbose</dt>
|
41
|
+
<dd>実行中に詳細情報を表示するようになります。</dd>
|
42
|
+
</dl>
|
43
|
+
|
44
|
+
#### 依存ファイルの追加
|
45
|
+
|
46
|
+
Neri は実行時に必要と思われるファイルを自動的に依存ファイルとして出力先にコピーしますが、
|
47
|
+
実行に必要なファイルが足りない場合もあります。
|
48
|
+
そうした場合はこれらのオプションで依存ファイルを手動で追加する必要があります。
|
49
|
+
|
50
|
+
<dl>
|
51
|
+
<dt>--dll <dll1>,<dll2>,...</dt>
|
52
|
+
<dd>bin フォルダ内の指定された dll ファイルを依存ファイルに追加します。</dd>
|
53
|
+
<dt>--lib <lib1>,<lib2>,...</dt>
|
54
|
+
<dd>ロードパス($LOAD_PATH)内の指定されたファイルを依存ファイルに追加します。</dd>
|
55
|
+
<dt>--gem <gem1>,<gem2>,...</dt>
|
56
|
+
<dd>指定された gem のファイルを依存ファイルに追加します。
|
57
|
+
デフォルトでは、該当 gem の lib フォルダ内のファイル一式を依存ファイルに追加します。
|
58
|
+
現状、gem 間の依存等はチェックしないので、必要な gem すべてを手動で追加する必要があります。</dd>
|
59
|
+
</dl>
|
60
|
+
|
61
|
+
#### 文字コード関係
|
62
|
+
|
63
|
+
Neri はデフォルトでは、enc フォルダ内の文字コードライブラリをすべて依存ファイルに加えますが、
|
64
|
+
その分全体のファイルサイズが大きくなってしまいます。
|
65
|
+
これらのオプションでコピーする文字コードライブラリを指定することで、最小限のデータ量にすることができます。
|
66
|
+
|
67
|
+
<dl>
|
68
|
+
<dt>--no-enc</dt>
|
69
|
+
<dd>文字コード関係ファイルを、実際に使用したもの以外は依存ファイルに加えないようにします。</dd>
|
70
|
+
<dt>--encoding <enc1>,<enc2>,...</dt>
|
71
|
+
<dd>追加する文字コード関係ファイルを手動で指定します。</dd>
|
72
|
+
</dl>
|
73
|
+
|
74
|
+
↓ 使用例:"windows_31j.so", "japanese_sjis.so" のみを依存ファイルに追加します。
|
75
|
+
|
76
|
+
$ neri --encoding windows_31j.so,japanese_sjis.so script.rb
|
77
|
+
|
78
|
+
#### 設定
|
79
|
+
|
80
|
+
<dl>
|
81
|
+
<dt>--enable-gems</dt>
|
82
|
+
<dd>rubygems を使用します。このオプションを使わない場合、依存チェック時に使用した gem のファイルは vendor_ruby フォルダ内にコピーされ、rubygems 無しでも実行できるようになります。</dd>
|
83
|
+
<dt>--enable-did-you-mean</dt>
|
84
|
+
<dd>did_you_mean を使用します。</dd>
|
85
|
+
<dt>--chdir-first</dt>
|
86
|
+
<dd>実行時に、カレントフォルダを実行ファイルと同じフォルダに設定します。</dd>
|
87
|
+
<dt>--pause-last</dt>
|
88
|
+
<dt>--no-pause-last</dt>
|
89
|
+
<dd>実行の最後に、pause を入れるか否かを設定します。省略した場合、コンソールアプリ(後述)の場合 on に、ウィンドウアプリの場合 off になります。</dd>
|
90
|
+
<dt>--pause-text <text></dt>
|
91
|
+
<dd>pause を入れる場合の表示内容を設定します。</dd>
|
92
|
+
</dl>
|
93
|
+
|
94
|
+
#### 出力関係
|
95
|
+
|
96
|
+
<dl>
|
97
|
+
<dt>--output-dir <dirname></dt>
|
98
|
+
<dd>出力先フォルダ名を指定します。省略すると、実行スクリプトファイルのファイル名から拡張子を省略したものになります。</dd>
|
99
|
+
<dt>--system-dir <dirname></dt>
|
100
|
+
<dd>ruby 等がコピーされる、システムフォルダ名を指定します。デフォルトは "system" です。</dd>
|
101
|
+
<dt>--data-file <filename></dt>
|
102
|
+
<dd>データファイル名を指定します。省略した場合、実行スクリプトファイルのファイル名の拡張子を ".dat" に変更したものになります。
|
103
|
+
なお、このオプションを省略&実行スクリプトファイル以外にデータファイルに入れるファイルが無い場合、データファイルは作成されず、実行スクリプトファイルがそのままシステムフォルダ内にコピーされます。</dd>
|
104
|
+
<dt>--encryption-key <key></dt>
|
105
|
+
<dd>データファイルの暗号化キーを設定します。省略した場合、暗号化は行われません。
|
106
|
+
暗号化は簡単なものなので、解読されては困るような重要なデータには用いないでください。</dd>
|
107
|
+
</dl>
|
108
|
+
|
109
|
+
#### Bat To Exe Converter
|
110
|
+
|
111
|
+
Neri は単独では bat ファイルを作成するのみですが、Bat To Exe Converter があれば exe ファイルを作成できます。
|
112
|
+
|
113
|
+
<dl>
|
114
|
+
<dt>--no-exe</dt>
|
115
|
+
<dd>exe ファイルを作成しません。</dd>
|
116
|
+
<dt>--b2ec-path <bat_to_exe_converter_path></dt>
|
117
|
+
<dd>Bat To Exe Converter がパスの通ったところにない場合、このオプションで場所を指定してください。</dd>
|
118
|
+
<dt>--icon <iconfile></dt>
|
119
|
+
<dd>アイコンを設定します。</dd>
|
120
|
+
<dt>--windows or --invisible</dt>
|
121
|
+
<dt>--console or --visible</dt>
|
122
|
+
<dd>ウィンドウアプリにするかコンソールアプリにするかを設定します。
|
123
|
+
ウィンドウアプリの場合、いわゆる「DOS窓」が開きません。
|
124
|
+
省略した場合、実行スクリプトファイルの拡張子が ".rbw" の場合、あるいは DXRuby を使用する場合にはウィンドウアプリになります。
|
125
|
+
そうでない場合はコンソールアプリになります。</dd>
|
126
|
+
<dt>--x64</dt>
|
127
|
+
<dd>64bit の exe ファイルを作成します。省略した場合、ruby 自体の bit 数に合わせます。</dd>
|
128
|
+
<dt>--admin</dt>
|
129
|
+
<dd>管理者として実行する exe ファイルを作成します。</dd>
|
130
|
+
<dt>--fileversion <version></dt>
|
131
|
+
<dt>--productversion <version></dt>
|
132
|
+
<dd>ファイルバージョン・製品バージョンを設定します。
|
133
|
+
<version> は、1,2,3,4 のように4つの数字をカンマ区切りで設定します。</dd>
|
134
|
+
<dt>--company <company_name></dt>
|
135
|
+
<dt>--productname <name></dt>
|
136
|
+
<dt>--internalname <name></dt>
|
137
|
+
<dt>--description <description></dt>
|
138
|
+
<dt>--copyright <copyright></dt>
|
139
|
+
<dd>会社名・製品名・内部名・ファイルの説明・著作権を設定します。</dd>
|
140
|
+
</dl>
|
141
|
+
|
142
|
+
#### UPX
|
143
|
+
|
144
|
+
[UPX](https://upx.github.io/) を使用することで、全体のファイルサイズを小さくすることができます。
|
145
|
+
|
146
|
+
<dl>
|
147
|
+
<dt>--use-upx</dt>
|
148
|
+
<dd>UPX を使用します。</dd>
|
149
|
+
<dt>--upx-path <upx path></dt>
|
150
|
+
<dd>UPX がパスの通ったところにない場合、このオプションで場所を指定してください。</dd>
|
151
|
+
<dt>--upx_targets '<glob>'</dt>
|
152
|
+
<dd>UPX を適用するファイルを指定します。デフォルトは 'bin/**/*.dll' です。</dd>
|
153
|
+
<dt>--upx-options <options></dt>
|
154
|
+
<dd>UPX に渡すオプションを設定します。</dd>
|
155
|
+
</dl>
|
156
|
+
|
157
|
+
#### 7-Zip
|
158
|
+
|
159
|
+
[7-Zip](http://7-zip.org/) を使用することで、出力フォルダをまとめて zip ファイルにすることができます。
|
160
|
+
|
161
|
+
<dl>
|
162
|
+
<dt>--zipfile <filename></dt>
|
163
|
+
<dd>zip ファイルを作成します。</dd>
|
164
|
+
<dt>--7zip-path <7-zip path></dt>
|
165
|
+
<dd>7-Zip がパスの通ったところにない場合、このオプションで場所を指定してください。</dd>
|
166
|
+
</dl>
|
167
|
+
|
168
|
+
#### Inno Setup
|
169
|
+
|
170
|
+
[Inno Setup](http://www.jrsoftware.org/isinfo.php) を使用することで、インストーラーを作成することができます。
|
171
|
+
|
172
|
+
<dl>
|
173
|
+
<dt>--innosetup <inno_script></dt>
|
174
|
+
<dd>.iss ファイルを指定します。</dd>
|
175
|
+
<dt>--iscc-path <iscc path></dt>
|
176
|
+
<dd>iscc がパスの通ったところにない場合、このオプションで場所を指定してください。</dd>
|
177
|
+
</dl>
|
178
|
+
|
179
|
+
#### レシピファイル
|
180
|
+
|
181
|
+
見てのとおり Neri の設定は多岐にわたるので、さまざまな設定を毎回入力するのは大変です。
|
182
|
+
そこで、それらの設定を「レシピファイル」として保存・適用することができます。
|
183
|
+
|
184
|
+
<dl>
|
185
|
+
<dt>--create-recipe <recipefile></dt>
|
186
|
+
<dd>レシピファイルを作成します。このオプションを指定した場合、実行ファイルの作成は行いません。</dd>
|
187
|
+
<dt>--recipe <recipefile></dt>
|
188
|
+
<dd>レシピファイルを適用して、実行ファイルを作成します。</dd>
|
189
|
+
</dl>
|
190
|
+
|
191
|
+
## データファイルの活用
|
192
|
+
|
193
|
+
たとえば以下のようにすることで、script.rb だけでなく、data フォルダ内のデータ一式をデータファイルに収めることができます。
|
194
|
+
|
195
|
+
$ neri script.rb data/*
|
196
|
+
|
197
|
+
データファイル内のスクリプトファイルは、`require` や `load` で読み込むことができます。
|
198
|
+
|
199
|
+
また、元のスクリプトファイルで `require 'neri/runtime'` しておくことで、以下のような命令でデータファイル内のデータにアクセスできます。
|
200
|
+
|
201
|
+
```ruby
|
202
|
+
Neri.file_exist?(filename) # -> bool
|
203
|
+
```
|
204
|
+
|
205
|
+
ファイルが「データファイル内」または「実際に」存在すれば true を、無ければ false を返します。
|
206
|
+
|
207
|
+
```ruby
|
208
|
+
Neri.file_read?(filename, encoding = Encoding::BINARY) # -> String
|
209
|
+
```
|
210
|
+
|
211
|
+
「データファイル内」または「実際に」存在するファイルをまるごと読み込みます(読み込むサイズは指定できません)。データファイル内にも実ファイルとしても存在する場合、データファイル内のものが優先されます。
|
212
|
+
|
213
|
+
```ruby
|
214
|
+
Neri.files # -> Array
|
215
|
+
```
|
216
|
+
|
217
|
+
データファイル内にあるファイルの一覧を配列で返します。
|
218
|
+
|
219
|
+
### [DXRuby](http://dxruby.osdn.jp/) 等との連携
|
220
|
+
|
221
|
+
DXRuby を使用する場合、DXRuby の Image.load, Image.load_tiles, Sound.new を上書きし、データファイル内に画像・音声ファイルがあればそちらから読み込むようになります。
|
222
|
+
これにより、スクリプトファイルを一切書き換えることなく、Neri を利用したファイルの簡易隠蔽機能が利用できます。
|
223
|
+
|
224
|
+
## Contributing
|
225
|
+
|
226
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/nodai2hITC/neri
|
227
|
+
|
228
|
+
## License
|
229
|
+
|
230
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
data/README.md
ADDED
@@ -0,0 +1,75 @@
|
|
1
|
+
# Neri
|
2
|
+
|
3
|
+
[日本語説明(こちらの方が詳細)](https://github.com/nodai2hITC/neri/blob/master/README.ja.md)
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
$ gem install neri
|
8
|
+
|
9
|
+
## Usage
|
10
|
+
|
11
|
+
$ neri [options] script.rb (other_files...) -- script_arguments
|
12
|
+
|
13
|
+
```
|
14
|
+
options:
|
15
|
+
--help or -h
|
16
|
+
--version or -v
|
17
|
+
--quiet
|
18
|
+
--verbose
|
19
|
+
|
20
|
+
--dll <dll1>,<dll2>,...
|
21
|
+
--lib <lib1>,<lib2>,...
|
22
|
+
--gem <gem1>,<gem2>,...
|
23
|
+
|
24
|
+
--no-enc
|
25
|
+
--encoding <enc1>,<enc2>,...
|
26
|
+
|
27
|
+
--enable-gems
|
28
|
+
--enable-did-you-mean
|
29
|
+
--chdir-first
|
30
|
+
--pause-last
|
31
|
+
--no-pause-last
|
32
|
+
--pause-text <text>
|
33
|
+
|
34
|
+
--output-dir <dirname>
|
35
|
+
--system-dir <dirname>
|
36
|
+
--data-file <filename>
|
37
|
+
--encryption-key <key>
|
38
|
+
|
39
|
+
--no-exe
|
40
|
+
--b2ec-path <bat_to_exe_converter_path>
|
41
|
+
--icon <iconfile>
|
42
|
+
--windows or --invisible
|
43
|
+
--console or --visible
|
44
|
+
--x64
|
45
|
+
--admin
|
46
|
+
--fileversion <version>
|
47
|
+
--productversion <version>
|
48
|
+
--company <company_name>
|
49
|
+
--productname <name>
|
50
|
+
--internalname <name>
|
51
|
+
--description <description>
|
52
|
+
--copyright <copyright>
|
53
|
+
|
54
|
+
--use-upx
|
55
|
+
--upx-path <upx path>
|
56
|
+
--upx_targets '<glob>'
|
57
|
+
--upx-options <options>
|
58
|
+
|
59
|
+
--zipfile <filename>
|
60
|
+
--7zip-path <7-zip path>
|
61
|
+
|
62
|
+
--innosetup <inno_script>
|
63
|
+
--iscc-path <iscc path>
|
64
|
+
|
65
|
+
--create-recipe <recipefile>
|
66
|
+
--recipe <recipefile>
|
67
|
+
```
|
68
|
+
|
69
|
+
## Contributing
|
70
|
+
|
71
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/nodai2hITC/neri
|
72
|
+
|
73
|
+
## License
|
74
|
+
|
75
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "neri"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start(__FILE__)
|
data/bin/setup
ADDED
data/exe/neri
ADDED
data/lib/neri/ayame.rb
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
require "neri/runtime"
|
2
|
+
|
3
|
+
require "ayame" unless defined? Ayame
|
4
|
+
|
5
|
+
class Ayame
|
6
|
+
class << self
|
7
|
+
alias :_neri_orig_new :new
|
8
|
+
|
9
|
+
def new(filename)
|
10
|
+
if Neri.exist_in_datafile?(filename)
|
11
|
+
ayame = load_from_memory(Neri.file_read(path))
|
12
|
+
return ayame
|
13
|
+
else
|
14
|
+
return _neri_orig_new(filename)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
data/lib/neri/dxruby.rb
ADDED
@@ -0,0 +1,50 @@
|
|
1
|
+
require "neri/runtime"
|
2
|
+
|
3
|
+
require "dxruby" unless defined? DXRuby
|
4
|
+
|
5
|
+
module DXRuby
|
6
|
+
class Image
|
7
|
+
class << self
|
8
|
+
alias :_neri_orig_load :load
|
9
|
+
alias :_neri_orig_load_tiles :load_tiles
|
10
|
+
|
11
|
+
def load(path, x=nil, y=nil, width=nil, height=nil)
|
12
|
+
if Neri.exist_in_datafile?(path)
|
13
|
+
image = load_from_file_in_memory(Neri.file_read(path))
|
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
|
19
|
+
end
|
20
|
+
|
21
|
+
def load_tiles(path, xcount, ycount, share_switch=true)
|
22
|
+
if Neri.exist_in_datafile?(path) && !share_switch
|
23
|
+
image = load_from_file_in_memory(Neri.file_read(path))
|
24
|
+
return image.slice_tiles(xcount, ycount)
|
25
|
+
else
|
26
|
+
return _neri_orig_load_tiles(path, xcount, ycount, share_switch)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
class Sound
|
33
|
+
class << self
|
34
|
+
alias :_neri_orig_new :new
|
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
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
require "neri/runtime"
|
2
|
+
|
3
|
+
require "dxruby_tiled" unless defined? DXRuby::Tiled
|
4
|
+
|
5
|
+
module DXRuby
|
6
|
+
module Tiled
|
7
|
+
def self.load_json(jsonfile, encoding = "UTF-8", dir = nil)
|
8
|
+
return Map.new(JSON.load(Neri.file_read(jsonfile, encoding), nil,
|
9
|
+
symbolize_names: true, create_additions: false),
|
10
|
+
dir || File.dirname(jsonfile))
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
data/lib/neri/runtime.rb
ADDED
@@ -0,0 +1,140 @@
|
|
1
|
+
require "neri/version"
|
2
|
+
|
3
|
+
alias :_neri_orig_require :require
|
4
|
+
alias :_neri_orig_load :load
|
5
|
+
|
6
|
+
def require(feature)
|
7
|
+
Neri.require(feature)
|
8
|
+
end
|
9
|
+
|
10
|
+
def load(file, priv = false)
|
11
|
+
Neri.load(file, priv)
|
12
|
+
end
|
13
|
+
|
14
|
+
module Neri
|
15
|
+
BLOCK_LENGTH = 32
|
16
|
+
@datafile = nil
|
17
|
+
@system_dir = nil
|
18
|
+
@files = {}
|
19
|
+
@xor = nil
|
20
|
+
|
21
|
+
class << self
|
22
|
+
def datafile=(datafile)
|
23
|
+
@datafile = datafile
|
24
|
+
@system_dir = File.dirname(File.expand_path(datafile)) + File::SEPARATOR
|
25
|
+
files_length = File.binread(@datafile, BLOCK_LENGTH).to_i
|
26
|
+
files_str = read(files_length, BLOCK_LENGTH)
|
27
|
+
pos = files_length + BLOCK_LENGTH
|
28
|
+
pos += BLOCK_LENGTH - pos % BLOCK_LENGTH unless pos % BLOCK_LENGTH == 0
|
29
|
+
files_str.force_encoding(Encoding::UTF_8)
|
30
|
+
files_str.split("\n").each do |line|
|
31
|
+
filename, length, offset = line.split("\t")
|
32
|
+
@files[filename] = [length.to_i, offset.to_i + pos]
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
def key=(key)
|
37
|
+
@xor = key.scan(/../).map{|a| a.to_i(16)}.pack("c*")
|
38
|
+
end
|
39
|
+
|
40
|
+
def require(feature)
|
41
|
+
filepath = nil
|
42
|
+
load_path.each do |path|
|
43
|
+
["", ".rb"].each do |ext|
|
44
|
+
filepath = path + feature + ext if exist_in_datafile?(path + feature + ext)
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
if filepath
|
49
|
+
return false if $LOADED_FEATURES.index(filepath)
|
50
|
+
code = load_code(filepath)
|
51
|
+
eval(code, nil, filepath)
|
52
|
+
$LOADED_FEATURES.push(filepath)
|
53
|
+
return true
|
54
|
+
else
|
55
|
+
return _neri_orig_require(feature)
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
def load(file, priv = false)
|
60
|
+
filepath = nil
|
61
|
+
(load_path + [""]).each do |path|
|
62
|
+
filepath = path + file if exist_in_datafile?(path + file)
|
63
|
+
end
|
64
|
+
|
65
|
+
if filepath
|
66
|
+
code = load_code(filepath)
|
67
|
+
if priv
|
68
|
+
eval(code, nil, filepath)
|
69
|
+
else
|
70
|
+
Module.new.module_eval(code, filepath)
|
71
|
+
end
|
72
|
+
else
|
73
|
+
_neri_orig_load(filepath || file, priv)
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
def file_exist?(filename)
|
78
|
+
return exist_in_datafile?(filename) || File.exist?(filename)
|
79
|
+
end
|
80
|
+
|
81
|
+
def file_read(filename, encoding = Encoding::BINARY)
|
82
|
+
str = nil
|
83
|
+
if exist_in_datafile?(filename)
|
84
|
+
length, offset = @files[filename.encode(Encoding::UTF_8)]
|
85
|
+
str = read(length, offset)
|
86
|
+
else
|
87
|
+
str = File.binread(filename)
|
88
|
+
end
|
89
|
+
str.force_encoding(encoding)
|
90
|
+
return str
|
91
|
+
end
|
92
|
+
|
93
|
+
def files()
|
94
|
+
return @files.keys
|
95
|
+
end
|
96
|
+
|
97
|
+
def exist_in_datafile?(filename)
|
98
|
+
return @files.has_key?(filename.encode(Encoding::UTF_8))
|
99
|
+
end
|
100
|
+
|
101
|
+
private
|
102
|
+
|
103
|
+
def xor(str)
|
104
|
+
str.force_encoding(Encoding::BINARY)
|
105
|
+
while str.bytesize % BLOCK_LENGTH != 0
|
106
|
+
str << rand(256).chr
|
107
|
+
end
|
108
|
+
if defined?(Xorcist)
|
109
|
+
return Xorcist.xor!(str, @xor * (str.bytesize / BLOCK_LENGTH))
|
110
|
+
else
|
111
|
+
s = []
|
112
|
+
str.unpack("Q*").zip((@xor * (str.bytesize / BLOCK_LENGTH)).unpack("Q*")){|a, b| s.push(a ^ b)}
|
113
|
+
return s.pack("Q*")
|
114
|
+
end
|
115
|
+
end
|
116
|
+
|
117
|
+
def read(length, offset)
|
118
|
+
if @xor
|
119
|
+
tmp_length = length
|
120
|
+
tmp_length += BLOCK_LENGTH - length % BLOCK_LENGTH unless length % BLOCK_LENGTH == 0
|
121
|
+
return xor(File.binread(@datafile, tmp_length, offset))[0, length]
|
122
|
+
else
|
123
|
+
return File.binread(@datafile, length, offset)
|
124
|
+
end
|
125
|
+
end
|
126
|
+
|
127
|
+
def load_path()
|
128
|
+
return $LOAD_PATH unless @system_dir
|
129
|
+
return $LOAD_PATH.map{|path| path.sub(@system_dir, "*neri*#{File::SEPARATOR}") + File::SEPARATOR }
|
130
|
+
end
|
131
|
+
|
132
|
+
def load_code(file)
|
133
|
+
code = file_read(file)
|
134
|
+
encoding = "UTF-8"
|
135
|
+
encoding = $1 if code.lines[0..2].join("\n").match(/coding:\s*(\S+)/)
|
136
|
+
code.force_encoding(encoding)
|
137
|
+
return code
|
138
|
+
end
|
139
|
+
end
|
140
|
+
end
|
data/lib/neri/version.rb
ADDED
data/lib/neri.rb
ADDED
data/neri.gemspec
ADDED
@@ -0,0 +1,36 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path("../lib", __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require "neri/version"
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "neri"
|
8
|
+
spec.version = Neri::VERSION
|
9
|
+
spec.authors = ["nodai2hITC"]
|
10
|
+
spec.email = ["nodai2h.itc@gmail.com"]
|
11
|
+
|
12
|
+
spec.summary = %q{One-Click Ruby Application Builder}
|
13
|
+
spec.description = %q{Neri builds Windows batfile or exefile from Ruby script.}
|
14
|
+
spec.homepage = "https://github.com/nodai2hITC/neri"
|
15
|
+
spec.license = "MIT"
|
16
|
+
|
17
|
+
# Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
|
18
|
+
# to allow pushing to a single host or delete this section to allow pushing to any host.
|
19
|
+
if spec.respond_to?(:metadata)
|
20
|
+
# spec.metadata["allowed_push_host"] = "TODO: Set to 'http://mygemserver.com'"
|
21
|
+
else
|
22
|
+
raise "RubyGems 2.0 or newer is required to protect against " \
|
23
|
+
"public gem pushes."
|
24
|
+
end
|
25
|
+
|
26
|
+
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
27
|
+
f.match(%r{^(test|spec|features)/})
|
28
|
+
end
|
29
|
+
spec.bindir = "exe"
|
30
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
31
|
+
spec.require_paths = ["lib"]
|
32
|
+
|
33
|
+
spec.add_development_dependency "bundler", "~> 1.15"
|
34
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
35
|
+
spec.add_development_dependency "pry"
|
36
|
+
end
|
data/share/default.ico
ADDED
Binary file
|
metadata
ADDED
@@ -0,0 +1,104 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: neri
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- nodai2hITC
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2017-10-04 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
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
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
description: Neri builds Windows batfile or exefile from Ruby script.
|
56
|
+
email:
|
57
|
+
- nodai2h.itc@gmail.com
|
58
|
+
executables:
|
59
|
+
- neri
|
60
|
+
extensions: []
|
61
|
+
extra_rdoc_files: []
|
62
|
+
files:
|
63
|
+
- ".gitignore"
|
64
|
+
- Gemfile
|
65
|
+
- LICENSE.txt
|
66
|
+
- README.ja.md
|
67
|
+
- README.md
|
68
|
+
- Rakefile
|
69
|
+
- bin/console
|
70
|
+
- bin/setup
|
71
|
+
- exe/neri
|
72
|
+
- lib/neri.rb
|
73
|
+
- lib/neri/ayame.rb
|
74
|
+
- lib/neri/dxruby.rb
|
75
|
+
- lib/neri/dxruby_tiled.rb
|
76
|
+
- lib/neri/runtime.rb
|
77
|
+
- lib/neri/version.rb
|
78
|
+
- neri.gemspec
|
79
|
+
- share/default.ico
|
80
|
+
homepage: https://github.com/nodai2hITC/neri
|
81
|
+
licenses:
|
82
|
+
- MIT
|
83
|
+
metadata: {}
|
84
|
+
post_install_message:
|
85
|
+
rdoc_options: []
|
86
|
+
require_paths:
|
87
|
+
- lib
|
88
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
89
|
+
requirements:
|
90
|
+
- - ">="
|
91
|
+
- !ruby/object:Gem::Version
|
92
|
+
version: '0'
|
93
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
94
|
+
requirements:
|
95
|
+
- - ">="
|
96
|
+
- !ruby/object:Gem::Version
|
97
|
+
version: '0'
|
98
|
+
requirements: []
|
99
|
+
rubyforge_project:
|
100
|
+
rubygems_version: 2.6.12
|
101
|
+
signing_key:
|
102
|
+
specification_version: 4
|
103
|
+
summary: One-Click Ruby Application Builder
|
104
|
+
test_files: []
|