nishidayuya-rd2odt 0.0.1.20090403.01 → 0.1.1

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.
Files changed (42) hide show
  1. data/NEWS +13 -0
  2. data/Rakefile +3 -1
  3. data/lib/rd2odt/compat/ruby-1.8.6.rb +86 -0
  4. data/lib/rd2odt/rdtool/NOTICE.rd2odt +8 -0
  5. data/lib/rd2odt/rdtool/README.rd +50 -0
  6. data/lib/rd2odt/rdtool/README.rd.ja +53 -0
  7. data/lib/rd2odt/rdtool/rd/block-element.rb +114 -0
  8. data/lib/rd2odt/rdtool/rd/complex-list-item.rb +65 -0
  9. data/lib/rd2odt/rdtool/rd/desclist.rb +55 -0
  10. data/lib/rd2odt/rdtool/rd/document-struct.rb +46 -0
  11. data/lib/rd2odt/rdtool/rd/element.rb +160 -0
  12. data/lib/rd2odt/rdtool/rd/filter.rb +255 -0
  13. data/lib/rd2odt/rdtool/rd/inline-element.rb +233 -0
  14. data/lib/rd2odt/rdtool/rd/labeled-element.rb +14 -0
  15. data/lib/rd2odt/rdtool/rd/list.rb +57 -0
  16. data/lib/rd2odt/rdtool/rd/loose-struct.rb +11 -0
  17. data/lib/rd2odt/rdtool/rd/methodlist.rb +57 -0
  18. data/lib/rd2odt/rdtool/rd/output-format-visitor.rb +28 -0
  19. data/lib/rd2odt/rdtool/rd/package.rb +4 -0
  20. data/lib/rd2odt/rdtool/rd/parser-util.rb +14 -0
  21. data/lib/rd2odt/rdtool/rd/rbl-file.rb +69 -0
  22. data/lib/rd2odt/rdtool/rd/rbl-suite.rb +37 -0
  23. data/lib/rd2odt/rdtool/rd/rd-struct.rb +86 -0
  24. data/lib/rd2odt/rdtool/rd/rd2html-lib.rb +490 -0
  25. data/lib/rd2odt/rdtool/rd/rd2html-opt.rb +67 -0
  26. data/lib/rd2odt/rdtool/rd/rd2man-lib.rb +241 -0
  27. data/lib/rd2odt/rdtool/rd/rd2rdo-lib.rb +19 -0
  28. data/lib/rd2odt/rdtool/rd/rd2rmi-lib.rb +32 -0
  29. data/lib/rd2odt/rdtool/rd/rdblockparser.tab.rb +1050 -0
  30. data/lib/rd2odt/rdtool/rd/rdfmt.rb +15 -0
  31. data/lib/rd2odt/rdtool/rd/rdinlineparser.tab.rb +1243 -0
  32. data/lib/rd2odt/rdtool/rd/rdvisitor.rb +214 -0
  33. data/lib/rd2odt/rdtool/rd/reference-resolver.rb +114 -0
  34. data/lib/rd2odt/rdtool/rd/search-file.rb +14 -0
  35. data/lib/rd2odt/rdtool/rd/tree.rb +103 -0
  36. data/lib/rd2odt/rdtool/rd/version.rb +39 -0
  37. data/lib/rd2odt/rdtool/rd/visitor.rb +86 -0
  38. data/lib/rd2odt.rb +12 -17
  39. data/rd2odt.gemspec +39 -4
  40. data/test/test-helper.rb +86 -1
  41. data/test/unit/rd2odt-spec.rb +13 -11
  42. metadata +39 -4
data/test/test-helper.rb CHANGED
@@ -3,6 +3,91 @@
3
3
  $top_srcdir = File.join(File.dirname(__FILE__), "..")
4
4
  $LOAD_PATH << File.join($top_srcdir, "lib")
5
5
 
6
- $KCODE = "u" if RUBY_VERSION < "1.8.9"
6
+ $KCODE = "u" if RUBY_VERSION < "1.9.0"
7
7
 
8
8
  require "rd2odt"
