Class: ProductConfig
- Inherits:
-
Object
- Object
- ProductConfig
- Defined in:
- lib/productconfig.rb
Instance Method Summary collapse
- #copyDirectoryWithoutHiddenRecursively(src, dest) ⇒ Object
- #createManifest(product, dataelements) ⇒ Object
- #genViews(dataelements) ⇒ Object
- #getFields(parent, e, depth, topLevelName) ⇒ Object
- #pname(e, delimiter, topLevelName) ⇒ Object
Instance Method Details
#copyDirectoryWithoutHiddenRecursively(src, dest) ⇒ Object
76 77 78 79 80 81 82 83 84 85 86 87 88 89 |
# File 'lib/productconfig.rb', line 76 def copyDirectoryWithoutHiddenRecursively(src, dest) # make the destination directory if it does not exist unless (File.directory?(dest)) then FileUtils.mkpath(dest) end # recursively copy files and folders without hidden files Dir.glob(File.join(src, '*'), File::FNM_PATHNAME) do |p| if (File.directory?(p)) copyDirectoryWithoutHiddenRecursively(p, File.join(dest, File.basename(p))) else FileUtils.cp(p, dest) end end end |
#createManifest(product, dataelements) ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/productconfig.rb', line 4 def createManifest(product,dataelements) result = "product :#{product}\n" result << "\tcoverages\n" (dataelements.collect {|x| x if x.type == "coverages"}).compact.each do |e| result << "\t\thas_one :#{e.name}\n" end result << "\tendcoverages\n" result << "\tentities\n" (dataelements.collect {|x| x if x.type == "entities"}).compact.each do |e| result << "\t\thas_one :#{e.name}\n" end result << "\tendentities\n" result << "endproduct\n" end |
#genViews(dataelements) ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/productconfig.rb', line 19 def genViews(dataelements) result = Array.new result[0] = Array.new result[1] = Array.new (dataelements.collect {|x| x if x.type == "coverages"}).compact.each do |e| text = "coverage :#{e.name}\n" text << getFields(nil,e,1,e.name) text << "endcoverage" a = Array.new a.push e.name a.push text result[0].push a end (dataelements.collect {|x| x if x.type == "entities"}).compact.each do |e| text = "entity :#{e.name}\n" text << getFields(nil,e,1,e.name) text << "endentity" a = Array.new a.push e.name a.push text result[1].push a end result end |
#getFields(parent, e, depth, topLevelName) ⇒ Object
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/productconfig.rb', line 47 def getFields(parent,e,depth,topLevelName) text = "" e.parent = parent if parent if (e.fields and e.fields.length > 0) e.fields.each do |f| ename="" ename = ":#{e.name}," if e.name != topLevelName text << "\tuse "+"#{pname(e,",",topLevelName)}"+"#{ename}:#{f[:name]}\n" end end if (e.children and e.children.length > 0) e.children.each do |c| text << getFields(e,c,depth+1,topLevelName) end end text end |
#pname(e, delimiter, topLevelName) ⇒ Object
66 67 68 69 70 71 72 73 74 |
# File 'lib/productconfig.rb', line 66 def pname(e,delimiter,topLevelName) pname = "" parent = e.parent while parent pname = ":" + parent.name + delimiter + pname if (parent.name != topLevelName) parent = parent.parent end pname end |