decant 0.2.0 → 0.4.0

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: ff0fe21b57ea4db012b2cedce3a14b6e8b34186a85071525949431524f0cdc4b
4
- data.tar.gz: a6953eace2994504c734d002f8357aacb1b0563a6a31513684826888c7aefe59
3
+ metadata.gz: 7d32c0ae7327b06ec1bb31a9d48fedef546f4fad06f842a62e0f55c991b2a7ca
4
+ data.tar.gz: 5c12770cb43243d034b513d40e36684cc775a31866eb4f909751a44eb25da7c2
5
5
  SHA512:
6
- metadata.gz: 66aee785137091d9a134161e3b45cd60b85e7e8d1d4f5a9a7601d4b389b83a1f408d0b08bd15460a101379c00137d568ee6070a699b28571dfaab6aea1a8ec40
7
- data.tar.gz: fc536bc67d8a596add87ebb75ded2cd81bbbda22f93e0ae7b1b9e6de01fc46c5b565b83415a119bf4edf37552e36efc98ca91550784cfb91e54e0781e03decd7
6
+ metadata.gz: e60a0037d18fc03e59704e16c2915ea2c108e7d91e9e811c75f61aadd993e7199880257e96a86ef68681ef5004e61f21dc7c3a08cfefd3a33221fdcddff3a7e5
7
+ data.tar.gz: db533bba59b5c0ccae359cc5a8f7f8b839b9d76d4765f77d95b5141224237335a91ac91e35883a3ceb34e88b9ea97672e7b58d183c1b5f2f8aad98316398d1d2
data/CHANGELOG.md CHANGED
@@ -1,8 +1,16 @@
1
1
  # CHANGELOG
2
2
 
3
+ ## Version 0.4.0 - 2025-06-30
4
+
5
+ - Add `Content.glob` which uses its collection's glob method and returns instances of the class.
6
+
7
+ ## Version 0.3.0 - 2024-11-19
8
+
9
+ - Add `Content#relative_path` which returns a file's relative path within its collection.
10
+
3
11
  ## Version 0.2.0 - 2024-10-13
4
12
 
5
- - Add support for a content instance knowing its own `#slug` - its relative path within its collection:
13
+ - Add support for a content instance knowing its own `#slug` - its extension-less relative path within its collection:
6
14
 
7
15
  ```ruby
8
16
  Page = Decant.define(dir: 'content', ext: 'md')
data/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  [![Ruby](https://github.com/benpickles/decant/actions/workflows/main.yml/badge.svg)](https://github.com/benpickles/decant/actions/workflows/main.yml)
4
4
 
5
- A frontmatter-aware wrapper around a directory of static content.
5
+ A dependency-free frontmatter-aware framework-agnostic wrapper around a directory of static content.
6
6
 
7
7
  ## Installation
8
8
 
@@ -44,13 +44,22 @@ module Decant
44
44
  dir.glob("#{pattern}#{ext}").select { |path| path.file? }
45
45
  end
46
46
 
47
+ # The relative path of +path+ within {#dir}.
48
+ #
49
+ # @param path [Pathname]
50
+ #
51
+ # @return [String]
52
+ def relative_path_for(path)
53
+ path.relative_path_from(dir).to_s
54
+ end
55
+
47
56
  # The extension-less relative path of +path+ within {#dir}.
48
57
  #
49
58
  # @param path [Pathname]
50
59
  #
51
60
  # @return [String]
52
61
  def slug_for(path)
53
- relative_path = path.relative_path_from(dir).to_s
62
+ relative_path = relative_path_for(path)
54
63
 
55
64
  # The collection has no configured extension, files are identified by
56
65
  # their full (relative) path so there's no extension to remove.
@@ -47,6 +47,27 @@ module Decant
47
47
  end
48
48
  end
49
49
  end
50
+
51
+ # @param pattern [String]
52
+ #
53
+ # @return [Array<Content>]
54
+ def glob(pattern)
55
+ collection.glob(pattern).map { |path| new(path) }
56
+ end
57
+ end
58
+
59
+ # The relative path of the file within its collection.
60
+ #
61
+ # @example
62
+ # Page = Decant.define(dir: 'content', ext: 'md')
63
+ #
64
+ # page = Page.find('features/slugs')
65
+ # page.path.expand_path # => "/Users/dave/my-website/content/features/slugs.md"
66
+ # page.relative_path # => "features/slugs.md"
67
+ #
68
+ # @return [String]
69
+ def relative_path
70
+ self.class.collection.relative_path_for(path)
50
71
  end
51
72
 
52
73
  # The extension-less relative path of the file within its collection.
@@ -1,4 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
  module Decant
3
- VERSION = '0.2.0'
3
+ VERSION = '0.4.0'
4
4
  end
metadata CHANGED
@@ -1,16 +1,16 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: decant
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ben Pickles
8
- autorequire:
9
8
  bindir: exe
10
9
  cert_chain: []
11
- date: 2024-10-13 00:00:00.000000000 Z
10
+ date: 1980-01-02 00:00:00.000000000 Z
12
11
  dependencies: []
13
- description: A frontmatter-aware wrapper around a directory of static content
12
+ description: A dependency-free frontmatter-aware framework-agnostic wrapper around
13
+ a directory of static content
14
14
  email:
15
15
  - spideryoung@gmail.com
16
16
  executables: []
@@ -39,7 +39,6 @@ metadata:
39
39
  source_code_uri: https://github.com/benpickles/decant
40
40
  changelog_uri: https://github.com/benpickles/decant/blob/main/CHANGELOG.md
41
41
  rubygems_mfa_required: 'true'
42
- post_install_message:
43
42
  rdoc_options: []
44
43
  require_paths:
45
44
  - lib
@@ -54,8 +53,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
54
53
  - !ruby/object:Gem::Version
55
54
  version: '0'
56
55
  requirements: []
57
- rubygems_version: 3.5.16
58
- signing_key:
56
+ rubygems_version: 3.6.7
59
57
  specification_version: 4
60
- summary: A frontmatter-aware wrapper around a directory of static content
58
+ summary: A dependency-free frontmatter-aware framework-agnostic wrapper around a directory
59
+ of static content
61
60
  test_files: []