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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2cae5ea3d85caa0a5a39f50c6714b20f5d17beb933e67ad7121f0b87a45b05b4
4
- data.tar.gz: 88d7ada937d4d4cbeb5ced51f057f0d0c33152ab9c5d9148ab9abb1b2c9309a9
3
+ metadata.gz: 70692d20be1e5c1f76afe4397718ceadc6c71a3457c2e408ba35ae0e11d40611
4
+ data.tar.gz: cddc23e982270efde7b2e0e9102b9d44ec71e2bd5c2863a98904b104ce1d9261
5
5
  SHA512:
6
- metadata.gz: d7e36df02d4529994fd6b277cd22cd0476481bdb06738fac615be5f8ed1565a0625e55f12b836fdff6a97473a7acba4ad875fd3b5cef30c7250a5f609fb6d5f7
7
- data.tar.gz: 60e419c7bfd92f2e710e42f004cb20f7af1b63720a8a86151e4a36067467afe136aee44fd7d585b825a72626ceaf839078e160518361fc81f5e9d9925d770ff9
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*
@@ -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
@@ -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
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module ContentFS
4
- VERSION = "0.5.1"
4
+ VERSION = "0.6.0"
5
5
 
6
6
  def self.version
7
7
  VERSION
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: contentfs
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.1
4
+ version: 0.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bryan Powell