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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d7262ad471060f31d350056263e7c7e7fef3a37451aa6e62dd8ec7fc6bc14ed6
4
- data.tar.gz: 72ab429eba23bbe05fe544a940c14b169460812abac111f789631c218dff9f9c
3
+ metadata.gz: e9d07ea7a38c72d9198df2495089bbf3722fc531ed745afcf48df6bc0a03030a
4
+ data.tar.gz: 87a3774c28aca0c9971af4dc1be8d7de9a6002e87b2cb517f4cf5435903c9561
5
5
  SHA512:
6
- metadata.gz: 4aa2e73de48f3fa830191fd343672aae42a2772508ec14a8934e9bcfe184d32eb6be6ae7b0f6aa10bd5374865b529fb79592aa61f03fb3ea0900dd369c6c846b
7
- data.tar.gz: af2b76f508014aadc00445fc9e942a4036579fdd7c2812f6b6b614e7d8539f0ea8a511b29e221fb87d4cfbb10b3551c07739596cd8fea35c71df84fec991ac93
6
+ metadata.gz: 225e0d639f677150e8b921e209adb6731b7e400facd61dbd9efed2d7cd3eb8dfe3b1d704ebf6c909062eb70b4eb172891beee69309bbc70ab048dd5042744f0a
7
+ data.tar.gz: 55acd1a86a174b36500b603b9720a4f121cdcf8dc88934392e2ce7b62194412a6e14b658766254254c6aa2967ad8adf2c1e5114ea6edda417557a3a11de56361
@@ -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 &&
@@ -7,10 +7,14 @@ module DTRCore
7
7
  class Parser
8
8
  include ::DTRCore::Common
9
9
 
10
- def initialize(file_path)
11
- raise "Unable to find file: #{file_path}." unless File.exist?(file_path)
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
- @content = File.read(file_path)
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* \* .+\n?)*)*)/)
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.1.1
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 00:00:00.000000000 Z
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.