Top Level Namespace

Defined Under Namespace

Modules: Abi Classes: ContractDetailsCache

Instance Method Summary collapse

Instance Method Details

#format_code(txt) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/abibase.rb', line 12

def format_code( txt )
  ##  {{ to {
  ## and }} to }
  txt = txt.strip.sub( /\A\{\{/, '{').sub( /\}\}\z/, '}' )

  data = JSON.parse( txt )
  ## pp data

  language = data['language']
  pp language
  if language != 'Solidity'
    puts "!! ERROR - expected Solidity for language; got: #{language}"
    exit 1
  end

  sources = data['sources']
  puts "  #{sources.size} source(s)"

  buf = ''
  sources.each do |name, h|
     buf << "///////////////////////////////////////////\n"
     buf << "// File: #{name}\n\n"
     buf << h['content']
     buf << "\n\n"
  end
  buf
end