dimples 6.0.3 → 6.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 986990cd4e91101c9f801db84eb33d44c76b240c
4
- data.tar.gz: 6083ffd330f3242331d28484249e8951ebbd3ad9
3
+ metadata.gz: 92e195459728e28b5120a92a4282b2dbf7fe169f
4
+ data.tar.gz: ff63f1c065662ccc3dd8b64ca66e5a28fa78d398
5
5
  SHA512:
6
- metadata.gz: d79ac9a507c426f73ec8bcf29a2dd8de4b8a2321637d6e92b054971b1611a7508f6fe35450693cfa4071707e54ac0b6476f693a80b11915db922e756c54dd1c5
7
- data.tar.gz: c451a21bffb0cf3bdcf235efa43e6df673976238133c1b1e46c0f4c89d75e18411f6260db9880b58dd2a99c7dd0ee41077ed110e45b521248c3b444da243f9c5
6
+ metadata.gz: e2bbd4a0f7e1165e4d2e3d2e8411d3ebe14a105cac745bc363d7638babecb673a3b6bc79c073a1c41c3ce99f9405302163f1fc30e1797fb9a6545d19570e3b63
7
+ data.tar.gz: e63c7504d58398086e15a4f42c3df8b281e59e50964aa28dd8467215b14a1c7a43e135acc79d1535988de4063e73cae5af012d2a1a0212cbfc7c7af434b3007c
@@ -44,7 +44,6 @@ source_path = if options[:source]
44
44
  Dir.pwd
45
45
  end
46
46
 
47
- plugins_path = File.join(source_path, 'plugins')
48
47
  config_path = options[:config] || File.join(source_path, 'config.json')
49
48
 
50
49
  if File.exist?(config_path)
@@ -60,12 +59,6 @@ else
60
59
  Optimist.die "Unable to find config file (#{config_path})"
61
60
  end
62
61
 
63
- if Dir.exist?(plugins_path)
64
- Dir.glob(File.join(plugins_path, '**', '*.rb')) do |path|
65
- require path
66
- end
67
- end
68
-
69
62
  config[:source] = source_path
70
63
 
71
64
  if options[:destination]
@@ -13,7 +13,6 @@ require 'dimples/configuration'
13
13
  require 'dimples/errors'
14
14
  require 'dimples/page'
15
15
  require 'dimples/pager'
16
- require 'dimples/plugin'
17
16
  require 'dimples/post'
18
17
  require 'dimples/renderer'
19
18
  require 'dimples/site'
@@ -30,10 +30,18 @@ module Dimples
30
30
 
31
31
  def generate
32
32
  prepare
33
- scan_sources
33
+
34
+ read_templates
35
+ read_posts
36
+ read_pages
37
+
34
38
  create_output_directory
35
39
  copy_static_assets
36
- publish_files
40
+
41
+ publish_posts
42
+ publish_pages
43
+ publish_archives if @config.generation.year_archives
44
+ publish_categories if @config.generation.categories
37
45
  rescue PublishingError, RenderingError, GenerationError => error
38
46
  @errors << error
39
47
  end
@@ -61,16 +69,6 @@ module Dimples
61
69
  @latest_post = nil
62
70
  end
63
71
 
64
- def scan_sources
65
- trigger_event(:before_file_scanning)
66
-
67
- read_templates
68
- read_posts
69
- read_pages
70
-
71
- trigger_event(:after_file_scanning)
72
- end
73
-
74
72
  def read_templates
75
73
  @templates = {}
76
74
  template_glob = File.join(@paths[:templates], '**', '*.*')
@@ -125,7 +123,7 @@ module Dimples
125
123
  FileUtils.remove_dir(@paths[:destination])
126
124
  end
127
125
 
128
- Dir.mkdir(@paths[:destination])
126
+ FileUtils.mkdir_p(@paths[:destination])
129
127
  rescue StandardError => e
130
128
  message = "Couldn't prepare the output directory (#{e.message})"
131
129
  raise GenerationError, message
@@ -138,21 +136,8 @@ module Dimples
138
136
  raise GenerationError, "Failed to copy site assets (#{e.message})"
139
137
  end
