wiki_md 0.1.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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 11fff1d1320ddb7772ebc6ffbc60c499a28dc15e133e099fe5af3ade050ce8fe
4
+ data.tar.gz: 9b545bbe223a5835a094b37d969c301ca31f1a48452d897f835b04fec9a9ad4f
5
+ SHA512:
6
+ metadata.gz: 7babfe509ca96d638f3fde08ed6397007b41187ac8d13f2e5f8f114d4ef5ed6acc781f678d6e4431bd2d24f8c0a7efb4d29c05a5ca7beb67f014894a9a1647a4
7
+ data.tar.gz: cd1174a5003adcd60ffea667e50b83cced57baab979fba4707e94ebf904e95587b1f8725c92cfa2c4ba23297c1c2a7d50e14dca6bf4009c4b35528b350f0516d
checksums.yaml.gz.sig ADDED
Binary file
data.tar.gz.sig ADDED
Binary file
data/lib/wiki_md.rb ADDED
@@ -0,0 +1,100 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ # file: wiki_md.rb
4
+
5
+ require 'dxsectionx'
6
+
7
+
8
+
9
+ class WikiMd
10
+
11
+ def initialize(wiki=nil)
12
+
13
+ if wiki then
14
+ s, _ = RXFHelper.read(wiki)
15
+ @dxsx = DxSectionX.new s
16
+ else
17
+
18
+ new_md()
19
+
20
+ end
21
+
22
+ end
23
+
24
+ def create_section(s)
25
+ @dxsx.create(x: s)
26
+ end
27
+
28
+ def delete_section(q)
29
+
30
+ r = find()
31
+
32
+ return false unless r
33
+
34
+ r.delete
35
+
36
+ end
37
+
38
+ def find(q)
39
+
40
+ return @dxsx.dx.find q if q =~ /^\d+$/
41
+ regex = q.is_a?(String) ? /#{q}/i : q
42
+ @dxsx.dx.all.find {|section| section.x =~ regex }
43
+ end
44
+
45
+ def new_md(x=nil)
46
+
47
+ s = nil
48
+ s, _ = RXFHelper.read(x) if x
49
+
50
+ s ||= <<EOF
51
+ <?dynarex schema="sections[title]/section(x)" format_mask="[!x]"?>
52
+ title: MyWiki
53
+
54
+ --#
55
+
56
+ EOF
57
+
58
+ @dxsx = DxSectionX.new s
59
+
60
+
61
+ end
62
+
63
+ alias import new_md
64
+
65
+ def title()
66
+ @dxsx.dx.title()
67
+ end
68
+
69
+ def title=(s)
70
+ @dxsx.dx.title = s
71
+ end
72
+
73
+ def to_sections()
74
+ @dxsx.to_doc.root.xpath('records/section')\
75
+ .map {|x| x.xml(pretty: true)}.join("\n")
76
+ end
77
+
78
+ def to_xml()
79
+ @dxsx.to_doc.xml(declaration: false, pretty: true)
80
+ end
81
+
82
+ def to_s()
83
+ @dxsx.to_s
84
+ end
85
+
86
+ def update(val)
87
+ self.method(val[/^<\?dynarex/] ? :import : :update_section).call val
88
+ end
89
+
90
+ def update_section(*args)
91
+
92
+ val, raw_q = args.reverse
93
+
94
+ q = raw_q ? raw_q : val.lines.first
95
+
96
+ r = find(q)
97
+ r.x = val =~ /# / ? val : r.x.lines.first + "\n" + val
98
+ end
99
+
100
+ end
metadata ADDED
@@ -0,0 +1,92 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: wiki_md
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - James Robertson
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain:
11
+ - |
12
+ -----BEGIN CERTIFICATE-----
13
+ MIIEXjCCAsagAwIBAgIBATANBgkqhkiG9w0BAQsFADAsMSowKAYDVQQDDCFnZW1t
14
+ YXN0ZXIvREM9amFtZXNyb2JlcnRzb24vREM9ZXUwHhcNMTgwOTE1MTg0NDMwWhcN
15
+ MTkwOTE1MTg0NDMwWjAsMSowKAYDVQQDDCFnZW1tYXN0ZXIvREM9amFtZXNyb2Jl
16
+ cnRzb24vREM9ZXUwggGiMA0GCSqGSIb3DQEBAQUAA4IBjwAwggGKAoIBgQDPXxC/
17
+ rMAwO24yY94T4JLT3R+znJABZWAW1RiOi3YmNzRvm6G1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mQZkCvwUb4emxNDvuaaPomy+C1cu3rgVUdQNPd/WyWHIuf1maZhIDWTJalY
34
+ tjb0N9prw0HZTv/h2eextC0wHlmDwcyYdPhuFzeeunAI/e+F4FtDFJhgd8vrp5fJ
35
+ nEQURKgvgTAqVg9tuqcjEE861mSCPc+12rmUHVBZDxMDQF6CQbnOxrYRIS+7fnia
36
+ kikBQtN17cUMyGOrZTVRhVGR
37
+ -----END CERTIFICATE-----
38
+ date: 2018-09-15 00:00:00.000000000 Z
39
+ dependencies:
40
+ - !ruby/object:Gem::Dependency
41
+ name: dxsectionx
42
+ requirement: !ruby/object:Gem::Requirement
43
+ requirements:
44
+ - - "~>"
45
+ - !ruby/object:Gem::Version
46
+ version: '0.2'
47
+ - - ">="
48
+ - !ruby/object:Gem::Version
49
+ version: 0.2.2
50
+ type: :runtime
51
+ prerelease: false
52
+ version_requirements: !ruby/object:Gem::Requirement
53
+ requirements:
54
+ - - "~>"
55
+ - !ruby/object:Gem::Version
56
+ version: '0.2'
57
+ - - ">="
58
+ - !ruby/object:Gem::Version
59
+ version: 0.2.2
60
+ description:
61
+ email: james@jamesrobertson.eu
62
+ executables: []
63
+ extensions: []
64
+ extra_rdoc_files: []
65
+ files:
66
+ - lib/wiki_md.rb
67
+ homepage: https://github.com/jrobertson/wiki_md
68
+ licenses:
69
+ - MIT
70
+ metadata: {}
71
+ post_install_message:
72
+ rdoc_options: []
73
+ require_paths:
74
+ - lib
75
+ required_ruby_version: !ruby/object:Gem::Requirement
76
+ requirements:
77
+ - - ">="
78
+ - !ruby/object:Gem::Version
79
+ version: '0'
80
+ required_rubygems_version: !ruby/object:Gem::Requirement
81
+ requirements:
82
+ - - ">="
83
+ - !ruby/object:Gem::Version
84
+ version: '0'
85
+ requirements: []
86
+ rubyforge_project:
87
+ rubygems_version: 2.7.6
88
+ signing_key:
89
+ specification_version: 4
90
+ summary: 'Designed for mainintaing many wiki entries within a single document in Markdown
91
+ format. #nothrills #personalwiki'
92
+ test_files: []
metadata.gz.sig ADDED
Binary file