dimples 13.0.2 → 13.1.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: 6159d051a362d8cbd0423abe50dda74607b4142e5c7ba0570c20816b46552a28
4
- data.tar.gz: b3f8d2cc0af9bc06bdca241065c6e2de5e2f871ffa09a4f7afe3dd4076ebebd1
3
+ metadata.gz: 0a3a083ef71c4142029367c026394e4d499f4e8760ff3bf54712d3ee319322b8
4
+ data.tar.gz: c8f2e5ee9b6fbfd7e35a4d496798ebd02cb2773d6f532d12138bf1db21b800fb
5
5
  SHA512:
6
- metadata.gz: ee08bdba1b9479f7b5cd160474614ff2c87deb5807b05a797aafb65fa2c60650143e8c7c88a2197c234bd320c3f07336de0ba4e36a9492ab190aa50417876dff
7
- data.tar.gz: 16005bd967364bd479015766d63806d55e8b11aebad36dd2e4a8f4e7700334704fc5cdd5131cbd018b1324c25cc914fbe957cc71c99e303135e6edb44d4a899e
6
+ metadata.gz: ebfa89f7de5099291e8416980b7e2fd9f129f2f1c436e1ac1815cd8688bd3eaecc1f7bd8283de1dd7a9b1759c66878337cd9aa8249521d7bb4d2ad18aa457581
7
+ data.tar.gz: ec7e6e716c5c533e9013d6008deffb11741244963a2cf79869c85a5e2a3fa2e6e75e74ee66d8633fe9cb96b0b5f2e4685329f8f04c9c3ffd88a07d3a9464276d
data/lib/dimples/site.rb CHANGED
@@ -50,15 +50,8 @@ module Dimples
50
50
  end
51
51
 
52
52
  def data
53
- @data ||= source_files(key: :data, extension: 'json').to_h do |path|
54
- key = File.basename(flatten_source_path(path:, key: :data), ".json").to_sym
55
- value = begin
56
- Context.from_hash(JSON.parse(File.read(path)))
57
- rescue JSON::ParserError
58
- nil
59
- end
60
-
61
- [key, value]
53
+ @data ||= scan_path(path: @config.source_paths[:data], extension: 'json') do |path|
54
+ Context.from_hash(JSON.parse(File.read(path)))
62
55
  end
63
56
  end
64
57
 
@@ -83,6 +76,21 @@ module Dimples
83
76
  path.gsub(@config.source_paths[key] + File::SEPARATOR, '').tr(File::SEPARATOR, '_')
84
77
  end
85
78
 
79
+ def scan_path(path:, extension:, &block)
80
+ {}.tap do |data|
81
+ Dir.children(path).each do |child|
82
+ child_path = File.join(path, child)
83
+
84
+ key = File.basename(child_path, ".#{extension}").to_sym
85
+ data[key] = if File.directory?(child_path)
86
+ scan_path(path: child_path, extension:, &block)
87
+ else
88
+ yield child_path if block_given?
89
+ end
90
+ end
91
+ end
92
+ end
93
+
86
94
  def generate_posts
87
95
  posts.each { |post| generate_post(post) }
88
96
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Dimples
4
- VERSION = '13.0.2'
4
+ VERSION = '13.1.1'
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: 13.0.2
4
+ version: 13.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daniel Bogan