stringento 2.0.0 → 2.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +2 -0
- data/.rubocop.yml +4 -3
- data/.ruby-version +1 -1
- data/.travis.yml +8 -4
- data/CHANGELOG.md +12 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/README.md +10 -9
- data/Rakefile +17 -0
- data/exe/.gitkeep +0 -0
- data/lib/stringento.rb +37 -1
- data/lib/stringento/version.rb +1 -1
- data/spec/examples/custom_formatter.rb +1 -1
- data/spec/stringento/formatter_spec.rb +1 -1
- data/spec/stringento/placeholder_spec.rb +1 -1
- data/spec/stringento/resolver_spec.rb +1 -1
- data/spec/stringento/template_spec.rb +1 -1
- data/spec/{stringento/stringento_spec.rb → stringento_spec.rb} +1 -1
- data/stringento.gemspec +16 -8
- metadata +33 -27
- data/Gemfile.lock +0 -123
- data/lib/stringento/stringento.rb +0 -46
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1442915dade623b9138576f4cb9cefbdeec02da6914232a7ca090f6325242777
|
4
|
+
data.tar.gz: 4750a15ac7da868887918d527ae46772288fdfb7ac2c9230f82994c41be69e6a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7b2d0b64265096bd92e0711a99f25f7208ef4e5d7ea20ab09063ea9045a196ac7cffb13524119fee709193027c378f80aabc1939431d207e2ff6f20272166993
|
7
|
+
data.tar.gz: c9a4f97bc857a15c1788150a6602ea53a8e269942150edc50b1fe149a67981770794124259b70864b7dea5bbf42e2a61b40ef6419c50b86cff06e90224b3b3b9
|
data/.rubocop.yml
CHANGED
data/.ruby-version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
2.6.
|
1
|
+
2.6.6
|
data/.travis.yml
CHANGED
@@ -4,10 +4,9 @@ env:
|
|
4
4
|
language: ruby
|
5
5
|
rvm:
|
6
6
|
# Build on the latest stable of all supported Rubies (https://www.ruby-lang.org/en/downloads/):
|
7
|
-
- 2.
|
8
|
-
- 2.
|
9
|
-
- 2.
|
10
|
-
- 2.6.0
|
7
|
+
- 2.5.8
|
8
|
+
- 2.6.6
|
9
|
+
- 2.7.1
|
11
10
|
cache: bundler
|
12
11
|
before_script:
|
13
12
|
- curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
|
@@ -18,3 +17,8 @@ script:
|
|
18
17
|
- bundle exec rspec spec --format documentation
|
19
18
|
after_script:
|
20
19
|
- ./cc-test-reporter after-build --exit-code $TRAVIS_TEST_RESULT
|
20
|
+
addons:
|
21
|
+
# https://docs.travis-ci.com/user/uploading-artifacts/
|
22
|
+
artifacts:
|
23
|
+
paths:
|
24
|
+
- Gemfile.lock
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,15 @@
|
|
1
|
+
# 2.1.0 (August 22nd, 2020)
|
2
|
+
|
3
|
+
Changes:
|
4
|
+
|
5
|
+
* Removed support for < Ruby 2.5
|
6
|
+
|
7
|
+
Development:
|
8
|
+
|
9
|
+
* Updated dependencies
|
10
|
+
* Removed Gemfile.lock
|
11
|
+
* Installed Rake / Publish Steps
|
12
|
+
|
1
13
|
# 2.0.0 (April 7th, 2019)
|
2
14
|
|
3
15
|
*Breaking change in the formatter signature*
|
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,74 @@
|
|
1
|
+
# Contributor Covenant Code of Conduct
|
2
|
+
|
3
|
+
## Our Pledge
|
4
|
+
|
5
|
+
In the interest of fostering an open and welcoming environment, we as
|
6
|
+
contributors and maintainers pledge to making participation in our project and
|
7
|
+
our community a harassment-free experience for everyone, regardless of age, body
|
8
|
+
size, disability, ethnicity, gender identity and expression, level of experience,
|
9
|
+
nationality, personal appearance, race, religion, or sexual identity and
|
10
|
+
orientation.
|
11
|
+
|
12
|
+
## Our Standards
|
13
|
+
|
14
|
+
Examples of behavior that contributes to creating a positive environment
|
15
|
+
include:
|
16
|
+
|
17
|
+
* Using welcoming and inclusive language
|
18
|
+
* Being respectful of differing viewpoints and experiences
|
19
|
+
* Gracefully accepting constructive criticism
|
20
|
+
* Focusing on what is best for the community
|
21
|
+
* Showing empathy towards other community members
|
22
|
+
|
23
|
+
Examples of unacceptable behavior by participants include:
|
24
|
+
|
25
|
+
* The use of sexualized language or imagery and unwelcome sexual attention or
|
26
|
+
advances
|
27
|
+
* Trolling, insulting/derogatory comments, and personal or political attacks
|
28
|
+
* Public or private harassment
|
29
|
+
* Publishing others' private information, such as a physical or electronic
|
30
|
+
address, without explicit permission
|
31
|
+
* Other conduct which could reasonably be considered inappropriate in a
|
32
|
+
professional setting
|
33
|
+
|
34
|
+
## Our Responsibilities
|
35
|
+
|
36
|
+
Project maintainers are responsible for clarifying the standards of acceptable
|
37
|
+
behavior and are expected to take appropriate and fair corrective action in
|
38
|
+
response to any instances of unacceptable behavior.
|
39
|
+
|
40
|
+
Project maintainers have the right and responsibility to remove, edit, or
|
41
|
+
reject comments, commits, code, wiki edits, issues, and other contributions
|
42
|
+
that are not aligned to this Code of Conduct, or to ban temporarily or
|
43
|
+
permanently any contributor for other behaviors that they deem inappropriate,
|
44
|
+
threatening, offensive, or harmful.
|
45
|
+
|
46
|
+
## Scope
|
47
|
+
|
48
|
+
This Code of Conduct applies both within project spaces and in public spaces
|
49
|
+
when an individual is representing the project or its community. Examples of
|
50
|
+
representing a project or community include using an official project e-mail
|
51
|
+
address, posting via an official social media account, or acting as an appointed
|
52
|
+
representative at an online or offline event. Representation of a project may be
|
53
|
+
further defined and clarified by project maintainers.
|
54
|
+
|
55
|
+
## Enforcement
|
56
|
+
|
57
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
58
|
+
reported by contacting the project team at oss@bluemarblepayroll.com. All
|
59
|
+
complaints will be reviewed and investigated and will result in a response that
|
60
|
+
is deemed necessary and appropriate to the circumstances. The project team is
|
61
|
+
obligated to maintain confidentiality with regard to the reporter of an incident.
|
62
|
+
Further details of specific enforcement policies may be posted separately.
|
63
|
+
|
64
|
+
Project maintainers who do not follow or enforce the Code of Conduct in good
|
65
|
+
faith may face temporary or permanent repercussions as determined by other
|
66
|
+
members of the project's leadership.
|
67
|
+
|
68
|
+
## Attribution
|
69
|
+
|
70
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
|
71
|
+
available at [http://contributor-covenant.org/version/1/4][version]
|
72
|
+
|
73
|
+
[homepage]: http://contributor-covenant.org
|
74
|
+
[version]: http://contributor-covenant.org/version/1/4/
|
data/README.md
CHANGED
@@ -75,7 +75,7 @@ Another extendable aspect is formatting. Consider a basic example where we want
|
|
75
75
|
In this case we can use a custom formatter called yes_no_unknown that understands how to do this for us. The custom formatter is controlled externally from this library, which means you can use this for whatever purpose you see fit. Here would be an example implementation of this custom formatter:
|
76
76
|
|
77
77
|
```ruby
|
78
|
-
class CustomFormatter <
|
78
|
+
class CustomFormatter < Stringento::Formatter
|
79
79
|
def yes_no_unknown_formatter(value, _arg)
|
80
80
|
if value.nil?
|
81
81
|
'Unknown'
|
@@ -102,7 +102,7 @@ end
|
|
102
102
|
example = 'The fox is quick: {fox.quick::yes_no_unknown}'
|
103
103
|
input = { fox: { quick: true } }
|
104
104
|
|
105
|
-
result = evaluate(example, input, resolver: NestedHashResolver.new, formatter: CustomFormatter.new)
|
105
|
+
result = Stringento.evaluate(example, input, resolver: NestedHashResolver.new, formatter: CustomFormatter.new)
|
106
106
|
```
|
107
107
|
|
108
108
|
The ```result``` variable should now be: 'The fox is quick: Yes'
|
@@ -148,14 +148,15 @@ Note: ensure you have proper authorization before trying to publish new versions
|
|
148
148
|
After code changes have successfully gone through the Pull Request review process then the following steps should be followed for publishing new versions:
|
149
149
|
|
150
150
|
1. Merge Pull Request into master
|
151
|
-
2. Update
|
152
|
-
3. Install dependencies:
|
153
|
-
4. Update
|
151
|
+
2. Update `lib/stringento/version.rb` using [semantic versioning](https://semver.org/)
|
152
|
+
3. Install dependencies: `bundle`
|
153
|
+
4. Update `CHANGELOG.md` with release notes
|
154
154
|
5. Commit & push master to remote and ensure CI builds master successfully
|
155
|
-
6.
|
156
|
-
|
157
|
-
|
158
|
-
|
155
|
+
6. Run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
156
|
+
|
157
|
+
## Code of Conduct
|
158
|
+
|
159
|
+
Everyone interacting in this codebase, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/bluemarblepayroll/stringento/blob/master/CODE_OF_CONDUCT.md).
|
159
160
|
|
160
161
|
## License
|
161
162
|
|
data/Rakefile
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
#
|
4
|
+
# Copyright (c) 2020-present, Blue Marble Payroll, LLC
|
5
|
+
#
|
6
|
+
# This source code is licensed under the MIT license found in the
|
7
|
+
# LICENSE file in the root directory of this source tree.
|
8
|
+
#
|
9
|
+
|
10
|
+
require 'bundler/gem_tasks'
|
11
|
+
require 'rspec/core/rake_task'
|
12
|
+
require 'rubocop/rake_task'
|
13
|
+
|
14
|
+
RSpec::Core::RakeTask.new(:spec)
|
15
|
+
RuboCop::RakeTask.new
|
16
|
+
|
17
|
+
task default: %i[rubocop spec]
|
data/exe/.gitkeep
ADDED
File without changes
|
data/lib/stringento.rb
CHANGED
@@ -7,4 +7,40 @@
|
|
7
7
|
# LICENSE file in the root directory of this source tree.
|
8
8
|
#
|
9
9
|
|
10
|
-
require_relative 'stringento/
|
10
|
+
require_relative 'stringento/formatter'
|
11
|
+
require_relative 'stringento/placeholder'
|
12
|
+
require_relative 'stringento/resolver'
|
13
|
+
require_relative 'stringento/template'
|
14
|
+
|
15
|
+
# Top-level API for main external consumption. It is better to use this than instantiating
|
16
|
+
# your own Template objects because this top-level object will cache Template objects based
|
17
|
+
# on the expression. It also provides less default resolver and formatter instantiations.
|
18
|
+
module Stringento
|
19
|
+
class << self
|
20
|
+
def evaluate(expression, input, resolver: nil, formatter: nil)
|
21
|
+
template(expression).evaluate(
|
22
|
+
input,
|
23
|
+
resolver: (resolver || default_resolver),
|
24
|
+
formatter: (formatter || default_formatter)
|
25
|
+
)
|
26
|
+
end
|
27
|
+
|
28
|
+
private
|
29
|
+
|
30
|
+
def templates
|
31
|
+
@templates ||= {}
|
32
|
+
end
|
33
|
+
|
34
|
+
def template(expression)
|
35
|
+
templates[expression.to_s] ||= Template.new(expression)
|
36
|
+
end
|
37
|
+
|
38
|
+
def default_resolver
|
39
|
+
@default_resolver ||= Resolver.new
|
40
|
+
end
|
41
|
+
|
42
|
+
def default_formatter
|
43
|
+
@default_formatter ||= Formatter.new
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
data/lib/stringento/version.rb
CHANGED
@@ -12,7 +12,7 @@ require './spec/examples/custom_formatter'
|
|
12
12
|
require './spec/examples/indifferent_hash_resolver'
|
13
13
|
require './spec/examples/nested_hash_resolver'
|
14
14
|
|
15
|
-
describe
|
15
|
+
describe Stringento do
|
16
16
|
context 'without custom formatter and resolver' do
|
17
17
|
describe '#evaluate' do
|
18
18
|
let(:tests) do
|
data/stringento.gemspec
CHANGED
@@ -5,28 +5,36 @@ require './lib/stringento/version'
|
|
5
5
|
Gem::Specification.new do |s|
|
6
6
|
s.name = 'stringento'
|
7
7
|
s.version = Stringento::VERSION
|
8
|
-
s.summary = '
|
8
|
+
s.summary = 'This library provides a pluggable string templating system.'
|
9
9
|
|
10
10
|
s.description = <<-DESCRIPTION
|
11
|
-
|
11
|
+
At its core, it can take a templated string (such as: '{last_name}, {first_name} {middle_name}') and a input object (default is a plain old Ruby object) and it will dynamically resolve the string based on the input.
|
12
12
|
DESCRIPTION
|
13
13
|
|
14
14
|
s.authors = ['Matthew Ruggio']
|
15
15
|
s.email = ['mruggio@bluemarblepayroll.com']
|
16
16
|
s.files = `git ls-files`.split("\n")
|
17
17
|
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
18
|
-
s.
|
18
|
+
s.bindir = 'exe'
|
19
|
+
s.executables = []
|
19
20
|
s.homepage = 'https://github.com/bluemarblepayroll/stringento'
|
20
21
|
s.license = 'MIT'
|
22
|
+
s.metadata = {
|
23
|
+
'bug_tracker_uri' => 'https://github.com/bluemarblepayroll/stringento/issues',
|
24
|
+
'changelog_uri' => 'https://github.com/bluemarblepayroll/stringento/blob/master/CHANGELOG.md',
|
25
|
+
'documentation_uri' => 'https://www.rubydoc.info/gems/stringento',
|
26
|
+
'homepage_uri' => s.homepage,
|
27
|
+
'source_code_uri' => s.homepage
|
28
|
+
}
|
21
29
|
|
22
|
-
s.required_ruby_version = '>= 2.
|
30
|
+
s.required_ruby_version = '>= 2.5'
|
23
31
|
|
24
32
|
s.add_development_dependency('faker', '~>1')
|
25
33
|
s.add_development_dependency('guard-rspec', '~>4.7')
|
26
|
-
s.add_development_dependency('pdf-inspector', '~>1')
|
27
34
|
s.add_development_dependency('pry', '~>0')
|
35
|
+
s.add_development_dependency('rake', '~>13.0')
|
28
36
|
s.add_development_dependency('rspec', '~> 3.8')
|
29
|
-
s.add_development_dependency('rubocop', '~>0.
|
30
|
-
s.add_development_dependency('simplecov', '~>0.
|
31
|
-
s.add_development_dependency('simplecov-console', '~>0.
|
37
|
+
s.add_development_dependency('rubocop', '~>0.88.0')
|
38
|
+
s.add_development_dependency('simplecov', '~>0.18.5')
|
39
|
+
s.add_development_dependency('simplecov-console', '~>0.7.0')
|
32
40
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: stringento
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Matthew Ruggio
|
8
8
|
autorequire:
|
9
|
-
bindir:
|
9
|
+
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2020-08-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faker
|
@@ -39,33 +39,33 @@ dependencies:
|
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '4.7'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
|
-
name:
|
42
|
+
name: pry
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
45
|
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: '
|
47
|
+
version: '0'
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: '
|
54
|
+
version: '0'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
|
-
name:
|
56
|
+
name: rake
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
59
|
- - "~>"
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: '0'
|
61
|
+
version: '13.0'
|
62
62
|
type: :development
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
66
|
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version: '0'
|
68
|
+
version: '13.0'
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: rspec
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
@@ -86,48 +86,48 @@ dependencies:
|
|
86
86
|
requirements:
|
87
87
|
- - "~>"
|
88
88
|
- !ruby/object:Gem::Version
|
89
|
-
version: 0.
|
89
|
+
version: 0.88.0
|
90
90
|
type: :development
|
91
91
|
prerelease: false
|
92
92
|
version_requirements: !ruby/object:Gem::Requirement
|
93
93
|
requirements:
|
94
94
|
- - "~>"
|
95
95
|
- !ruby/object:Gem::Version
|
96
|
-
version: 0.
|
96
|
+
version: 0.88.0
|
97
97
|
- !ruby/object:Gem::Dependency
|
98
98
|
name: simplecov
|
99
99
|
requirement: !ruby/object:Gem::Requirement
|
100
100
|
requirements:
|
101
101
|
- - "~>"
|
102
102
|
- !ruby/object:Gem::Version
|
103
|
-
version: 0.
|
103
|
+
version: 0.18.5
|
104
104
|
type: :development
|
105
105
|
prerelease: false
|
106
106
|
version_requirements: !ruby/object:Gem::Requirement
|
107
107
|
requirements:
|
108
108
|
- - "~>"
|
109
109
|
- !ruby/object:Gem::Version
|
110
|
-
version: 0.
|
110
|
+
version: 0.18.5
|
111
111
|
- !ruby/object:Gem::Dependency
|
112
112
|
name: simplecov-console
|
113
113
|
requirement: !ruby/object:Gem::Requirement
|
114
114
|
requirements:
|
115
115
|
- - "~>"
|
116
116
|
- !ruby/object:Gem::Version
|
117
|
-
version: 0.
|
117
|
+
version: 0.7.0
|
118
118
|
type: :development
|
119
119
|
prerelease: false
|
120
120
|
version_requirements: !ruby/object:Gem::Requirement
|
121
121
|
requirements:
|
122
122
|
- - "~>"
|
123
123
|
- !ruby/object:Gem::Version
|
124
|
-
version: 0.
|
125
|
-
description: "
|
126
|
-
|
124
|
+
version: 0.7.0
|
125
|
+
description: " At its core, it can take a templated string (such as: '{last_name},
|
126
|
+
{first_name} {middle_name}') and a input object (default is a plain old Ruby object)
|
127
|
+
and it will dynamically resolve the string based on the input.\n"
|
127
128
|
email:
|
128
129
|
- mruggio@bluemarblepayroll.com
|
129
|
-
executables:
|
130
|
-
- console
|
130
|
+
executables: []
|
131
131
|
extensions: []
|
132
132
|
extra_rdoc_files: []
|
133
133
|
files:
|
@@ -137,17 +137,18 @@ files:
|
|
137
137
|
- ".ruby-version"
|
138
138
|
- ".travis.yml"
|
139
139
|
- CHANGELOG.md
|
140
|
+
- CODE_OF_CONDUCT.md
|
140
141
|
- Gemfile
|
141
|
-
- Gemfile.lock
|
142
142
|
- Guardfile
|
143
143
|
- LICENSE
|
144
144
|
- README.md
|
145
|
+
- Rakefile
|
145
146
|
- bin/console
|
147
|
+
- exe/.gitkeep
|
146
148
|
- lib/stringento.rb
|
147
149
|
- lib/stringento/formatter.rb
|
148
150
|
- lib/stringento/placeholder.rb
|
149
151
|
- lib/stringento/resolver.rb
|
150
|
-
- lib/stringento/stringento.rb
|
151
152
|
- lib/stringento/template.rb
|
152
153
|
- lib/stringento/version.rb
|
153
154
|
- spec/examples/custom_formatter.rb
|
@@ -157,13 +158,18 @@ files:
|
|
157
158
|
- spec/stringento/formatter_spec.rb
|
158
159
|
- spec/stringento/placeholder_spec.rb
|
159
160
|
- spec/stringento/resolver_spec.rb
|
160
|
-
- spec/stringento/stringento_spec.rb
|
161
161
|
- spec/stringento/template_spec.rb
|
162
|
+
- spec/stringento_spec.rb
|
162
163
|
- stringento.gemspec
|
163
164
|
homepage: https://github.com/bluemarblepayroll/stringento
|
164
165
|
licenses:
|
165
166
|
- MIT
|
166
|
-
metadata:
|
167
|
+
metadata:
|
168
|
+
bug_tracker_uri: https://github.com/bluemarblepayroll/stringento/issues
|
169
|
+
changelog_uri: https://github.com/bluemarblepayroll/stringento/blob/master/CHANGELOG.md
|
170
|
+
documentation_uri: https://www.rubydoc.info/gems/stringento
|
171
|
+
homepage_uri: https://github.com/bluemarblepayroll/stringento
|
172
|
+
source_code_uri: https://github.com/bluemarblepayroll/stringento
|
167
173
|
post_install_message:
|
168
174
|
rdoc_options: []
|
169
175
|
require_paths:
|
@@ -172,17 +178,17 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
172
178
|
requirements:
|
173
179
|
- - ">="
|
174
180
|
- !ruby/object:Gem::Version
|
175
|
-
version: 2.
|
181
|
+
version: '2.5'
|
176
182
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
177
183
|
requirements:
|
178
184
|
- - ">="
|
179
185
|
- !ruby/object:Gem::Version
|
180
186
|
version: '0'
|
181
187
|
requirements: []
|
182
|
-
rubygems_version: 3.0.
|
188
|
+
rubygems_version: 3.0.3
|
183
189
|
signing_key:
|
184
190
|
specification_version: 4
|
185
|
-
summary:
|
191
|
+
summary: This library provides a pluggable string templating system.
|
186
192
|
test_files:
|
187
193
|
- spec/examples/custom_formatter.rb
|
188
194
|
- spec/examples/indifferent_hash_resolver.rb
|
@@ -191,5 +197,5 @@ test_files:
|
|
191
197
|
- spec/stringento/formatter_spec.rb
|
192
198
|
- spec/stringento/placeholder_spec.rb
|
193
199
|
- spec/stringento/resolver_spec.rb
|
194
|
-
- spec/stringento/stringento_spec.rb
|
195
200
|
- spec/stringento/template_spec.rb
|
201
|
+
- spec/stringento_spec.rb
|
data/Gemfile.lock
DELETED
@@ -1,123 +0,0 @@
|
|
1
|
-
PATH
|
2
|
-
remote: .
|
3
|
-
specs:
|
4
|
-
stringento (2.0.0)
|
5
|
-
|
6
|
-
GEM
|
7
|
-
remote: https://rubygems.org/
|
8
|
-
specs:
|
9
|
-
Ascii85 (1.0.3)
|
10
|
-
afm (0.2.2)
|
11
|
-
ansi (1.5.0)
|
12
|
-
ast (2.4.0)
|
13
|
-
coderay (1.1.2)
|
14
|
-
concurrent-ruby (1.1.5)
|
15
|
-
diff-lcs (1.3)
|
16
|
-
docile (1.3.1)
|
17
|
-
faker (1.9.3)
|
18
|
-
i18n (>= 0.7)
|
19
|
-
ffi (1.9.25)
|
20
|
-
formatador (0.2.5)
|
21
|
-
guard (2.15.0)
|
22
|
-
formatador (>= 0.2.4)
|
23
|
-
listen (>= 2.7, < 4.0)
|
24
|
-
lumberjack (>= 1.0.12, < 2.0)
|
25
|
-
nenv (~> 0.1)
|
26
|
-
notiffany (~> 0.0)
|
27
|
-
pry (>= 0.9.12)
|
28
|
-
shellany (~> 0.0)
|
29
|
-
thor (>= 0.18.1)
|
30
|
-
guard-compat (1.2.1)
|
31
|
-
guard-rspec (4.7.3)
|
32
|
-
guard (~> 2.1)
|
33
|
-
guard-compat (~> 1.1)
|
34
|
-
rspec (>= 2.99.0, < 4.0)
|
35
|
-
hashery (2.1.2)
|
36
|
-
hirb (0.7.3)
|
37
|
-
i18n (1.6.0)
|
38
|
-
concurrent-ruby (~> 1.0)
|
39
|
-
jaro_winkler (1.5.2)
|
40
|
-
json (2.1.0)
|
41
|
-
listen (3.1.5)
|
42
|
-
rb-fsevent (~> 0.9, >= 0.9.4)
|
43
|
-
rb-inotify (~> 0.9, >= 0.9.7)
|
44
|
-
ruby_dep (~> 1.2)
|
45
|
-
lumberjack (1.0.13)
|
46
|
-
method_source (0.9.2)
|
47
|
-
nenv (0.3.0)
|
48
|
-
notiffany (0.1.1)
|
49
|
-
nenv (~> 0.1)
|
50
|
-
shellany (~> 0.0)
|
51
|
-
parallel (1.13.0)
|
52
|
-
parser (2.6.0.0)
|
53
|
-
ast (~> 2.4.0)
|
54
|
-
pdf-inspector (1.3.0)
|
55
|
-
pdf-reader (>= 1.0, < 3.0.a)
|
56
|
-
pdf-reader (2.2.0)
|
57
|
-
Ascii85 (~> 1.0.0)
|
58
|
-
afm (~> 0.2.1)
|
59
|
-
hashery (~> 2.0)
|
60
|
-
ruby-rc4
|
61
|
-
ttfunk
|
62
|
-
powerpack (0.1.2)
|
63
|
-
pry (0.12.2)
|
64
|
-
coderay (~> 1.1.0)
|
65
|
-
method_source (~> 0.9.0)
|
66
|
-
rainbow (3.0.0)
|
67
|
-
rb-fsevent (0.10.3)
|
68
|
-
rb-inotify (0.9.10)
|
69
|
-
ffi (>= 0.5.0, < 2)
|
70
|
-
rspec (3.8.0)
|
71
|
-
rspec-core (~> 3.8.0)
|
72
|
-
rspec-expectations (~> 3.8.0)
|
73
|
-
rspec-mocks (~> 3.8.0)
|
74
|
-
rspec-core (3.8.0)
|
75
|
-
rspec-support (~> 3.8.0)
|
76
|
-
rspec-expectations (3.8.2)
|
77
|
-
diff-lcs (>= 1.2.0, < 2.0)
|
78
|
-
rspec-support (~> 3.8.0)
|
79
|
-
rspec-mocks (3.8.0)
|
80
|
-
diff-lcs (>= 1.2.0, < 2.0)
|
81
|
-
rspec-support (~> 3.8.0)
|
82
|
-
rspec-support (3.8.0)
|
83
|
-
rubocop (0.63.1)
|
84
|
-
jaro_winkler (~> 1.5.1)
|
85
|
-
parallel (~> 1.10)
|
86
|
-
parser (>= 2.5, != 2.5.1.1)
|
87
|
-
powerpack (~> 0.1)
|
88
|
-
rainbow (>= 2.2.2, < 4.0)
|
89
|
-
ruby-progressbar (~> 1.7)
|
90
|
-
unicode-display_width (~> 1.4.0)
|
91
|
-
ruby-progressbar (1.10.0)
|
92
|
-
ruby-rc4 (0.1.5)
|
93
|
-
ruby_dep (1.5.0)
|
94
|
-
shellany (0.0.1)
|
95
|
-
simplecov (0.16.1)
|
96
|
-
docile (~> 1.1)
|
97
|
-
json (>= 1.8, < 3)
|
98
|
-
simplecov-html (~> 0.10.0)
|
99
|
-
simplecov-console (0.4.2)
|
100
|
-
ansi
|
101
|
-
hirb
|
102
|
-
simplecov
|
103
|
-
simplecov-html (0.10.2)
|
104
|
-
thor (0.20.3)
|
105
|
-
ttfunk (1.5.1)
|
106
|
-
unicode-display_width (1.4.1)
|
107
|
-
|
108
|
-
PLATFORMS
|
109
|
-
ruby
|
110
|
-
|
111
|
-
DEPENDENCIES
|
112
|
-
faker (~> 1)
|
113
|
-
guard-rspec (~> 4.7)
|
114
|
-
pdf-inspector (~> 1)
|
115
|
-
pry (~> 0)
|
116
|
-
rspec (~> 3.8)
|
117
|
-
rubocop (~> 0.63.1)
|
118
|
-
simplecov (~> 0.16.1)
|
119
|
-
simplecov-console (~> 0.4.2)
|
120
|
-
stringento!
|
121
|
-
|
122
|
-
BUNDLED WITH
|
123
|
-
1.17.3
|
@@ -1,46 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
#
|
4
|
-
# Copyright (c) 2019-present, Blue Marble Payroll, LLC
|
5
|
-
#
|
6
|
-
# This source code is licensed under the MIT license found in the
|
7
|
-
# LICENSE file in the root directory of this source tree.
|
8
|
-
#
|
9
|
-
|
10
|
-
require_relative 'formatter'
|
11
|
-
require_relative 'placeholder'
|
12
|
-
require_relative 'resolver'
|
13
|
-
require_relative 'template'
|
14
|
-
|
15
|
-
# Top-level API for main external consumption. It is better to use this than instantiating
|
16
|
-
# your own Template objects because this top-level object will cache Template objects based
|
17
|
-
# on the expression. It also provides less default resolver and formatter instantiations.
|
18
|
-
module Stringento
|
19
|
-
class << self
|
20
|
-
def evaluate(expression, input, resolver: nil, formatter: nil)
|
21
|
-
template(expression).evaluate(
|
22
|
-
input,
|
23
|
-
resolver: (resolver || default_resolver),
|
24
|
-
formatter: (formatter || default_formatter)
|
25
|
-
)
|
26
|
-
end
|
27
|
-
|
28
|
-
private
|
29
|
-
|
30
|
-
def templates
|
31
|
-
@templates ||= {}
|
32
|
-
end
|
33
|
-
|
34
|
-
def template(expression)
|
35
|
-
templates[expression.to_s] ||= Template.new(expression)
|
36
|
-
end
|
37
|
-
|
38
|
-
def default_resolver
|
39
|
-
@default_resolver ||= Resolver.new
|
40
|
-
end
|
41
|
-
|
42
|
-
def default_formatter
|
43
|
-
@default_formatter ||= Formatter.new
|
44
|
-
end
|
45
|
-
end
|
46
|
-
end
|