decant 0.2.0 → 0.3.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 +5 -1
- data/README.md +1 -1
- data/lib/decant/collection.rb +10 -1
- data/lib/decant/content.rb +14 -0
- data/lib/decant/version.rb +1 -1
- metadata +6 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 90e12a57f5b2470e597cf6070cedd064bd26bb1680fa9e14a337a9ec8c712888
|
4
|
+
data.tar.gz: 9ebce2f4febbfa2449cf671ab75781463df89b37e63359320014710dd613baae
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: df551129f9cbf4222331f01cad5ddf4651fa631ad5a6d7b2fa2dc4f83f7f908e12d4c958278bf96a3e59d4e6cd019d788d6cc4b4fec7dfeb38fd439eb1cd724f
|
7
|
+
data.tar.gz: 351ffd284c342a388f324019d09c97bb19d8761b0f90457cb49aa4d855e54c1c2f5c54960303e4d30b82eb75876a3a2f25828e281df57f58954d7136528ebc77
|
data/CHANGELOG.md
CHANGED
@@ -1,8 +1,12 @@
|
|
1
1
|
# CHANGELOG
|
2
2
|
|
3
|
+
## Version 0.3.0 - 2024-11-19
|
4
|
+
|
5
|
+
- Add `Content#relative_path` which returns a file's relative path within its collection.
|
6
|
+
|
3
7
|
## Version 0.2.0 - 2024-10-13
|
4
8
|
|
5
|
-
- Add support for a content instance knowing its own `#slug` - its relative path within its collection:
|
9
|
+
- Add support for a content instance knowing its own `#slug` - its extension-less relative path within its collection:
|
6
10
|
|
7
11
|
```ruby
|
8
12
|
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
|
|
data/lib/decant/collection.rb
CHANGED
@@ -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
|
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.
|
data/lib/decant/content.rb
CHANGED
@@ -49,6 +49,20 @@ module Decant
|
|
49
49
|
end
|
50
50
|
end
|
51
51
|
|
52
|
+
# The relative path of the file within its collection.
|
53
|
+
#
|
54
|
+
# @example
|
55
|
+
# Page = Decant.define(dir: 'content', ext: 'md')
|
56
|
+
#
|
57
|
+
# page = Page.find('features/slugs')
|
58
|
+
# page.path.expand_path # => "/Users/dave/my-website/content/features/slugs.md"
|
59
|
+
# page.relative_path # => "features/slugs.md"
|
60
|
+
#
|
61
|
+
# @return [String]
|
62
|
+
def relative_path
|
63
|
+
self.class.collection.relative_path_for(path)
|
64
|
+
end
|
65
|
+
|
52
66
|
# The extension-less relative path of the file within its collection.
|
53
67
|
#
|
54
68
|
# @example
|
data/lib/decant/version.rb
CHANGED
metadata
CHANGED
@@ -1,16 +1,17 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: decant
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ben Pickles
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-
|
11
|
+
date: 2024-11-19 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
|
-
description: A frontmatter-aware wrapper around
|
13
|
+
description: A dependency-free frontmatter-aware framework-agnostic wrapper around
|
14
|
+
a directory of static content
|
14
15
|
email:
|
15
16
|
- spideryoung@gmail.com
|
16
17
|
executables: []
|
@@ -57,5 +58,6 @@ requirements: []
|
|
57
58
|
rubygems_version: 3.5.16
|
58
59
|
signing_key:
|
59
60
|
specification_version: 4
|
60
|
-
summary: A frontmatter-aware wrapper around a directory
|
61
|
+
summary: A dependency-free frontmatter-aware framework-agnostic wrapper around a directory
|
62
|
+
of static content
|
61
63
|
test_files: []
|