nocode 0.0.8 → 0.0.9

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f42cd4574b36e4098fbb2c3de7263d8530ee2c935ec1d86da30950c51f45998e
4
- data.tar.gz: a1259cd1075a946a056db27b2a3da5c7acebee2002c0f1e01b2f6a5fef203fa9
3
+ metadata.gz: f199fcae3341fccc2e54c1c139ba2c7e65a20dda27d2be31c79de02f9ec2558a
4
+ data.tar.gz: c10d64f895d34e567b846c52727205d1394641adcd68b1b1d2707c509577700c
5
5
  SHA512:
6
- metadata.gz: 7be2f97365a7d2494e956362074d47c07cf39a741af34299b2bd30e70c2a74f8bf7566a24de816b4af692deede762c4e03ba9b2e1f8ddd81cf161a263e6e6f1b
7
- data.tar.gz: '0099f90f5b0a569f2fe95b93d16aa5e737f957830bcfcb84d598f362c21edec9c759e113f0d01049a5ecfa05bb17d5e70ec49436b5c558a66f0e194d8c32ff28'
6
+ metadata.gz: 1a53bcec0412b9b8be57d9cb61601db583aa210542f9372c05d4cdee0e693861d05e017a697103253a2d522a2253e609481ded8e0524362ccaf6640a9d13f9d3
7
+ data.tar.gz: 131855e439116d1718cf46c53cc32597187aeae36156d71fff508fa4a0a20739a9965b055874aadc93cae4a5dd3fbf3f4b0201d5f7c75a9d1d63ed60e9150044
data/CHANGELOG.md CHANGED
@@ -1,4 +1,6 @@
1
+ #### 0.0.9 - February 18th, 2022
1
2
 
3
+ * Replace StringTemplate with Nay library.
2
4
  #### 0.0.8 - February 14th, 2022
3
5
 
4
6
  * Add `map` step to iterate and collect a dataset result.
@@ -1,7 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require_relative 'string_template'
4
-
5
3
  module Nocode
6
4
  module Util
7
5
  # Built on top of StringTemplate but instead of only working for a string, this will
@@ -34,7 +32,7 @@ module Nocode
34
32
  [recursive_evaluate(k, values), recursive_evaluate(v, values)]
35
33
  end
36
34
  when String
37
- Util::StringTemplate.new(expression).evaluate(values)
35
+ Nay.evaluate(expression, values)
38
36
  else
39
37
  expression
40
38
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Nocode
4
- VERSION = '0.0.8'
4
+ VERSION = '0.0.9'
5
5
  end
data/lib/nocode.rb CHANGED
@@ -4,6 +4,7 @@ require 'benchmark'
4
4
  require 'csv'
5
5
  require 'fileutils'
6
6
  require 'json'
7
+ require 'nay'
7
8
  require 'singleton'
8
9
  require 'time'
9
10
  require 'yaml'
data/nocode.gemspec CHANGED
@@ -29,6 +29,8 @@ Gem::Specification.new do |s|
29
29
 
30
30
  s.required_ruby_version = '>= 2.6'
31
31
 
32
+ s.add_dependency('nay', '~>0.0', '>=0.0.2')
33
+
32
34
  s.add_development_dependency('bundler-audit')
33
35
  s.add_development_dependency('guard-rspec')
34
36
  s.add_development_dependency('pry')
metadata CHANGED
@@ -1,15 +1,35 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nocode
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.8
4
+ version: 0.0.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matthew Ruggio
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-02-15 00:00:00.000000000 Z
11
+ date: 2022-02-18 00:00:00.000000000 Z
12
12
  dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: nay
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '0.0'
20
+ - - ">="
21
+ - !ruby/object:Gem::Version
22
+ version: 0.0.2
23
+ type: :runtime
24
+ prerelease: false
25
+ version_requirements: !ruby/object:Gem::Requirement
26
+ requirements:
27
+ - - "~>"
28
+ - !ruby/object:Gem::Version
29
+ version: '0.0'
30
+ - - ">="
31
+ - !ruby/object:Gem::Version
32
+ version: 0.0.2
13
33
  - !ruby/object:Gem::Dependency
14
34
  name: bundler-audit
15
35
  requirement: !ruby/object:Gem::Requirement
@@ -209,7 +229,6 @@ files:
209
229
  - lib/nocode/util/dictionary.rb
210
230
  - lib/nocode/util/object_template.rb
211
231
  - lib/nocode/util/optionable.rb
212
- - lib/nocode/util/string_template.rb
213
232
  - lib/nocode/version.rb
214
233
  - nocode.gemspec
215
234
  homepage: https://github.com/mattruggio/nocode
@@ -1,49 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Nocode
4
- module Util
5
- # Takes in an expression and interpolates in any parameters using << >> notation.
6
- # For example:
7
- # input = { 'person' => 'hops' }
8
- # Nocode::Util::StringTemplate.new("Hello, << person.name >>!").evaluate(input)
9
- # Should produce: "Hello, hops!"
10
- class StringTemplate
11
- LEFT_TOKEN = '<<'
12
- RIGHT_TOKEN = '>>'
13
- SEPARATOR = '.'
14
- REG_EXPR = /#{Regexp.quote(LEFT_TOKEN)}(.*?)#{Regexp.quote(RIGHT_TOKEN)}/.freeze
15
-
16
- attr_reader :expression
17
-
18
- def initialize(expression)
19
- @expression = expression.to_s
20
-
21
- freeze
22
- end
23
-
24
- def evaluate(values = {})
25
- resolved = tokens_to_values(tokens, values)
26
-
27
- tokens.inject(expression) do |memo, token|
28
- memo.gsub("#{LEFT_TOKEN}#{token}#{RIGHT_TOKEN}", resolved[token].to_s)
29
- end
30
- end
31
-
32
- private
33
-
34
- def tokens
35
- expression.to_s.scan(REG_EXPR).flatten
36
- end
37
-
38
- def tokens_to_values(tokens, values)
39
- tokens.each_with_object({}) do |token, memo|
40
- cleansed = token.strip
41
- parts = cleansed.split(SEPARATOR)
42
- value = values.dig(*parts)
43
-
44
- memo[token] = value
45
- end
46
- end
47
- end
48
- end
49
- end