ydocx 1.2.5 → 1.2.6

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: d110c0230d26d291bbc973e022379d669a7fa963dc0baf27fa3b0ccaaa193bab
4
+ data.tar.gz: f21bfa758230376fadeab73e75645dd06862957c0d8c7d120bd489d7ffeb9b1b
5
+ SHA512:
6
+ metadata.gz: 75d8e7bed0a19192c43c4b75be52b9c5f9da1ef265052420d299b810189faf3b880cc3e5f207621695a6cd8d156c477aed00c87b6e82366c7d8dedc012411e90
7
+ data.tar.gz: 84bb26bab8bc03ea116f90f1df1708d4f646f0b0094a6e685723f2e7448e409a5db8c46845c54d44ee723fd9dd0cf866946d49e8b15f6a0a56d63c01610925cc
@@ -1,3 +1,8 @@
1
+ === 1.2.6 / 19.01.2021
2
+
3
+ * Updated to use for ruby 3.0.0. RMagick->rmagic
4
+ * Replaced hoe by bundler/gem_tasks
5
+
1
6
  === 1.2.5 / 07.07.2014
2
7
 
3
8
  * Updated to use rubyzip >= 1.0.0
data/README.txt CHANGED
@@ -29,7 +29,7 @@
29
29
  * rubyzip (< 1.0.0)
30
30
  * nokogiri
31
31
  * htmlentities
32
- * RMagick
32
+ * rmagick
33
33
 
34
34
  Install them using bundle install.
35
35
 
@@ -1,8 +1,4 @@
1
1
  #!/usr/bin/env ruby
2
- # encoding: utf-8
3
2
 
4
3
  require 'ydocx/document'
5
4
 
6
- module YDocx
7
- VERSION = '1.2.5'
8
- end
@@ -4,9 +4,9 @@
4
4
  require 'pathname'
5
5
  require 'zip'
6
6
  begin
7
- require 'RMagick'
7
+ require 'rmagick'
8
8
  rescue LoadError
9
- warn "Couldn't load RMagick: .wmf conversion off"
9
+ warn "Couldn't load rmagick: .wmf conversion off"
10
10
  end
11
11
  require 'ydocx/parser'
12
12
  require 'ydocx/builder'
@@ -158,19 +158,19 @@ module YDocx
158
158
  ns = r.namespaces.merge additional_namespaces
