nocode 0.0.4 → 0.0.5
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/CHANGELOG.md +5 -1
- data/README.md +1 -1
- data/lib/nocode/executor.rb +11 -5
- data/lib/nocode/steps/dataset/append.rb +21 -0
- data/lib/nocode/steps/dataset/coalesce.rb +22 -0
- data/lib/nocode/steps/dataset/insert.rb +29 -0
- data/lib/nocode/steps/dataset/prepend.rb +21 -0
- data/lib/nocode/steps/dataset/range.rb +32 -0
- data/lib/nocode/steps/serialize/csv.rb +0 -6
- data/lib/nocode/steps/sleep.rb +2 -0
- data/lib/nocode/version.rb +1 -1
- metadata +7 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8726547b06744c6a7870a8634901b344e41a65bb1ede23c7e68e99d2218d482f
|
4
|
+
data.tar.gz: 3462f703d7639662c0da4f96ec9913749698c7f7a08a58387671db909a88785f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f7bcfd37d152798a753801944a6a4787e3ad83a08fcfca0b40d9a0957cd7c5142a298adbb64215ed2e161c9e7f842b89ab460f6374fb8ec552a3482aa0b712eb
|
7
|
+
data.tar.gz: 6e024f679e2973888d5bb67c20988c8e93b296a6b6c4dbc66f7cb1f55d8638db48842834fd00c2a6d24050d9aa61950666107ff285a469e3f63835f74e7a5e7d
|
data/CHANGELOG.md
CHANGED
@@ -1,7 +1,11 @@
|
|
1
|
+
#### 0.0.5 - February 13th, 2022
|
2
|
+
|
3
|
+
* Added initial Dataset steps.
|
4
|
+
|
1
5
|
#### 0.0.4 - February 13th, 2022
|
2
6
|
|
3
7
|
* Increase class documentation
|
4
|
-
* Add YAML serialization/
|
8
|
+
* Add YAML serialization/deserialization
|
5
9
|
|
6
10
|
#### 0.0.3 - February 12th, 2022
|
7
11
|
|
data/README.md
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
#### Execute Ruby code through YAML
|
4
4
|
|
5
|
-
[](https://badge.fury.io/rb/nocode) [](https://github.com/mattruggio/nocode/actions/workflows/rubygem.yml)
|
5
|
+
[](https://badge.fury.io/rb/nocode) [](https://github.com/mattruggio/nocode/actions/workflows/rubygem.yml) [](https://codeclimate.com/github/mattruggio/nocode/maintainability) [](https://opensource.org/licenses/MIT)
|
6
6
|
|
7
7
|
This is a proof of concept showing how a YAML interface could be draped over arbitrary Ruby code. The YAML contains a series of steps with each step mapping to a specific Ruby class. The Ruby classes just have one responsibility: to implement #perform.
|
8
8
|
|
data/lib/nocode/executor.rb
CHANGED
@@ -6,6 +6,12 @@ require_relative 'step_registry'
|
|
6
6
|
module Nocode
|
7
7
|
# Manages the lifecycle and executes a job.
|
8
8
|
class Executor
|
9
|
+
NAME_KEY = 'name'
|
10
|
+
OPTIONS_KEY = 'options'
|
11
|
+
PARAMETERS_KEY = 'parameters'
|
12
|
+
STEPS_KEY = 'steps'
|
13
|
+
TYPE_KEY = 'type'
|
14
|
+
|
9
15
|
attr_reader :yaml, :io
|
10
16
|
|
11
17
|
def initialize(yaml, io: $stdout)
|
@@ -17,8 +23,8 @@ module Nocode
|
|
17
23
|
end
|
18
24
|
|
19
25
|
def execute
|
20
|
-
steps = yaml[
|
21
|
-
parameters = yaml[
|
26
|
+
steps = yaml[STEPS_KEY] || []
|
27
|
+
parameters = yaml[PARAMETERS_KEY] || {}
|
22
28
|
context = Context.new(io: io, parameters: parameters)
|
23
29
|
|
24
30
|
log_title
|
@@ -39,9 +45,9 @@ module Nocode
|
|
39
45
|
|
40
46
|
def make_step(step, context)
|
41
47
|
step = Util::ObjectTemplate.new(step).evaluate(context.to_h)
|
42
|
-
type = step[
|
43
|
-
name = step[
|
44
|
-
options = step[
|
48
|
+
type = step[TYPE_KEY].to_s
|
49
|
+
name = step[NAME_KEY].to_s
|
50
|
+
options = step[OPTIONS_KEY] || {}
|
45
51
|
step_class = StepRegistry.constant!(type)
|
46
52
|
|
47
53
|
step_class.new(
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Nocode
|
4
|
+
module Steps
|
5
|
+
module Dataset
|
6
|
+
# Add entries specified in the options to the end of the specified register's
|
7
|
+
# existing entries.
|
8
|
+
class Append < Step
|
9
|
+
option :entries, :register
|
10
|
+
|
11
|
+
def perform
|
12
|
+
registers[register_option] = array(registers[register_option])
|
13
|
+
|
14
|
+
array(entries_option).each do |entry|
|
15
|
+
registers[register_option].append(entry)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Nocode
|
4
|
+
module Steps
|
5
|
+
module Dataset
|
6
|
+
# Combine all specified from_registers into one dataset and place in the specified
|
7
|
+
# to_register. If anything currently exists in the to_register then it will be coerced
|
8
|
+
# to an array and prepended to the beginning.
|
9
|
+
class Coalesce < Step
|
10
|
+
option :from_registers, :to_register
|
11
|
+
|
12
|
+
def perform
|
13
|
+
registers[to_register_option] = array(registers[to_register_option])
|
14
|
+
|
15
|
+
array(from_registers_option).each do |from_register|
|
16
|
+
registers[to_register_option] += array(registers[from_register])
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Nocode
|
4
|
+
module Steps
|
5
|
+
module Dataset
|
6
|
+
# Insert the entries to the at_index of the specified register.
|
7
|
+
# If at_index is nil then they will appended to the end.
|
8
|
+
class Insert < Step
|
9
|
+
option :at_index, :entries, :register
|
10
|
+
|
11
|
+
def perform
|
12
|
+
registers[register_option] = array(registers[register_option])
|
13
|
+
|
14
|
+
registers[register_option].insert(at_index, *entries)
|
15
|
+
end
|
16
|
+
|
17
|
+
private
|
18
|
+
|
19
|
+
def entries
|
20
|
+
array(entries_option)
|
21
|
+
end
|
22
|
+
|
23
|
+
def at_index
|
24
|
+
at_index_option.nil? ? -1 : at_index_option.to_i
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Nocode
|
4
|
+
module Steps
|
5
|
+
module Dataset
|
6
|
+
# Add entries specified in the options to the beginning of the specified register's
|
7
|
+
# existing entries.
|
8
|
+
class Prepend < Step
|
9
|
+
option :entries, :register
|
10
|
+
|
11
|
+
def perform
|
12
|
+
registers[register_option] = array(registers[register_option])
|
13
|
+
|
14
|
+
array(entries_option).reverse_each do |entry|
|
15
|
+
registers[register_option].prepend(entry)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Nocode
|
4
|
+
module Steps
|
5
|
+
module Dataset
|
6
|
+
# Slice a dataset and keep on the entries between start_index and end_index, inclusively.
|
7
|
+
# If start_index is not provided then it defaults to 0.
|
8
|
+
# If end_index is not provided then it defaults to the end of the dataset.
|
9
|
+
class Range < Step
|
10
|
+
option :end_index,
|
11
|
+
:register,
|
12
|
+
:start_index
|
13
|
+
|
14
|
+
def perform
|
15
|
+
registers[register_option] = array(registers[register_option])
|
16
|
+
|
17
|
+
registers[register_option] = registers[register_option][start_index..end_index]
|
18
|
+
end
|
19
|
+
|
20
|
+
private
|
21
|
+
|
22
|
+
def start_index
|
23
|
+
start_index_option.nil? ? 0 : start_index_option.to_i
|
24
|
+
end
|
25
|
+
|
26
|
+
def end_index
|
27
|
+
end_index_option.nil? ? -1 : end_index_option.to_i
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
data/lib/nocode/steps/sleep.rb
CHANGED
data/lib/nocode/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: nocode
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.5
|
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-
|
11
|
+
date: 2022-02-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler-audit
|
@@ -179,6 +179,11 @@ files:
|
|
179
179
|
- lib/nocode/step.rb
|
180
180
|
- lib/nocode/step_registry.rb
|
181
181
|
- lib/nocode/steps/copy.rb
|
182
|
+
- lib/nocode/steps/dataset/append.rb
|
183
|
+
- lib/nocode/steps/dataset/coalesce.rb
|
184
|
+
- lib/nocode/steps/dataset/insert.rb
|
185
|
+
- lib/nocode/steps/dataset/prepend.rb
|
186
|
+
- lib/nocode/steps/dataset/range.rb
|
182
187
|
- lib/nocode/steps/delete.rb
|
183
188
|
- lib/nocode/steps/deserialize/csv.rb
|
184
189
|
- lib/nocode/steps/deserialize/json.rb
|