dtr_core 0.1.1 → 0.2.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 +6 -0
- data/lib/dtr_core/parser.rb +9 -5
- 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: e9d07ea7a38c72d9198df2495089bbf3722fc531ed745afcf48df6bc0a03030a
|
4
|
+
data.tar.gz: 87a3774c28aca0c9971af4dc1be8d7de9a6002e87b2cb517f4cf5435903c9561
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 225e0d639f677150e8b921e209adb6731b7e400facd61dbd9efed2d7cd3eb8dfe3b1d704ebf6c909062eb70b4eb172891beee69309bbc70ab048dd5042744f0a
|
7
|
+
data.tar.gz: 55acd1a86a174b36500b603b9720a4f121cdcf8dc88934392e2ce7b62194412a6e14b658766254254c6aa2967ad8adf2c1e5114ea6edda417557a3a11de56361
|
data/lib/dtr_core/contract.rb
CHANGED
@@ -17,6 +17,12 @@ module DTRCore
|
|
17
17
|
new(parser.name_section, parser.state_section, parser.function_section)
|
18
18
|
end
|
19
19
|
|
20
|
+
def self.from_dtr_raw(content)
|
21
|
+
parser = DTRCore::Parser.new('', content:)
|
22
|
+
|
23
|
+
new(parser.name_section, parser.state_section, parser.function_section)
|
24
|
+
end
|
25
|
+
|
20
26
|
def ==(other)
|
21
27
|
name == other.name &&
|
22
28
|
state == other.state &&
|
data/lib/dtr_core/parser.rb
CHANGED
@@ -7,10 +7,14 @@ module DTRCore
|
|
7
7
|
class Parser
|
8
8
|
include ::DTRCore::Common
|
9
9
|
|
10
|
-
def initialize(file_path)
|
11
|
-
|
10
|
+
def initialize(file_path, content: nil)
|
11
|
+
if content
|
12
|
+
@content = content
|
13
|
+
else
|
14
|
+
raise "Unable to find file: #{file_path}." unless File.exist?(file_path)
|
12
15
|
|
13
|
-
|
16
|
+
@content = File.read(file_path)
|
17
|
+
end
|
14
18
|
end
|
15
19
|
|
16
20
|
attr_reader :content
|
@@ -23,13 +27,13 @@ module DTRCore
|
|
23
27
|
|
24
28
|
raise 'Missing contract name.' if name_section.nil?
|
25
29
|
|
26
|
-
@name_section ||= name_section
|
30
|
+
@name_section ||= name_section.strip
|
27
31
|
end
|
28
32
|
|
29
33
|
def state_section
|
30
34
|
return @state_definitions if @state_definitions
|
31
35
|
|
32
|
-
state_section = first_match_for_content(/\[State\]:\s*((?:\s*\*\s*\[.+?\]\n(?:\s
|
36
|
+
state_section = first_match_for_content(/\[State\]:\s*((?:\s*\*\s*\[.+?\]\n(?:\s*\*.+\n?)*)*)/)
|
33
37
|
|
34
38
|
return nil if state_section.nil?
|
35
39
|
|
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.2.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-05-
|
11
|
+
date: 2024-05-12 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: Core smart contract intermediate language (Digicus Textual Representation)
|
14
14
|
parser.
|