pxindex-builder 0.1.2 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 67934e9d607e3570a66cf15e057f400ff5ecf589
4
- data.tar.gz: fd66201c28faf4f5227ec224c81eb00ef8751a5a
3
+ metadata.gz: 3229af6d51962358d1f061ef1a0b97bb4c218b33
4
+ data.tar.gz: cef39271b8bd4e31d084c3e7cf4e1ad4b075daa2
5
5
  SHA512:
6
- metadata.gz: 40f97d7d4c6a4201f63bacbaefa3374f92887285064b152f25f8d6a1f0efac63e63d390908215984ab0cc6976e24074c0daaaaa5e4eabdc26e2033cea65a42b8
7
- data.tar.gz: 00c5a55685c184d0af6b9dcdbc6423e38d3120f96a4b7e48ac5014a7d3303ee02fba27512e62033343937d75f3a36569a9602e227c97f8a56f545f9ae57bbeac
6
+ metadata.gz: 2faa208ab98b3ade27b8d35b3efb67c0214fac5e94de2cc3e95df971495c785cc26105fd7230b075b30147893660c44dca0f6c9468a7bac8920d2e897a7be78e
7
+ data.tar.gz: a6cd4aea8b62250abf85e2867182536a3a7e15ba9030d16ab763729058b6f6465fa97f6045999a2c2137fb0bcd1976b3178e7415fd780ba162826b3039601e80
checksums.yaml.gz.sig CHANGED
Binary file
@@ -2,6 +2,7 @@
2
2
 
3
3
  # file: pxindex-builder.rb
4
4
 
5
+ require 'line-tree'
5
6
  require 'wordsdotdat'
6
7
  require 'phrase_lookup'
7
8
  require 'polyrex-builder'
@@ -9,18 +10,52 @@ require 'polyrex-builder'
9
10
 
10
11
  class PxIndexBuilder
11
12
 
12
- attr_reader :to_xml, :to_h
13
-
14
- def initialize(obj, ignore=[])
15
-
16
- h = if obj.is_a? String then
13
+ attr_reader :to_xml, :to_h, :to_s
14
+
15
+ def initialize(obj, debug: false, ignore: [])
16
+
17
+ @debug = debug
18
+ puts 'inside initialize: ' if @debug
19
+
20
+ if obj.is_a? String then
17
21
 
18
22
  s, _ = RXFHelper.read(obj)
19
- YAML.load(s)
23
+
24
+ s =~ /^---/ ? import_phrases(YAML.load(s), s, ignore) : import_index(s)
20
25
 
21
26
  elsif obj.is_a? Hash
22
- obj
27
+ import_phrases obj, s, ignore
23
28
  end
29
+
30
+ end
31
+
32
+
33
+ private
34
+
35
+ def import_index(raw_s)
36
+
37
+ # find the entries which aren't on the main index
38
+ s = raw_s.sub(/<[^>]+>\n/,'')
39
+ doc = LineTree.new(s, debug: @debug).to_doc(encapsulate: true)
40
+ a = doc.root.xpath('entry/text()')
41
+ puts 'doc: ' + doc.xml if @debug
42
+ a2 = doc.root.xpath('entry//entry/text()')
43
+ puts 'a2: ' + a2.inspect if @debug
44
+ a3 = a2 - a
45
+ puts 'a3:' + a3.inspect if @debug
46
+
47
+ # add the new entries to the main index
48
+ s << "\n" + a3.join("\n")
49
+
50
+ s.prepend '<?ph schema="entries/section[heading]/entry[title, url]"?>
51
+
52
+ '
53
+
54
+ @to_s = s
55
+
56
+ end
57
+
58
+ def import_phrases(h, s, ignore=[])
24
59
 
25
60
  words = h.keys.join(' ').split(/ +/).map {|x| x[/\w+/]}.uniq\
26
61
  #.tap {|x| puts 't: ' + x.inspect}
@@ -43,12 +78,13 @@ class PxIndexBuilder
43
78
  end
44
79
 
45
80
  @to_h = h = scan(index)
81
+ puts 'h: ' + h.inspect if @debug
46
82
  @to_xml = PolyrexBuilder.new(h, parents: %i(entry)).to_xml
