wiki_md 0.4.2 → 0.5.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
  SHA256:
3
- metadata.gz: d7dae25e868d52bfea1461356265ae5b03e61fd5c88eab4c1c777d5b5d7e8e00
4
- data.tar.gz: 6915a2cbe47d1e4149c3382b1115b7e7381d139cc717090f35203bd045ae0cdc
3
+ metadata.gz: 23d30c7bf1b6a100c37547aa1c5ff9e65b8c15cfb764672ed234d02193c63cf2
4
+ data.tar.gz: aaa03a60bb5698f4973a1bc5482c05e351d23890e6a77c44569250e48ea49dd3
5
5
  SHA512:
6
- metadata.gz: 1322e935d64b161170ba2954929c7997b5f02e07605b0b4672b3e9f62e81792cb3a2d5329ff908cf9bbee31677c6a718343ca99838cbd80b7c9ec0e8150516d9
7
- data.tar.gz: dcf4f022352ca137e5c504237e45e1387913770206d08d5ce4e5be0c300bee7e8bb6e4a0bad65872c0f6ed9310fc98f0d727c78f41c94e61de9ae6da41275f9f
6
+ metadata.gz: ad6a1590ee1f11d6572aadcfc6e3125b98a0fee494ccf89dbdb38e162a70ea5a3ba7d9425ce0106e7e8979d26b2407c2a8bb338f8606701fbd34f6d2bedf3917
7
+ data.tar.gz: d955659c15fa48942c4c0cc5bffff1a4b9e1925957dc1f95ff1839ae6ef0ed20cde55f707b748cc4551463f63c2cbf32c8e8c60e579039304d42935cd270b306
checksums.yaml.gz.sig CHANGED
Binary file
data/lib/wiki_md.rb CHANGED
@@ -21,16 +21,38 @@ class WikiMd
21
21
  if wiki then
22
22
 
23
23
  s, type = RXFHelper.read(wiki, auto: false)
24
- @filename = wiki if type == :file or type == :dfs
25
- puts ('s: ' + s.inspect).debug if @debug
26
- @dxsx = DxSectionX.new s, debug: debug, autosave: true
27
24
 
28
- @filepath = File.dirname @filename
25
+ if debug then
26
+ puts [
27
+ 's: ' + s.inspect,
28
+ 'type: ' + type.inspect,
29
+ 's.lines.length: ' + s.lines.length.inspect]\
30
+ .join("\n").debug
31
+ puts ('file exists? ' + FileX.exists?(File.dirname(s)).inspect).debug
29
32
 
30
- indexfile = File.join(@filepath, 'index.xml')
33
+ end
31
34
 
32
- # check for the index.xml file
33
- @dx = load_index(indexfile)
35
+ if type == :unknown and s.lines.length == 1 and
36
+ FileX.exists?(File.dirname(s)) then
37
+ puts 'before new_md()'.debug if debug
38
+ new_md()
39
+ @filename = wiki
40
+
41
+ elsif type == :file or type == :dfs
42
+
43
+ @filename = wiki
44
+
45
+ puts ('s: ' + s.inspect).debug if @debug
46
+ @dxsx = DxSectionX.new s, debug: debug, autosave: true
47
+
48
+ @filepath = File.dirname @filename
49
+
50
+ indexfile = File.join(@filepath, 'index.xml')
51
+
52
+ # check for the index.xml file
53
+ @dx = load_index(indexfile)
54
+
55
+ end
34
56
 
35
57
  else
36
58
 
@@ -63,23 +85,37 @@ class WikiMd
63
85
 
64
86
  @dxsx.create(x: s2)
65
87
 
66
- @dx.create title: title + ' #' + tagline.lstrip.split.join(' #'),
88
+ record = {title: title + ' #' + tagline.lstrip.split.join(' #'),
67
89
  url: [@base_url, File.basename(@filename)[/.*(?=\.\w+)/],
68
- URI.escape(title)].join('/')
90
+ URI.escape(title)].join('/')}
91
+
92
+ @dx.create record
69
93
  FileX.write @filename, @dxsx.to_s if @filename
70
- @dxtags.generate
94
+ @dxtags.add record
71
95
 
72
96
  end
73
97
 
74
98
  alias add_section create_section
75
99
 
76
100
  def delete_section(q)
