nocode 0.0.7 → 0.0.8
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 +9 -2
- data/lib/nocode/steps/each.rb +25 -9
- data/lib/nocode/steps/io/delete.rb +24 -0
- data/lib/nocode/steps/io/list.rb +25 -0
- data/lib/nocode/steps/map.rb +52 -0
- data/lib/nocode/steps/record/map.rb +25 -0
- data/lib/nocode/version.rb +1 -1
- metadata +6 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f42cd4574b36e4098fbb2c3de7263d8530ee2c935ec1d86da30950c51f45998e
|
4
|
+
data.tar.gz: a1259cd1075a946a056db27b2a3da5c7acebee2002c0f1e01b2f6a5fef203fa9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7be2f97365a7d2494e956362074d47c07cf39a741af34299b2bd30e70c2a74f8bf7566a24de816b4af692deede762c4e03ba9b2e1f8ddd81cf161a263e6e6f1b
|
7
|
+
data.tar.gz: '0099f90f5b0a569f2fe95b93d16aa5e737f957830bcfcb84d598f362c21edec9c759e113f0d01049a5ecfa05bb17d5e70ec49436b5c558a66f0e194d8c32ff28'
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,10 @@
|
|
1
|
+
|
2
|
+
#### 0.0.8 - February 14th, 2022
|
3
|
+
|
4
|
+
* Add `map` step to iterate and collect a dataset result.
|
5
|
+
* Add `record/map` step to iterate over a hash.
|
6
|
+
* Add `io/list` to populate a register with the contents of a directory.
|
7
|
+
* Add `io/delete` to delete a file specified in the path option.
|
1
8
|
#### 0.0.7 - February 13th, 2022
|
2
9
|
|
3
10
|
* Move shared logging logic to context (until a first class log writer emerges).
|
@@ -6,11 +13,11 @@
|
|
6
13
|
#### 0.0.6 - February 13th, 2022
|
7
14
|
|
8
15
|
* Expose registers to main YAML configuration.
|
9
|
-
* Add
|
16
|
+
* Add `each` step to serve as an example of an iterator.
|
10
17
|
|
11
18
|
#### 0.0.5 - February 13th, 2022
|
12
19
|
|
13
|
-
* Added initial
|
20
|
+
* Added initial `dataset` steps.
|
14
21
|
|
15
22
|
#### 0.0.4 - February 13th, 2022
|
16
23
|
|
data/lib/nocode/steps/each.rb
CHANGED
@@ -12,20 +12,36 @@ module Nocode
|
|
12
12
|
|
13
13
|
skip_options_evaluation!
|
14
14
|
|
15
|
-
# rubocop:disable Metrics/AbcSize
|
16
15
|
def perform
|
17
|
-
entries = array(registers[register_option])
|
18
|
-
|
19
16
|
entries.each_with_index do |entry, index|
|
20
|
-
|
21
|
-
|
22
|
-
registers["#{element_register_prefix_option}_element"] = entry
|
23
|
-
registers["#{element_register_prefix_option}_index"] = index
|
17
|
+
registers[element_key] = entry
|
18
|
+
registers[index_key] = index
|
24
19
|
|
25
|
-
|
20
|
+
execute_steps
|
26
21
|
end
|
27
22
|
end
|
28
|
-
|
23
|
+
|
24
|
+
private
|
25
|
+
|
26
|
+
def execute_steps
|
27
|
+
StepsExecutor.new(context: context, steps: steps).execute
|
28
|
+
end
|
29
|
+
|
30
|
+
def entries
|
31
|
+
array(registers[register_option])
|
32
|
+
end
|
33
|
+
|
34
|
+
def steps
|
35
|
+
array(steps_option)
|
36
|
+
end
|
37
|
+
|
38
|
+
def element_key
|
39
|
+
"#{element_register_prefix_option}_element"
|
40
|
+
end
|
41
|
+
|
42
|
+
def index_key
|
43
|
+
"#{element_register_prefix_option}_index"
|
44
|
+
end
|
29
45
|
end
|
30
46
|
end
|
31
47
|
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Nocode
|
4
|
+
module Steps
|
5
|
+
module Io
|
6
|
+
# Delete the specified path. Does nothing if the file does not exist.
|
7
|
+
class Delete < Step
|
8
|
+
option :path
|
9
|
+
|
10
|
+
def perform
|
11
|
+
return if path.to_s.empty?
|
12
|
+
|
13
|
+
FileUtils.rm_f(path) if File.exist?(path)
|
14
|
+
end
|
15
|
+
|
16
|
+
private
|
17
|
+
|
18
|
+
def path
|
19
|
+
File.join(*array(path_option))
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Nocode
|
4
|
+
module Steps
|
5
|
+
module Io
|
6
|
+
# List all files in the path option. Wildcards can be used.
|
7
|
+
#
|
8
|
+
# Mechanic: https://ruby-doc.org/core-2.5.0/Dir.html#method-c-glob
|
9
|
+
class List < Step
|
10
|
+
option :path,
|
11
|
+
:register
|
12
|
+
|
13
|
+
def perform
|
14
|
+
registers[register_option] = Dir[path].reject { |p| File.directory?(p) }
|
15
|
+
end
|
16
|
+
|
17
|
+
private
|
18
|
+
|
19
|
+
def path
|
20
|
+
File.join(*array(path_option))
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,52 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Nocode
|
4
|
+
module Steps
|
5
|
+
# Iterate over a register. Each iteration will store the current element and index in
|
6
|
+
# special registers called: _element and _index. You can prefix these registers by setting
|
7
|
+
# the element_register_prefix option.
|
8
|
+
#
|
9
|
+
# The main difference between this and 'each' is that this will collect the iterator
|
10
|
+
# element register and set the register to this new collection.
|
11
|
+
class Map < Step
|
12
|
+
option :element_register_prefix,
|
13
|
+
:register,
|
14
|
+
:steps
|
15
|
+
|
16
|
+
skip_options_evaluation!
|
17
|
+
|
18
|
+
def perform
|
19
|
+
registers[register_option] = entries.map.with_index do |entry, index|
|
20
|
+
registers[element_key] = entry
|
21
|
+
registers[index_key] = index
|
22
|
+
|
23
|
+
execute_steps
|
24
|
+
|
25
|
+
registers[element_key]
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
private
|
30
|
+
|
31
|
+
def execute_steps
|
32
|
+
StepsExecutor.new(context: context, steps: steps).execute
|
33
|
+
end
|
34
|
+
|
35
|
+
def entries
|
36
|
+
array(registers[register_option])
|
37
|
+
end
|
38
|
+
|
39
|
+
def steps
|
40
|
+
array(steps_option)
|
41
|
+
end
|
42
|
+
|
43
|
+
def element_key
|
44
|
+
"#{element_register_prefix_option}_element"
|
45
|
+
end
|
46
|
+
|
47
|
+
def index_key
|
48
|
+
"#{element_register_prefix_option}_index"
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Nocode
|
4
|
+
module Steps
|
5
|
+
module Record
|
6
|
+
# Create a new hash from an existing hash mapping each key as configured by the
|
7
|
+
# key_mappings option. The key_mappings option should be in the form of:
|
8
|
+
# new_key => old_key
|
9
|
+
class Map < Step
|
10
|
+
option :key_mappings, :register
|
11
|
+
|
12
|
+
def perform
|
13
|
+
input = registers[register_option] || {}
|
14
|
+
output = {}
|
15
|
+
|
16
|
+
(key_mappings_option || {}).each do |to, from|
|
17
|
+
output[to.to_s] = input[from.to_s]
|
18
|
+
end
|
19
|
+
|
20
|
+
registers[register_option] = output
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
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.8
|
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-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler-audit
|
@@ -189,9 +189,13 @@ files:
|
|
189
189
|
- lib/nocode/steps/deserialize/json.rb
|
190
190
|
- lib/nocode/steps/deserialize/yaml.rb
|
191
191
|
- lib/nocode/steps/each.rb
|
192
|
+
- lib/nocode/steps/io/delete.rb
|
193
|
+
- lib/nocode/steps/io/list.rb
|
192
194
|
- lib/nocode/steps/io/read.rb
|
193
195
|
- lib/nocode/steps/io/write.rb
|
194
196
|
- lib/nocode/steps/log.rb
|
197
|
+
- lib/nocode/steps/map.rb
|
198
|
+
- lib/nocode/steps/record/map.rb
|
195
199
|
- lib/nocode/steps/serialize/csv.rb
|
196
200
|
- lib/nocode/steps/serialize/json.rb
|
197
201
|
- lib/nocode/steps/serialize/yaml.rb
|