47
83
 
48
84
 
49
85
  end
50
86
 
51
- private
87
+
52
88
 
53
89
  def scan(rows)
54
90
 
data.tar.gz.sig CHANGED
Binary file
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pxindex-builder
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - James Robertson
@@ -31,8 +31,28 @@ cert_chain:
31
31
  rpKyBm8O20gPepUR+u4B3OOMZL1vUMzoAppGGdK/fa9iZHfP9tccqmgXIQ8c4X1f
32
32
  C74enOZQySX7LA==
33
33
  -----END CERTIFICATE-----
34
- date: 2017-12-17 00:00:00.000000000 Z
34
+ date: 2018-04-14 00:00:00.000000000 Z
35
35
  dependencies:
36
+ - !ruby/object:Gem::Dependency
37
+ name: line-tree
38
+ requirement: !ruby/object:Gem::Requirement
39
+ requirements:
40
+ - - "~>"
41
+ - !ruby/object:Gem::Version
42
+ version: '0.6'
43
+ - - ">="
44
+ - !ruby/object:Gem::Version
45
+ version: 0.6.8
46
+ type: :runtime
47
+ prerelease: false
48
+ version_requirements: !ruby/object:Gem::Requirement
49
+ requirements:
50
+ - - "~>"
51
+ - !ruby/object:Gem::Version
52
+ version: '0.6'
53
+ - - ">="
54
+ - !ruby/object:Gem::Version
55
+ version: 0.6.8
36
56
  - !ruby/object:Gem::Dependency
37
57
  name: wordsdotdat
38
58
  requirement: !ruby/object:Gem::Requirement
@@ -62,7 +82,7 @@ dependencies:
62
82
  version: '0.1'
63
83
  - - ">="
64
84
  - !ruby/object:Gem::Version
65
- version: 0.1.5
85
+ version: 0.1.7
66
86
  type: :runtime
67
87
  prerelease: false
68
88
  version_requirements: !ruby/object:Gem::Requirement
@@ -72,27 +92,27 @@ dependencies:
72
92
  version: '0.1'
73
93
  - - ">="
74
94
  - !ruby/object:Gem::Version
75
- version: 0.1.5
95
+ version: 0.1.7
76
96
  - !ruby/object:Gem::Dependency
77
97
  name: polyrex-builder
78
98
  requirement: !ruby/object:Gem::Requirement
79
99
  requirements:
80
100
  - - "~>"
81
101
  - !ruby/object:Gem::Version
82
- version: '0.2'
102
+ version: '0.3'
83
103
  - - ">="
84
104
  - !ruby/object:Gem::Version
85
- version: 0.2.0
105
+ version: 0.3.0
86
106
  type: :runtime
87
107
  prerelease: false
88
108
  version_requirements: !ruby/object:Gem::Requirement
89
109
  requirements:
90
110
  - - "~>"
91
111
  - !ruby/object:Gem::Version
92
- version: '0.2'
112
+ version: '0.3'
93
113
  - - ">="
94
114
  - !ruby/object:Gem::Version
95
- version: 0.2.0
115
+ version: 0.3.0
96
116
  description:
97
117
  email: james@jamesrobertson.eu
98
118
  executables: []
@@ -123,5 +143,6 @@ rubyforge_project:
123
143
  rubygems_version: 2.6.13
124
144
  signing_key:
125
145
  specification_version: 4
126
- summary: Builds a Polyrex index (pxindex) XML document from a YAML document
146
+ summary: Builds a Polyrex index (pxindex) XML document from a YAML document or an
147
+ indented list
127
148
  test_files: []
metadata.gz.sig CHANGED
@@ -1,2 +1,2 @@
1
- {؃��P�`)�� ��+���*�iЮ�am3�V<k�����N+A(��� ���4�&߀�oq����9�ŵ�*�� $d[����u �Wq0�c/��#�!�s�6�5ΰɖD5=$v\
2
- .���\*�q
1
+ _𕀣"%�Xx�6
2
+ sng:�R�����}� �������W�t�XP@L�\��Ti�u�9�2Ԧ+Qf-�H���&��QK� l�m�m��$��� ?��h���f�V�U|Zz�x�������LE���(�� ���j8�E���[�A