md_edit 0.2.4 → 0.2.5

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: 986cdda88657491ac7a0bea9c3b0eb20c080bf62
4
- data.tar.gz: caa4c16f09f31ff54b69dd6b038bb29df308cec8
3
+ metadata.gz: b45b0027d22fba03dc6ebcb44af13f825393cb2a
4
+ data.tar.gz: 2084acfa0dac9d73741b60c9515ed399a10aab0c
5
5
  SHA512:
6
- metadata.gz: e3819a872dad7b876821edea8c7dd18baec1f051da5cb00683e4dfd6538f3ac80395c5fb81b20c1082d3ddff65a857fa99d82e909438fb006a116de5a5e0a6d5
7
- data.tar.gz: f84b0a093987636e1d53f5a0d0afd93d1d88c9af73f94cab56506d2250f990fc5a8dfef5cc5b351f73e14b42c2ec22d9610e55d715dc52449d025db8b3872630
6
+ metadata.gz: 408dc27176617edc2b59cb8e8668aa9d9e97a8b99a5776da18cd353026642663effae63122056ea6416f781666136dfd1805d9285c15a35867b25bbf00cfdbc1
7
+ data.tar.gz: 8b07998a428345ac47f650495e0c32b90dbd1dc7879ecaccc097b895c3fb185fa465780bc9766622446470a4437e039e5dfe5672567147eee00e11fb677390e6
Binary file
data.tar.gz.sig CHANGED
Binary file
@@ -37,15 +37,15 @@ class MdEdit
37
37
 
38
38
  def create(s)
39
39
 
40
- @s << "\n\n" + s.sub(/^(?=\w)/,'## ').sub(/#+ [a-z]/){|x| x.upcase}\
41
- .sub(/(?!=^\n)$/,"\n\n")
40
+ @s = @s.rstrip + "\n\n" + s.sub(/^(?=\w)/,'## ').sub(/#+ [a-z]/)\
41
+ {|x| x.upcase}.sub(/(?!=^\n)$/,"\n\n")
42
42
  load_sections(@s)
43
43
  save()
44
44
 
45
45
  :created
46
46
  end
47
47
 
48
- # specify a heeading to delete a section
48
+ # specify a heading to delete a section
49
49
  #
50
50
  def delete(s)
51
51
 
@@ -111,14 +111,18 @@ class MdEdit
111
111
 
112
112
  results = []
113
113
 
114
- r = @headingslookup.q s
114
+ r = @headingslookup.q s
115
+ puts 'query() r: ' + r.inspect if @debug
115
116
 
116
117
  if r and r.any? then
117
118
 
118
119
  results = if full_trail then
119
120
  r
120
121
  else
121
- r.map{|x| x.split(' > ')[1..-1].join(' > ')}.reject(&:empty?)
122
+ r.map do |x|
123
+ headings = x.split(' > ')
124
+ headings.length > 1 ? headings[1..-1].join(' > ') : headings[0]
125
+ end.reject(&:empty?)
122
126
  end
123
127
 
124
128
  end
@@ -281,7 +285,7 @@ class MdEdit
281
285
  h = @sections.keys.inject({}) do |r,x|
282
286
  r.merge(x.sub(/^#+ +/,'').downcase => 5 - x.count('#'))
283
287
  end
284
-
288
+ puts 'h: ' + h.inspect if @debug
285
289
  @headingslookup = PhraseLookup.new h
286
290
  @h = h.to_a.map {|k,v| [k.split(' > ').last, v]}.to_h
287
291
  @s = s
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: md_edit
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.4
4
+ version: 0.2.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - James Robertson
@@ -31,7 +31,7 @@ cert_chain:
31
31
  R5r1JjTBaaHOaqI14bIkwUSY5q1cO4Wl7HWly80kX2AD8o/tPHvyF9Tx3pBvaboU
32
32
  etnSPHbQwmBvFQ==
33
33
  -----END CERTIFICATE-----
34
- date: 2017-12-30 00:00:00.000000000 Z
34
+ date: 2018-01-14 00:00:00.000000000 Z
35
35
  dependencies:
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: line-tree
metadata.gz.sig CHANGED
Binary file