9
+ require "tempfile"
10
+
11
+ module XmlMatchers
12
+ class BeSameAsThisXml
13
+ def initialize(expected)
14
+ @expected = expected
15
+ if String === expected || Symbol === expected
16
+ @expected_dom = to_dom(expected.to_s)
17
+ end
18
+ end
19
+
20
+ def matches?(actual)
21
+ @actual = actual
22
+ if String === actual || Symbol === actual
23
+ @actual_dom = to_dom(actual.to_s)
24
+ end
25
+ return expected_dom.to_s == actual_dom.to_s
26
+ end
27
+
28
+ def failure_message
29
+ return "difference: #{diff}"
30
+ end
31
+
32
+ alias negative_failure_message failure_message
33
+
34
+ private
35
+
36
+ DOM_PREFIX = <<EOF
37
+ <?xml version='1.0' encoding='UTF-8'?>
38
+
39
+ <office:document-content xmlns:script='urn:oasis:names:tc:opendocument:xmlns:script:1.0' xmlns:oooc='http://openoffice.org/2004/calc' xmlns:number='urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0' xmlns:dr3d='urn:oasis:names:tc:opendocument:xmlns:dr3d:1.0' xmlns:math='http://www.w3.org/1998/Math/MathML' xmlns:dom='http://www.w3.org/2001/xml-events' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xmlns:text='urn:oasis:names:tc:opendocument:xmlns:text:1.0' xmlns:svg='urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0' xmlns:ooo='http://openoffice.org/2004/office' xmlns:xforms='http://www.w3.org/2002/xforms' xmlns:table='urn:oasis:names:tc:opendocument:xmlns:table:1.0' xmlns:meta='urn:oasis:names:tc:opendocument:xmlns:meta:1.0' xmlns:form='urn:oasis:names:tc:opendocument:xmlns:form:1.0' xmlns:field='urn:openoffice:names:experimental:ooxml-odf-interop:xmlns:field:1.0' xmlns:draw='urn:oasis:names:tc:opendocument:xmlns:drawing:1.0' office:version='1.1' xmlns:office='urn:oasis:names:tc:opendocument:xmlns:office:1.0' xmlns:xsd='http://www.w3.org/2001/XMLSchema' xmlns:xlink='http://www.w3.org/1999/xlink' xmlns:fo='urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0' xmlns:dc='http://purl.org/dc/elements/1.1/' xmlns:style='urn:oasis:names:tc:opendocument:xmlns:style:1.0' xmlns:ooow='http://openoffice.org/2004/writer' xmlns:chart='urn:oasis:names:tc:opendocument:xmlns:chart:1.0'>
40
+
41
+
42
+ EOF
43
+
44
+ DOM_SUFFIX = <<EOF
45
+
46
+
47
+ </office:document-content>
48
+ EOF
49
+
50
+ def expected_dom
51
+ return (@expected_dom ||= to_dom(RD2ODT.ah_to_xml(@expected)))
52
+ end
53
+
54
+ def actual_dom
55
+ return (@actual_dom ||= to_dom(RD2ODT.ah_to_xml(@expected)))
56
+ end
57
+
58
+ def to_dom(s)
59
+ root = REXML::Document.new(DOM_PREFIX + s + DOM_SUFFIX)
60
+ result = root[2][1] # `result' is only XML from `s'.
61
+ return result
62
+ end
63
+
64
+ def diff
65
+ Tempfile.open("rd2odt-test") do |expected_file|
66
+ Tempfile.open("rd2odt-test") do |actual_file|
67
+ expected_file.puts(expected_dom.to_s)
68
+ expected_file.close
69
+ actual_file.puts(actual_dom.to_s)
70
+ actual_file.close
71
+
72
+ result = `docdiff --utf8 --char --tty #{expected_file.path} #{actual_file.path}`
73
+ return result
74
+ end
75
+ end
76
+ end
77
+ end
78
+
79
+ def be_same_as_this_xml(expected)
80
+ return BeSameAsThisXml.new(expected)
81
+ end
82
+ end
83
+
84
+ # for test on Ruby 1.8.6.
85
+ if RUBY_VERSION < "1.8.7"
86
+ class Hash
87
+ def each
88
+ keys.sort.each do |k|
89
+ yield(k, self[k])
90
+ end
91
+ end
92
+ end
93
+ end
@@ -571,8 +571,10 @@ describe RD2ODT::RD2ODTVisitor, "apply_to_Verbatim" do
571
571
  end
572
572
 
573
573
  describe RD2ODT::RD2ODTVisitor, "apply_to_Include" do
574
+ include XmlMatchers
575
+
574
576
  before do
575
- class Time
577
+ class ::Time
576
578
  class << self
577
579
  alias orig_now now
578
580
 
@@ -593,7 +595,7 @@ describe RD2ODT::RD2ODTVisitor, "apply_to_Include" do
593
595
  end
594
596
 
595
597
  after do
596
- class Time
598
+ class ::Time
597
599
  class << self
598
600
  alias now orig_now
599
601
  end
@@ -616,10 +618,10 @@ EOF
616
618
  result.length.should == 3
617
619
  result.class.should == Array
618
620
  @visitor.number_of_include_files.should == 1
619
- @visitor.additional_styles[0].to_s.should == <<EOF.chomp
621
+ @visitor.additional_styles[0].to_s.should be_same_as_this_xml(<<EOF.chomp)
620
622
  <style:style style:name='#{@name_prefix}Standard' style:class='text' style:family='paragraph'/>