159
159
  [
160
160
  { # old type shape
161
- :attr => 'id',
161
+ :attr => 'r:id',
162
162
  :path => 'w:pict//v:shape//v:imagedata',
163
163
  :wrap => 'w:pict//v:shape//w10:wrap',
164
164
  :type => '',
165
165
  },
166
166
  { # in anchor
167
- :attr => 'embed',
167
+ :attr => 'r:embed',
168
168
  :path => 'w:drawing//wp:anchor//a:graphic//a:graphicData//pic:pic//pic:blipFill//a:blip',
169
169
  :wrap => 'w:drawing//wp:anchor//wp:wrapTight',
170
170
  :type => 'wrapText',
171
171
  },
172
172
  { # stand alone
173
- :attr => 'embed',
173
+ :attr => 'r:embed',
174
174
  :path => 'w:drawing//a:graphic//a:graphicData//pic:pic//pic:blipFill//a:blip',
175
175
  :wrap => 'w:drawing//wp:wrapTight',
176
176
  :type => 'wrapText',
@@ -232,7 +232,7 @@ module YDocx
232
232
  end
233
233
  end
234
234
  unless r.xpath('w:sym').empty?
235
- code = r.xpath('w:sym').first['char'].downcase # w:char
235
+ code = r.xpath('w:sym').first['w:char'].downcase # w:char
236
236
  content << character_replace(code)
237
237
  pos += 1
238
238
  end
@@ -110,7 +110,7 @@ module YDocx
110
110
  end
111
111
  def parse_title(node, text)
112
112
  if @indecies.empty? and !text.empty? and node.previous and
113
- (node.previous.inner_text.strip.empty? or node.parent.previous.nil?)
113
+ (node.parent.previous.nil? or node.previous.inner_text.strip.empty?)
114
114
  # The first line as package name
115
115
  title = (@lang == 'fr' ? 'Titre' : 'Titel')
116
116
  @indecies << {:text => title, :id => title.downcase}
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ module YDocx
4
+ VERSION = '1.2.6'
5
+ end
@@ -0,0 +1,87 @@
1
+ #!/usr/bin/env ruby
2
+ # encoding: utf-8
3
+ require 'spec_helper'
4
+
5
+ RSpec.configure do |config|
6
+ config.expect_with(:rspec) { |c| c.syntax = :should }
7
+ end
8
+
9
+ describe "ydocx" do
10
+
11
+ before :all do
12
+ end
13
+
14
+ before :each do
15
+ Dir.glob("#{YDcoxHelper::DataDir}/*.xml").each { |file| FileUtils.rm_f(file, :verbose => $VERBOSE) }
16
+ Dir.glob("#{YDcoxHelper::DataDir}/*.html").each { |file| FileUtils.rm_f(file, :verbose => $VERBOSE) }
17
+ end
18
+
19
+ after :each do
20
+ end
21
+
22
+ after :all do
23
+ Dir.glob("#{YDcoxHelper::DataDir}/*.xml").each { |file| FileUtils.rm_f(file, :verbose => $VERBOSE) }
24
+ Dir.glob("#{YDcoxHelper::DataDir}/*.html").each { |file| FileUtils.rm_f(file, :verbose => $VERBOSE) }
25
+ end
26
+
27
+ it "should convert sinovial_FR to xml" do
28
+ require 'ydocx/templates/fachinfo'
29
+ sinovial_FR = File.join(YDcoxHelper::DataDir, 'Sinovial_FR.docx')
30
+ File.exists?(sinovial_FR).should be true
31
+ doc = YDocx::Document.open(sinovial_FR, { :lang => :fr})
32
+ sinovial_FR_xml = sinovial_FR.sub('.docx', '.xml')
33
+ doc.to_xml(sinovial_FR_xml, {:format => :fachinfo})
34
+ out = doc.output_file('xml')
35
+ File.exists?(sinovial_FR_xml).should be true
36
+ doc.parser.lang.to_s.should == 'fr'
37
+ doc = Nokogiri::XML(open(sinovial_FR_xml))
38
+ doc.xpath('//chapters/chapter[contains(heading, "Fabricant")]').size.should > 0
39
+ doc.xpath('//chapters/chapter[contains(heading, "Distributeur")]').size.should > 0
40
+ doc.xpath('//chapters/chapter[contains(heading, "Remarques particulières")]').size.should > 0
41
+ end
42
+
43
+ it "should convert sinovial_DE to xml" do
44
+ sinovial_DE = File.join(YDcoxHelper::DataDir, 'Sinovial_DE.docx')
45
+ File.exists?(sinovial_DE).should be true
46
+ doc = YDocx::Document.open(sinovial_DE)
47
+ sinovial_DE_xml = sinovial_DE.sub('.docx', '.xml')
48
+ doc.to_xml(sinovial_DE_xml, {:format => :fachinfo})
49
+ out = doc.output_file('xml')
50
+ File.exists?(sinovial_DE_xml).should be true
51
+ doc.parser.lang.to_s.should == 'de'
52
+ doc = Nokogiri::XML(open(sinovial_DE_xml))
53
+ doc.xpath('//chapters/chapter[contains(heading, "Packung")]').size.should > 0
54
+ doc.xpath('//chapters/chapter[contains(heading, "Hersteller")]').size.should > 0
55
+ doc.xpath('//chapters/chapter[contains(heading, "Vertriebsfirma")]').size.should > 0
56
+ end
57
+
58
+ it "should convert sinovial_DE to html" do
59
+ sinovial_DE = File.join(YDcoxHelper::DataDir, 'Sinovial_DE.docx')
60
+ File.exists?(sinovial_DE).should be true
61
+ doc = YDocx::Document.open(sinovial_DE)
62
+ sinovial_DE_html = sinovial_DE.sub('.docx', '.html')
63
+ doc.to_html(sinovial_DE_html, {:format => :fachinfo})
64
+ out = doc.output_file('html')
65
+ File.exists?(sinovial_DE_html).should be true
66
+ end
67
+
68
+ it "should convert various pseudo fachinfo to xml" do
69
+ require 'ydocx/templates/fachinfo'
70
+ files = [ 'Sinovial_0.8_DE.docx', 'Sinovial_0.8_FR.docx',
71
+ 'Sinovial_DE.docx', 'Sinovial_FR.docx',
72
+ ]
73
+ files.each {
74
+ |file|
75
+ file_name = File.join(YDcoxHelper::DataDir, file)
76
+ File.exists?(file_name).should be true
77
+ file.match('_DE') ? lang = 'de' : lang = 'fr'
78
+ doc = YDocx::Document.open(file_name, { :lang => lang} )
79
+ file_name_xml = file_name.sub('.docx', '.xml')
80
+ doc.to_xml(file_name_xml, {:format => :fachinfo})
81
+ out = doc.output_file('xml')
82
+ File.exists?(file_name_xml).should be true
83
+ doc.parser.lang.should == lang
84
+ doc = Nokogiri::XML(open(file_name_xml))
85
+ }
86
+ end
87
+ end
@@ -0,0 +1,17 @@
1
+ #!/usr/bin/env ruby
2
+ # encoding: utf-8
3
+
4
+ require 'simplecov'
5
+ if ENV['COVERAGE']
6
+ SimpleCov.start
7
+ end
8
+
9
+ require 'fileutils'
10
+ require 'pp'
11
+ require 'ydocx'
12
+
13
+ module YDcoxHelper
14
+ DataDir = File.join(File.dirname(__FILE__), '..', 'spec', 'data')
15
+ end
16
+ require 'rspec'
17
+ require 'ydocx'
metadata CHANGED
@@ -1,113 +1,64 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: ydocx
3
- version: !ruby/object:Gem::Version
4
- hash: 21
5
- prerelease:
6
- segments:
7
- - 1
8
- - 2
9
- - 5
10
- version: 1.2.5
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.2.6
11
5
  platform: ruby
12
- authors:
13
- - Yasuhiro Asaka, Zeno R.R. Davatz
6
+ authors:
7
+ - "'Yasuhiro Asak, Zeno R.R. Davatz"
14
8
  autorequire:
15
9
  bindir: bin
16
10
  cert_chain: []
17
-
18
- date: 2014-07-07 00:00:00 Z
19
- dependencies:
20
- - !ruby/object:Gem::Dependency
21
- name: rdoc
22
- prerelease: false
23
- requirement: &id001 !ruby/object:Gem::Requirement
24
- none: false
25
- requirements:
26
- - - ~>
27
- - !ruby/object:Gem::Version
28
- hash: 27
29
- segments:
30
- - 4
31
- - 0
32
- version: "4.0"
33
- type: :development
34
- version_requirements: *id001
35
- - !ruby/object:Gem::Dependency
36
- name: hoe
37
- prerelease: false
38
- requirement: &id002 !ruby/object:Gem::Requirement
39
- none: false
40
- requirements:
41
- - - ~>
42
- - !ruby/object:Gem::Version
43
- hash: 11
44
- segments:
45
- - 3
46
- - 6
47
- version: "3.6"
48
- type: :development
49
- version_requirements: *id002
50
- description: ""
51
- email:
52
- - yasaka@ywesee.com, zdavatz@ywesee.com
53
- executables:
54
- - docx2html
11
+ date: 2021-01-20 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: ''
14
+ email: yasaka@ywesee.com, zdavatz@ywesee.com
15
+ executables:
55
16
  - docx2xml
17
+ - docx2html
56
18
  extensions: []
57
-
58
- extra_rdoc_files:
59
- - History.txt
60
- - Manifest.txt
61
- - README.txt
62
- files:
19
+ extra_rdoc_files: []
20
+ files:
63
21
  - History.txt
64
22
  - Manifest.txt
65
23
  - README.txt
66
- - Rakefile
67
24
  - bin/docx2html
68
25
  - bin/docx2xml
69
26
  - lib/ydocx.rb
70
27
  - lib/ydocx/builder.rb
28
+ - lib/ydocx/command.rb
71
29
  - lib/ydocx/document.rb
72
30
  - lib/ydocx/markup_method.rb
73
31
  - lib/ydocx/parser.rb
74
- - lib/ydocx/command.rb
75
32
  - lib/ydocx/templates/fachinfo.rb
76
33
  - lib/ydocx/templates/patinfo.rb
77
- - .gemtest
78
- homepage: https://github.com/zdavatz/ydocx
79
- licenses: []
80
-
34
+ - lib/ydocx/version.rb
35
+ - spec/data/Sinovial_0.8_DE.docx
36
+ - spec/data/Sinovial_0.8_FR.docx
37
+ - spec/data/Sinovial_DE.docx
38
+ - spec/data/Sinovial_FR.docx
39
+ - spec/lib/sinovial_spec.rb
40
+ - spec/spec_helper.rb
41
+ homepage: https://github.com/zdavatz/ydocx/
42
+ licenses:
43
+ - GPL-3.0
44
+ metadata: {}
81
45
  post_install_message:
82
- rdoc_options:
83
- - --main
84
- - README.txt
85
- require_paths:
46
+ rdoc_options: []
47
+ require_paths:
86
48
  - lib
87
- required_ruby_version: !ruby/object:Gem::Requirement
88
- none: false
89
- requirements:
49
+ required_ruby_version: !ruby/object:Gem::Requirement
50
+ requirements:
90
51
  - - ">="
91
- - !ruby/object:Gem::Version
92
- hash: 3
93
- segments:
94
- - 0
95
- version: "0"
96
- required_rubygems_version: !ruby/object:Gem::Requirement
97
- none: false
98
- requirements:
52
+ - !ruby/object:Gem::Version
53
+ version: '0'
54
+ required_rubygems_version: !ruby/object:Gem::Requirement
55
+ requirements:
99
56
  - - ">="
100
- - !ruby/object:Gem::Version
101
- hash: 3
102
- segments:
103
- - 0
104
- version: "0"
57
+ - !ruby/object:Gem::Version
58
+ version: '0'
105
59
  requirements: []
106
-
107
- rubyforge_project: ydocx
108
- rubygems_version: 1.8.25
60
+ rubygems_version: 3.1.2
109
61
  signing_key:
110
- specification_version: 3
111
- summary: ""
62
+ specification_version: 4
63
+ summary: Parsing docx files with Ruby and output them as HTML and XML
112
64
  test_files: []
113
-
data/.gemtest DELETED
File without changes
data/Rakefile DELETED
@@ -1,26 +0,0 @@
1
- # -*- ruby -*-
2
-
3
- require 'rubygems'
4
- require 'hoe'
5
- require 'simplecov'
6
-
7
- # Hoe.plugin :compiler
8
- # Hoe.plugin :gem_prelude_sucks
9
- # Hoe.plugin :inline
10
- # Hoe.plugin :minitest
11
- # Hoe.plugin :racc
12
- # Hoe.plugin :rubyforge
13
-
14
- Hoe.spec 'ydocx' do
15
-
16
- developer('Yasuhiro Asaka, Zeno R.R. Davatz', 'yasaka@ywesee.com, zdavatz@ywesee.com')
17
-
18
- end
19
-
20
- namespace :spec do
21
- desc "Create rspec coverage"
22
- task :coverage do
23
- ENV['COVERAGE'] = 'true'
24
- Rake::Task["spec"].execute
25
- end
26
- end