101
+
102
+ regex = q.is_a?(String) ? /#{q}/i : q
103
+ r = @dxsx.dx.all.find {|section| section.x.lines.first =~ regex }
77
104
 
78
- r = find()
105
+ return unless r
79
106
 
80
- return false unless r
107
+ r.delete
108
+
109
+ rx = @dx.all.find {|x| x.title =~ regex}
110
+
111
+ return unless rx
112
+
113
+ title = rx.title
114
+ rx.delete
115
+ @dxtags.delete title
116
+ puts ('deleted title: ' + title.inspect).debug if @debug
81
117
 
82
- r.delete
118
+ :section_deleted
83
119
 
84
120
  end
85
121
 
@@ -87,8 +123,7 @@ class WikiMd
87
123
 
88
124
  puts ('WikiMd::find q: ' + q.inspect).debug if @debug
89
125
  return @dxsx.dx.find q if q =~ /^\d+$/
90
- regex = q.is_a?(String) ? /#{q}/i : q
91
- r = @dxsx.dx.all.find {|section| section.x.lines.first =~ regex }
126
+
92
127
  puts (' r: ' + r.inspect).debug if @debug
93
128
  return unless r
94
129
 
@@ -107,6 +142,8 @@ class WikiMd
107
142
 
108
143
  def new_md(x=nil, title: 'MyWiki')
109
144
 
145
+ puts 'inside new_md'.debug if @debug
146
+
110
147
  s = nil
111
148
  s, _ = RXFHelper.read(x) if x
112
149
 
@@ -251,10 +288,11 @@ EOF
251
288
 
252
289
  if title != @active_heading or tagline2 != tagline1 then
253
290
 
254
- rx.update title: @active_heading + ' #' + tagline1.split.join(' #'),
291
+ record = {title: @active_heading + ' #' + tagline1.split.join(' #'),
255
292
  url: [@base_url, File.basename(@filename)[/.*(?=\.\w+)/],
256
- URI.escape(title)].join('/')
257
- @dxtags.generate
293
+ URI.escape(title)].join('/')}
294
+ rx.update record
295
+ @dxtags.add record
258
296
 
259
297
  end
260
298
 
@@ -270,11 +308,12 @@ EOF
270
308
  a.length > 1 ? a.map(&:capitalize).join : a.first
271
309
  end
272
310
 
273
- @dx.create title: @active_heading + ' #' + newtagline,
311
+ record = {title: @active_heading + ' #' + newtagline,
274
312
  url: [@base_url, File.basename(@filename)[/.*(?=\.\w+)/],
275
- URI.escape(@active_heading)].join('/')
276
- @dxtags.generate
277
-
313
+ URI.escape(@active_heading)].join('/')}
314
+ @dx.create record
315
+ @dxtags.add record
316
+
278
317
  end
279
318
 
280
319
  end
data.tar.gz.sig CHANGED
Binary file
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: wiki_md
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.2
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - James Robertson
@@ -35,7 +35,7 @@ cert_chain:
35
35
  nEQURKgvgTAqVg9tuqcjEE861mSCPc+12rmUHVBZDxMDQF6CQbnOxrYRIS+7fnia
36
36
  kikBQtN17cUMyGOrZTVRhVGR
37
37
  -----END CERTIFICATE-----
38
- date: 2018-11-03 00:00:00.000000000 Z
38
+ date: 2018-11-04 00:00:00.000000000 Z
39
39
  dependencies:
40
40
  - !ruby/object:Gem::Dependency
41
41
  name: dxsectionx
@@ -63,20 +63,20 @@ dependencies:
63
63
  requirements:
64
64
  - - "~>"
65
65
  - !ruby/object:Gem::Version
66
- version: '0.3'
66
+ version: '0.4'
67
67
  - - ">="
68
68
  - !ruby/object:Gem::Version
69
- version: 0.3.2
69
+ version: 0.4.0
70
70
  type: :runtime
71
71
  prerelease: false
72
72
  version_requirements: !ruby/object:Gem::Requirement
73
73
  requirements:
74
74
  - - "~>"
75
75
  - !ruby/object:Gem::Version
76
- version: '0.3'
76
+ version: '0.4'
77
77
  - - ">="
78
78
  - !ruby/object:Gem::Version
79
- version: 0.3.2
79
+ version: 0.4.0
80
80
  description:
81
81
  email: james@jamesrobertson.eu
82
82
  executables: []
metadata.gz.sig CHANGED
Binary file