dimples 3.0.6 → 3.0.7

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: f1fcb58443841c212bac82b1a41c55215f67bf75
4
- data.tar.gz: 7523fcde7bc143b6957fc5d7cd143ed9b93fcfe3
3
+ metadata.gz: 2d3f5d7e758762e3cba7f8d53520a06c1a7abe3f
4
+ data.tar.gz: be2d879b4f1475166d56b4210f03e26afe3834e9
5
5
  SHA512:
6
- metadata.gz: e17511e2db523562c9b6d7a0f5d653b396266601271d9d60bf0a273bcd1d3342e1ce9e4638357482c38836b310b3dce090617cd7ffc2b62703df324a5e0c6e95
7
- data.tar.gz: 5d7bd437e97142deaf5935d4c9a9d9308ae1caf7812574e874edf1e8941f449f7c43dc4d02db02942c8ec5d62cd61f4b283731f04ac9d8d86368e175e82c9dfa
6
+ metadata.gz: 2eb2cd4791972d0475602e3860a8054e1ad1d554c31b8933d9551b4e5549f27de10dbdadb6cf6da19603e1c7dd4aef35781e9e6d5db2090da85a803057b9c85e
7
+ data.tar.gz: 0a4f49d040199d11db9b8d5a4df417db3f60cfb65786263d3265617f4f3166cde8d39885fa311ff25313442dbaf3213ec3f658fd0a7503ef4c8d05419f7e8ecf
@@ -15,7 +15,7 @@ module Dimples
15
15
  end
16
16
 
17
17
  def inspect
18
- "#<#{self.class.to_s} @slug=#{@slug} @name=#{@name}>"
18
+ "#<#{self.class} @slug=#{@slug} @name=#{@name}>"
19
19
  end
20
20
  end
21
21
  end
@@ -50,7 +50,7 @@ module Dimples
50
50
  end
51
51
 
52
52
  def inspect
53
- "#<#{self.class.to_s} @output_path=#{output_path}>"
53
+ "#<#{self.class} @output_path=#{output_path}>"
54
54
  end
55
55
  end
56
56
  end
@@ -6,7 +6,8 @@ module Dimples
6
6
  def paginate(site, items, path, layout, options = {})
7
7
  context = options.delete(:context) || {}
8
8
  url = path.gsub(site.output_paths[:site], '') + '/'
9
- per_page = options.delete(:per_page) || site.config['pagination']['per_page']
9
+ per_page = options.delete(:per_page) ||
10
+ site.config['pagination']['per_page']
10
11
 
11
12
  pager = Pager.new(url, items, per_page, options)
12
13
 
@@ -41,7 +41,7 @@ module Dimples
41
41
  end
42
42
 
43
43
  def inspect
44
- "#<#{self.class.to_s} @slug=#{@slug} @output_path=#{output_path}>"
44
+ "#<#{self.class} @slug=#{@slug} @output_path=#{output_path}>"
45
45
  end
46
46
  end
47
47
  end
@@ -10,17 +10,7 @@ module Dimples
10
10
  context[:this] ||= self
11
11
  context[:type] ||= self.class.name.split('::').last.downcase.to_sym
12
12
 
13
- scope = Object.new.tap do |s|
14
- context.each_pair do |key, value|
15
- s.instance_variable_set("@#{key}".to_sym, value)
16
- end
17
- end
18
-
19
- scope.class.send(:define_method, :render_template) do |template, context = {}|
20
- @site.templates[template].render(context) if @site.templates[template]
21
- end
22
-
23
- output = rendering_engine.render(scope) { body }.strip
13
+ output = rendering_engine.render(scope(context)) { body }.strip
24
14
  @rendered_contents = output
25
15
 
26
16
  if @site.templates[layout]
@@ -30,6 +20,19 @@ module Dimples
30
20
  end
31
21
  end
32
22
 
23
+ def scope(context)
24
+ Object.new.tap do |scope|
25
+ context.each_pair do |key, value|
26
+ scope.instance_variable_set("@#{key}".to_sym, value)
27
+ end
28
+
29
+ method_name = :render_template
30
+ scope.class.send(:define_method, method_name) do |template, locals = {}|
31
+ @site.templates[template]&.render(locals)
32
+ end
33
+ end
34
+ end
35
+
33
36
  def rendering_engine
34
37
  @rendering_engine ||= begin
35
38
  callback = proc { contents }
@@ -45,10 +45,7 @@ module Dimples
45
45
  end
46
46
 
47
47
  def generate
48
- scan_templates
49
- scan_pages
50
- scan_posts
51
-
48
+ scan_files
52
49
  prepare_output_directory
53
50
 
54
51
  generate_pages unless @pages.count.zero?
@@ -70,6 +67,14 @@ module Dimples
70
67
  @errors.count.zero?
71
68
  end
72
69
 
70
+ def scan_files
71
+ Dimples.logger.debug('Scanning files...') if @config['verbose_logging']
72
+
73
+ scan_templates
74
+ scan_pages
75
+ scan_posts
76
+ end
77
+
73
78
  def scan_templates
74
79
  Dir.glob(File.join(@source_paths[:templates], '**', '*.*')).each do |path|
75
80
  template = Dimples::Template.new(self, path)
@@ -257,7 +262,7 @@ module Dimples
257
262
  end
258
263
 
259
264
  def inspect
260
- "#<#{self.class.to_s} " \
265
+ "#<#{self.class} " \
261
266
  "@source_paths=#{@source_paths} " \
262
267
  "@output_paths=#{@output_paths}>"
263
268
  end
@@ -21,7 +21,7 @@ module Dimples
21
21
  end
22
22
 
23
23
  def inspect
24
- "#<#{self.class.to_s} @slug=#{@slug} @path=#{@path}>"
24
+ "#<#{self.class} @slug=#{@slug} @path=#{@path}>"
25
25
  end
26
26
  end
27
27
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Dimples
4
- VERSION = '3.0.6'
4
+ VERSION = '3.0.7'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dimples
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.6
4
+ version: 3.0.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daniel Bogan