iab-Oil 0.1.2 → 0.1.3
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.
- data/lib/Element.rb +22 -0
- data/lib/LayoutInterpreter.rb +15 -1
- data/lib/ProductInterpreter.rb +62 -0
- metadata +2 -1
data/lib/Element.rb
CHANGED
@@ -9,4 +9,26 @@ class Element
|
|
9
9
|
@fields = []
|
10
10
|
@type = type
|
11
11
|
end
|
12
|
+
|
13
|
+
def info
|
14
|
+
puts "@coverage=#{@coverage},@name=#{@name},@type=#{@type},PARENT=#{parent},CHILDREN=#{offspring}"
|
15
|
+
end
|
16
|
+
|
17
|
+
def succinct_info
|
18
|
+
"@name=#{@name}"
|
19
|
+
end
|
20
|
+
|
21
|
+
def parent
|
22
|
+
return @parent.info if @parent
|
23
|
+
end
|
24
|
+
|
25
|
+
def offspring
|
26
|
+
childrenStr=""
|
27
|
+
if (@children and @children.length > 0)
|
28
|
+
@children.each do |c|
|
29
|
+
childrenStr += "<#{c.succinct_info}>"
|
30
|
+
end
|
31
|
+
end
|
32
|
+
childrenStr
|
33
|
+
end
|
12
34
|
end
|
data/lib/LayoutInterpreter.rb
CHANGED
@@ -160,7 +160,21 @@ class LayoutInterpreter < DslContext
|
|
160
160
|
dsl << "hideFields \"#{args[1][:hide]}\"\n" if args[1][:hide]
|
161
161
|
dsl << "columns \"#{args[1][:columns]}\"\n" if args[1][:columns]
|
162
162
|
end
|
163
|
-
|
163
|
+
#if a use statement accompanies the entity clause in a layout then take this
|
164
|
+
#in preference to using the product level view for the entity
|
165
|
+
if (args[1] and args[1][:use])
|
166
|
+
dsl << "entity :#{args[0]}\nuse #{interpretUse(args[1][:use])}\nendentity"
|
167
|
+
else
|
168
|
+
dsl << @contents.to_s
|
169
|
+
end
|
164
170
|
@erb << CoverageInterpreter.execute(dsl, args[1])
|
165
171
|
end
|
172
|
+
|
173
|
+
def interpretUse(use)
|
174
|
+
result = ''
|
175
|
+
use.each do |e|
|
176
|
+
result << "#{(e == use.first ? '':',')}:#{e}"
|
177
|
+
end
|
178
|
+
result
|
179
|
+
end
|
166
180
|
end
|
@@ -0,0 +1,62 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__),'DSLContext')
|
2
|
+
|
3
|
+
#create class that fills in for the RAILS class when rails is not around, e.g. when testing
|
4
|
+
#when RAILS is around this will have no effect
|
5
|
+
class HashWithIndifferentAccess < Hash
|
6
|
+
end
|
7
|
+
|
8
|
+
class ProductInterpreter < DslContext
|
9
|
+
|
10
|
+
bubble :than, :is, :list, :the, :to, :at, :it, :end
|
11
|
+
|
12
|
+
def getResult
|
13
|
+
@classDef+@requires
|
14
|
+
end
|
15
|
+
|
16
|
+
def product(*args)
|
17
|
+
@requires = ""
|
18
|
+
@classDef = "class Marshaller::#{args[0]} < ActiveRecord::Base\n"
|
19
|
+
@classDef << "@@nodeName = \"#{args[0]}\"\n"
|
20
|
+
end
|
21
|
+
|
22
|
+
def endproduct
|
23
|
+
@classDef << "def self.nodeName\n"
|
24
|
+
@classDef << "@@nodeName\n"
|
25
|
+
@classDef << "end\n"
|
26
|
+
@classDef << "end\n"
|
27
|
+
end
|
28
|
+
|
29
|
+
def entities(*args)
|
30
|
+
@libtype = "entities"
|
31
|
+
end
|
32
|
+
|
33
|
+
def endentities
|
34
|
+
|
35
|
+
end
|
36
|
+
|
37
|
+
def coverages(*args)
|
38
|
+
@libtype = "coverages"
|
39
|
+
end
|
40
|
+
|
41
|
+
def endcoverages
|
42
|
+
|
43
|
+
end
|
44
|
+
|
45
|
+
def has_one(*args)
|
46
|
+
@requires << "require '#{LIBRARY_ROOT}/#{@libtype}/#{args[0]}EntityModel.rb'\n"
|
47
|
+
@requires << "require '#{LIBRARY_ROOT}/#{@libtype}/#{args[0]}NodeName.rb'\n"
|
48
|
+
@classDef << "has_one :#{args[0]}\n"
|
49
|
+
end
|
50
|
+
|
51
|
+
def has_many(*args)
|
52
|
+
@requires << "require '#{LIBRARY_ROOT}/#{@libtype}/#{args[0]}EntityModel.rb'\n"
|
53
|
+
@requires << "require '#{LIBRARY_ROOT}/#{@libtype}/#{args[0]}NodeName.rb'\n"
|
54
|
+
@classDef << "has_many :#{args[0]}\n"
|
55
|
+
end
|
56
|
+
|
57
|
+
def has_between(*args)
|
58
|
+
@requires << "require '#{LIBRARY_ROOT}/#{@libtype}/#{args[2]}EntityModel.rb'\n"
|
59
|
+
@requires << "require '#{LIBRARY_ROOT}/#{@libtype}/#{args[2]}NodeName.rb'\n"
|
60
|
+
@classDef << "has_many :#{args[2]}\n"
|
61
|
+
end
|
62
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: iab-Oil
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Gary Mawdsley
|
@@ -55,6 +55,7 @@ files:
|
|
55
55
|
- lib/VPMSProductSchemaInterpreter.rb
|
56
56
|
- lib/LayoutInterpreter.rb
|
57
57
|
- lib/VPMSSchemaInterpreter.rb
|
58
|
+
- lib/ProductInterpreter.rb
|
58
59
|
- lib/ProductInterpreter2.rb
|
59
60
|
- lib/xslt/VPMSPackageSchemaInterpreter.xsl
|
60
61
|
- lib/xslt/VPMSSchemaInterpreter.xsl
|