Class: Ethereum::ProjectInitializer

Inherits:
Object
  • Object
show all
Defined in:
lib/ethereum/project_initializer.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(location, optimize = false) ⇒ ProjectInitializer

Returns a new instance of ProjectInitializer.


7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/ethereum/project_initializer.rb', line 7

def initialize(location, optimize = false)
  ENV['ETHEREUM_SOLIDITY_BINARY'] ||= "/usr/local/bin/solc"
  solidity = ENV['ETHEREUM_SOLIDITY_BINARY']
  contract_dir = location
  if optimize 
    opt_flag = "--optimize"
  else
    opt_flag = ""
  end
  compile_command = "#{solidity} #{opt_flag} --combined-json abi,bin #{contract_dir}"
  raw_data = `#{compile_command}`
  data = JSON.parse(raw_data)
  @contract_names = data["contracts"].keys
  @libraries = {} 
  @contracts = @contract_names.collect do |contract_name|
    ContractInitializer.new(contract_name, data["contracts"][contract_name], self)
  end
end

Instance Attribute Details

#combined_outputObject

Returns the value of attribute combined_output


5
6
7
# File 'lib/ethereum/project_initializer.rb', line 5

def combined_output
  @combined_output
end

#contract_namesObject

Returns the value of attribute contract_names


5
6
7
# File 'lib/ethereum/project_initializer.rb', line 5

def contract_names
  @contract_names
end

#contractsObject

Returns the value of attribute contracts


5
6
7
# File 'lib/ethereum/project_initializer.rb', line 5

def contracts
  @contracts
end

#librariesObject

Returns the value of attribute libraries


5
6
7
# File 'lib/ethereum/project_initializer.rb', line 5

def libraries
  @libraries
end