hyper_card_builder 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/.DS_Store +0 -0
- data/.hyper_card/history/first_minitest.md +136 -0
- data/.hyper_card/history/test_env.md +425 -0
- data/.hyper_card/history/test_thor_hello.md +64 -0
- data/.hyper_card/test_split_pdf.md +341 -0
- data/CHANGELOG.md +5 -0
- data/CODE_OF_CONDUCT.md +132 -0
- data/LICENSE.txt +21 -0
- data/README.org +33 -0
- data/Rakefile +8 -0
- data/exe/hyper_card_builder +5 -0
- data/lib/hyper_card_builder/version.rb +5 -0
- data/lib/hyper_card_builder.rb +87 -0
- data/sig/hyper_card_builder.rbs +4 -0
- data/test_env/hc_array.yaml +16 -0
- data/test_env/linux_basic/s0_commands.pdf +0 -0
- data/test_env/linux_basic/sf_summary.pdf +0 -0
- data/test_env/linux_basic/title.pdf +0 -0
- data/test_env/linux_basic.pdf +0 -0
- metadata +120 -0
|
@@ -0,0 +1,341 @@
|
|
|
1
|
+
daddygongon: linux_basic.pdfをyamlに従って分割して,linux_basic directoryに格納するテストを作成
|
|
2
|
+
|
|
3
|
+
Workspace: ```ruby
|
|
4
|
+
# test/test_linux_basic_split_test.rb
|
|
5
|
+
# frozen_string_literal: true
|
|
6
|
+
|
|
7
|
+
require "test_helper"
|
|
8
|
+
require "fileutils"
|
|
9
|
+
require "open3"
|
|
10
|
+
|
|
11
|
+
class TestLinuxBasicSplit < Minitest::Test
|
|
12
|
+
LINUX_BASIC_PDF = "spec/fixtures/linux_basic.pdf"
|
|
13
|
+
YAML_CONFIG = "spec/fixtures/linux_basic.yaml"
|
|
14
|
+
OUTPUT_DIR = "linux_basic"
|
|
15
|
+
|
|
16
|
+
def setup
|
|
17
|
+
FileUtils.rm_rf(OUTPUT_DIR)
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
def teardown
|
|
21
|
+
FileUtils.rm_rf(OUTPUT_DIR)
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
def test_split_linux_basic_pdf_by_yaml
|
|
25
|
+
cmd = [
|
|
26
|
+
"bundle", "exec", "exe/hyper_card_builder",
|
|
27
|
+
"split",
|
|
28
|
+
"--pdf", LINUX_BASIC_PDF,
|
|
29
|
+
"--yaml", YAML_CONFIG,
|
|
30
|
+
"--outdir", OUTPUT_DIR
|
|
31
|
+
]
|
|
32
|
+
output, status = Open3.capture2(*cmd)
|
|
33
|
+
assert status.success?, "CLI did not exit successfully: #{output}"
|
|
34
|
+
|
|
35
|
+
# Check that output directory exists
|
|
36
|
+
assert Dir.exist?(OUTPUT_DIR), "Output directory not created"
|
|
37
|
+
|
|
38
|
+
# Check that files are created according to YAML (example: section1.pdf, section2.pdf, ...)
|
|
39
|
+
yaml_sections = YAML.load_file(YAML_CONFIG)
|
|
40
|
+
yaml_sections.each do |section|
|
|
41
|
+
filename = File.join(OUTPUT_DIR, "#{section['name']}.pdf")
|
|
42
|
+
assert File.exist?(filename), "Expected file #{filename} not found"
|
|
43
|
+
end
|
|
44
|
+
end
|
|
45
|
+
end
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
daddygongon: #file:Rakefile:32-54 を参照してsplitコマンドをhyper_card_builder.rbに作成
|
|
49
|
+
|
|
50
|
+
GitHub Copilot: ````ruby
|
|
51
|
+
# ...existing code...
|
|
52
|
+
|
|
53
|
+
desc "split PDF_FILE YAML_FILE", "Split PDF_FILE according to YAML_FILE and save to target_dir"
|
|
54
|
+
def split(pdf_file, yaml_file)
|
|
55
|
+
require "fileutils"
|
|
56
|
+
require "yaml"
|
|
57
|
+
|
|
58
|
+
data = YAML.load(File.read(yaml_file))
|
|
59
|
+
source_file = data[:source_file] || pdf_file
|
|
60
|
+
target_dir = data[:target_dir] || "linux_basic"
|
|
61
|
+
FileUtils.mkdir_p(target_dir) unless Dir.exist?(target_dir)
|
|
62
|
+
|
|
63
|
+
data[:toc].each do |v|
|
|
64
|
+
init = v[:init]
|
|
65
|
+
fin = v[:fin]
|
|
66
|
+
pages = if fin.nil?
|
|
67
|
+
fin = init
|
|
68
|
+
"#{init}"
|
|
69
|
+
else
|
|
70
|
+
"#{init}-#{fin}"
|
|
71
|
+
end
|
|
72
|
+
o_file = [v[:no], v[:head], pages].compact.join('_') + ".pdf"
|
|
73
|
+
target = File.join(target_dir, o_file)
|
|
74
|
+
comm = "qpdf #{source_file} --pages . #{init}-#{fin} -- #{target}"
|
|
75
|
+
puts comm
|
|
76
|
+
system(comm)
|
|
77
|
+
end
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
# ...existing code...
|
|
81
|
+
````
|
|
82
|
+
|
|
83
|
+
daddygongon: rake aborted!
|
|
84
|
+
Command failed with status (1): [/Users/bob/.rbenv/versions/3.4.4/bin/ruby -Ilib:test:. -w -e 'require "minitest/autorun"; require "test/test_hyper_card_builder.rb"; require "test/test_hc_array_yaml.rb"; require "test/test_split_pdf.rb"; require "test/test_helper.rb"' -- ]
|
|
85
|
+
/Users/bob/.rbenv/gems/3.4.0/gems/minitest-5.26.2/lib/minitest/test_task.rb:194:in 'block in Minitest::TestTask#define'
|
|
86
|
+
とのエラー.
|
|
87
|
+
|
|
88
|
+
GitHub Copilot: このエラーは、test_split_pdf.rb のテストコードが `split` コマンドの引数の渡し方と、hyper_card_builder.rb の Thor コマンド定義が一致していないために発生しています。
|
|
89
|
+
|
|
90
|
+
### 問題点
|
|
91
|
+
- テストでは `--pdf`, `--yaml`, `--outdir` というオプション形式で渡しています。
|
|
92
|
+
- Thor の `split` コマンドは `split PDF_FILE YAML_FILE` のように位置引数で受け取る設計です。
|
|
93
|
+
|
|
94
|
+
### 解決方法
|
|
95
|
+
テストコードを以下のように修正してください。
|
|
96
|
+
Thor のコマンド定義に合わせて、引数をオプションではなく位置引数で渡します。
|
|
97
|
+
|
|
98
|
+
````ruby
|
|
99
|
+
# ...existing code...
|
|
100
|
+
def test_split_linux_basic_pdf_by_yaml
|
|
101
|
+
cmd = [
|
|
102
|
+
"bundle", "exec", "exe/hyper_card_builder",
|
|
103
|
+
"split",
|
|
104
|
+
LINUX_BASIC_PDF,
|
|
105
|
+
YAML_CONFIG
|
|
106
|
+
]
|
|
107
|
+
output, status = Open3.capture2(*cmd)
|
|
108
|
+
assert status.success?, "CLI did not exit successfully: #{output}"
|
|
109
|
+
|
|
110
|
+
# Check that output directory exists
|
|
111
|
+
yaml_sections = YAML.load_file(YAML_CONFIG)
|
|
112
|
+
target_dir = yaml_sections[:target_dir] || "linux_basic"
|
|
113
|
+
assert Dir.exist?(target_dir), "Output directory not created"
|
|
114
|
+
|
|
115
|
+
# Check that files are created according to YAML
|
|
116
|
+
yaml_sections[:toc].each do |section|
|
|
117
|
+
pages = section[:fin].nil? ? "#{section[:init]}" : "#{section[:init]}-#{section[:fin]}"
|
|
118
|
+
filename = [section[:no], section[:head], pages].compact.join('_') + ".pdf"
|
|
119
|
+
filepath = File.join(target_dir, filename)
|
|
120
|
+
assert File.exist?(filepath), "Expected file #{filepath} not found"
|
|
121
|
+
end
|
|
122
|
+
end
|
|
123
|
+
# ...existing code...
|
|
124
|
+
````
|
|
125
|
+
|
|
126
|
+
これで Thor のコマンド定義とテストの引数の渡し方が一致し、エラーが解消されるはずです。
|
|
127
|
+
|
|
128
|
+
daddygongon: #file:test_hc_array_yaml.rb:23-31 を参照して,test_envディレクトリで,作業するように修正.そこへtest/linux_basic.pdfをcpして作業する.
|
|
129
|
+
|
|
130
|
+
GitHub Copilot: ````ruby
|
|
131
|
+
# frozen_string_literal: true
|
|
132
|
+
|
|
133
|
+
require "test_helper"
|
|
134
|
+
require "fileutils"
|
|
135
|
+
require "open3"
|
|
136
|
+
require "yaml"
|
|
137
|
+
|
|
138
|
+
class TestLinuxBasicSplit < Minitest::Test
|
|
139
|
+
TEST_ENV_DIR = File.expand_path("../test_env", __dir__)
|
|
140
|
+
LINUX_BASIC_PDF_SRC = File.expand_path("../linux_basic.pdf", __dir__)
|
|
141
|
+
LINUX_BASIC_PDF = File.join(TEST_ENV_DIR, "linux_basic.pdf")
|
|
142
|
+
YAML_CONFIG = File.join(TEST_ENV_DIR, "linux_basic.yaml")
|
|
143
|
+
OUTPUT_DIR = File.join(TEST_ENV_DIR, "linux_basic")
|
|
144
|
+
|
|
145
|
+
def setup
|
|
146
|
+
FileUtils.rm_rf(TEST_ENV_DIR)
|
|
147
|
+
FileUtils.mkdir_p(TEST_ENV_DIR)
|
|
148
|
+
FileUtils.cp(LINUX_BASIC_PDF_SRC, LINUX_BASIC_PDF)
|
|
149
|
+
# サンプルYAMLを作成
|
|
150
|
+
yaml_data = {
|
|
151
|
+
source_file: "./linux_basic.pdf",
|
|
152
|
+
target_dir: "./linux_basic",
|
|
153
|
+
toc: [
|
|
154
|
+
{ no: nil, init: 1, fin: nil, head: "title" },
|
|
155
|
+
{ no: "s0", init: 2, fin: nil, head: "commands" },
|
|
156
|
+
{ no: "sf", init: 8, fin: 8, head: "summary" }
|
|
157
|
+
]
|
|
158
|
+
}
|
|
159
|
+
File.write(YAML_CONFIG, yaml_data.to_yaml)
|
|
160
|
+
end
|
|
161
|
+
|
|
162
|
+
def teardown
|
|
163
|
+
FileUtils.rm_rf(TEST_ENV_DIR)
|
|
164
|
+
end
|
|
165
|
+
|
|
166
|
+
def test_split_linux_basic_pdf_by_yaml
|
|
167
|
+
exe_path = File.expand_path("../exe/hyper_card_builder", __dir__)
|
|
168
|
+
Dir.chdir(TEST_ENV_DIR) do
|
|
169
|
+
cmd = [
|
|
170
|
+
"bundle", "exec", exe_path,
|
|
171
|
+
"split",
|
|
172
|
+
"linux_basic.pdf",
|
|
173
|
+
"linux_basic.yaml"
|
|
174
|
+
]
|
|
175
|
+
output, status = Open3.capture2(*cmd)
|
|
176
|
+
assert status.success?, "CLI did not exit successfully: #{output}"
|
|
177
|
+
|
|
178
|
+
yaml_sections = YAML.load_file("linux_basic.yaml")
|
|
179
|
+
target_dir = yaml_sections[:target_dir] || "linux_basic"
|
|
180
|
+
assert Dir.exist?(target_dir), "Output directory not created"
|
|
181
|
+
|
|
182
|
+
yaml_sections[:toc].each do |section|
|
|
183
|
+
pages = section[:fin].nil? ? "#{section[:init]}" : "#{section[:init]}-#{section[:fin]}"
|
|
184
|
+
filename = [section[:no], section[:head], pages].compact.join('_') + ".pdf"
|
|
185
|
+
filepath = File.join(target_dir, filename)
|
|
186
|
+
assert File.exist?(filepath), "Expected file #{filepath} not found"
|
|
187
|
+
end
|
|
188
|
+
end
|
|
189
|
+
end
|
|
190
|
+
end
|
|
191
|
+
````
|
|
192
|
+
|
|
193
|
+
daddygongon: YAML_CONFIGはYAML_FILEにして,hc_array.yamlとして保存し,splitではhc_array.yamlをdefaultにしてyaml_fileを引数にする変更.
|
|
194
|
+
|
|
195
|
+
GitHub Copilot: ````ruby
|
|
196
|
+
# ...existing code...
|
|
197
|
+
|
|
198
|
+
desc "puts_hc_array", "Outputs hc_array.yaml"
|
|
199
|
+
def puts_hc_array
|
|
200
|
+
hc_array = {
|
|
201
|
+
source_file: "./linux_basic.pdf",
|
|
202
|
+
target_dir: "./linux_basic",
|
|
203
|
+
toc: [
|
|
204
|
+
{ no: nil, init: 1, fin: nil, head: "title" },
|
|
205
|
+
{ no: "s0", init: 2, fin: nil, head: "commands" },
|
|
206
|
+
{ no: "sf", init: 8, fin: 8, head: "summary" }
|
|
207
|
+
]
|
|
208
|
+
}
|
|
209
|
+
File.open("hc_array.yaml", "w") { |f| f.write(hc_array.to_yaml) }
|
|
210
|
+
puts "hc_array.yaml generated."
|
|
211
|
+
end
|
|
212
|
+
|
|
213
|
+
desc "split PDF_FILE [YAML_FILE]", "Split PDF_FILE according to YAML_FILE (default: hc_array.yaml) and save to target_dir"
|
|
214
|
+
def split(pdf_file, yaml_file = "hc_array.yaml")
|
|
215
|
+
require "fileutils"
|
|
216
|
+
require "yaml"
|
|
217
|
+
|
|
218
|
+
data = YAML.load(File.read(yaml_file))
|
|
219
|
+
source_file = data[:source_file] || pdf_file
|
|
220
|
+
target_dir = data[:target_dir] || "linux_basic"
|
|
221
|
+
FileUtils.mkdir_p(target_dir) unless Dir.exist?(target_dir)
|
|
222
|
+
|
|
223
|
+
data[:toc].each do |v|
|
|
224
|
+
init = v[:init]
|
|
225
|
+
fin = v[:fin]
|
|
226
|
+
pages = if fin.nil?
|
|
227
|
+
fin = init
|
|
228
|
+
"#{init}"
|
|
229
|
+
else
|
|
230
|
+
"#{init}-#{fin}"
|
|
231
|
+
end
|
|
232
|
+
o_file = [v[:no], v[:head], pages].compact.join('_') + ".pdf"
|
|
233
|
+
target = File.join(target_dir, o_file)
|
|
234
|
+
comm = "qpdf #{source_file} --pages . #{init}-#{fin} -- #{target}"
|
|
235
|
+
puts comm
|
|
236
|
+
system(comm)
|
|
237
|
+
end
|
|
238
|
+
end
|
|
239
|
+
|
|
240
|
+
# ...existing code...
|
|
241
|
+
````
|
|
242
|
+
|
|
243
|
+
````ruby
|
|
244
|
+
# ...existing code...
|
|
245
|
+
YAML_FILE = File.join(TEST_ENV_DIR, "hc_array.yaml")
|
|
246
|
+
# ...existing code...
|
|
247
|
+
|
|
248
|
+
def setup
|
|
249
|
+
FileUtils.rm_rf(TEST_ENV_DIR)
|
|
250
|
+
FileUtils.mkdir_p(TEST_ENV_DIR)
|
|
251
|
+
FileUtils.cp(LINUX_BASIC_PDF_SRC, LINUX_BASIC_PDF)
|
|
252
|
+
# サンプルYAMLを作成
|
|
253
|
+
yaml_data = {
|
|
254
|
+
source_file: "./linux_basic.pdf",
|
|
255
|
+
target_dir: "./linux_basic",
|
|
256
|
+
toc: [
|
|
257
|
+
{ no: nil, init: 1, fin: nil, head: "title" },
|
|
258
|
+
{ no: "s0", init: 2, fin: nil, head: "commands" },
|
|
259
|
+
{ no: "sf", init: 8, fin: 8, head: "summary" }
|
|
260
|
+
]
|
|
261
|
+
}
|
|
262
|
+
File.write(YAML_FILE, yaml_data.to_yaml)
|
|
263
|
+
end
|
|
264
|
+
|
|
265
|
+
# ...existing code...
|
|
266
|
+
|
|
267
|
+
def test_split_linux_basic_pdf_by_yaml
|
|
268
|
+
exe_path = File.expand_path("../exe/hyper_card_builder", __dir__)
|
|
269
|
+
Dir.chdir(TEST_ENV_DIR) do
|
|
270
|
+
cmd = [
|
|
271
|
+
"bundle", "exec", exe_path,
|
|
272
|
+
"split",
|
|
273
|
+
"linux_basic.pdf"
|
|
274
|
+
# YAML_FILEは省略(デフォルトでhc_array.yamlを使う)
|
|
275
|
+
]
|
|
276
|
+
output, status = Open3.capture2(*cmd)
|
|
277
|
+
assert status.success?, "CLI did not exit successfully: #{output}"
|
|
278
|
+
|
|
279
|
+
yaml_sections = YAML.load_file("hc_array.yaml")
|
|
280
|
+
target_dir = yaml_sections[:target_dir] || "linux_basic"
|
|
281
|
+
assert Dir.exist?(target_dir), "Output directory not created"
|
|
282
|
+
|
|
283
|
+
yaml_sections[:toc].each do |section|
|
|
284
|
+
pages = section[:fin].nil? ? "#{section[:init]}" : "#{section[:init]}-#{section[:fin]}"
|
|
285
|
+
filename = [section[:no], section[:head], pages].compact.join('_') + ".pdf"
|
|
286
|
+
filepath = File.join(target_dir, filename)
|
|
287
|
+
assert File.exist?(filepath), "Expected file #{filepath} not found"
|
|
288
|
+
end
|
|
289
|
+
end
|
|
290
|
+
end
|
|
291
|
+
# ...existing code...
|
|
292
|
+
````
|
|
293
|
+
|
|
294
|
+
daddygongon: "linux_basic.pdf"は呼ばないように変更.
|
|
295
|
+
|
|
296
|
+
GitHub Copilot: ````ruby
|
|
297
|
+
# ...existing code...
|
|
298
|
+
cmd = [
|
|
299
|
+
"bundle", "exec", exe_path,
|
|
300
|
+
"split"
|
|
301
|
+
# PDF_FILEもYAML_FILEも省略(デフォルトでhc_array.yamlを使う)
|
|
302
|
+
]
|
|
303
|
+
# ...existing code...
|
|
304
|
+
````
|
|
305
|
+
|
|
306
|
+
これで `"linux_basic.pdf"` をコマンド引数に渡さず、splitコマンドは `hc_array.yaml` をデフォルトで利用します。
|
|
307
|
+
|
|
308
|
+
daddygongon: ここも,pdf_fileは呼ばないように変更
|
|
309
|
+
|
|
310
|
+
GitHub Copilot: ````ruby
|
|
311
|
+
# ...existing code...
|
|
312
|
+
|
|
313
|
+
desc "split [YAML_FILE]", "Split PDF according to YAML_FILE (default: hc_array.yaml) and save to target_dir"
|
|
314
|
+
def split(yaml_file = "hc_array.yaml")
|
|
315
|
+
require "fileutils"
|
|
316
|
+
require "yaml"
|
|
317
|
+
|
|
318
|
+
data = YAML.load(File.read(yaml_file))
|
|
319
|
+
source_file = data[:source_file] || "./linux_basic.pdf"
|
|
320
|
+
target_dir = data[:target_dir] || "linux_basic"
|
|
321
|
+
FileUtils.mkdir_p(target_dir) unless Dir.exist?(target_dir)
|
|
322
|
+
|
|
323
|
+
data[:toc].each do |v|
|
|
324
|
+
init = v[:init]
|
|
325
|
+
fin = v[:fin]
|
|
326
|
+
pages = if fin.nil?
|
|
327
|
+
fin = init
|
|
328
|
+
"#{init}"
|
|
329
|
+
else
|
|
330
|
+
"#{init}-#{fin}"
|
|
331
|
+
end
|
|
332
|
+
o_file = [v[:no], v[:head], pages].compact.join('_') + ".pdf"
|
|
333
|
+
target = File.join(target_dir, o_file)
|
|
334
|
+
comm = "qpdf #{source_file} --pages . #{init}-#{fin} -- #{target}"
|
|
335
|
+
puts comm
|
|
336
|
+
system(comm)
|
|
337
|
+
end
|
|
338
|
+
end
|
|
339
|
+
|
|
340
|
+
# ...existing code...
|
|
341
|
+
````
|
data/CHANGELOG.md
ADDED
data/CODE_OF_CONDUCT.md
ADDED
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
# Contributor Covenant Code of Conduct
|
|
2
|
+
|
|
3
|
+
## Our Pledge
|
|
4
|
+
|
|
5
|
+
We as members, contributors, and leaders pledge to make participation in our
|
|
6
|
+
community a harassment-free experience for everyone, regardless of age, body
|
|
7
|
+
size, visible or invisible disability, ethnicity, sex characteristics, gender
|
|
8
|
+
identity and expression, level of experience, education, socio-economic status,
|
|
9
|
+
nationality, personal appearance, race, caste, color, religion, or sexual
|
|
10
|
+
identity and orientation.
|
|
11
|
+
|
|
12
|
+
We pledge to act and interact in ways that contribute to an open, welcoming,
|
|
13
|
+
diverse, inclusive, and healthy community.
|
|
14
|
+
|
|
15
|
+
## Our Standards
|
|
16
|
+
|
|
17
|
+
Examples of behavior that contributes to a positive environment for our
|
|
18
|
+
community include:
|
|
19
|
+
|
|
20
|
+
* Demonstrating empathy and kindness toward other people
|
|
21
|
+
* Being respectful of differing opinions, viewpoints, and experiences
|
|
22
|
+
* Giving and gracefully accepting constructive feedback
|
|
23
|
+
* Accepting responsibility and apologizing to those affected by our mistakes,
|
|
24
|
+
and learning from the experience
|
|
25
|
+
* Focusing on what is best not just for us as individuals, but for the overall
|
|
26
|
+
community
|
|
27
|
+
|
|
28
|
+
Examples of unacceptable behavior include:
|
|
29
|
+
|
|
30
|
+
* The use of sexualized language or imagery, and sexual attention or advances of
|
|
31
|
+
any kind
|
|
32
|
+
* Trolling, insulting or derogatory comments, and personal or political attacks
|
|
33
|
+
* Public or private harassment
|
|
34
|
+
* Publishing others' private information, such as a physical or email address,
|
|
35
|
+
without their explicit permission
|
|
36
|
+
* Other conduct which could reasonably be considered inappropriate in a
|
|
37
|
+
professional setting
|
|
38
|
+
|
|
39
|
+
## Enforcement Responsibilities
|
|
40
|
+
|
|
41
|
+
Community leaders are responsible for clarifying and enforcing our standards of
|
|
42
|
+
acceptable behavior and will take appropriate and fair corrective action in
|
|
43
|
+
response to any behavior that they deem inappropriate, threatening, offensive,
|
|
44
|
+
or harmful.
|
|
45
|
+
|
|
46
|
+
Community leaders have the right and responsibility to remove, edit, or reject
|
|
47
|
+
comments, commits, code, wiki edits, issues, and other contributions that are
|
|
48
|
+
not aligned to this Code of Conduct, and will communicate reasons for moderation
|
|
49
|
+
decisions when appropriate.
|
|
50
|
+
|
|
51
|
+
## Scope
|
|
52
|
+
|
|
53
|
+
This Code of Conduct applies within all community spaces, and also applies when
|
|
54
|
+
an individual is officially representing the community in public spaces.
|
|
55
|
+
Examples of representing our community include using an official email address,
|
|
56
|
+
posting via an official social media account, or acting as an appointed
|
|
57
|
+
representative at an online or offline event.
|
|
58
|
+
|
|
59
|
+
## Enforcement
|
|
60
|
+
|
|
61
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
|
62
|
+
reported to the community leaders responsible for enforcement at
|
|
63
|
+
[INSERT CONTACT METHOD].
|
|
64
|
+
All complaints will be reviewed and investigated promptly and fairly.
|
|
65
|
+
|
|
66
|
+
All community leaders are obligated to respect the privacy and security of the
|
|
67
|
+
reporter of any incident.
|
|
68
|
+
|
|
69
|
+
## Enforcement Guidelines
|
|
70
|
+
|
|
71
|
+
Community leaders will follow these Community Impact Guidelines in determining
|
|
72
|
+
the consequences for any action they deem in violation of this Code of Conduct:
|
|
73
|
+
|
|
74
|
+
### 1. Correction
|
|
75
|
+
|
|
76
|
+
**Community Impact**: Use of inappropriate language or other behavior deemed
|
|
77
|
+
unprofessional or unwelcome in the community.
|
|
78
|
+
|
|
79
|
+
**Consequence**: A private, written warning from community leaders, providing
|
|
80
|
+
clarity around the nature of the violation and an explanation of why the
|
|
81
|
+
behavior was inappropriate. A public apology may be requested.
|
|
82
|
+
|
|
83
|
+
### 2. Warning
|
|
84
|
+
|
|
85
|
+
**Community Impact**: A violation through a single incident or series of
|
|
86
|
+
actions.
|
|
87
|
+
|
|
88
|
+
**Consequence**: A warning with consequences for continued behavior. No
|
|
89
|
+
interaction with the people involved, including unsolicited interaction with
|
|
90
|
+
those enforcing the Code of Conduct, for a specified period of time. This
|
|
91
|
+
includes avoiding interactions in community spaces as well as external channels
|
|
92
|
+
like social media. Violating these terms may lead to a temporary or permanent
|
|
93
|
+
ban.
|
|
94
|
+
|
|
95
|
+
### 3. Temporary Ban
|
|
96
|
+
|
|
97
|
+
**Community Impact**: A serious violation of community standards, including
|
|
98
|
+
sustained inappropriate behavior.
|
|
99
|
+
|
|
100
|
+
**Consequence**: A temporary ban from any sort of interaction or public
|
|
101
|
+
communication with the community for a specified period of time. No public or
|
|
102
|
+
private interaction with the people involved, including unsolicited interaction
|
|
103
|
+
with those enforcing the Code of Conduct, is allowed during this period.
|
|
104
|
+
Violating these terms may lead to a permanent ban.
|
|
105
|
+
|
|
106
|
+
### 4. Permanent Ban
|
|
107
|
+
|
|
108
|
+
**Community Impact**: Demonstrating a pattern of violation of community
|
|
109
|
+
standards, including sustained inappropriate behavior, harassment of an
|
|
110
|
+
individual, or aggression toward or disparagement of classes of individuals.
|
|
111
|
+
|
|
112
|
+
**Consequence**: A permanent ban from any sort of public interaction within the
|
|
113
|
+
community.
|
|
114
|
+
|
|
115
|
+
## Attribution
|
|
116
|
+
|
|
117
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage],
|
|
118
|
+
version 2.1, available at
|
|
119
|
+
[https://www.contributor-covenant.org/version/2/1/code_of_conduct.html][v2.1].
|
|
120
|
+
|
|
121
|
+
Community Impact Guidelines were inspired by
|
|
122
|
+
[Mozilla's code of conduct enforcement ladder][Mozilla CoC].
|
|
123
|
+
|
|
124
|
+
For answers to common questions about this code of conduct, see the FAQ at
|
|
125
|
+
[https://www.contributor-covenant.org/faq][FAQ]. Translations are available at
|
|
126
|
+
[https://www.contributor-covenant.org/translations][translations].
|
|
127
|
+
|
|
128
|
+
[homepage]: https://www.contributor-covenant.org
|
|
129
|
+
[v2.1]: https://www.contributor-covenant.org/version/2/1/code_of_conduct.html
|
|
130
|
+
[Mozilla CoC]: https://github.com/mozilla/diversity
|
|
131
|
+
[FAQ]: https://www.contributor-covenant.org/faq
|
|
132
|
+
[translations]: https://www.contributor-covenant.org/translations
|
data/LICENSE.txt
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Shigeto R. Nishitani
|
|
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.org
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
* HyperCardBuilder
|
|
2
|
+
|
|
3
|
+
Hyper Card Building CLA
|
|
4
|
+
|
|
5
|
+
** Installation
|
|
6
|
+
|
|
7
|
+
Install the gem and add to the application's Gemfile by executing:
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
bundle add hyper_card_builder
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
If bundler is not being used to manage dependencies, install the gem by executing:
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
gem install hyper_card_builder
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
** Usage
|
|
20
|
+
|
|
21
|
+
TODO: Write usage instructions here
|
|
22
|
+
|
|
23
|
+
** Contributing
|
|
24
|
+
|
|
25
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/daddygongon/hyper_card_builder. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [[https://github.com/\[USERNAME\]/hyper_card_builder/blob/main/CODE_OF_CONDUCT.md][MIT License]].
|
|
26
|
+
|
|
27
|
+
** License
|
|
28
|
+
|
|
29
|
+
The gem is available as open source under the terms of the [[https://opensource.org/licenses/MIT][MIT License]].
|
|
30
|
+
|
|
31
|
+
** Code of Conduct
|
|
32
|
+
|
|
33
|
+
Everyone interacting in the HyperCardBuilder project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [[https://github.com/daddygongon/hyper_card_builder/blob/main/CODE_OF_CONDUCT.md][Code of Conduct]].
|
data/Rakefile
ADDED
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require_relative "hyper_card_builder/version"
|
|
4
|
+
require "thor"
|
|
5
|
+
require "yaml" # ← 追加
|
|
6
|
+
|
|
7
|
+
module HyperCardBuilder
|
|
8
|
+
class Error < StandardError; end
|
|
9
|
+
|
|
10
|
+
class CLI < Thor
|
|
11
|
+
desc "hello", "Prints Hello."
|
|
12
|
+
def hello
|
|
13
|
+
puts "Hello."
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
desc "puts_hc_array", "Outputs hc_array.yaml"
|
|
17
|
+
def puts_hc_array
|
|
18
|
+
hc_array = {
|
|
19
|
+
source_file: "./linux_basic.pdf",
|
|
20
|
+
target_dir: "./linux_basic",
|
|
21
|
+
toc: [
|
|
22
|
+
{ no: nil, init: 1, fin: nil, head: "title" },
|
|
23
|
+
{ no: "s0", init: 2, fin: nil, head: "commands" },
|
|
24
|
+
{ no: "sf", init: 8, fin: 8, head: "summary" }
|
|
25
|
+
]
|
|
26
|
+
}
|
|
27
|
+
File.open("hc_array.yaml", "w") { |f| f.write(hc_array.to_yaml) }
|
|
28
|
+
puts "hc_array.yaml generated."
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
desc "split [YAML_FILE]", "Split PDF according to YAML_FILE (default: hc_array.yaml) and save to target_dir"
|
|
32
|
+
def split(yaml_file = "hc_array.yaml")
|
|
33
|
+
require "fileutils"
|
|
34
|
+
require "yaml"
|
|
35
|
+
|
|
36
|
+
data = YAML.load(File.read(yaml_file))
|
|
37
|
+
source_file = data[:source_file] || "./linux_basic.pdf"
|
|
38
|
+
target_dir = data[:target_dir] || "linux_basic"
|
|
39
|
+
FileUtils.mkdir_p(target_dir) unless Dir.exist?(target_dir)
|
|
40
|
+
|
|
41
|
+
data[:toc].each do |v|
|
|
42
|
+
init = v[:init]
|
|
43
|
+
fin = v[:fin]
|
|
44
|
+
pages = if fin.nil?
|
|
45
|
+
fin = init
|
|
46
|
+
"#{init}"
|
|
47
|
+
else
|
|
48
|
+
"#{init}-#{fin}"
|
|
49
|
+
end
|
|
50
|
+
o_file = [v[:no], v[:head], pages].compact.join('_') + ".pdf"
|
|
51
|
+
target = File.join(target_dir, o_file)
|
|
52
|
+
comm = "qpdf #{source_file} --pages . #{init}-#{fin} -- #{target}"
|
|
53
|
+
puts comm
|
|
54
|
+
system(comm)
|
|
55
|
+
end
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
desc "split_wo_pages [YAML_FILE]", "Split PDF wo pages according to YAML_FILE (default: hc_array.yaml) and save to target_dir"
|
|
59
|
+
def split_wo_pages(yaml_file = "hc_array.yaml")
|
|
60
|
+
require "fileutils"
|
|
61
|
+
require "yaml"
|
|
62
|
+
|
|
63
|
+
data = YAML.load(File.read(yaml_file))
|
|
64
|
+
source_file = data[:source_file] || "./linux_basic.pdf"
|
|
65
|
+
target_dir = data[:target_dir] || "linux_basic"
|
|
66
|
+
FileUtils.mkdir_p(target_dir) unless Dir.exist?(target_dir)
|
|
67
|
+
|
|
68
|
+
data[:toc].each do |v|
|
|
69
|
+
init = v[:init]
|
|
70
|
+
fin = v[:fin]
|
|
71
|
+
pages = if fin.nil?
|
|
72
|
+
fin = init
|
|
73
|
+
"#{init}"
|
|
74
|
+
else
|
|
75
|
+
"#{init}-#{fin}"
|
|
76
|
+
end
|
|
77
|
+
o_file = [v[:no], v[:head]].compact.join('_') + ".pdf"
|
|
78
|
+
target = File.join(target_dir, o_file)
|
|
79
|
+
p target
|
|
80
|
+
comm = "qpdf #{source_file} --pages . #{init}-#{fin} -- #{target}"
|
|
81
|
+
puts comm
|
|
82
|
+
system(comm)
|
|
83
|
+
end
|
|
84
|
+
end
|
|
85
|
+
|
|
86
|
+
end
|
|
87
|
+
end
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|