621
623
  EOF
622
- @visitor.additional_styles[1].to_s.should == <<EOF.chomp
624
+ @visitor.additional_styles[1].to_s.should be_same_as_this_xml(<<EOF.chomp)
623
625
  <style:style style:name='#{@name_prefix}Text_20_body' style:class='text' style:parent-style-name='#{@name_prefix}Standard' style:display-name='#{@name_prefix}Text body' style:family='paragraph'>
624
626
  <style:paragraph-properties fo:margin-bottom='0.212cm' fo:margin-top='0cm'/>
625
627
  </style:style>
@@ -688,7 +690,7 @@ EOF
688
690
  result[0].should == <<EOF.chomp.to_sym
689
691
  <text:p text:style-name='#{@name_prefix}Standard'>これは&lt;&lt;&lt;のサンプルです.</text:p>
690
692
  EOF
691
- result[1].should == <<EOF.chomp.to_sym
693
+ result[1].should be_same_as_this_xml(<<EOF.chomp.to_sym)
692
694
  <table:table table:name='#{@name_prefix}表1' table:style-name='#{@name_prefix}表1'>
693
695
  <table:table-column table:number-columns-repeated='3' table:style-name='#{@name_prefix}表1.A'/>
694
696
  <table:table-row>
@@ -720,12 +722,12 @@ EOF
720
722
  EOF
721
723
  result.length.should == 3
722
724
  result.class.should == Array
723
- @visitor.automatic_styles[0].to_s.should == <<EOF.chomp
725
+ @visitor.automatic_styles[0].to_s.should be_same_as_this_xml(<<EOF.chomp)
724
726
  <style:style style:name='#{@name_prefix}表1' style:family='table'>
725
727
  <style:table-properties table:align='margins' style:width='16.999cm'/>
726
728
  </style:style>
727
729
  EOF
728
- @visitor.automatic_styles[1].to_s.should == <<EOF.chomp
730
+ @visitor.automatic_styles[1].to_s.should be_same_as_this_xml(<<EOF.chomp)
729
731
  <style:style style:name='#{@name_prefix}表1.A' style:family='table-column'>
730
732
  <style:table-column-properties style:column-width='5.666cm' style:rel-column-width='21845*'/>
731
733
  </style:style>
@@ -742,7 +744,7 @@ EOF
742
744
  result[0].should == <<EOF.chomp.to_sym
743
745
  <text:p text:style-name='#{@name_prefix}Standard'>これは&lt;&lt;&lt;のサンプルです.</text:p>
744
746
  EOF
745
- result[1].should == <<EOF.chomp.to_sym
747
+ result[1].should be_same_as_this_xml(<<EOF.chomp.to_sym)
746
748
  <text:p text:style-name='#{@name_prefix}Standard'><draw:g text:anchor-type='paragraph' draw:z-index='0' draw:style-name='#{@name_prefix}gr1'><draw:custom-shape svg:x='3.348cm' svg:y='0.088cm' svg:height='3.911cm' draw:style-name='#{@name_prefix}gr2' svg:width='3.887cm'>
747
749
  <text:p/>
748
750
  <draw:enhanced-geometry draw:glue-points='10800 0 3160 3160 0 10800 3160 18440 10800 21600 18440 18440 21600 10800 18440 3160' draw:type='smiley' draw:enhanced-path='U 10800 10800 10800 10800 0 23592960 Z N U 7305 7515 1165 1165 0 23592960 Z N U 14295 7515 1165 1165 0 23592960 Z N M 4870 ?f1 C 8680 ?f2 12920 ?f2 16730 ?f1 F N' draw:modifiers='17520' draw:text-areas='3200 3200 18400 18400' svg:viewBox='0 0 21600 21600'>
@@ -807,17 +809,17 @@ EOF
807
809
  EOF
808
810
  result.length.should == 3
809
811
  result.class.should == Array
810
- @visitor.automatic_styles[0].to_s.should == <<EOF.chomp
812
+ @visitor.automatic_styles[0].to_s.should be_same_as_this_xml(<<EOF.chomp)
811
813
  <style:style style:name='#{@name_prefix}P1' style:family='paragraph'>
812
814
  <style:paragraph-properties fo:text-align='center'/>
813
815
  </style:style>
814
816
  EOF
815
- @visitor.automatic_styles[1].to_s.should == <<EOF.chomp
817
+ @visitor.automatic_styles[1].to_s.should be_same_as_this_xml(<<EOF.chomp)
816
818
  <style:style style:name='#{@name_prefix}gr1' style:family='graphic'>
