myoutline 0.2.1 → 0.3.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: 752b310a3ffc4f555e366c6a4b0f82a2377873b1
4
- data.tar.gz: 7fb8965d9a4f5516f012cfbfe053f374c48c17f6
3
+ metadata.gz: efb9af4d7dcfa27f317ee3d832df291e617c10f0
4
+ data.tar.gz: eb9f2b405e4cc0d4a8a8eea37ef7a477917060dc
5
5
  SHA512:
6
- metadata.gz: 2da3cacae84e95865054d059430f03810092841ec1ba4b925e85874623cdb4bc99bc17e9f8d6548879178810af509a8057c7f84651d792bc2e4c342acdc01441
7
- data.tar.gz: 78906df6f38baae13d4b3482747ae3a204e0cc05e0e984b63884dca8e3f20de11d1de044e7e481d3ee01925e34122d5171dbc74e07a7a7e110164b6841b1bd37
6
+ metadata.gz: 6ff486f872144eecafa450529d20e034cfa72fb61de51b723e040ee71d458b1cdc7f6de7befd28fc8b362613f527dbb878b63af0bbf227833b7f37a772e45a18
7
+ data.tar.gz: f13de27b4ded08cad7452b1063c8ab0b67e853c10698516f495a0b6b362de572e1afbc56a952690b3b57cf4348fa406594d0535afd4cb1a195fabc75e37ba0b7
checksums.yaml.gz.sig CHANGED
Binary file
data/lib/myoutline.rb CHANGED
@@ -4,40 +4,42 @@
4
4
 
5
5
  require 'pxindex'
6
6
  require 'nokogiri'
7
+ require 'filetree_xml'
8
+ require 'polyrex-links'
9
+
7
10
 
8
11
 
9
12
  class MyOutline
10
13
 
11
- attr_reader :pxi
14
+ attr_reader :pxi, :links
12
15
 
13
16
  def initialize(source, debug: false, allsorted: true,
14
17
  autoupdate: true, topic_url: '$topic')
15
18
 
16
- @debug, @source, @topic_url = debug, source, topic_url
19
+ @debug, @source, @topic_url, @allsorted, @autoupdate = debug, source,
20
+ topic_url, allsorted, autoupdate
17
21
 
18
22
  raw_s, _ = RXFHelper.read(source)
19
-
20
- # find the entries which aren't on the main index
21
- s = raw_s.sub(/<[^>]+>\n/,'')
22
- doc = LineTree.new(s, debug: true).to_doc(encapsulate: true)
23
- a = doc.root.xpath('entry/text()')
24
- puts 'doc: ' + doc.xml if debug
25
- a2 = doc.root.xpath('entry//entry/text()')
26
- puts 'a2: ' + a2.inspect if debug
27
- a3 = a2 - a
28
- puts 'a3:' + a3.inspect if debug
29
-
30
- # add the new entries to the main index
31
- s << a3.join("\n")
23
+ build_index(raw_s)
32
24
 
33
- s.prepend '<?ph schema="entries/section[heading]/entry[title, url]"?>
34
25
 
35
- '
36
-
37
- @pxi = PxIndex.new(s, debug: debug, indexsorted: true,
38
- allsorted: allsorted)
39
- save() if autoupdate and self.to_s != raw_s
26
+ end
27
+
28
+ def fetch(uri)
40
29
 
30
+ s, remaining = @links.locate uri
31
+ puts 'fetch() s: ' + s.inspect if @debug
32
+ redirect = s =~ /^\[r\] +/i
33
+ return s if redirect
34
+
35
+ # md_edit goes here
36
+ contents, _ = RXFHelper.read(s)
37
+
38
+ return contents
39
+ end
40
+
41
+ def ls(path='.')
42
+ @ftx.ls(path).map(&:to_s)
41
43
  end
42
44
 
43
45
  def save(filename=nil)
@@ -96,18 +98,63 @@ class MyOutline
96
98
 
97
99
  end
98
100
 