140
138
 
141
- def publish_files
142
- trigger_event(:before_publishing)
143
-
144
- publish_posts
145
- publish_pages
146
- publish_archives if @config.generation.year_archives
147
- publish_categories if @config.generation.categories
148
-
149
- trigger_event(:after_publishing)
150
- end
151
-
152
139
  def publish_posts
153
140
  @posts.each do |post|
154
- trigger_event(:before_post_write, post)
155
-
156
141
  path = File.join(
157
142
  @paths[:destination],
158
143
  post.date.strftime(@config.paths.posts),
@@ -160,8 +145,6 @@ module Dimples
160
145
  )
161
146
 
162
147
  post.write(path)
163
-
164
- trigger_event(:after_post_write, post)
165
148
  end
166
149
 
167
150
  if @config.generation.main_feed
@@ -179,8 +162,6 @@ module Dimples
179
162
 
180
163
  def publish_pages
181
164
  @pages.each do |page|
182
- trigger_event(:before_page_write, page)
183
-
184
165
  path = if page.path
185
166
  File.dirname(page.path).sub(
186
167
  @paths[:pages],
@@ -191,8 +172,6 @@ module Dimples
191
172
  end
192
173
 
193
174
  page.write(path)
194
-
195
- trigger_event(:after_page_write, page)
196
175
  end
197
176
  end
198
177
 
@@ -312,33 +291,15 @@ module Dimples
312
291
  end
313
292
 
314
293
  def archive_year(year)
315
- @archives[:year][year.to_s] ||= {
316
- month: {},
317
- posts: []
318
- }
294
+ @archives[:year][year.to_s] ||= { month: {}, posts: [] }
319
295
  end
320
296
 
321
297
  def archive_month(year, month)
322
- archive_year(year)[:month][month.to_s] ||= {
323
- day: {},
324
- posts: []
325
- }
298
+ archive_year(year)[:month][month.to_s] ||= { day: {}, posts: [] }
326
299
  end
327
300
 
328
301
  def archive_day(year, month, day)
329
- archive_month(year, month)[:day][day.to_s] ||= {
330
- posts: []
331
- }
332
- end
333
-
334
- def plugins
335
- @plugins ||= Plugin.subclasses&.map { |subclass| subclass.new(self) }
336
- end
337
-
338
- def trigger_event(event, item = nil)
339
- plugins&.each do |plugin|
340
- plugin.process(event, item) if plugin.supports_event?(event)
341
- end
302
+ archive_month(year, month)[:day][day.to_s] ||= { posts: [] }
342
303
  end
343
304
  end
344
305
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Dimples
4
- VERSION = '6.0.3'
4
+ VERSION = '6.1.0'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dimples
3
3
  version: !ruby/object:Gem::Version
4
- version: 6.0.3
4
+ version: 6.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daniel Bogan
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-09-04 00:00:00.000000000 Z
11
+ date: 2018-09-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: hashie
@@ -184,7 +184,6 @@ files:
184
184
  - lib/dimples/frontable.rb
185
185
  - lib/dimples/page.rb
186
186
  - lib/dimples/pager.rb
187
- - lib/dimples/plugin.rb
188
187
  - lib/dimples/post.rb
189
188
  - lib/dimples/renderer.rb
190
189
  - lib/dimples/site.rb
@@ -1,39 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Dimples
4
- # A Ruby class that can receive events from Dimples as a site is processed.
5
- class Plugin
6
- EVENTS = %i[
7
- before_file_scanning
8
- after_file_scanning
9
- before_publishing
10
- after_publishing
11
- before_post_write
12
- before_page_write
13
- after_post_write
14
- after_page_write
15
- ].freeze
16
-
17
- class << self
18
- attr_reader :subclasses
19
- end
20
-
21
- def self.inherited(subclass)
22
- (@subclasses ||= []) << subclass
23
- end
24
-
25
- def initialize(site)
26
- @site = site
27
- end
28
-
29
- def process(event, item); end
30
-
31
- def supported_events
32
- []
33
- end
34
-
35
- def supports_event?(event)
36
- supported_events.include?(event)
37
- end
38
- end
39
- end