817
819
  <style:graphic-properties style:flow-with-text='false' style:horizontal-pos='from-left' style:wrap='none' style:vertical-rel='paragraph' draw:wrap-influence-on-position='once-concurrent' style:horizontal-rel='paragraph' style:run-through='foreground' style:vertical-pos='from-top'/>
818
820
  </style:style>
819
821
  EOF
820
- @visitor.automatic_styles[2].to_s.should == <<EOF.chomp
822
+ @visitor.automatic_styles[2].to_s.should be_same_as_this_xml(<<EOF.chomp)
821
823
  <style:style style:name='#{@name_prefix}gr2' style:family='graphic'>
822
824
  <style:graphic-properties draw:textarea-vertical-align='middle' draw:auto-grow-height='false' style:run-through='foreground' draw:textarea-horizontal-align='justify'/>
823
825
  </style:style>
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nishidayuya-rd2odt
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1.20090403.01
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yuya.Nishida.
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-04-01 00:00:00 -07:00
12
+ date: 2009-05-16 00:00:00 -07:00
13
13
  default_executable:
14
14
  dependencies: []
15
15
 
@@ -24,9 +24,43 @@ extra_rdoc_files: []
24
24
  files:
25
25
  - bin/rd2odt
26
26
  - lib/rd2odt.rb
27
+ - lib/rd2odt/compat/ruby-1.8.6.rb
28
+ - lib/rd2odt/rdtool/NOTICE.rd2odt
29
+ - lib/rd2odt/rdtool/README.rd
30
+ - lib/rd2odt/rdtool/README.rd.ja
31
+ - lib/rd2odt/rdtool/rd/block-element.rb
32
+ - lib/rd2odt/rdtool/rd/complex-list-item.rb
33
+ - lib/rd2odt/rdtool/rd/desclist.rb
34
+ - lib/rd2odt/rdtool/rd/document-struct.rb
35
+ - lib/rd2odt/rdtool/rd/element.rb
36
+ - lib/rd2odt/rdtool/rd/filter.rb
37
+ - lib/rd2odt/rdtool/rd/inline-element.rb
38
+ - lib/rd2odt/rdtool/rd/labeled-element.rb
39
+ - lib/rd2odt/rdtool/rd/list.rb
40
+ - lib/rd2odt/rdtool/rd/loose-struct.rb
41
+ - lib/rd2odt/rdtool/rd/methodlist.rb
42
+ - lib/rd2odt/rdtool/rd/output-format-visitor.rb
43
+ - lib/rd2odt/rdtool/rd/package.rb
44
+ - lib/rd2odt/rdtool/rd/parser-util.rb
45
+ - lib/rd2odt/rdtool/rd/rbl-file.rb
46
+ - lib/rd2odt/rdtool/rd/rbl-suite.rb
47
+ - lib/rd2odt/rdtool/rd/rd-struct.rb
48
+ - lib/rd2odt/rdtool/rd/rd2html-lib.rb
49
+ - lib/rd2odt/rdtool/rd/rd2html-opt.rb
50
+ - lib/rd2odt/rdtool/rd/rd2man-lib.rb
51
+ - lib/rd2odt/rdtool/rd/rd2rdo-lib.rb
52
+ - lib/rd2odt/rdtool/rd/rd2rmi-lib.rb
53
+ - lib/rd2odt/rdtool/rd/rdblockparser.tab.rb
54
+ - lib/rd2odt/rdtool/rd/rdfmt.rb
55
+ - lib/rd2odt/rdtool/rd/rdinlineparser.tab.rb
56
+ - lib/rd2odt/rdtool/rd/rdvisitor.rb
57
+ - lib/rd2odt/rdtool/rd/reference-resolver.rb
58
+ - lib/rd2odt/rdtool/rd/search-file.rb
59
+ - lib/rd2odt/rdtool/rd/tree.rb
60
+ - lib/rd2odt/rdtool/rd/version.rb
61
+ - lib/rd2odt/rdtool/rd/visitor.rb
27
62
  - doc/sample.rd.ja
28
63
  - doc/sample.rd.ja.ott
29
- - doc/sample.rd.ja.pdf
30
64
  - doc/sample/body-text.rd
31
65
  - doc/sample/enum-list-over-headline-multi-level.rd
32
66
  - doc/sample/enum-list-over-headline.rd
@@ -64,11 +98,12 @@ rdoc_options: []
64
98
 
65
99
  require_paths:
66
100
  - lib
101
+ - lib/rd2odt/rdtool
67
102
  required_ruby_version: !ruby/object:Gem::Requirement
68
103
  requirements:
69
104
  - - ">="
70
105
  - !ruby/object:Gem::Version
71
- version: 1.8.7
106
+ version: 1.8.6
72
107
  version:
73
108
  required_rubygems_version: !ruby/object:Gem::Requirement
74
109
  requirements: