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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ed15027e66018294873cd41ec95c5c771cf0cf4f78230b1137ec46e3c4637533
4
- data.tar.gz: aff3295b000958c970d20b15b09091086e0d7678c43ab17e69760cecada49ec0
3
+ metadata.gz: 6ecd3a4c56cad50da239035f9d16f05529f647e3f7c4cf5fd7c981c6d0a843b6
4
+ data.tar.gz: 1636285a4c6ec40eba45a7b345395c11d11992321311e1516bcbeaff77beafc2
5
5
  SHA512:
6
- metadata.gz: c2bd1cb4d634e604778c6eb2db9c825d45b9d3a2f98dea0e71180b97c9663c3ae106b8e5abfe3f585df241326c5ddf6f695ec6a0e7be7a155f4b2d795f4e0f14
7
- data.tar.gz: fe51d7b831a6ee46e9b2f03db9f7a4d78aebbad1ea81748cd24c0ebea5e27eed1dc870c9b71bd52c27c33d0c6f9c38606f09ae339f9df23da7fb313f5beab983
6
+ metadata.gz: d0b6e9a24fd4d9aff67295c1e87c754e26ffa6aa9d2a635a1aaa982adfb1f7b69189ee02cda3c0c1eecbdc6afe3cbb74467bd82b0aec6a3ca1578ea1a9f80ed8
7
+ data.tar.gz: 4879ddd6320ee3211e6313a741ab00f97eccae0b4dd78230f3b877b13898613dadeeb051bd9a56f4d802f5eec33a21e548622eed484c46b6aee24f88c64565c1
data/Gemfile.lock ADDED
@@ -0,0 +1,19 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ insider (0.1.0)
5
+
6
+ GEM
7
+ remote: https://rubygems.org/
8
+ specs:
9
+ rake (13.3.1)
10
+
11
+ PLATFORMS
12
+ x86_64-linux
13
+
14
+ DEPENDENCIES
15
+ insider!
16
+ rake (~> 13.0)
17
+
18
+ BUNDLED WITH
19
+ 2.3.15
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Insider
4
- VERSION = "0.1.0"
4
+ VERSION = "0.1.1"
5
5
  end
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.each do |key, value|
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.0
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-26 00:00:00.000000000 Z
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