dtr_core 0.8.1 → 0.9.0
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/lib/dtr_core/contract.rb +12 -4
- data/lib/dtr_core/function.rb +1 -1
- data/lib/dtr_core/parser.rb +11 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b6eb9933172ea48536b0efceffe9e9e222a54e37f214b8041dc5edd40c01f2d6
|
4
|
+
data.tar.gz: 731d58a093c47bfd2b63f4ea884d4422d703b2c2ba47baacbda105bfb02e2264
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: '04824f70c5646161afb24637f614f1ba2431414cc5f98b8847b15f74299ba563957586ba40a88d36847d1cfce649462199a42508a0d276397dbe3f38d1ee7e59'
|
7
|
+
data.tar.gz: 106a92f8de4ca9385d44f510dbb942b05d073bd2584d7dabbfe7d3003d348a121c21765da246e2c450a25df92cfb5151d1b541cf5b28029d96acd6ff1875c423
|
data/lib/dtr_core/contract.rb
CHANGED
@@ -3,28 +3,29 @@
|
|
3
3
|
module DTRCore
|
4
4
|
# Represents a contract in a DTR file.
|
5
5
|
class Contract
|
6
|
-
attr_reader :helpers, :interface, :name, :state, :user_defined_types
|
6
|
+
attr_reader :helpers, :interface, :name, :state, :user_defined_types, :non_translatables
|
7
7
|
|
8
|
-
def initialize(name, state, interface, user_defined_types, helpers)
|
8
|
+
def initialize(name, state, interface, user_defined_types, helpers, non_translatables)
|
9
9
|
@name = name
|
10
10
|
@state = state
|
11
11
|
@interface = interface
|
12
12
|
@user_defined_types = user_defined_types
|
13
13
|
@helpers = helpers
|
14
|
+
@non_translatables = non_translatables
|
14
15
|
end
|
15
16
|
|
16
17
|
def self.from_dtr(filepath)
|
17
18
|
parser = DTRCore::Parser.new(filepath)
|
18
19
|
|
19
20
|
new(parser.name_section, parser.state_section, parser.interface_section, parser.user_defined_types_section,
|
20
|
-
parser.helpers_section)
|
21
|
+
parser.helpers_section, parser.non_translatable_section)
|
21
22
|
end
|
22
23
|
|
23
24
|
def self.from_dtr_raw(content)
|
24
25
|
parser = DTRCore::Parser.new('', content:)
|
25
26
|
|
26
27
|
new(parser.name_section, parser.state_section, parser.interface_section, parser.user_defined_types_section,
|
27
|
-
parser.helpers_section)
|
28
|
+
parser.helpers_section, parser.non_translatable_section)
|
28
29
|
end
|
29
30
|
|
30
31
|
def ==(other)
|
@@ -42,6 +43,7 @@ module DTRCore
|
|
42
43
|
return_string += interface_to_s
|
43
44
|
return_string += user_defined_types_to_s
|
44
45
|
return_string += helpers_to_s
|
46
|
+
return_string += non_translatables_to_s
|
45
47
|
|
46
48
|
return_string
|
47
49
|
end
|
@@ -75,5 +77,11 @@ module DTRCore
|
|
75
77
|
|
76
78
|
"[Helpers]:\n#{@helpers&.map(&:to_s)&.join("\n")}\n:[Helpers]\n"
|
77
79
|
end
|
80
|
+
|
81
|
+
def non_translatables_to_s
|
82
|
+
return '' if @non_translatables.nil?
|
83
|
+
|
84
|
+
"[NonTranslatable]:\n#{@non_translatables}\n:[NonTranslatable]"
|
85
|
+
end
|
78
86
|
end
|
79
87
|
end
|
data/lib/dtr_core/function.rb
CHANGED
@@ -97,7 +97,7 @@ module DTRCore
|
|
97
97
|
instruction = DTRCore::Instruction.new(
|
98
98
|
instruction[/instruction:\s*(?<all>[^\s,]+)/, 1],
|
99
99
|
parse_function_instruction_input(instruction),
|
100
|
-
instruction[/\s*assign:\s
|
100
|
+
instruction[/\s*assign:\s*\[?(?<all>[^\s\,\]]+)\]?/, 1],
|
101
101
|
instruction[/\s*scope:\s*(?<all>[^\s\,]+)/, 1].to_i || 0
|
102
102
|
)
|
103
103
|
|
data/lib/dtr_core/parser.rb
CHANGED
@@ -77,7 +77,7 @@ module DTRCore
|
|
77
77
|
end
|
78
78
|
|
79
79
|
def helpers_section
|
80
|
-
return @
|
80
|
+
return @helpers_section if @helpers_section
|
81
81
|
|
82
82
|
helpers_section = capture_section(/\[Helpers\]:(?<all>.*)\s*:\[Helpers\]/m)
|
83
83
|
|
@@ -91,5 +91,15 @@ module DTRCore
|
|
91
91
|
|
92
92
|
@helpers_section ||= function_definitions
|
93
93
|
end
|
94
|
+
|
95
|
+
def non_translatable_section
|
96
|
+
return @non_translatable_section if @non_translatable_section
|
97
|
+
|
98
|
+
non_translatable_section = capture_section(/\[NonTranslatable\]:(?<all>.*)\s*:\[NonTranslatable\]/m)
|
99
|
+
|
100
|
+
return nil if non_translatable_section.nil?
|
101
|
+
|
102
|
+
@non_translatable_section = non_translatable_section
|
103
|
+
end
|
94
104
|
end
|
95
105
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dtr_core
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.9.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Rob Durst
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-
|
11
|
+
date: 2024-07-07 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: Core smart contract intermediate language (Digicus Textual Representation)
|
14
14
|
parser.
|