dtr_core 0.8.0 → 0.9.0
Sign up to get free protection for your applications and to get access to all the features.
- 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 -7
- data/lib/dtr_core/user_defined_type.rb +1 -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
@@ -41,8 +41,6 @@ module DTRCore
|
|
41
41
|
.split(/\n\s*\*\s*\[/).map { |x| "[#{x.strip}" }
|
42
42
|
.map { |definition| DTRCore::State.from_definition(definition) }
|
43
43
|
|
44
|
-
raise 'Empty state section.' if state_definitions.empty?
|
45
|
-
|
46
44
|
@state_section ||= state_definitions
|
47
45
|
end
|
48
46
|
|
@@ -59,8 +57,6 @@ module DTRCore
|
|
59
57
|
|
60
58
|
function_definitions.reject! { |x| x.name.nil? }
|
61
59
|
|
62
|
-
raise 'Empty interface section.' if function_definitions.empty?
|
63
|
-
|
64
60
|
@interface_section ||= function_definitions
|
65
61
|
end
|
66
62
|
|
@@ -81,7 +77,7 @@ module DTRCore
|
|
81
77
|
end
|
82
78
|
|
83
79
|
def helpers_section
|
84
|
-
return @
|
80
|
+
return @helpers_section if @helpers_section
|
85
81
|
|
86
82
|
helpers_section = capture_section(/\[Helpers\]:(?<all>.*)\s*:\[Helpers\]/m)
|
87
83
|
|
@@ -93,9 +89,17 @@ module DTRCore
|
|
93
89
|
|
94
90
|
function_definitions.reject! { |x| x.name.nil? }
|
95
91
|
|
96
|
-
raise 'Empty helpers section.' if function_definitions.empty?
|
97
|
-
|
98
92
|
@helpers_section ||= function_definitions
|
99
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
|
100
104
|
end
|
101
105
|
end
|
@@ -33,7 +33,7 @@ module DTRCore
|
|
33
33
|
next { name: splitted[0].strip, type: splitted[1].strip } if splitted.length > 1
|
34
34
|
|
35
35
|
splitted = x.split('=')
|
36
|
-
next { name: splitted[0].strip,
|
36
|
+
next { name: splitted[0].strip, type: splitted[1].strip } if splitted.length > 1
|
37
37
|
|
38
38
|
nil
|
39
39
|
end&.compact
|
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.
|