iab-FinancialProductBuilder 0.1.3 → 0.1.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. data/lib/deriveDSL.rb +1 -1
  2. data/lib/models.rb +31 -22
  3. metadata +1 -1
data/lib/deriveDSL.rb CHANGED
@@ -74,7 +74,7 @@ dictionaryEntries = modelData.genDict(elements)
74
74
  # in .../libraries/coverages
75
75
  # in .../libraries/entities
76
76
  resultDMFiles.each do |k,v|
77
- File.open(File.join(OUTPUT, ORG,'git','libraries',"#{v[3]}","#{k}DataModel.rb"), 'w') {|f| f.write(v[0]) }
77
+ File.open(File.join(OUTPUT, ORG,'git','libraries',"#{v[3]}","#{k}EntityModel.rb"), 'w') {|f| f.write(v[0]) }
78
78
  File.open(File.join(OUTPUT, ORG,'git','libraries',"#{v[3]}","#{k}NodeName.rb"), 'w') {|f| f.write(v[1]) }
79
79
  File.open(File.join(OUTPUT, ORG,'git','libraries',"#{v[3]}","#{k}PropertyHash"), 'w') {|f| f.write(v[2]) }
80
80
  end
data/lib/models.rb CHANGED
@@ -3,17 +3,18 @@ require 'Element'
3
3
 
4
4
  class Models
5
5
  def generateFiles(result)
6
+ list = (result.collect {|x| x if x.coverage}).compact
6
7
  @result = Hash.new
7
8
  #collect statement reduces the list to a list of coverages only
8
9
  @entitycoverage = ""
9
10
  @entityModel = ""
10
11
  @nodeName = ""
11
- createClass((result.collect {|x| x if x.coverage}).compact)
12
+ createClass(nil,list)
12
13
 
13
14
  @entitycoverage = ""
14
15
  @propertyHash = ""
15
16
  @fieldDECs=""
16
- createHash((result.collect {|x| x if x.coverage}).compact)
17
+ createHash(nil,list)
17
18
 
18
19
  @result
19
20
  end
@@ -21,13 +22,14 @@ class Models
21
22
  def genDict(result)
22
23
  @distinctLabels = Hash.new
23
24
  @dictionary = ""
24
- createDictionaryEntries(result)
25
+ #createDictionaryEntries(result)
25
26
  @dictionary
26
27
  end
27
28
 
28
29
  # -- build entity model and propertyhashes files to plug into IAB library
29
- def createHash(list)
30
+ def createHash(parent,list)
30
31
  list.each do |e|
32
+ e.parent = parent if parent
31
33
  if (e.coverage)
32
34
  @entitycoverage = e.name
33
35
  end
@@ -36,7 +38,7 @@ class Models
36
38
  @propertyHash << "#{fieldline(f)}\n"
37
39
  @fieldDECs << "#{fieldDEC(e,f)}\n"
38
40
  end
39
- createHash(e.children) if e.children.length > 0
41
+ createHash(e,e.children) if e.children.length > 0
40
42
  if (e.coverage)
41
43
  @result[e.name.to_sym][2] = @propertyHash + @fieldDECs
42
44
  @result[e.name.to_sym][3] = e.type
@@ -46,20 +48,6 @@ class Models
46
48
  end
47
49
  end
48
50
 
49
- def createDictionaryEntries(list)
50
- list.each do |e|
51
- fieldPrefix = "'#{pname(e)}#{e.name}".downcase
52
- e.fields.each do |f|
53
- key = "#{pname(e)}#{e.name}#{f[:name]}"
54
- if !@distinctLabels.has_key?(key.to_sym)
55
- @dictionary << "\t\t\t#{fieldPrefix}_#{f[:name].downcase}' => '#{f[:name]}',\n"
56
- @distinctLabels[key.to_sym] = 1
57
- end
58
- end
59
- createDictionaryEntries(e.children) if e.children.length > 0
60
- end
61
- end
62
-
63
51
  def hashline(e)
64
52
  "#{pname(e)}#{e.name}: !map:HashWithIndifferentAccess\n xpath: \"#{pname2(e,'/')}#{e.name}\""
65
53
  end
@@ -71,21 +59,28 @@ class Models
71
59
  "#{pname(e)}#{e.name}#{f[:name]}: !map:HashWithIndifferentAccess\n xpath: \"#{pname2(e,'/')}#{e.name}/#{f}\""
72
60
  end
73
61
 
74
- def createClass(list)
62
+ def createClass(parent,list)
75
63
  list.each do |e|
64
+ e.parent = parent if parent
76
65
  if (e.coverage)
77
66
  @entitycoverage = e.name
78
67
  end
68
+ #build up the node name clauses
79
69
  @nodeName << "#{classline(e)}\n"
80
70
  nodeclauses(e.name)
81
71
 
82
72
  @entityModel << "#{classline(e)}\n"
73
+ #puts "classline for #{e.name} is #{classline(e)}"
74
+ #iterate around the children and build the entity model
83
75
  e.children.each do |c|
76
+ c.parent = e
84
77
  @entityModel << "#{childline(c)}\n"
85
78
  end
86
79
  @entityModel << "end\n"
87
80
  @nodeName << "end\n"
88
- createClass(e.children) if e.children.length > 0
81
+
82
+ #now take the children in turn
83
+ createClass(e,e.children) if e.children.length > 0
89
84
  if (e.coverage)
90
85
  @result[e.name.to_sym] = []
91
86
  @result[e.name.to_sym][0] = @entityModel
@@ -122,8 +117,22 @@ class Models
122
117
  pname = parent.name + delimiter + pname
123
118
  parent = parent.parent
124
119
  end
125
- pname = @entitycoverage + delimiter + pname if !e.coverage
120
+ pname = pname if !e.coverage
126
121
  pname
127
122
  end
123
+
124
+ def createDictionaryEntries(list)
125
+ list.each do |e|
126
+ fieldPrefix = "'#{pname(e)}#{e.name}".downcase
127
+ e.fields.each do |f|
128
+ key = "#{pname(e)}#{e.name}#{f[:name]}"
129
+ if !@distinctLabels.has_key?(key.to_sym)
130
+ @dictionary << "\t\t\t#{fieldPrefix}_#{f[:name].downcase}' => '#{f[:name]}',\n"
131
+ @distinctLabels[key.to_sym] = 1
132
+ end
133
+ end
134
+ createDictionaryEntries(e.children) if e.children.length > 0
135
+ end
136
+ end
128
137
  end
129
138
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: iab-FinancialProductBuilder
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gary Mawdsley