Method: Shaml::CommandLoader#convert_file

Defined in:
lib/shaml/command.rb

#convert_file(file, appname, modelname, propertydescriptor = nil) ⇒ Object



36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
# File 'lib/shaml/command.rb', line 36

def convert_file(file, appname, modelname, propertydescriptor = nil)
  out = ""
  pstring = ""
  propertydescriptor = "" if propertydescriptor.nil?
  insideprop = false
  file.each_line do |line|
    if insideprop then
      if line.strip =~ /__END__PROPERTY__/ then
        propertydescriptor.split(";").each do |property|
          p = property.split(":")
          out << pstring.gsub("PropertyType",p[1]).gsub("Property",p[0])
        end
        insideprop = false
      else
        pstring << line.gsub("WebBase",appname).gsub("WebSample", camelcase(modelname)).gsub("websample", modelname);
      end
    else
      if line.strip =~ /__BEGIN__PROPERTY__/ then
        pstring = ""
        insideprop = true
      else
        out << line.gsub("WebBase",appname).gsub("WebSample", camelcase(modelname)).gsub("websample", modelname);
      end
    end
  end
  out
end