insider 0.1.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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: ed15027e66018294873cd41ec95c5c771cf0cf4f78230b1137ec46e3c4637533
4
+ data.tar.gz: aff3295b000958c970d20b15b09091086e0d7678c43ab17e69760cecada49ec0
5
+ SHA512:
6
+ metadata.gz: c2bd1cb4d634e604778c6eb2db9c825d45b9d3a2f98dea0e71180b97c9663c3ae106b8e5abfe3f585df241326c5ddf6f695ec6a0e7be7a155f4b2d795f4e0f14
7
+ data.tar.gz: fe51d7b831a6ee46e9b2f03db9f7a4d78aebbad1ea81748cd24c0ebea5e27eed1dc870c9b71bd52c27c33d0c6f9c38606f09ae339f9df23da7fb313f5beab983
data/CHANGELOG.md ADDED
@@ -0,0 +1,33 @@
1
+ # Changelog
2
+
3
+ All notable changes to this project will be documented in this file.
4
+
5
+ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
+ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
+
8
+ ## [Unreleased]
9
+
10
+ ## [0.1.0] - 2026-01-25
11
+
12
+ ### Added
13
+ - Initial release of Insider gem
14
+ - Template class with variable substitution functionality
15
+ - Support for `{{variable}}` syntax in templates
16
+ - `Insider[id]` class method for creating templates
17
+ - `insider(name)` instance method for creating templates
18
+ - `apply(variables)` method for template rendering
19
+ - Complete API documentation with YARD comments
20
+ - Comprehensive README with installation and usage examples
21
+ - MIT License
22
+
23
+ ### Features
24
+ - Simple and intuitive template engine
25
+ - Support for multiple variable substitutions
26
+ - Reusable template instances
27
+ - Zero dependency footprint
28
+ - Ruby 2.6.0+ compatibility
29
+
30
+ ### Documentation
31
+ - Full README with examples and API reference
32
+ - Inline code documentation with YARD tags
33
+ - Basic changelog structure
data/Gemfile ADDED
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ source "https://rubygems.org"
4
+
5
+ # Specify your gem's dependencies in insider.gemspec
6
+ gemspec
7
+
8
+ gem "rake", "~> 13.0"
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2026 Erik Olson
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
13
+ all 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
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,99 @@
1
+ # Insider
2
+
3
+ A simple and elegant Ruby gem for string template interpolation with variable substitution.
4
+
5
+ ## Features
6
+
7
+ - Simple template engine with `{{variable}}` syntax
8
+ - Lightweight and dependency-free
9
+ - Easy-to-use API for quick template rendering
10
+ - Support for multiple variable substitutions
11
+
12
+ ## Installation
13
+
14
+ Add this line to your application's Gemfile:
15
+
16
+ ```ruby
17
+ gem 'insider'
18
+ ```
19
+
20
+ And then execute:
21
+
22
+ ```bash
23
+ bundle install
24
+ ```
25
+
26
+ Or install it yourself as:
27
+
28
+ ```bash
29
+ gem install insider
30
+ ```
31
+
32
+ ## Usage
33
+ ```ruby
34
+ # first and always
35
+ require 'insider'
36
+
37
+
38
+ # 1. By using including the module within a class
39
+ class MyClass
40
+ include Insider
41
+ attr_reader :message
42
+ def initialize name
43
+ @name = name
44
+ # 2. creating an insider instance
45
+ @message = insider("my_class_id")
46
+ end
47
+ def hello!
48
+ # 3. the template can be set
49
+ @message.template = %["Hello, {{name}}!"]
50
+ # 4. and arguments applied
51
+ @message.apply(name: @name)
52
+ # 5. anywhere!
53
+ end
54
+ end
55
+
56
+ # then, by creating a class instance
57
+ @x = MyClass.new("World")
58
+ # our insider can work.
59
+ @x.hello! => "Hello, World!"
60
+
61
+ ### AND / OR ###
62
+
63
+ # Use the module directly
64
+ # 1. create an instance
65
+ @template = Insider[:my_template]
66
+ # 2. set the template
67
+ @template.template = "Hello, {{name}}!"
68
+ # 3. apply arguments
69
+ @template.apply(name: "World") => "Hello, World!"
70
+ ```
71
+
72
+ ## API Reference
73
+
74
+ ### Insider::Template
75
+
76
+ #### Methods
77
+
78
+ - `initialize(id)` - Creates a new template with the given identifier
79
+ - `template` - Getter/setter for the template string
80
+ - `apply(variables = {})` - Applies variable substitution to the template
81
+
82
+ ### Insider Module
83
+
84
+ - `Insider[id]` - Creates a new template instance with the given ID
85
+ - `insider(name)` - Instance method to create a new template
86
+
87
+ ## Development
88
+
89
+ After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
90
+
91
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
92
+
93
+ ## Contributing
94
+
95
+ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/insider.
96
+
97
+ ## License
98
+
99
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
data/Rakefile ADDED
@@ -0,0 +1,4 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "bundler/gem_tasks"
4
+ task default: %i[]
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Insider
4
+ VERSION = "0.1.0"
5
+ end
data/lib/insider.rb ADDED
@@ -0,0 +1,65 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "insider/version"
4
+
5
+ module Insider
6
+ # Custom error class for Insider gem
7
+ class Error < StandardError; end
8
+
9
+ # Template class for managing and rendering string templates with variable substitution
10
+ class Template
11
+ # @return [String, nil] The template string with {{variable}} placeholders
12
+ attr_accessor :template
13
+
14
+ # Initialize a new Template instance
15
+ # @param id [String, Integer] The identifier for the template
16
+ def initialize(id)
17
+ @id = id
18
+ end
19
+
20
+ # Apply variable substitution to the template
21
+ # @param variables [Hash] Hash of variable names and their replacement values
22
+ # @return [String] The rendered template with all placeholders replaced
23
+ # @example
24
+ # template = Template.new(:greeting)
25
+ # template.template = "Hello, {{name}}!"
26
+ # template.apply(name: "World") #=> "Hello, World!"
27
+ def apply(variables = {})
28
+ result = @template.dup
29
+ variables.each do |key, value|
30
+ result.gsub!("{{#{key}}}", value.to_s)
31
+ end
32
+ result
33
+ end
34
+ end
35
+
36
+ # Instance method to create a new Template
37
+ # @param name [String, Integer] The identifier for the template
38
+ # @return [Template] A new Template instance
39
+ def insider(name)
40
+ Template.new(name)
41
+ end
42
+
43
+ # Class method to create a new Template
44
+ # @param key [String, Integer] The identifier for the template
45
+ # @return [Template] A new Template instance
46
+ # @example
47
+ # template = Insider[:email]
48
+ # template.template = "Dear {{name}}, your order {{order_id}} is ready."
49
+ # template.apply(name: "John", order_id: "12345") #=> "Dear John, your order 12345 is ready."
50
+ def self.[](key)
51
+ Template.new(key)
52
+ end
53
+ end
54
+
55
+ ##
56
+ # @example Basic usage
57
+ # insider = Insider[:my_template]
58
+ # insider.template = "Hello, {{x}}!"
59
+ # insider.apply(x: "World!") #=> "Hello, World!"
60
+ #
61
+ # @example Multiple variables
62
+ # template = Insider[:email]
63
+ # template.template = "Dear {{name}}, your order {{order_id}} is {{status}}."
64
+ # template.apply(name: "Alice", order_id: "12345", status: "shipped")
65
+ # #=> "Dear Alice, your order 12345 is shipped."
data/sig/insider.rbs ADDED
@@ -0,0 +1,4 @@
1
+ module Insider
2
+ VERSION: String
3
+ # See the writing guide of rbs: https://github.com/ruby/rbs#guides
4
+ end
metadata ADDED
@@ -0,0 +1,57 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: insider
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Erik Olson
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2026-01-26 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: A lightweight and elegant Ruby gem for string template interpolation
14
+ using {{variable}} syntax. Perfect for generating dynamic content, emails, or any
15
+ text that requires variable substitution.
16
+ email:
17
+ - xorgnak@xorgnak.com
18
+ executables: []
19
+ extensions: []
20
+ extra_rdoc_files: []
21
+ files:
22
+ - CHANGELOG.md
23
+ - Gemfile
24
+ - LICENSE.txt
25
+ - README.md
26
+ - Rakefile
27
+ - lib/insider.rb
28
+ - lib/insider/version.rb
29
+ - sig/insider.rbs
30
+ homepage: https://github.com/xorgnak/insider
31
+ licenses:
32
+ - MIT
33
+ metadata:
34
+ allowed_push_host: https://rubygems.org
35
+ homepage_uri: https://github.com/xorgnak/insider
36
+ source_code_uri: https://github.com/xorgnak/insider
37
+ changelog_uri: https://github.com/xorgnak/insider/blob/main/CHANGELOG.md
38
+ post_install_message:
39
+ rdoc_options: []
40
+ require_paths:
41
+ - lib
42
+ required_ruby_version: !ruby/object:Gem::Requirement
43
+ requirements:
44
+ - - ">="
45
+ - !ruby/object:Gem::Version
46
+ version: 2.6.0
47
+ required_rubygems_version: !ruby/object:Gem::Requirement
48
+ requirements:
49
+ - - ">="
50
+ - !ruby/object:Gem::Version
51
+ version: '0'
52
+ requirements: []
53
+ rubygems_version: 3.3.15
54
+ signing_key:
55
+ specification_version: 4
56
+ summary: Simple Ruby template engine with variable substitution
57
+ test_files: []