dimples 10.1.1 → 10.1.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1851462f5263625c3180103f3be8e6484246bdd21609a401ab779f26d489cfc7
4
- data.tar.gz: 5b2312987fd9ceb6c78f8be7152445bf25161fd4e16f6bf9a1e055b9b21d5502
3
+ metadata.gz: b4cb30bd078959510f0f81a130d22689cf34eba48ea90361806c9b046214e447
4
+ data.tar.gz: d24ddeeabc388b164fb82151ea13b9ae50cb7ecf1888d700bcccec9a56ec8ea1
5
5
  SHA512:
6
- metadata.gz: 92451497846e5d3724a09d98ea88e9eec50f96b282061cf96fcb17be39bc180bad42d2e9994077545bd70b3f4ba68a8d11fee2d29cd66f2b812c82a8673c1811
7
- data.tar.gz: a23cc742b62eed3ace4b40bb38002c392c5be58525177f4d159e3f983ad15ccbda1331e5cf9080841f1295b604cb09d361b215c647bd09040deb7c23f017eb47
6
+ metadata.gz: f41a59f95690d77f5cb5836e558b15c39696bacd214966b43ca66d7c45f57f8fafe4267e320b17420c414a432dabb992d39fddf7403d0fe5ad185ab9a72a8b24
7
+ data.tar.gz: 06b9420670c7863edf252586cd589a3f37a9f6b2649ea858a5839436e3b324bad692505dd8678fef0d5f40833a92bf0db2e60b973322149036cc996681ee30d6
@@ -16,6 +16,7 @@ module Dimples
16
16
  @contents = File.read(@path)
17
17
 
18
18
  parse_metadata(@contents)
19
+ assign_metadata
19
20
  end
20
21
 
21
22
  def parse_metadata(contents)
@@ -24,18 +25,22 @@ module Dimples
24
25
 
25
26
  @metadata.merge!(YAML.safe_load(matches[1], symbolize_names: true, permitted_classes: [Date]))
26
27
  @contents = matches.post_match.strip
28
+ end
27
29
 
30
+ def assign_metadata
28
31
  @metadata.each_key do |key|
29
32
  self.class.send(:define_method, key.to_sym) { @metadata[key] }
30
33
  end
31
34
  end
32
35
 
33
36
  def write(output_path = nil, metadata = {})
34
- output = render(metadata)
35
-
36
37
  output_path = File.join(output_directory, filename) if output_path.nil?
37
38
  output_dir = File.dirname(output_path)
38
39
 
40
+ @metadata[:url] = url_for(output_dir)
41
+
42
+ output = render(metadata)
43
+
39
44
  FileUtils.mkdir_p(output_dir) unless File.directory?(output_dir)
40
45
  File.write(output_path, output)
41
46
  end
@@ -54,8 +59,8 @@ module Dimples
54
59
  @site.config[:output][:root]
55
60
  end
56
61
 
57
- def url
58
- @metadata[:url] || output_directory.gsub(@site.config[:output][:root], '')
62
+ def url_for(path)
63
+ path.gsub(@site.config[:output][:root], '').concat('/')
59
64
  end
60
65
 
61
66
  def template
@@ -12,7 +12,7 @@ module Dimples
12
12
  end
13
13
 
14
14
  def url
15
- @metadata[:url] || super.tap do |url|
15
+ super.tap do |url|
16
16
  url.concat(filename) unless filename == 'index.html'
17
17
  end
18
18
  end
@@ -8,7 +8,11 @@ module Dimples
8
8
  @output_directory ||= File.dirname(@path).gsub(
9
9
  @site.config[:sources][:posts],
10
10
  @site.config[:output][:posts]
11
- ).concat("/#{@metadata[:slug]}/")
11
+ ).concat("/#{slug}/")
12
+ end
13
+
14
+ def slug
15
+ File.basename(@path)
12
16
  end
13
17
 
14
18
  def template
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Dimples
4
- VERSION = '10.1.1'
4
+ VERSION = '10.1.3'
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: 10.1.1
4
+ version: 10.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daniel Bogan
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-02-04 00:00:00.000000000 Z
11
+ date: 2024-04-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: erb
@@ -76,7 +76,7 @@ licenses:
76
76
  - MIT
77
77
  metadata:
78
78
  rubygems_mfa_required: 'true'
79
- post_install_message:
79
+ post_install_message:
80
80
  rdoc_options: []
81
81
  require_paths:
82
82
  - lib
@@ -92,7 +92,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
92
92
  version: '0'
93
93
  requirements: []
94
94
  rubygems_version: 3.4.10
95
- signing_key:
95
+ signing_key:
96
96
  specification_version: 4
97
97
  summary: A basic static site generator
98
98
  test_files: []