polyrex 0.8.3 → 0.8.4
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/polyrex.rb +23 -11
- metadata +12 -2
data/lib/polyrex.rb
CHANGED
@@ -8,10 +8,11 @@ require 'polyrex-objects'
|
|
8
8
|
require 'polyrex-createobject'
|
9
9
|
require 'ostruct'
|
10
10
|
require 'polyrex-object-methods'
|
11
|
+
require 'polyrex-xslt'
|
11
12
|
require 'rexle'
|
12
13
|
|
13
14
|
class Polyrex
|
14
|
-
attr_accessor :summary_fields
|
15
|
+
attr_accessor :summary_fields, :xslt_schema
|
15
16
|
|
16
17
|
def initialize(location)
|
17
18
|
|
@@ -20,6 +21,7 @@ class Polyrex
|
|
20
21
|
summary_h = Hash[*@doc.xpath("summary/*").map {|x| [x.name, x.text]}.flatten]
|
21
22
|
@summary = OpenStruct.new summary_h
|
22
23
|
@summary_fields = summary_h.keys.map(&:to_sym)
|
24
|
+
@polyrex_xslt = PolyrexXSLT.new
|
23
25
|
end
|
24
26
|
|
25
27
|
def create(id=nil)
|
@@ -71,15 +73,6 @@ class Polyrex
|
|
71
73
|
def element(s)
|
72
74
|
@doc.element(s)
|
73
75
|
end
|
74
|
-
|
75
|
-
def xpath(s, &blk)
|
76
|
-
|
77
|
-
if block_given? then
|
78
|
-
@doc.xpath(s, &blk)
|
79
|
-
else
|
80
|
-
@doc.xpath s
|
81
|
-
end
|
82
|
-
end
|
83
76
|
|
84
77
|
def records
|
85
78
|
@doc.xpath("records/*").map do |record|
|
@@ -91,6 +84,25 @@ class Polyrex
|
|
91
84
|
@summary
|
92
85
|
end
|
93
86
|
|
87
|
+
def to_xslt()
|
88
|
+
@polyrex_xslt.schema = @schema
|
89
|
+
@polyrex_xslt.to_xslt
|
90
|
+
end
|
91
|
+
|
92
|
+
def xpath(s, &blk)
|
93
|
+
|
94
|
+
if block_given? then
|
95
|
+
@doc.xpath(s, &blk)
|
96
|
+
else
|
97
|
+
@doc.xpath s
|
98
|
+
end
|
99
|
+
end
|
100
|
+
|
101
|
+
def xslt_schema(s)
|
102
|
+
@polyrex_xslt.xslt_schema = s
|
103
|
+
self
|
104
|
+
end
|
105
|
+
|
94
106
|
private
|
95
107
|
|
96
108
|
def polyrex_new(schema)
|
@@ -255,5 +267,5 @@ class Polyrex
|
|
255
267
|
@doc.element('summary/' + x.to_s).text = @summary.method(x).call
|
256
268
|
end
|
257
269
|
end
|
258
|
-
|
270
|
+
|
259
271
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: polyrex
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.8.
|
4
|
+
version: 0.8.4
|
5
5
|
platform: ruby
|
6
6
|
authors: []
|
7
7
|
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2011-01-
|
12
|
+
date: 2011-01-30 00:00:00 +00:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -62,6 +62,16 @@ dependencies:
|
|
62
62
|
- !ruby/object:Gem::Version
|
63
63
|
version: "0"
|
64
64
|
version:
|
65
|
+
- !ruby/object:Gem::Dependency
|
66
|
+
name: polyrex-xslt
|
67
|
+
type: :runtime
|
68
|
+
version_requirement:
|
69
|
+
version_requirements: !ruby/object:Gem::Requirement
|
70
|
+
requirements:
|
71
|
+
- - ">="
|
72
|
+
- !ruby/object:Gem::Version
|
73
|
+
version: "0"
|
74
|
+
version:
|
65
75
|
description:
|
66
76
|
email:
|
67
77
|
executables: []
|