jp_quest 0.3.0 → 0.3.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +0 -2
- data/CHANGELOG.md +5 -1
- data/dist/example.rb +5 -4
- data/lib/jp_quest/snbt/formatter.rb +34 -6
- data/lib/jp_quest/util/version.rb +1 -1
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8b60021d6bf3d6a4f83ca95bd2f82bbb807e6a4fcd7a565f4cc8522c1be7c5f2
|
4
|
+
data.tar.gz: afd68be002b732797ca2fa25d2ce11f0eb511ad861d81a31d7957735a8153cea
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: caf15b2caa051d76815762bec0d5417d9bbf1067352549f59e0fa5031d69b4194249384f5a56473c79fd21fc10370434fbd2b04b560ee34ef1ad7cf780cf9d4c
|
7
|
+
data.tar.gz: c50ffae11c5bf0e857f64c67ff8e570f990ad95c1b8bb52f4e41cb49eda525161cc2cd883db314c972e1820bcb9b2027cb0ce3127dd29fae104861a5baa2b0b6
|
data/.rubocop.yml
CHANGED
data/CHANGELOG.md
CHANGED
data/dist/example.rb
CHANGED
@@ -1,8 +1,9 @@
|
|
1
|
-
|
1
|
+
require "jp_quest"
|
2
2
|
|
3
3
|
performer = JpQuest::SNBT::Performer.new
|
4
4
|
|
5
|
-
|
6
|
-
#
|
5
|
+
file_path = "dist/quests/chapters/medium_eyes.snbt"
|
6
|
+
# file_path = "dist/dawncraft.snbt"
|
7
|
+
performer.perform(file_path)
|
7
8
|
|
8
|
-
performer.perform_directory
|
9
|
+
# performer.perform_directory
|
@@ -12,7 +12,7 @@ module JpQuest
|
|
12
12
|
# @param [String] indent インデント
|
13
13
|
# @return [String] SNBT形式に整形したコンテンツ
|
14
14
|
def format_overwritable_lines(content, indent)
|
15
|
-
full_lines =
|
15
|
+
full_lines = adjust_line_length(content)
|
16
16
|
format_for_snbt(full_lines, indent, content)
|
17
17
|
end
|
18
18
|
|
@@ -28,17 +28,16 @@ module JpQuest
|
|
28
28
|
"#{indent}#{content[:type]}: #{formatted_lines}"
|
29
29
|
end
|
30
30
|
|
31
|
-
#
|
31
|
+
# 行数をstart_line~end_lineと一致させる
|
32
32
|
#
|
33
33
|
# @param [Hash] content コンテンツ
|
34
34
|
# @return [void]
|
35
|
-
def
|
35
|
+
def adjust_line_length(content)
|
36
36
|
required_lines = extract_required_line_counts(content)
|
37
37
|
lines = content[:text].split("\n")
|
38
38
|
|
39
|
-
|
40
|
-
|
41
|
-
end
|
39
|
+
delete_over_lines(lines, required_lines)
|
40
|
+
add_missing_lines(lines, required_lines, content[:indent])
|
42
41
|
|
43
42
|
lines
|
44
43
|
end
|
@@ -88,6 +87,35 @@ module JpQuest
|
|
88
87
|
(content[:end_line] - content[:start_line]) + line_offset - without_brackets
|
89
88
|
end
|
90
89
|
|
90
|
+
# 不要な行を削除
|
91
|
+
#
|
92
|
+
# @param [Array<String>] lines 行
|
93
|
+
# @param [Integer] required_lines 必要な行数
|
94
|
+
# @return [void]
|
95
|
+
def delete_over_lines(lines, required_lines)
|
96
|
+
return unless lines.length > required_lines
|
97
|
+
|
98
|
+
gap_length = lines.length - required_lines
|
99
|
+
gap_length.times do
|
100
|
+
index = lines.index("")
|
101
|
+
lines.delete_at(index) if index
|
102
|
+
end
|
103
|
+
end
|
104
|
+
|
105
|
+
# 不足している行を追加
|
106
|
+
#
|
107
|
+
# @param [Array<String>] lines 行
|
108
|
+
# @param [Integer] required_lines 必要な行数
|
109
|
+
# @param [String] indent インデント
|
110
|
+
# @return [void]
|
111
|
+
def add_missing_lines(lines, required_lines, indent)
|
112
|
+
return unless lines.length < required_lines
|
113
|
+
|
114
|
+
while lines.length < required_lines
|
115
|
+
lines << empty_middle_line(indent)
|
116
|
+
end
|
117
|
+
end
|
118
|
+
|
91
119
|
# 中間行の空行を作成
|
92
120
|
#
|
93
121
|
# @return [String] 空行
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jp_quest
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- milkeclair
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-10-
|
11
|
+
date: 2024-10-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: jp_translator_from_gpt
|
@@ -91,7 +91,7 @@ metadata:
|
|
91
91
|
source_code_uri: https://github.com/milkeclair/jp_quest/blob/main
|
92
92
|
changelog_uri: https://github.com/milkeclair/jp_quest/blob/main/CHANGELOG.md
|
93
93
|
rubygems_mfa_required: 'true'
|
94
|
-
post_install_message:
|
94
|
+
post_install_message:
|
95
95
|
rdoc_options: []
|
96
96
|
require_paths:
|
97
97
|
- lib
|
@@ -107,7 +107,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
107
107
|
version: '0'
|
108
108
|
requirements: []
|
109
109
|
rubygems_version: 3.5.21
|
110
|
-
signing_key:
|
110
|
+
signing_key:
|
111
111
|
specification_version: 4
|
112
112
|
summary: translate to japanese for ftbquest
|
113
113
|
test_files: []
|