jp_quest 0.3.0 → 0.3.1

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 90987ac46d58c0e6bf724a01a86b5909693c64c53ee46cbf0a8efc49909e2cfe
4
- data.tar.gz: 9708d0bab80b268cf03bdd4c4a946f34f5d79a5c39d7e947b4f57d20a4098183
3
+ metadata.gz: 8b60021d6bf3d6a4f83ca95bd2f82bbb807e6a4fcd7a565f4cc8522c1be7c5f2
4
+ data.tar.gz: afd68be002b732797ca2fa25d2ce11f0eb511ad861d81a31d7957735a8153cea
5
5
  SHA512:
6
- metadata.gz: 88da5d49a1abea3c2c32b74d06fbf8d14584a7f99440004ce4342c1ed77c1fdd9b2703154a48ed415257b31ecd105d98c46719609126460bffa0a92cfcafb672
7
- data.tar.gz: 9a66c779465e0584d11513367a97b7917783e30d3044bd0b19604376f3fd7efc53ba6515593eea7b1f5008054507e49f3ef830db780eddd725018c53d2abf5d7
6
+ metadata.gz: caf15b2caa051d76815762bec0d5417d9bbf1067352549f59e0fa5031d69b4194249384f5a56473c79fd21fc10370434fbd2b04b560ee34ef1ad7cf780cf9d4c
7
+ data.tar.gz: c50ffae11c5bf0e857f64c67ff8e570f990ad95c1b8bb52f4e41cb49eda525161cc2cd883db314c972e1820bcb9b2027cb0ce3127dd29fae104861a5baa2b0b6
data/.rubocop.yml CHANGED
@@ -1,8 +1,6 @@
1
1
  AllCops:
2
2
  TargetRubyVersion: 3.0
3
3
  NewCops: enable
4
- Exclude:
5
- - "bin/**/*"
6
4
 
7
5
  Style/StringLiterals:
8
6
  EnforcedStyle: double_quotes
data/CHANGELOG.md CHANGED
@@ -27,4 +27,8 @@
27
27
 
28
28
  ## [0.3.0] - 2024-10/12
29
29
 
30
- - MODの翻訳機能を追加しやすいように、モジュールの構造を変更
30
+ - MODの翻訳機能を追加しやすいように、モジュールの構造を変更
31
+
32
+ ## [0.3.1] - 2024-10/25
33
+
34
+ - 不要な空行が追加されるバグを修正
data/dist/example.rb CHANGED
@@ -1,8 +1,9 @@
1
- require_relative "../lib/jp_quest"
1
+ require "jp_quest"
2
2
 
3
3
  performer = JpQuest::SNBT::Performer.new
4
4
 
5
- # file_path = "some.snbt"
6
- # performer.perform(file_path)
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(dir_path: "dist/quests")
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 = add_missing_lines(content)
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 add_missing_lines(content)
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
- while lines.length < required_lines
40
- lines << empty_middle_line(content[:indent])
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] 空行
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module JpQuest
4
- VERSION = "0.3.0"
4
+ VERSION = "0.3.1"
5
5
  end
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.0
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-12 00:00:00.000000000 Z
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: []