pbsimply 3.5.0 → 3.5.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: 2f75e4f4e81729dbe5a291d473f1f2dc83bd51d52076179bd1a5517cf6bde380
4
- data.tar.gz: df909fb121e61744b056e0d934e07acd43d88d1630873c78910cc92a6462c390
3
+ metadata.gz: 1e6667388a878546c3fb8b5c5880661c66012a3ad65f4ce834fba8da89d470dc
4
+ data.tar.gz: 14b13fbe88d551bffb92d5a2c61f8e6a1378a437baa2a805a170e152314f37c5
5
5
  SHA512:
6
- metadata.gz: 06417d28977298a737faee844340700128d9d047d938ea16737ede93d1d8609e6844d0f3b49c138b4129b9c658f9a1444f38eb89e80848aa3362e1d04b47b720
7
- data.tar.gz: da761d0166bc05e276296b449393f2914ea6b462ebe28d6d96ea1f392323bfa919864c3d655e1279029f57773cbdd7d89464cb33f0f74be28032455ddd275ac2
6
+ metadata.gz: d650ffb297c0bd3ce21e05fc0edbb8d67f01c24af295b4a2ca387ccfacecefd81649469e7ddd1600958ed0943ba2f4bf46839fb6fbd0ed0c5d7e4c8efeede449
7
+ data.tar.gz: 5d35227c8476719684bc8c0abf04bf49ba4c34cbf065b487230750aeea5a1d0582b187299603ccdaf93d0047017b8a9b276bd6d8a49fa04c17ad577d173da1db
@@ -4,15 +4,17 @@ class PBSimply
4
4
  class Document
5
5
  include Frontmatter
6
6
 
7
- def initialize(config, dir, filename, base_frontmatter, now)
8
- @config = config
9
- @dir = dir
7
+ def initialize(pbs, filename)
8
+ @config = pbs.config
9
+ @dir = pbs.dir
10
10
  @filename = filename
11
11
  @ext = File.extname filename
12
- @orig_filepath = File.join(dir, filename)
13
- @now = now
14
- frontmatter, @pos = read_frontmatter(dir, filename)
15
- @frontmatter = base_frontmatter.merge frontmatter
12
+ @orig_filepath = File.join(pbs.dir, filename)
13
+ @now = pbs.now
14
+ @accs_processing = pbs.accs_processing
15
+ @outfile = pbs.outfile
16
+ frontmatter, @pos = read_frontmatter(pbs.dir, filename)
17
+ @frontmatter = pbs.frontmatter.merge frontmatter
16
18
  @modified = true
17
19
  @proc_doc_path = nil
18
20
  end
@@ -78,13 +78,13 @@ module PBSimply::Prayer
78
78
  begin
79
79
  @article_order = @indexes.to_a.sort_by {|i| i[1]["date"]}
80
80
  rescue
81
- abort "*** Automatic Blessing Method Error: Maybe some article have no date."
81
+ abort "*** Automatic Blessing Method Error: Maybe some article has no date."
82
82
  end
83
83
  when "timestamp"
84
84
  begin
85
85
  @article_order = @indexes.to_a.sort_by {|i| i[1]["timestamp"]}
86
86
  rescue
87
- abort "*** Automatic Blessing Method Error: Maybe some article have no timetsamp."
87
+ abort "*** Automatic Blessing Method Error: Maybe some article has no timetsamp."
88
88
  end
89
89
  when "lexical"
90
90
  @article_order = @indexes.to_a.sort_by {|i| i[1]["_filename"]}
data/lib/pbsimply.rb CHANGED
@@ -129,10 +129,15 @@ class PBSimply
129
129
  @accs_index = {}
130
130
  @now = Time.now
131
131
  @hooks = PBSimply::Hooks.new(self, @config)
132
+ @dir = nil
133
+ @frontmatter = {}
134
+ @accs_processing = false
132
135
 
133
136
  @debug = (ENV["DEBUG"] == "yes")
134
137
  end
135
138
 
139
+ attr_reader :config, :dir, :frontmatter, :now, :accs_processing, :outfile
140
+
136
141
  # Process command-line
137
142
  def treat_cmdline(dir=nil)
138
143
  # Options definition.
@@ -188,6 +193,7 @@ class PBSimply
188
193
  def proc_dir
189
194
  draft_articles = []
190
195
  target_docs = []
196
+ effective_docs = []
191
197
  $stderr.puts "in #{@dir}..."
192
198
 
193
199
  $stderr.puts "Checking Frontmatter..."
@@ -207,7 +213,7 @@ class PBSimply
207
213
  end
208
214
 
209
215
  $stderr.puts "Checking frontmatter in #{filename}"
210
- doc = Document.new(@config, @dir, filename, @frontmatter, @now)
216
+ doc = Document.new(self, filename)
211
217
 
212
218
  if doc.draft?
213
219
  draft_articles.push({
@@ -219,9 +225,13 @@ class PBSimply
219
225
  end
220
226
 
221
227
  doc.orig_frontmatter = @indexes[filename]
228
+ @indexes[filename] = doc.frontmatter
222
229
 
223
230
  # Push to target documents without checking modification.
224
231
  target_docs.push(doc)
232
+
233
+ # Push to all effective documents.
234
+ effective_docs.push(doc)
225
235
  end
226
236
  ENV.delete("pbsimply_currentdoc")
227
237
  ENV.delete("pbsimply_filename")
@@ -231,20 +241,9 @@ class PBSimply
231
241
  proc_docs target_docs
232
242
 
233
243
  delete_missing
234
-
235
- # Update modified doc's frontmatter
236
- if @preflight
237
- target_docs.each do |doc|
238
- @indexes[doc.filename] = doc.effective_forntmatter
239
- end
240
- else
241
- target_docs.each do |doc|
242
- @indexes[doc.filename] = doc.frontmatter
243
- end
244
- end
245
244
 
246
245
  # Save index.
247
- @db.dump(@indexes) unless @skip_index
246
+ save_index(effective_docs) unless @skip_index
248
247
 
249
248
  # ACCS processing
250
249
  if @accs && !target_docs.empty?
@@ -371,7 +370,7 @@ class PBSimply
371
370
 
372
371
  load_index
373
372
 
374
- doc = Document.new(@config, dir, filename, @frontmatter, @now)
373
+ doc = Document.new(self, filename)
375
374
  @index = doc.frontmatter
376
375
 
377
376
  proc_docs([doc])
@@ -479,4 +478,12 @@ class PBSimply
479
478
  raise CommandLineError.new "ACCS-only processing needs ACCS directory as an argument."
480
479
  end
481
480
  end
481
+
482
+ def save_index(effective_docs)
483
+ new_indexes = {}
484
+ effective_docs.each do |doc|
485
+ new_indexes[doc.filename] = doc.effective_forntmatter
486
+ end
487
+ @db.dump(new_indexes)
488
+ end
482
489
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pbsimply
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.5.0
4
+ version: 3.5.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Masaki Haruka