contentfs 0.5.1 → 0.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +6 -0
- data/lib/contentfs/content.rb +4 -3
- data/lib/contentfs/database.rb +7 -7
- data/lib/contentfs/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 70692d20be1e5c1f76afe4397718ceadc6c71a3457c2e408ba35ae0e11d40611
|
4
|
+
data.tar.gz: cddc23e982270efde7b2e0e9102b9d44ec71e2bd5c2863a98904b104ce1d9261
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4677403196321b02096ea81e982e5499602b7f333cf826780fd407634b81da37b625fa1a0c1bbeb51c14dcb67dcc1cfbdc6fa6078394411464de3d8d1c12a9f7
|
7
|
+
data.tar.gz: b6caaa759c1ea97d5ab945327b2dee30ba8930431cbe74bc79a3a6aad1bf8fe8bb3b7f830d7cbafc6d95c89213adb0468687589677ce92787a1d27467b0898df
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,9 @@
|
|
1
|
+
## [v0.6.0](https://github.com/metabahn/contentfs/releases/tag/v0.6.0)
|
2
|
+
|
3
|
+
*released on 2021-04-02*
|
4
|
+
|
5
|
+
* `add` [#12](https://github.com/metabahn/contentfs/pull/12) Provide a pattern for preprocessing content ([bryanp](https://github.com/bryanp))
|
6
|
+
|
1
7
|
## [v0.5.1](https://github.com/metabahn/contentfs/releases/tag/v0.5.1)
|
2
8
|
|
3
9
|
*released on 2021-04-02*
|
data/lib/contentfs/content.rb
CHANGED
@@ -12,8 +12,8 @@ module ContentFS
|
|
12
12
|
#
|
13
13
|
class Content
|
14
14
|
class << self
|
15
|
-
def load(path, database:, metadata: {}, namespace: [])
|
16
|
-
new(path: path, database: database, metadata: metadata, namespace: namespace)
|
15
|
+
def load(path, database:, metadata: {}, namespace: [], &block)
|
16
|
+
new(path: path, database: database, metadata: metadata, namespace: namespace, &block)
|
17
17
|
end
|
18
18
|
end
|
19
19
|
|
@@ -22,7 +22,7 @@ module ContentFS
|
|
22
22
|
|
23
23
|
attr_reader :format, :prefix, :slug, :metadata, :namespace
|
24
24
|
|
25
|
-
def initialize(path:, database:, metadata: {}, namespace: [])
|
25
|
+
def initialize(path:, database:, metadata: {}, namespace: [], &block)
|
26
26
|
path = Pathname.new(path)
|
27
27
|
extname = path.extname
|
28
28
|
name = path.basename(extname)
|
@@ -34,6 +34,7 @@ module ContentFS
|
|
34
34
|
@database = database
|
35
35
|
|
36
36
|
content = path.read
|
37
|
+
content = block.call(content) if block
|
37
38
|
@metadata = metadata.merge(parse_metadata(content))
|
38
39
|
@content = content.gsub(FRONT_MATTER_REGEXP, "")
|
39
40
|
end
|
data/lib/contentfs/database.rb
CHANGED
@@ -11,8 +11,8 @@ module ContentFS
|
|
11
11
|
#
|
12
12
|
class Database
|
13
13
|
class << self
|
14
|
-
def load(path, parent: nil, namespace: [], root: true)
|
15
|
-
new(path: path, parent: parent, namespace: namespace, root: root)
|
14
|
+
def load(path, parent: nil, namespace: [], root: true, &block)
|
15
|
+
new(path: path, parent: parent, namespace: namespace, root: root, &block)
|
16
16
|
end
|
17
17
|
end
|
18
18
|
|
@@ -20,7 +20,7 @@ module ContentFS
|
|
20
20
|
|
21
21
|
attr_reader :prefix, :slug, :namespace, :metadata
|
22
22
|
|
23
|
-
def initialize(path:, parent: nil, namespace: [], root: false)
|
23
|
+
def initialize(path:, parent: nil, namespace: [], root: false, &block)
|
24
24
|
path = Pathname.new(path)
|
25
25
|
name = path.basename(path.extname)
|
26
26
|
prefix, remainder = Prefix.build(name)
|
@@ -44,7 +44,7 @@ module ContentFS
|
|
44
44
|
content_path = path.join.glob("_content.*")[0]
|
45
45
|
|
46
46
|
@content = if content_path&.exist?
|
47
|
-
Content.load(content_path, database: self, metadata: @metadata, namespace: @namespace)
|
47
|
+
Content.load(content_path, database: self, metadata: @metadata, namespace: @namespace, &block)
|
48
48
|
end
|
49
49
|
|
50
50
|
children, nested, includes = {}, {}, {}
|
@@ -53,14 +53,14 @@ module ContentFS
|
|
53
53
|
next if underscored && path.directory?
|
54
54
|
|
55
55
|
if path.directory?
|
56
|
-
database = Database.load(path, parent: self, namespace: @namespace, root: false)
|
56
|
+
database = Database.load(path, parent: self, namespace: @namespace, root: false, &block)
|
57
57
|
nested[database.slug] = database
|
58
58
|
elsif underscored
|
59
|
-
content = Content.load(path, database: self, metadata: @metadata, namespace: @namespace)
|
59
|
+
content = Content.load(path, database: self, metadata: @metadata, namespace: @namespace, &block)
|
60
60
|
|
61
61
|
includes[content.slug.to_s[1..].to_sym] = content
|
62
62
|
else
|
63
|
-
content = Content.load(path, database: self, metadata: @metadata, namespace: @namespace)
|
63
|
+
content = Content.load(path, database: self, metadata: @metadata, namespace: @namespace, &block)
|
64
64
|
|
65
65
|
children[content.slug] = content
|
66
66
|
end
|
data/lib/contentfs/version.rb
CHANGED