insider 0.1.0 → 0.1.1
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 +4 -4
- data/Gemfile.lock +19 -0
- data/lib/insider/version.rb +1 -1
- data/lib/insider.rb +22 -2
- metadata +3 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 6ecd3a4c56cad50da239035f9d16f05529f647e3f7c4cf5fd7c981c6d0a843b6
|
|
4
|
+
data.tar.gz: 1636285a4c6ec40eba45a7b345395c11d11992321311e1516bcbeaff77beafc2
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: d0b6e9a24fd4d9aff67295c1e87c754e26ffa6aa9d2a635a1aaa982adfb1f7b69189ee02cda3c0c1eecbdc6afe3cbb74467bd82b0aec6a3ca1578ea1a9f80ed8
|
|
7
|
+
data.tar.gz: 4879ddd6320ee3211e6313a741ab00f97eccae0b4dd78230f3b877b13898613dadeeb051bd9a56f4d802f5eec33a21e548622eed484c46b6aee24f88c64565c1
|
data/Gemfile.lock
ADDED
data/lib/insider/version.rb
CHANGED
data/lib/insider.rb
CHANGED
|
@@ -6,17 +6,34 @@ module Insider
|
|
|
6
6
|
# Custom error class for Insider gem
|
|
7
7
|
class Error < StandardError; end
|
|
8
8
|
|
|
9
|
+
@@TEMPLATE = {
|
|
10
|
+
before: "{{before}} {{prompt}}",
|
|
11
|
+
after: "{{prompt}} {{after}}",
|
|
12
|
+
above: "{{above}}\n{{prompt}}",
|
|
13
|
+
below: "{{prompt}}\n{{below}}"
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
def self.template
|
|
17
|
+
@@TEMPLATE
|
|
18
|
+
end
|
|
19
|
+
|
|
9
20
|
# Template class for managing and rendering string templates with variable substitution
|
|
10
21
|
class Template
|
|
11
22
|
# @return [String, nil] The template string with {{variable}} placeholders
|
|
12
|
-
attr_accessor :template
|
|
23
|
+
attr_accessor :template, :prompt, :variables
|
|
13
24
|
|
|
14
25
|
# Initialize a new Template instance
|
|
15
26
|
# @param id [String, Integer] The identifier for the template
|
|
16
27
|
def initialize(id)
|
|
17
28
|
@id = id
|
|
29
|
+
@prompt = ""
|
|
30
|
+
@variables = {}
|
|
18
31
|
end
|
|
19
32
|
|
|
33
|
+
def using k
|
|
34
|
+
@template = Insider.template[k.to_sym]
|
|
35
|
+
end
|
|
36
|
+
|
|
20
37
|
# Apply variable substitution to the template
|
|
21
38
|
# @param variables [Hash] Hash of variable names and their replacement values
|
|
22
39
|
# @return [String] The rendered template with all placeholders replaced
|
|
@@ -26,7 +43,10 @@ module Insider
|
|
|
26
43
|
# template.apply(name: "World") #=> "Hello, World!"
|
|
27
44
|
def apply(variables = {})
|
|
28
45
|
result = @template.dup
|
|
29
|
-
variables.
|
|
46
|
+
@variables.merge({
|
|
47
|
+
prompt: @prompt,
|
|
48
|
+
id: @id
|
|
49
|
+
}).merge(variables).each_pair do |key, value|
|
|
30
50
|
result.gsub!("{{#{key}}}", value.to_s)
|
|
31
51
|
end
|
|
32
52
|
result
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: insider
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.1.
|
|
4
|
+
version: 0.1.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Erik Olson
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2026-01-
|
|
11
|
+
date: 2026-01-28 00:00:00.000000000 Z
|
|
12
12
|
dependencies: []
|
|
13
13
|
description: A lightweight and elegant Ruby gem for string template interpolation
|
|
14
14
|
using {{variable}} syntax. Perfect for generating dynamic content, emails, or any
|
|
@@ -21,6 +21,7 @@ extra_rdoc_files: []
|
|
|
21
21
|
files:
|
|
22
22
|
- CHANGELOG.md
|
|
23
23
|
- Gemfile
|
|
24
|
+
- Gemfile.lock
|
|
24
25
|
- LICENSE.txt
|
|
25
26
|
- README.md
|
|
26
27
|
- Rakefile
|