Class: BConv::Bake

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

Constant Summary collapse

START_INFO =
1
END_INFO =
2
BEFORE_INFO =
3
VAR =
4

Instance Method Summary collapse

Constructor Details

#initialize(map, setMock, configFile, debugMode) ⇒ Bake

Returns a new instance of Bake.



16
17
18
19
20
21
# File 'lib/Bake.rb', line 16

def initialize(map, setMock, configFile, debugMode)
  @map = map
  @setMock = setMock
  @configFile = configFile
  @debugMode = debugMode
end

Instance Method Details

#getHash(bakeLines) ⇒ Object



46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
# File 'lib/Bake.rb', line 46

def getHash(bakeLines)
  b_hash = {}
  key = ""
  value = []
  state = Bake::BEFORE_INFO
  
  bakeLines.each_line do |line|
    if line.start_with?("  ") && line[2] != " "
        if state == Bake::VAR
          value << line.strip if value != nil
          value = line.strip if value == nil
          b_hash.store(key,value)
        end
    elsif line.start_with?(" ") && line[1] != " "
      if state == Bake::START_INFO || state == Bake::VAR
        key = ""
        value = []
        key = line.strip
        b_hash.store(key,value)
        state = VAR
      end
    else
      if line.match("START_INFO") && line[0] != " "
        state = Bake::START_INFO
      elsif line.match("END_INFO")
        state = Bake::END_INFO
      end
    end
  end
  
  if state != Bake::END_INFO
    puts "Error: There is a problem with END_INFO. No output file could be generated!"
    return nil
  end
    
  return b_hash
end

#runObject



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/Bake.rb', line 23

def run
  bakeLines = ''
  begin
  cmd = @setMock ? ['ruby','C:/_dev/projects/bakeMock/bakeMock/bakeMock.rb'] : ['bake']
  cmd << '-b' << @map['BuildConfig']
  cmd << '-m' << @map['MainProj']
  cmd << '-p' << @map['Proj2Convert']
  cmd << '--conversion_info'
  Util.strToArray('Workspace', @map).each { |w| cmd << '-w' << w }

  Dir.chdir(File.dirname(@configFile)) do      
    bakeLines = `#{cmd.join(' ')}`
  end
  
  rescue Exception => e
    puts e.message
    puts e.back_trace if @debugMode == true
    abort
  end
        
  return bakeLines
end