htot_conv 1.1.0 → 1.2.0

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d4da682b780c3e60acaca1f0f9e58b3ee05093e1
4
- data.tar.gz: f81ca329608b01c808b8ade2959bd4a375cd9374
3
+ metadata.gz: 20fd33c42352c14c340c14b0241ee5fb93087d13
4
+ data.tar.gz: a88a66b27d89cc9c450fff2dabe72d210b43af0c
5
5
  SHA512:
6
- metadata.gz: e3cdbe7f7ca82f32647831cada306928ea51bda2054e488efa0b259267dfd321919ebc9a84c2cc7fee253bd8b39d16fa1e2af2b665c408ec9b9e0b3eb4e0217a
7
- data.tar.gz: 6e8e298f5c4f56935487c66b9a4b9286e9a8ddf7e6e7b8d4b07e3d58b69f59a265f176c4582600a201fad95fb6f57ac4102fa34a8dc4dfa6eec482a29cb944b0
6
+ metadata.gz: 8ec5506b5f8d79abb2948b06ab6d208be3aa596def16e06c80e8f41e468230424fe898b75f1cd42051e2766d11a6c0a42ebb33964f1288a330ff6efa8222627b
7
+ data.tar.gz: 12669a0c9f527e7985c90a3e25a43cb2edb0f76470608289652ee686a546fbfbdf15a1b77f35b4732dd34dd74e9d93c5d5d036b0e97675edd03933fff01415ec
@@ -18,6 +18,11 @@
18
18
  * HTML `<ul><li>` and/or `<ol><li>` [nesting list](https://www.w3.org/wiki/HTML_lists#Nesting_lists).
19
19
  * All text outside of `<li>` elements is ignored.
20
20
 
21
+ ## `mspdi`
22
+
23
+ * MS Project 20xx XML Data Interchange (i.e. files saved as "XML" format on MS Project).
24
+ * Treat the task name as a key text, the other attributes as values.
25
+
21
26
  ## `opml`
22
27
 
23
28
  * [OPML](http://dev.opml.org/)
@@ -3,6 +3,7 @@ require 'htot_conv/parser/base.rb'
3
3
  require 'htot_conv/parser/simple_text.rb'
4
4
  require 'htot_conv/parser/dir_tree.rb'
5
5
  require 'htot_conv/parser/html_list.rb'
6
+ require 'htot_conv/parser/mspdi.rb'
6
7
  require 'htot_conv/parser/opml.rb'
7
8
 
8
9
  module HTOTConv
@@ -0,0 +1,83 @@
1
+ # frozen_string_literal: true
2
+ require 'htot_conv/parser/base'
3
+
4
+ module HTOTConv
5
+ module Parser
6
+ class Mspdi < Base
7
+ def self.option_help
8
+ {
9
+ :key_header => {
10
+ :default => [],
11
+ :pat => Array,
12
+ :desc => "key header",
13
+ },
14
+ :value_header => {
15
+ :default => [],
16
+ :pat => Array,
17
+ :desc => "value header",
18
+ },
19
+ }
20
+ end
21
+
22
+ def parse(input)
23
+ outline = HTOTConv::Outline.new
24
+ outline.key_header = @option[:key_header]
25
+ outline.value_header = @option[:value_header]
26
+
27
+ parser = Nokogiri::XML::SAX::Parser.new(ListDoc.new(outline))
28
+ parser.parse(input)
29
+
30
+ outline
31
+ end
32
+
33
+ class ListDoc < Nokogiri::XML::SAX::Document
34
+ def initialize(outline)
35
+ @outline = outline
36
+ @breadcrumb = []
37
+ end
38
+
39
+ def start_element(name, attrs=[])
40
+ @breadcrumb << name
41
+ @values = {} if name == 'Task'
42
+ end
43
+
44
+ def end_element(name)
45
+ @breadcrumb.pop
46
+ generate_outline_item if name == 'Task'
47
+ end
48
+
49
+ def characters(string)
50
+ if @breadcrumb.include?('Task')
51
+ type = @breadcrumb.last
52
+ @values[type] = ''.dup unless @values.include?(type)
53
+ @values[type] << string
54
+ end
55
+ end
56
+
57
+ alias :cdata_block :characters
58
+
59
+ private
60
+ def generate_outline_item
61
+ text = ""
62
+ level = 1
63
+ values = []
64
+ @values.each do |pair|
65
+ attr_name, attr_val = pair
66
+ if attr_name == "Name"
67
+ text = attr_val
68
+ elsif attr_name == "OutlineLevel"
69
+ level = attr_val.to_i
70
+ else
71
+ if @outline.value_header.include?(attr_name)
72
+ values[@outline.value_header.index(attr_name)] = attr_val
73
+ end
74
+ end
75
+ end
76
+
77
+ @outline.add_item(text, level, values)
78
+ end
79
+ end
80
+
81
+ end
82
+ end
83
+ end
@@ -1,4 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
  module HTOTConv
3
- VERSION = "1.1.0"
3
+ VERSION = "1.2.0"
4
4
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: htot_conv
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - "@cat_in_136"
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-02-06 00:00:00.000000000 Z
11
+ date: 2018-03-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rubyXL
@@ -141,6 +141,7 @@ files:
141
141
  - lib/htot_conv/parser/base.rb
142
142
  - lib/htot_conv/parser/dir_tree.rb
143
143
  - lib/htot_conv/parser/html_list.rb
144
+ - lib/htot_conv/parser/mspdi.rb
144
145
  - lib/htot_conv/parser/opml.rb
145
146
  - lib/htot_conv/parser/simple_text.rb
146
147
  - lib/htot_conv/util.rb
@@ -165,7 +166,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
165
166
  version: '0'
166
167
  requirements: []
167
168
  rubyforge_project:
168
- rubygems_version: 2.6.13
169
+ rubygems_version: 2.6.14
169
170
  signing_key:
170
171
  specification_version: 4
171
172
  summary: Hierarchical-Tree Outline Text Converter