rpg-callouts 1.0.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 +7 -0
- data/LICENSE +21 -0
- data/README.md +53 -0
- data/callouts/config.yml +12 -0
- data/lib/rpg-callouts.rb +65 -0
- data/lib/rpg_callouts/merge.rb +48 -0
- data/lib/rpg_callouts/version.rb +5 -0
- metadata +64 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: 0e4733dd33bfb3ad9281033115cca37191c55c30c582980e7bdf08970ddba054
|
|
4
|
+
data.tar.gz: d4ce7d22fa58b6a6b16132f3616f2fca068db2868a3fc5ad1a33a27ed6787c02
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: 667078f8795ae6b71a68663ef92bc403410b5f26fb37bf407cf1a844b88219c0faa3badffb0ffeace5e721327d94dcb22f568a996e78977a63f919c8d7c901ed
|
|
7
|
+
data.tar.gz: 2e49c8180b0b2f741d11e123013b877a0c6502a7a8616b09b870270b8e573cb46ca722c95e157099027ad2e5b7b5bb3cd878b604232860f411561dae52b721bf
|
data/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Directsun Games
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
data/README.md
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
# rpg-callouts
|
|
2
|
+
|
|
3
|
+
Stand-alone Jekyll plugin that merges Just the Docs callout definitions into the host site config.
|
|
4
|
+
|
|
5
|
+
| Class | Title | Color |
|
|
6
|
+
| --- | --- | --- |
|
|
7
|
+
| `monster` | Monster | red |
|
|
8
|
+
| `monster-no-title` | — | red |
|
|
9
|
+
| `item` | Item | blue |
|
|
10
|
+
|
|
11
|
+
Site `_config.yml` wins if you redefine the same callout names. Merge is in memory only — nothing is copied into the site source.
|
|
12
|
+
|
|
13
|
+
## Install
|
|
14
|
+
|
|
15
|
+
```ruby
|
|
16
|
+
group :jekyll_plugins do
|
|
17
|
+
gem "rpg-callouts", path: "../rpg-callouts"
|
|
18
|
+
end
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
```yaml
|
|
22
|
+
# _config.yml
|
|
23
|
+
plugins:
|
|
24
|
+
- rpg-callouts
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
## Usage
|
|
28
|
+
|
|
29
|
+
```markdown
|
|
30
|
+
{: .monster}
|
|
31
|
+
> **Goblin**
|
|
32
|
+
>
|
|
33
|
+
> AC 6 [13], HD 1-1 (3hp), Att 1 × spear (1d6)
|
|
34
|
+
|
|
35
|
+
{: .item}
|
|
36
|
+
> **Silver Key**
|
|
37
|
+
>
|
|
38
|
+
> Opens the locked door in area 3.
|
|
39
|
+
|
|
40
|
+
{: .monster-no-title}
|
|
41
|
+
> Same red styling, no "Monster" heading.
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
## Options
|
|
45
|
+
|
|
46
|
+
```yaml
|
|
47
|
+
# _config.yml
|
|
48
|
+
rpg_callouts:
|
|
49
|
+
enabled: true # set false to skip
|
|
50
|
+
config_file: callouts.yml # optional alternate YAML (absolute or site-relative)
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
Default definitions live in `callouts/config.yml` inside this gem.
|
data/callouts/config.yml
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
# Callout definitions for Just the Docs.
|
|
2
|
+
# Merged into the host site config in memory (never copied into the site).
|
|
3
|
+
# Keys already set in the site `_config.yml` win.
|
|
4
|
+
callouts:
|
|
5
|
+
monster:
|
|
6
|
+
title: Monster
|
|
7
|
+
color: red
|
|
8
|
+
monster-no-title:
|
|
9
|
+
color: red
|
|
10
|
+
item:
|
|
11
|
+
title: Item
|
|
12
|
+
color: blue
|
data/lib/rpg-callouts.rb
ADDED
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "yaml"
|
|
4
|
+
require "jekyll"
|
|
5
|
+
|
|
6
|
+
require_relative "rpg_callouts/version"
|
|
7
|
+
require_relative "rpg_callouts/merge"
|
|
8
|
+
|
|
9
|
+
module RpgCallouts
|
|
10
|
+
module_function
|
|
11
|
+
|
|
12
|
+
def root
|
|
13
|
+
File.expand_path("..", __dir__)
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def default_config_path
|
|
17
|
+
File.join(root, "callouts", "config.yml")
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
def apply!(site)
|
|
21
|
+
options = site.config["rpg_callouts"] || {}
|
|
22
|
+
return if options["enabled"] == false
|
|
23
|
+
|
|
24
|
+
path = options["config_file"] || default_config_path
|
|
25
|
+
fragment = load_fragment(path, site)
|
|
26
|
+
return if fragment.empty?
|
|
27
|
+
|
|
28
|
+
RpgCallouts::Merge.into_site!(site, fragment)
|
|
29
|
+
Jekyll.logger.info("rpg-callouts:", "merged callouts into site config")
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
def load_fragment(path, site)
|
|
33
|
+
resolved = resolve_config_path(path, site)
|
|
34
|
+
raise ArgumentError, "rpg-callouts config missing: #{resolved}" unless File.file?(resolved)
|
|
35
|
+
|
|
36
|
+
data = YAML.safe_load(
|
|
37
|
+
File.read(resolved),
|
|
38
|
+
permitted_classes: [Date, Time, Symbol],
|
|
39
|
+
aliases: true
|
|
40
|
+
)
|
|
41
|
+
raise ArgumentError, "rpg-callouts config must be a mapping: #{resolved}" unless data.is_a?(Hash)
|
|
42
|
+
|
|
43
|
+
data
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
def resolve_config_path(path, site)
|
|
47
|
+
return path if absolute_path?(path)
|
|
48
|
+
return default_config_path if path == default_config_path
|
|
49
|
+
|
|
50
|
+
candidates = [
|
|
51
|
+
File.expand_path(path, site.source),
|
|
52
|
+
File.expand_path(path, Dir.pwd),
|
|
53
|
+
File.expand_path(path, root)
|
|
54
|
+
]
|
|
55
|
+
candidates.find { |candidate| File.file?(candidate) } || candidates.first
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
def absolute_path?(path)
|
|
59
|
+
path.start_with?(File::SEPARATOR) || path.match?(/\A[A-Za-z]:[\\\/]/)
|
|
60
|
+
end
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
Jekyll::Hooks.register :site, :after_reset do |site|
|
|
64
|
+
RpgCallouts.apply!(site)
|
|
65
|
+
end
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module RpgCallouts
|
|
4
|
+
# Deep-merges gem/config fragments into `site.config`.
|
|
5
|
+
# Later overlays win within the fragment; site `_config.yml` wins overall.
|
|
6
|
+
module Merge
|
|
7
|
+
module_function
|
|
8
|
+
|
|
9
|
+
def into_site!(site, fragment)
|
|
10
|
+
fragment.each do |key, value|
|
|
11
|
+
site.config[key] = deep_merge(value, site.config[key])
|
|
12
|
+
end
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
# Overlay wins on leaf conflicts. Hashes merge recursively.
|
|
16
|
+
def deep_merge(base, overlay)
|
|
17
|
+
return dup_value(base) if overlay.nil?
|
|
18
|
+
return dup_value(overlay) unless hash?(base) && hash?(overlay)
|
|
19
|
+
|
|
20
|
+
result = stringify_keys(base)
|
|
21
|
+
stringify_keys(overlay).each do |key, value|
|
|
22
|
+
result[key] = result.key?(key) ? deep_merge(result[key], value) : dup_value(value)
|
|
23
|
+
end
|
|
24
|
+
result
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
def hash?(value)
|
|
28
|
+
value.is_a?(Hash)
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
def stringify_keys(hash)
|
|
32
|
+
hash.each_with_object({}) do |(key, value), out|
|
|
33
|
+
out[key.to_s] = value
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
def dup_value(value)
|
|
38
|
+
case value
|
|
39
|
+
when Hash
|
|
40
|
+
value.each_with_object({}) { |(key, child), out| out[key.to_s] = dup_value(child) }
|
|
41
|
+
when Array
|
|
42
|
+
value.map { |child| dup_value(child) }
|
|
43
|
+
else
|
|
44
|
+
value
|
|
45
|
+
end
|
|
46
|
+
end
|
|
47
|
+
end
|
|
48
|
+
end
|
metadata
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: rpg-callouts
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 1.0.0
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- directsun
|
|
8
|
+
bindir: bin
|
|
9
|
+
cert_chain: []
|
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
|
11
|
+
dependencies:
|
|
12
|
+
- !ruby/object:Gem::Dependency
|
|
13
|
+
name: jekyll
|
|
14
|
+
requirement: !ruby/object:Gem::Requirement
|
|
15
|
+
requirements:
|
|
16
|
+
- - ">="
|
|
17
|
+
- !ruby/object:Gem::Version
|
|
18
|
+
version: '3.8'
|
|
19
|
+
- - "<"
|
|
20
|
+
- !ruby/object:Gem::Version
|
|
21
|
+
version: '5.0'
|
|
22
|
+
type: :runtime
|
|
23
|
+
prerelease: false
|
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
25
|
+
requirements:
|
|
26
|
+
- - ">="
|
|
27
|
+
- !ruby/object:Gem::Version
|
|
28
|
+
version: '3.8'
|
|
29
|
+
- - "<"
|
|
30
|
+
- !ruby/object:Gem::Version
|
|
31
|
+
version: '5.0'
|
|
32
|
+
email: []
|
|
33
|
+
executables: []
|
|
34
|
+
extensions: []
|
|
35
|
+
extra_rdoc_files: []
|
|
36
|
+
files:
|
|
37
|
+
- LICENSE
|
|
38
|
+
- README.md
|
|
39
|
+
- callouts/config.yml
|
|
40
|
+
- lib/rpg-callouts.rb
|
|
41
|
+
- lib/rpg_callouts/merge.rb
|
|
42
|
+
- lib/rpg_callouts/version.rb
|
|
43
|
+
homepage: https://github.com/sunflowermans/rpg-callouts
|
|
44
|
+
licenses:
|
|
45
|
+
- MIT
|
|
46
|
+
metadata: {}
|
|
47
|
+
rdoc_options: []
|
|
48
|
+
require_paths:
|
|
49
|
+
- lib
|
|
50
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
51
|
+
requirements:
|
|
52
|
+
- - ">="
|
|
53
|
+
- !ruby/object:Gem::Version
|
|
54
|
+
version: '3.0'
|
|
55
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
56
|
+
requirements:
|
|
57
|
+
- - ">="
|
|
58
|
+
- !ruby/object:Gem::Version
|
|
59
|
+
version: '0'
|
|
60
|
+
requirements: []
|
|
61
|
+
rubygems_version: 3.6.9
|
|
62
|
+
specification_version: 4
|
|
63
|
+
summary: Just the Docs callouts for RPG adventures (monster, item).
|
|
64
|
+
test_files: []
|