dynarex 1.0.5 → 1.0.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (2) hide show
  1. data/lib/dynarex.rb +19 -15
  2. metadata +22 -2
@@ -6,7 +6,9 @@ require 'nokogiri'
6
6
  require 'open-uri'
7
7
  require 'builder'
8
8
  require 'ostruct'
9
+ require 'dynarex-import'
9
10
  require 'rexle'
11
+ require 'line-tree'
10
12
 
11
13
  class Dynarex
12
14
 
@@ -35,6 +37,14 @@ class Dynarex
35
37
  @format_mask = @format_mask.to_s.gsub(/\s/, separator)
36
38
  @summary[:format_mask] = @format_mask
37
39
  end
40
+
41
+ def import(options={})
42
+ o = {xml: '', schema: ''}.merge(options)
43
+ h = {xml: o[:xml], schema: @schema, foreign_schema: o[:schema]}
44
+ buffer = DynarexImport.new(h).to_xml
45
+ open(buffer)
46
+ self
47
+ end
38
48
 
39
49
  def fields
40
50
  @fields
@@ -331,25 +341,19 @@ EOF
331
341
  root_name, raw_summary, record_name, raw_fields = s.match(ptrn).captures
332
342
  summary, fields = [raw_summary || '',raw_fields].map {|x| x.split(/,/).map &:strip}
333
343
 
334
- xml = Builder::XmlMarkup.new( target: buffer='', indent: 2 )
335
- xml.instruct! :xml, version: "1.0", encoding: "UTF-8"
336
-
337
- xml.send root_name do
338
- xml.summary do
339
- summary.each do |item|
340
- xml.send item
341
- end
342
- xml.recordx_type 'dynarex'
343
- xml.format_mask fields.map {|x| "[!%s]" % x}.join(' ')
344
- xml.schema s
345
- end
346
- xml.records
347
- end
344
+ lines =<<LINES
345
+ #{root_name}
346
+ summary#{"\n" + ' ' * 4 + summary.join("\n" + ' ' * 4) unless summary.empty?}
347
+ recordx_type dynarex
348
+ format_mask #{fields.map {|x| "[!%s]" % x}.join(' ')}
349
+ schema #{s}
350
+ records
351
+ LINES
348
352
 
349
353
  @records = {}
350
354
  @flat_records = {}
351
355
 
352
- buffer
356
+ LineTree.new(lines).to_xml
353
357
  end
354
358
 
355
359
  def attach_record_methods()
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dynarex
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.5
4
+ version: 1.0.6
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-22 00:00:00 +00:00
12
+ date: 2011-02-06 00:00:00 +00:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -22,6 +22,26 @@ dependencies:
22
22
  - !ruby/object:Gem::Version
23
23
  version: "0"
24
24
  version:
25
+ - !ruby/object:Gem::Dependency
26
+ name: dynarex-import
27
+ type: :runtime
28
+ version_requirement:
29
+ version_requirements: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: "0"
34
+ version:
35
+ - !ruby/object:Gem::Dependency
36
+ name: line-tree
37
+ type: :runtime
38
+ version_requirement:
39
+ version_requirements: !ruby/object:Gem::Requirement
40
+ requirements:
41
+ - - ">="
42
+ - !ruby/object:Gem::Version
43
+ version: "0"
44
+ version:
25
45
  description:
26
46
  email:
27
47
  executables: []