99
- def to_tree(alphabet: true)
101
+
102
+ def to_tree
103
+ format_tree(alphabet: true, nourl: true)
104
+ end
105
+
106
+ def to_treelinks
107
+ format_tree()
108
+ end
109
+
110
+ private
111
+
112
+ def build_index(raw_s)
113
+
114
+ # find the entries which aren't on the main index
115
+ s = raw_s.sub(/<[^>]+>\n/,'')
116
+ doc = LineTree.new(s, debug: @debug).to_doc(encapsulate: true)
117
+ a = doc.root.xpath('entry/text()')
118
+ puts 'doc: ' + doc.xml if @debug
119
+ a2 = doc.root.xpath('entry//entry/text()')
120
+ puts 'a2: ' + a2.inspect if @debug
121
+ a3 = a2 - a
122
+ puts 'a3:' + a3.inspect if @debug
123
+
124
+ # add the new entries to the main index
125
+ s << a3.join("\n")
126
+
127
+ s.prepend '<?ph schema="entries/section[heading]/entry[title, url]"?>
128
+
129
+ '
130
+
131
+ @pxi = PxIndex.new(s, debug: @debug, indexsorted: true,
132
+ allsorted: @allsorted)
133
+ save() if @autoupdate and self.to_s != raw_s
134
+ read(self.to_s)
135
+ end
136
+
137
+ def format_tree(alphabet: false, nourl: false)
100
138
 
101
139
  a = @pxi.to_s.lines
102
140
  a.shift # remove the ph declaration
103
141
  a.reject! {|x| x =~ /^(?:#[^\n]+|\n+)$/} unless alphabet
104
- a.map! {|x| r = x[/^.*(?= # )/]; r ? r + "\n" : x } # strip out the URLS
142
+
143
+ if nourl then
144
+ # strip out the URLS?
145
+ a.map! {|x| r = x[/^.*(?= # )/]; r ? r + "\n" : x }
146
+ end
105
147
 
106
148
  a.join
107
149
 
108
- end
150
+ end
109
151
 
110
- private
152
+ def read(s)
153
+ @links = PolyrexLinks.new.import(s, debug: @debug)
154
+
155
+ s3 = s.lines.map {|x| x.split(/ | # /,2)[0]}.join("\n")
156
+ @ftx = FileTreeXML.new(s3, debug: @debug)
157
+ end
111
158
 
112
159
  def xslt()
113
160
  <<EOF
data.tar.gz.sig CHANGED
Binary file
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: myoutline
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - James Robertson
@@ -30,7 +30,7 @@ cert_chain:
30
30
  DFhc5TDtqEkJYiaiznQFl34HUKeCAdeAHkmD8jP3fUC8O7zcLXq69EAXGMXw4efB
31
31
  3Co=
32
32
  -----END CERTIFICATE-----
33
- date: 2018-03-30 00:00:00.000000000 Z
33
+ date: 2018-04-02 00:00:00.000000000 Z
34
34
  dependencies:
35
35
  - !ruby/object:Gem::Dependency
36
36
  name: pxindex
@@ -72,6 +72,46 @@ dependencies:
72
72
  - - ">="
73
73
  - !ruby/object:Gem::Version
74
74
  version: 1.8.2
75
+ - !ruby/object:Gem::Dependency
76
+ name: filetree_xml
77
+ requirement: !ruby/object:Gem::Requirement
78
+ requirements:
79
+ - - "~>"
80
+ - !ruby/object:Gem::Version
81
+ version: '0.1'
82
+ - - ">="
83
+ - !ruby/object:Gem::Version
84
+ version: 0.1.3
85
+ type: :runtime
86
+ prerelease: false
87
+ version_requirements: !ruby/object:Gem::Requirement
88
+ requirements:
89
+ - - "~>"
90
+ - !ruby/object:Gem::Version
91
+ version: '0.1'
92
+ - - ">="
93
+ - !ruby/object:Gem::Version
94
+ version: 0.1.3
95
+ - !ruby/object:Gem::Dependency
96
+ name: polyrex-links
97
+ requirement: !ruby/object:Gem::Requirement
98
+ requirements:
99
+ - - "~>"
100
+ - !ruby/object:Gem::Version
101
+ version: '0.2'
102
+ - - ">="
103
+ - !ruby/object:Gem::Version
104
+ version: 0.2.0
105
+ type: :runtime
106
+ prerelease: false
107
+ version_requirements: !ruby/object:Gem::Requirement
108
+ requirements:
109
+ - - "~>"
110
+ - !ruby/object:Gem::Version
111
+ version: '0.2'
112
+ - - ">="
113
+ - !ruby/object:Gem::Version
114
+ version: 0.2.0
75
115
  description:
76
116
  email: james@jamesrobertson.eu
77
117
  executables: []
metadata.gz.sig CHANGED
Binary file