iab-Oil 0.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,175 @@
1
+ require File.join(File.dirname(__FILE__),'DSLContext')
2
+ require File.join(File.dirname(__FILE__),'VPMSComponentSchemaInterpreter')
3
+ require 'yaml'
4
+
5
+ #create class that fills in for the RAILS class when rails is not around, e.g. when testing
6
+ #when RAILS is around this will have no effect
7
+ class HashWithIndifferentAccess < Hash
8
+ end
9
+
10
+ class VPMSSchemaInterpreter < DslContext
11
+
12
+ bubble :than, :is, :list, :the, :to, :at, :it, :end
13
+
14
+ def getResult
15
+ getResult = ""
16
+ getResult << startSchema
17
+ @erbAry.each do |a|
18
+ b = a.to_s
19
+ getResult << "\t"
20
+ getResult << processXPath(a, b)
21
+ end
22
+ getResult << endSchema
23
+ end
24
+
25
+ def processXPath(*args)
26
+ processXpath = ""
27
+ xpath = args[0]
28
+ boolEndOfPath = (args[0].length == 1)
29
+ processXpath << "\t"
30
+ processXpath << startElement(args[0].first, args[1], boolEndOfPath)
31
+ xpath.delete_at(0)
32
+ if xpath.length > 0
33
+ processXpath << startComplexType
34
+ processXpath << processXPath(xpath, args[1])
35
+ processXpath << endComplexType
36
+ end
37
+ processXpath << endElement
38
+ processXpath
39
+ end
40
+
41
+ def startSchema
42
+ #ToDo: Make this a widget - a schema open widget for example
43
+ openSchema = ""
44
+ openSchema << "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>\n"
45
+ openSchema << "<xs:schema xmlns:xs=\"http://www.w3.org/2001/XMLSchema\">\n"
46
+ openSchema
47
+ end
48
+
49
+ def endSchema
50
+ endSchema = ""
51
+ endSchema << "</xs:schema>\n"
52
+ endSchema
53
+ end
54
+
55
+ def startElement(*args)
56
+ #ToDo: Make this a widget - an element open widget for example
57
+ openElement = ""
58
+ openElement << "<xs:element name=\"#{args[0]}\""
59
+ #ToDo: do something better to get type info -
60
+ #if this is the ultimate point in the xpath, this pushes in a data type of string - thats all
61
+ if (args[2] == true) then
62
+ openElement << " type=\"xs:string\">\n"
63
+ else
64
+ openElement << ">\n"
65
+ end
66
+ #ToDo: Read the element type and other atts off the MD hash metadata.
67
+ #args 1 is the full xpath of the element used potentially to key into the md hash
68
+ #Potentially do this if args 2 is true (it's the last xpath step) and use args 1 for the key
69
+ #args 2 represents a key into a hash
70
+ #the @metaProps hash for example - see 'coverage'
71
+ #If there is an entry in that hash for this element's xpath, then a type attribute can be
72
+ #determined for it and gets used from the md hash - When the element is nesting a ct, there's no type attribute
73
+ #This key would be used to read off values in that hash, if it is a hash of hashes -
74
+ #i.e. if the buildingsCoverSumInsuredAmount key in the metaProps referenced a hash of metadata:
75
+ #It would also be possible to reference entries for this element in the existing
76
+ #xml dictionary, which is keyed on this element's xpath
77
+ openElement
78
+ end
79
+
80
+ def endElement
81
+ endElement = ""
82
+ endElement << "</xs:element>\n"
83
+ endElement
84
+ end
85
+
86
+ def startComplexType
87
+ #ToDo: Make this a widget - a schema open widget for example
88
+ openElement = ""
89
+ openElement << "<xs:complexType>\n"
90
+ openElement << startSequence
91
+ openElement
92
+ end
93
+
94
+ def endComplexType
95
+ endElement = ""
96
+ endElement << endSequence
97
+ endElement << "</xs:complexType>\n"
98
+ endElement
99
+ end
100
+
101
+ def startSequence
102
+ #ToDo: Make this a widget - a schema open widget for example
103
+ openElement = ""
104
+ openElement << "<xs:sequence>\n"
105
+ openElement
106
+ end
107
+
108
+ def endSequence
109
+ endElement = ""
110
+ endElement << "</xs:sequence>\n"
111
+ endElement
112
+ end
113
+
114
+ def coverage(*args)
115
+ @erbAry = []
116
+ @metaProps = {}
117
+ @erb = ""
118
+ @metaprop = ""
119
+ @argName = "#{args[0]}"
120
+ io = open(File.join(COVERAGE_DEF_ROOT,"/#{@argName}PropertyHash"),'r' )
121
+ @prdhash = YAML::load(io)
122
+ end
123
+
124
+ def endcoverage(*args)
125
+ end
126
+
127
+ def use(*args)
128
+
129
+ h = ""
130
+ lasth = ""
131
+ lasta = ""
132
+ args.each do |a|
133
+ unless a.class == Hash
134
+ lasth = String.new(h)
135
+ h << "#{a}"
136
+ lasta = a
137
+ end
138
+ end
139
+ hashname = @argName + h
140
+
141
+ #now figure out whether the last arg above leads to an empty hash
142
+ #i.e. it is really a single value field
143
+ #if so backup a level and read the property whose name = the last arg value passed in
144
+
145
+ specificProperty = false
146
+ myHash = @prdhash["#{hashname}"].clone
147
+ if (myHash.length == 1)
148
+ hashname = @argName + lasth
149
+ specificProperty = true
150
+ myHash = @prdhash["#{hashname}"].clone
151
+ end
152
+
153
+ @erb << myHash["#{'xpath'}"]
154
+
155
+ myHash.each do |property, value|
156
+ if (property != 'xpath' and (property =~ /MD$/) == nil) then
157
+ if (value == "" && (!specificProperty || (specificProperty && property == "#{lasta}"))) then
158
+ @erb << "/"
159
+ @erb << property
160
+ #In progress
161
+ #@metaprop = @erb.sub('/', '') stands as an xpath key to the metadata in the 'element properties' hash
162
+
163
+ end
164
+ end
165
+ end
166
+
167
+ erbTemp = @erb.split('/')
168
+ @erbAry.push(erbTemp)
169
+ @erb = ""
170
+
171
+ #xpaths each now in erbArray
172
+
173
+ end
174
+ end
175
+
@@ -0,0 +1,15 @@
1
+ <?xml version="1.0" encoding="ISO-8859-1"?>
2
+ <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
3
+ xmlns:xs="http://www.w3.org/2001/XMLSchema" version="1.0">
4
+
5
+ <xsl:output method="xml" encoding="ISO-8859-1" indent="yes" omit-xml-declaration="yes"/>
6
+
7
+ <xsl:template match="/">
8
+ <xsl:apply-templates select="xs:schema"/>
9
+ </xsl:template>
10
+
11
+ <xsl:template match="xs:schema">
12
+ <xsl:copy-of select="node()"/>
13
+ </xsl:template>
14
+
15
+ </xsl:stylesheet>
@@ -0,0 +1,90 @@
1
+ <?xml version="1.0" encoding="ISO-8859-1"?>
2
+ <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
3
+ xmlns:xs="http://www.w3.org/2001/XMLSchema" version="1.0">
4
+ <xsl:output method="xml" encoding="ISO-8859-1" indent="yes" omit-xml-declaration="yes"/>
5
+
6
+ <xsl:key match="xs:element" name="allElements" use="@name"/>
7
+ <xsl:key match="xs:element" name="prevElements" use="concat(../../../../../../../../../@name,../../../../../../@name,../../../@name,@name)"/>
8
+
9
+ <xsl:template match="/">
10
+ <xsl:call-template name="differentiateSchemaNodes">
11
+ <xsl:with-param name="ns" select="xs:schema"/>
12
+ </xsl:call-template>
13
+ </xsl:template>
14
+
15
+ <xsl:template name="differentiateSchemaNodes">
16
+ <xsl:param name="ns"/>
17
+ <xsl:for-each select="$ns/xs:element[count(. | key('allElements', @name)[1]) = 1]">
18
+ <xsl:apply-templates select="." mode="organiseSchemaNode">
19
+ <xsl:with-param name="ns" select="$ns"/>
20
+ </xsl:apply-templates>
21
+ </xsl:for-each>
22
+ </xsl:template>
23
+
24
+ <xsl:template match="*" mode="organiseSchemaNode">
25
+ <xsl:param name="ns"/>
26
+ <xsl:copy>
27
+ <xsl:apply-templates select="@*"/>
28
+ <xsl:if test="count(xs:complexType/xs:sequence)">
29
+ <xs:complexType>
30
+ <xs:sequence>
31
+ <xsl:call-template name="differentiateNodes">
32
+ <xsl:with-param name="ns" select="$ns/xs:element/xs:complexType/xs:sequence"/>
33
+ </xsl:call-template>
34
+ </xs:sequence>
35
+ </xs:complexType>
36
+ </xsl:if>
37
+ </xsl:copy>
38
+ </xsl:template>
39
+
40
+ <xsl:template name="differentiateNodes">
41
+ <xsl:param name="ns"/>
42
+ <!--
43
+ nodes in differentiate nodes is: <xsl:value-of select="count($ns/xs:element)"/>
44
+ nodeset in differentiate nodes is:
45
+ <xsl:copy-of select="$ns"/>
46
+ end nodeset
47
+ -->
48
+ <xsl:for-each select="$ns/xs:element[count(. | key('allElements', @name)[1]) = 1]">
49
+ <xsl:apply-templates select="." mode="organiseNode">
50
+ <xsl:with-param name="ns" select="$ns"/>
51
+ <xsl:with-param name="nn" select="@name"/>
52
+ </xsl:apply-templates>
53
+ </xsl:for-each>
54
+ </xsl:template>
55
+
56
+ <xsl:template match="*" mode="organiseNode">
57
+ <xsl:param name="ns"/>
58
+ <xsl:param name="nn"/>
59
+ <xsl:copy>
60
+ <xsl:apply-templates select="@*"/>
61
+ <xsl:if test="count(xs:complexType/xs:sequence)">
62
+ <xs:complexType>
63
+ <xs:sequence>
64
+ <!-- each unique child do
65
+ <xsl:value-of select="count($ns/xs:element[@name=$nn])"/>
66
+ <xsl:value-of select="count($ns/xs:element[@name=$nn]/xs:complexType/xs:sequence/xs:element[count(. | key('prevElements', concat(../../../../../../@name,../../../@name,@name))[1]) = 1])"/>
67
+ -->
68
+
69
+ <xsl:for-each select="$ns/xs:element[@name=$nn]/xs:complexType/xs:sequence/xs:element[count(. | key('prevElements', concat(../../../../../../../../../@name,../../../../../../@name,../../../@name,@name))[1]) = 1]">
70
+ <xsl:apply-templates select="." mode="organiseNode">
71
+ <xsl:with-param name="ns" select="$ns/xs:element[@name=$nn]/xs:complexType/xs:sequence"/>
72
+ <xsl:with-param name="nn" select="@name"/>
73
+ </xsl:apply-templates>
74
+ </xsl:for-each>
75
+
76
+ </xs:sequence>
77
+ </xs:complexType>
78
+ </xsl:if>
79
+ </xsl:copy>
80
+ </xsl:template>
81
+
82
+ <xsl:template match="xs:element" mode="trackPath"><xsl:value-of select="@name"/></xsl:template>
83
+
84
+ <xsl:template match="@*|node()">
85
+ <xsl:copy>
86
+ <xsl:apply-templates select="@*|node()"/>
87
+ </xsl:copy>
88
+ </xsl:template>
89
+
90
+ </xsl:stylesheet>
metadata ADDED
@@ -0,0 +1,89 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: iab-Oil
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.2
5
+ platform: ruby
6
+ authors:
7
+ - Gary Mawdsley
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2009-03-31 00:00:00 -07:00
13
+ default_executable:
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: mime-types
17
+ type: :runtime
18
+ version_requirement:
19
+ version_requirements: !ruby/object:Gem::Requirement
20
+ requirements:
21
+ - - ">="
22
+ - !ruby/object:Gem::Version
23
+ version: "1.15"
24
+ version:
25
+ - !ruby/object:Gem::Dependency
26
+ name: diff-lcs
27
+ type: :runtime
28
+ version_requirement:
29
+ version_requirements: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: 1.1.2
34
+ version:
35
+ description: Oil is a RAILS based mini language for Financial Applications
36
+ email: garymawdsley@gmail.com
37
+ executables: []
38
+
39
+ extensions: []
40
+
41
+ extra_rdoc_files: []
42
+
43
+ files:
44
+ - lib/CollesceProductInterpreter.rb
45
+ - lib/RailsProcessInterpreter.rb
46
+ - lib/CoverageInterpreter2.rb
47
+ - lib/RatingEngineResolver.rb
48
+ - lib/CoverageInterpreter.rb
49
+ - lib/SiteProcessInterpreter.rb
50
+ - lib/DataModelInterpreter.rb
51
+ - lib/VPMSComponentSchemaInterpreter.rb
52
+ - lib/DSLContext.rb
53
+ - lib/VPMSPackageSchemaInterpreter.rb
54
+ - lib/Element.rb
55
+ - lib/VPMSProductSchemaInterpreter.rb
56
+ - lib/LayoutInterpreter.rb
57
+ - lib/VPMSSchemaInterpreter.rb
58
+ - lib/ProductInterpreter2.rb
59
+ - lib/xslt/VPMSPackageSchemaInterpreter.xsl
60
+ - lib/xslt/VPMSSchemaInterpreter.xsl
61
+ has_rdoc: true
62
+ homepage: http://github.com/iab/Oil
63
+ post_install_message:
64
+ rdoc_options:
65
+ - --inline-source
66
+ - --charset=UTF-8
67
+ require_paths:
68
+ - lib
69
+ required_ruby_version: !ruby/object:Gem::Requirement
70
+ requirements:
71
+ - - ">="
72
+ - !ruby/object:Gem::Version
73
+ version: "0"
74
+ version:
75
+ required_rubygems_version: !ruby/object:Gem::Requirement
76
+ requirements:
77
+ - - ">="
78
+ - !ruby/object:Gem::Version
79
+ version: "0"
80
+ version:
81
+ requirements: []
82
+
83
+ rubyforge_project: Oil
84
+ rubygems_version: 1.2.0
85
+ signing_key:
86
+ specification_version: 2
87
+ summary: Oil is a RAILS based mini language for Financial Applications
88
+ test_files: []
89
+