doc2text 0.3.2 → 0.4.3

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.
@@ -1,99 +0,0 @@
1
- module Doc2Text
2
- module Odt
3
- module XmlNodes
4
- module Node
5
- attr_reader :parent, :children, :attrs, :prefix, :name
6
- attr_accessor :text
7
-
8
- def self.create_node(prefix, name, parent = nil, attrs = [], markdown_odt_parser = nil)
9
- begin
10
- clazz = XmlNodes.const_get "#{titleize prefix}::#{titleize name}"
11
- rescue NameError => e
12
- # markdown_odt_parser.logger.warn "No such <#{prefix}:#{name}> found"
13
- Generic.new(parent, attrs, prefix, name, markdown_odt_parser)
14
- else
15
- clazz.new(parent, attrs, prefix, name, markdown_odt_parser)
16
- end
17
- end
18
-
19
- def self.titleize(tag)
20
- tag.split('-').map(&:capitalize).join
21
- end
22
-
23
- def initialize(parent = nil, attrs = [], prefix = nil, name = nil, markdown_odt_parser = nil)
24
- @parent, @attrs, @prefix, @name, @markdown_odt_parser = parent, attrs, prefix, name, markdown_odt_parser
25
- @children = []
26
- @has_text = false
27
- end
28
-
29
- def root?
30
- !@parent
31
- end
32
-
33
- def has_text?
34
- @has_text
35
- end
36
-
37
- def open
38
- ''
39
- end
40
-
41
- def close
42
- ''
43
- end
44
-
45
- def office_text?
46
- false
47
- end
48
-
49
- def delete
50
- return true unless @children
51
- @children.each { |child| child.delete }
52
- @children = []
53
- end
54
-
55
- def eql?(object)
56
- return false unless object.is_a? Node
57
- object.xml_name == xml_name
58
- end
59
-
60
- def generic?
61
- instance_of? Node
62
- end
63
-
64
- def xml_name
65
- "#{@prefix}:#{@name}"
66
- end
67
-
68
- def to_s
69
- "#{xml_name} : #{attrs}"
70
- end
71
-
72
- def expand
73
- expanded = "#{open}#{@children.map(&:expand).join}#{close}"
74
- delete
75
- expanded.clone
76
- end
77
-
78
- def not_enclosing?
79
- !root? && parent.class.not_enclosing_tags && parent.class.not_enclosing_tags.find do |tag|
80
- @prefix == parent.prefix && @name == tag
81
- end
82
- end
83
-
84
- def self.included(base)
85
- base.extend ClassMethods
86
- end
87
-
88
- module ClassMethods
89
- attr_reader :not_enclosing_tags
90
-
91
- def not_enclosing(tag)
92
- @not_enclosing_tags ||= []
93
- @not_enclosing_tags << tag
94
- end
95
- end
96
- end
97
- end
98
- end
99
- end