polyrex 0.8.33 → 0.8.34

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 92235d2d1902a3c7102e6aa83415ef6787e02082
4
- data.tar.gz: facb8e958cf9a0ffe7ae9394a3eb7206f05b9e4e
3
+ metadata.gz: f22bfea02d697da5897d487fe3174e92b1505f9f
4
+ data.tar.gz: e2381385c4388dc4c40e612d219aa15b38a9a97d
5
5
  SHA512:
6
- metadata.gz: 78dd49747c22f4ab8b501c6dc0d70ff32f4b96b138f8caa4ee9ce60e971e8651aa475c5d7726d072f7e379f06ef870e7fd029fcf1f4cb2f45e275d4bb4ca2f1d
7
- data.tar.gz: 863514cf1dddbd5b4d7b81090b188badb1423a9c228d0fa3e21403f18b714ac25109d34f6537b976bf4f6af9d30c534e29d17e39513db6c50db519bde6b93180
6
+ metadata.gz: 37f84775b83c3fc0c4d9e0a6056b9764adb3525f888eaaa8199cc74e7e9f15435dd4a7fdf9b1131938d0d703ab58259d6b5b899075b79bde81e319ce5fc93dbf
7
+ data.tar.gz: e62a494eff2b7e6a6a12544d3974e5a4176e7f2458e0a5521449c227b8792569a62ce83b37bc2a7cf15e7bb521f862fc1a3900c6f149fa0aafd9cee4b628b9e1
checksums.yaml.gz.sig CHANGED
Binary file
data/lib/polyrex.rb CHANGED
@@ -39,12 +39,21 @@ end
39
39
  class Polyrex
40
40
  attr_accessor :summary_fields, :xslt_schema, :id_counter, :schema, :type
41
41
 
42
- def initialize(location=nil, id_counter='1')
42
+ def initialize(location=nil, opt={})
43
43
 
44
- @id_counter = id_counter
44
+ options = {id_counter: '1'}.merge opt
45
+ @id_counter = options[:id_counter]
45
46
 
46
47
  if location then
48
+ self.method(:schema=).call(options[:schema]) if options[:schema]
47
49
  open(location)
50
+
51
+ if options[:schema] then
52
+ fields = @schema[/\/.*/].scan(/\[([^\]]+)/).map \
53
+ {|x| x.first.split(',').map(&:strip)}
54
+ refresh_records self.records, fields, 0
55
+ end
56
+
48
57
  summary_h = Hash[*@doc.root.xpath("summary/*").map {|x| [x.name, x.text]}.flatten]
49
58
  #@summary = OpenStruct.new summary_h
50
59
  @summary = RecordX.new summary_h
@@ -185,7 +194,8 @@ xsl_buffer =<<EOF
185
194
  </xsl:stylesheet>
186
195
  EOF
187
196
  xslt = Nokogiri::XSLT(xsl_buffer)
188
- Dynarex.new xslt.transform(Nokogiri::XML(root.xml)).to_s
197
+ buffer = xslt.transform(Nokogiri::XML(root.xml)).to_s
198
+ Dynarex.new buffer
189
199
 
190
200
  end
191
201
 
@@ -210,6 +220,20 @@ EOF
210
220
 
211
221
  private
212
222
 
223
+ def refresh_records(records, fields, level)
224
+
225
+ records.each do |record|
226
+
227
+ level -= 1 unless fields[level]
228
+ fields[level].each {|x| record.method(x).call }
229
+
230
+ if record.records.any? then
231
+ refresh_records record.records, fields, level+1
232
+ end
233
+ end
234
+
235
+ end
236
+
213
237
  def polyrex_new(schema)
214
238
  # -- required for the parsing feature
215
239
  doc = PolyrexSchema.new(schema).to_doc
@@ -446,10 +470,12 @@ EOF
446
470
  @local_filepath = s
447
471
  end
448
472
 
449
- @doc = Rexle.new buffer
473
+ buffer.gsub!(/<schema>[^<]+/, '<schema>' + @schema) if @schema
450
474
 
451
- schema = @schema ? @schema : @doc.root.text('summary/schema')
475
+ @doc = Rexle.new buffer
452
476
 
477
+ schema = @doc.root.text('summary/schema')
478
+
453
479
  unless @format_masks
454
480
  schema_rpath = schema.gsub(/\[[^\]]+\]/,'')
455
481
  @recordx = schema_rpath.split('/')
data.tar.gz.sig CHANGED
Binary file
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.33
4
+ version: 0.8.34
5
5
  platform: ruby
6
6
  authors:
7
7
  - James Robertson
@@ -29,7 +29,7 @@ cert_chain:
29
29
  7hfiCsNv+0o/OwBNlpn8pTTpd3jV6o1Qq0Y7QiFomKd6XWlaHT4ZNtZdb/XTpC7W
30
30
  ZUZv+oXV5L4FrLlOrnTUhA+cZRntSyHs
31
31
  -----END CERTIFICATE-----
32
- date: 2013-09-23 00:00:00.000000000 Z
32
+ date: 2013-09-24 00:00:00.000000000 Z
33
33
  dependencies:
34
34
  - !ruby/object:Gem::Dependency
35
35
  name: polyrex-schema
metadata.gz.sig CHANGED
Binary file