trailblazer-core-utils 0.0.2 → 0.0.3
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 +6 -0
- data/Rakefile +1 -1
- data/lib/trailblazer/core/utils/convert_operation_test.rb +25 -8
- data/lib/trailblazer/core/utils/inspect.rb +24 -0
- data/lib/trailblazer/core/utils/version.rb +1 -1
- data/lib/trailblazer/core.rb +1 -0
- metadata +3 -3
- data/sig/trailblazer/core/utils.rbs +0 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 275a1cdc26964260f5ee4cf9fb3b7a29b11529284991424f362ea2458c6981f0
|
4
|
+
data.tar.gz: 40c2da81a31c35a032c3cda8864e3814d3c8097d885a7036d6ed20e2e3c18090
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f6a3c8fbd5f39a5a354e669473e60b1b14059f6846237def36d5eb9e7b8d2941602b473038225dbf95bb8540850e7ca6e581bbf36835a3c587876bbe9b4ff928
|
7
|
+
data.tar.gz: 6a536400f0d83044a6fc641cb1f787b2e5be2928e6d1bda147ab56915804ef1ce9e4da3346c4a7c7602d89dc543e06e814505a58800f63f989f8102425bfcdd3
|
data/CHANGELOG.md
CHANGED
data/Rakefile
CHANGED
@@ -2,15 +2,17 @@ module Trailblazer
|
|
2
2
|
module Core
|
3
3
|
module Utils
|
4
4
|
# Convert an Activity test into an operation test.
|
5
|
-
# Store at {
|
5
|
+
# Store at {:target}
|
6
6
|
#
|
7
7
|
# {#~ctx_to_result} allows to always convert ctx to result within the block.
|
8
8
|
|
9
|
+
# TODO: add {skip}
|
9
10
|
module ConvertOperationTest
|
10
|
-
def self.call(filepath)
|
11
|
+
def self.call(filepath, target:, source_gem:)
|
11
12
|
within_marker = false
|
12
13
|
within_ignore = false
|
13
14
|
within_ctx_to_result = false
|
15
|
+
within_keep = false
|
14
16
|
|
15
17
|
op_test =
|
16
18
|
File.foreach(filepath).collect do |line|
|
@@ -21,7 +23,14 @@ module Trailblazer
|
|
21
23
|
within_marker = false
|
22
24
|
end
|
23
25
|
|
24
|
-
if line.match(/#~
|
26
|
+
if line.match(/#~keep$/)
|
27
|
+
within_keep = true
|
28
|
+
end
|
29
|
+
if line.match(/#~keep end/)
|
30
|
+
within_keep = false
|
31
|
+
end
|
32
|
+
|
33
|
+
if line.match(/#~ignore/)
|
25
34
|
within_ignore = true
|
26
35
|
end
|
27
36
|
if line.match(/#~ignore end/)
|
@@ -38,9 +47,17 @@ module Trailblazer
|
|
38
47
|
if within_ignore
|
39
48
|
# puts "@@@@@ #{line.inspect}"
|
40
49
|
line = ""
|
50
|
+
elsif within_keep
|
51
|
+
line
|
41
52
|
else
|
42
|
-
|
43
|
-
|
53
|
+
if match = line.match(/#!hint (.+)/)
|
54
|
+
ws = line.match(/^(\s+)/) # Find out number of whitespace before code starts.
|
55
|
+
|
56
|
+
line = (" " * ws[1].size) + match[1] + "\n"
|
57
|
+
else
|
58
|
+
line = line.sub("< Trailblazer::Activity::Railway", "< Trailblazer::Operation")
|
59
|
+
line = line.sub("< Trailblazer::Activity::FastTrack", "< Trailblazer::Operation")
|
60
|
+
line = line.gsub("::Activity", "::Operation")
|
44
61
|
|
45
62
|
# if within_marker
|
46
63
|
line = line.sub("signal, (ctx, _) =", "result =")
|
@@ -57,6 +74,7 @@ module Trailblazer
|
|
57
74
|
semantic = match[2]
|
58
75
|
line = "#{match[1]}result.success? # => #{semantic == ":success" ? true : false}\n"
|
59
76
|
end
|
77
|
+
end
|
60
78
|
# end
|
61
79
|
|
62
80
|
line = line.sub("assert_equal ctx", "assert_equal result")
|
@@ -66,10 +84,9 @@ module Trailblazer
|
|
66
84
|
line
|
67
85
|
end
|
68
86
|
|
69
|
-
op_test.insert(
|
70
|
-
op_test << "end"
|
87
|
+
op_test.insert(0, "# THIS FILE IS AUTOGENERATED FROM #{source_gem}/#{filepath}\n")
|
71
88
|
|
72
|
-
File.write
|
89
|
+
File.write target, op_test.join("")
|
73
90
|
end
|
74
91
|
|
75
92
|
end # ConvertOperationTest
|
@@ -0,0 +1,24 @@
|
|
1
|
+
module Trailblazer
|
2
|
+
module Core
|
3
|
+
module Utils
|
4
|
+
def self.inspect(object)
|
5
|
+
return object.inspect unless object.is_a?(Hash)
|
6
|
+
|
7
|
+
old_string = object.inspect
|
8
|
+
# old_string = %({{symbol: 1, "string" => 2},"string" => 1})
|
9
|
+
|
10
|
+
new_string = old_string.gsub(/([{ ])(\w+): /, '\1:\2=>')
|
11
|
+
new_string = new_string.gsub(" => ", "=>")
|
12
|
+
|
13
|
+
return new_string
|
14
|
+
"asdfafasdff"
|
15
|
+
|
16
|
+
# if Gem::Version.new(RUBY_VERSION) < Gem::Version.new("2.7.0") || RUBY_ENGINE == 'jruby'
|
17
|
+
# "#{name}"
|
18
|
+
# else
|
19
|
+
# ":#{name}"
|
20
|
+
# end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
data/lib/trailblazer/core.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: trailblazer-core-utils
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nick Sutterer
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2024-11-07 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description:
|
14
14
|
email:
|
@@ -24,9 +24,9 @@ files:
|
|
24
24
|
- lib/trailblazer/core.rb
|
25
25
|
- lib/trailblazer/core/utils.rb
|
26
26
|
- lib/trailblazer/core/utils/convert_operation_test.rb
|
27
|
+
- lib/trailblazer/core/utils/inspect.rb
|
27
28
|
- lib/trailblazer/core/utils/symbol_inspect_for.rb
|
28
29
|
- lib/trailblazer/core/utils/version.rb
|
29
|
-
- sig/trailblazer/core/utils.rbs
|
30
30
|
homepage: https://trailblazer.to
|
31
31
|
licenses: []
|
32
32
|
metadata:
|