pbsimply 3.0.2 → 3.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/pbsimply/hooks.rb +32 -3
- data/lib/pbsimply.rb +4 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5c2cee1a598dad5d08c823c51768afebae4d8e0459b3507658ca10a613c33bc4
|
4
|
+
data.tar.gz: c13273c93cc68212ad5bb72b785dc01a640415c03bc5be98faccee449f8c54ee
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1e90c599fc508e0e44aa1e882dca4de285f150dde10eecfaf7c22d20ca674cd4b29be5ace1a139a8fe36b5581afd1d81438c168c2823739a0ef1ddfbeacf1116
|
7
|
+
data.tar.gz: e0a079093ca72cc0575b7858a687e838a8c848ff9c9eff036cba99e7678ee9de4f098890d619e1b5078049252f4b277bb20fc09c50d4db0488c4fb148e88ed58
|
data/lib/pbsimply/hooks.rb
CHANGED
@@ -16,7 +16,17 @@ class PBSimply::Hooks
|
|
16
16
|
@hooks << proc
|
17
17
|
end
|
18
18
|
|
19
|
-
|
19
|
+
def add(&proc)
|
20
|
+
@hooks << proc
|
21
|
+
end
|
22
|
+
|
23
|
+
# Invoke command updating files
|
24
|
+
def cmd(*cmdarg)
|
25
|
+
proc = ->(arg) do
|
26
|
+
system(*cmdarg)
|
27
|
+
end
|
28
|
+
self << proc
|
29
|
+
end
|
20
30
|
|
21
31
|
def run(arg)
|
22
32
|
STDERR.puts "Hooks processing (#{@name})"
|
@@ -32,14 +42,32 @@ class PBSimply::Hooks
|
|
32
42
|
end
|
33
43
|
end
|
34
44
|
|
45
|
+
# Timing Object for pre, process
|
46
|
+
class HooksHolderPre < HooksHolder
|
47
|
+
# Invoke command as filter.
|
48
|
+
def filter(*cmdarg)
|
49
|
+
proc = ->(arg) do
|
50
|
+
IO.popen(cmdarg, "w+") do |io|
|
51
|
+
io.print File.read ENV["pbsimply_currentdoc"]
|
52
|
+
io.close_write
|
53
|
+
File.open(ENV["pbsimply_currentdoc"], "w") do |f|
|
54
|
+
f.write io.read
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
self << proc
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
35
62
|
def initialize(pbsimply)
|
36
63
|
@pbsimply = pbsimply
|
64
|
+
@hooks_loaded = false
|
37
65
|
|
38
66
|
# Called first phase before generate. This hooks called before blessing.
|
39
67
|
#
|
40
68
|
# Argument: frontmatter, procdoc.
|
41
69
|
# procdoc is processing source document path.
|
42
|
-
@pre =
|
70
|
+
@pre = HooksHolderPre.new "pre"
|
43
71
|
|
44
72
|
# Called after document was generated.
|
45
73
|
#
|
@@ -73,7 +101,8 @@ class PBSimply::Hooks
|
|
73
101
|
def load
|
74
102
|
if File.file?("./.pbsimply-hooks.rb")
|
75
103
|
require './.pbsimply-hooks.rb'
|
76
|
-
PBSimply::Hooks.load_hooks(self)
|
104
|
+
PBSimply::Hooks.load_hooks(self) unless @hooks_loaded
|
105
|
+
@hooks_loaded = true
|
77
106
|
end
|
78
107
|
end
|
79
108
|
|
data/lib/pbsimply.rb
CHANGED
@@ -201,6 +201,8 @@ class PBSimply
|
|
201
201
|
# Push to target documents without checking modification.
|
202
202
|
target_docs.push([filename, frontmatter, pos])
|
203
203
|
end
|
204
|
+
ENV.delete("pbsimply_currentdoc")
|
205
|
+
ENV.delete("pbsimply_filename")
|
204
206
|
|
205
207
|
delete_turn_draft draft_articles
|
206
208
|
|
@@ -236,6 +238,8 @@ class PBSimply
|
|
236
238
|
# Proccess documents
|
237
239
|
target_docs.each do |filename, frontmatter, pos|
|
238
240
|
ext = File.extname filename
|
241
|
+
ENV["pbsimply_currentdoc"] = File.join(@workdir, "current_document#{ext}")
|
242
|
+
ENV["pbsimply_filename"] = filename
|
239
243
|
@index = frontmatter
|
240
244
|
File.open(File.join(@dir, filename)) do |f|
|
241
245
|
f.seek(pos)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pbsimply
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.0
|
4
|
+
version: 3.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Masaki Haruka
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-10-
|
11
|
+
date: 2023-10-16 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: Pre compile, static serving website builder.
|
14
14
|
email:
|