dynarex-tags 0.5.0 → 0.6.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 +4 -4
- checksums.yaml.gz.sig +0 -0
- data/lib/dynarex-tags.rb +53 -53
- data.tar.gz.sig +0 -0
- metadata +30 -30
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1ed697129ddcfd3a2cbfc650bc7e4828f6df0ade942a39640fc55fb764daae4f
|
4
|
+
data.tar.gz: 8e0671fcdfcd675e60030133618b63d3ea289c0a154c03a57e2d99120c3e2a6c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 26d3a75760b83cf8dcc3758c6061b6b354e84c43ed94b3010d11b3c62898ecb43af42056c8b144fc109da175917c708a1ead7be521e0dff23bdc08a653fbed07
|
7
|
+
data.tar.gz: 698fba777462534e8caf14bdcd523816f75701ac0a028d29d04f49bd6cc860f76cc3540fc39e35751348cc41f0743afdbe9d8eab6f05915feea79a9b3318a8e2
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data/lib/dynarex-tags.rb
CHANGED
@@ -3,49 +3,49 @@
|
|
3
3
|
# file: dynarex-tags.rb
|
4
4
|
|
5
5
|
require 'dynarex'
|
6
|
-
require '
|
6
|
+
require 'rxfreadwrite'
|
7
7
|
|
8
8
|
|
9
9
|
class DynarexTags
|
10
|
-
include
|
10
|
+
include RXFReadWriteModule
|
11
11
|
using ColouredText
|
12
12
|
|
13
|
-
def initialize(tags_parent_path, tagfile_xslt: nil, indexfile_xslt: nil,
|
13
|
+
def initialize(tags_parent_path, tagfile_xslt: nil, indexfile_xslt: nil,
|
14
14
|
debug: false)
|
15
15
|
|
16
16
|
puts ('tags_parent_path: ' + tags_parent_path).debug if debug
|
17
17
|
@filepath = tags_parent_path
|
18
|
-
|
19
|
-
@tagfile_xslt, @indexfile_xslt, @debug = tagfile_xslt,
|
18
|
+
|
19
|
+
@tagfile_xslt, @indexfile_xslt, @debug = tagfile_xslt,
|
20
20
|
indexfile_xslt, debug
|
21
|
-
|
21
|
+
|
22
22
|
@tags_path = File.join(tags_parent_path, 'tags')
|
23
23
|
FileX.mkdir_p @tags_path
|
24
|
-
@index_filename = File.join(tags_parent_path, 'dxtags.xml')
|
24
|
+
@index_filename = File.join(tags_parent_path, 'dxtags.xml')
|
25
25
|
|
26
26
|
s = FileX.exists?(@index_filename) ? \
|
27
|
-
@index_filename : 'tags/tag(keyword,count)'
|
27
|
+
@index_filename : 'tags/tag(keyword,count)'
|
28
28
|
|
29
29
|
puts ('dxtags filepath: ' + s.inspect).debug if debug
|
30
30
|
@dxtags = Dynarex.new s, json_out: false
|
31
|
-
@dxtags.xslt = @indexfile_xslt if @indexfile_xslt
|
32
|
-
|
31
|
+
@dxtags.xslt = @indexfile_xslt if @indexfile_xslt
|
32
|
+
|
33
33
|
end
|
34
|
-
|
34
|
+
|
35
35
|
def add(title: nil, url: nil)
|
36
|
-
|
37
|
-
|
36
|
+
|
37
|
+
|
38
38
|
puts ('title: ' + title.inspect).debug if @debug
|
39
39
|
puts ('url: ' + url.inspect).debug if @debug
|
40
|
-
|
40
|
+
|
41
41
|
h = @dxtags.all.inject({}) {|r,x| r.merge(x.keyword.downcase => x.count) }
|
42
|
-
|
42
|
+
|
43
43
|
a = title.scan(/(?<=\B#)[\w_]+/).uniq
|
44
44
|
|
45
45
|
a.each do |tag|
|
46
|
-
|
46
|
+
|
47
47
|
t = tag.downcase
|
48
|
-
|
48
|
+
|
49
49
|
h[t] = save_tag(h[t], t, title, url)
|
50
50
|
|
51
51
|
if @dxtags.record_exists? tag then
|
@@ -54,40 +54,40 @@ class DynarexTags
|
|
54
54
|
@dxtags.create({keyword: tag, count: h[t]}, id: t)
|
55
55
|
end
|
56
56
|
|
57
|
-
end
|
58
|
-
|
59
|
-
@dxtags.save @index_filename
|
57
|
+
end
|
58
|
+
|
59
|
+
@dxtags.save @index_filename
|
60
60
|
|
61
61
|
end
|
62
|
-
|
62
|
+
|
63
63
|
def delete(title)
|
64
|
-
|
64
|
+
|
65
65
|
# find the title in each of the tags file directory
|
66
66
|
a = title.downcase.scan(/(?<=#)[\w_]+/)
|
67
|
-
|
67
|
+
|
68
68
|
a.each do |tag|
|
69
69
|
|
70
70
|
puts ("deleting tag: %s for title: %s" % [tag, title]).debug if @debug
|
71
71
|
tagfile = File.join(@tags_path, tag + '.xml')
|
72
|
-
dx = Dynarex.new(tagfile, json_out: false, autosave: true)
|
72
|
+
dx = Dynarex.new(tagfile, json_out: false, autosave: true)
|
73
73
|
rx = dx.find_by_title title
|
74
|
-
rx.delete
|
74
|
+
rx.delete
|
75
75
|
dx.rm if dx.all.empty?
|
76
76
|
|
77
|
-
# find the title in dxtags.xml and delete it
|
77
|
+
# find the title in dxtags.xml and delete it
|
78
78
|
entry = @dxtags.find tag
|
79
|
-
|
79
|
+
|
80
80
|
next unless entry
|
81
|
-
|
81
|
+
|
82
82
|
if entry.count == '1' then
|
83
83
|
entry.delete
|
84
84
|
else
|
85
85
|
entry.count = entry.count.to_i - 1
|
86
86
|
end
|
87
|
-
|
87
|
+
|
88
88
|
end
|
89
|
-
|
90
|
-
@dxtags.save @index_filename
|
89
|
+
|
90
|
+
@dxtags.save @index_filename
|
91
91
|
|
92
92
|
end
|
93
93
|
|
@@ -95,17 +95,17 @@ class DynarexTags
|
|
95
95
|
|
96
96
|
rx = @dxtags.find tag.downcase
|
97
97
|
puts ('rx: ' + rx.inspect).debug if @debug
|
98
|
-
|
98
|
+
|
99
99
|
if rx then
|
100
100
|
|
101
101
|
tagfile = File.join(@tags_path, tag.downcase + '.xml')
|
102
102
|
dx = Dynarex.new(tagfile, json_out: false)
|
103
103
|
r = dx.all
|
104
|
-
|
104
|
+
|
105
105
|
def r.to_md()
|
106
106
|
self.map {|x| "* [%s](%s)" % [x.title, x.url]}.join("\n")
|
107
107
|
end
|
108
|
-
|
108
|
+
|
109
109
|
return r
|
110
110
|
|
111
111
|
end
|
@@ -113,13 +113,13 @@ class DynarexTags
|
|
113
113
|
end
|
114
114
|
|
115
115
|
def generate(indexfilename=File.join(@filepath, 'index.xml'), &blk)
|
116
|
-
|
116
|
+
|
117
117
|
dx = Dynarex.new indexfilename
|
118
118
|
|
119
|
-
h = @dxtags.all.inject({}) {|r,x| r.merge(x.keyword.downcase => x.count) }
|
120
|
-
|
119
|
+
h = @dxtags.all.inject({}) {|r,x| r.merge(x.keyword.downcase => x.count) }
|
120
|
+
|
121
121
|
dx.all.each do |x|
|
122
|
-
|
122
|
+
|
123
123
|
a = if block_given? then
|
124
124
|
blk.call(x)
|
125
125
|
else
|
@@ -128,38 +128,38 @@ class DynarexTags
|
|
128
128
|
end
|
129
129
|
|
130
130
|
a.each do |tag, title, url|
|
131
|
-
|
131
|
+
|
132
132
|
t = tag.downcase
|
133
|
-
|
133
|
+
|
134
134
|
h[t] = save_tag(h[t], t, title, url)
|
135
|
-
|
135
|
+
|
136
136
|
end
|
137
137
|
end
|
138
138
|
|
139
|
-
|
140
|
-
h.each do |tag, count|
|
141
|
-
|
139
|
+
|
140
|
+
h.each do |tag, count|
|
141
|
+
|
142
142
|
if @dxtags.record_exists? tag then
|
143
143
|
@dxtags.update(tag, {count: count.to_s})
|
144
144
|
else
|
145
145
|
@dxtags.create({keyword: tag, count: count.to_s}, id: tag.downcase)
|
146
146
|
end
|
147
|
-
|
147
|
+
|
148
148
|
end
|
149
|
-
|
150
|
-
@dxtags.save @index_filename
|
149
|
+
|
150
|
+
@dxtags.save @index_filename
|
151
151
|
|
152
152
|
end
|
153
153
|
|
154
|
-
def tags()
|
155
|
-
|
154
|
+
def tags()
|
155
|
+
|
156
156
|
@dxtags.all.inject({}) do |r, x|
|
157
157
|
tagfile = File.join(@tags_path, x.keyword.downcase + '.xml')
|
158
158
|
dx = Dynarex.new(tagfile, json_out: false)
|
159
159
|
r.merge({x.keyword.downcase => dx.all.map(&:to_h)})
|
160
160
|
end
|
161
|
-
|
162
|
-
|
161
|
+
|
162
|
+
|
163
163
|
end
|
164
164
|
|
165
165
|
|
@@ -167,7 +167,7 @@ class DynarexTags
|
|
167
167
|
|
168
168
|
|
169
169
|
def save_tag(tag_count, tag, title, url)
|
170
|
-
|
170
|
+
|
171
171
|
puts ('tag_count: ' + tag_count.inspect).debug if @debug
|
172
172
|
tagfile = File.join(@tags_path, tag + '.xml')
|
173
173
|
buffer = tag_count ? tagfile : 'items/item(title,url)'
|
@@ -180,5 +180,5 @@ class DynarexTags
|
|
180
180
|
dx.save tagfile
|
181
181
|
dx.all.length
|
182
182
|
end
|
183
|
-
|
183
|
+
|
184
184
|
end
|
data.tar.gz.sig
CHANGED
Binary file
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dynarex-tags
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.6.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- James Robertson
|
@@ -11,31 +11,31 @@ cert_chain:
|
|
11
11
|
- |
|
12
12
|
-----BEGIN CERTIFICATE-----
|
13
13
|
MIIEXjCCAsagAwIBAgIBATANBgkqhkiG9w0BAQsFADAsMSowKAYDVQQDDCFnZW1t
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
14
|
+
YXN0ZXIvREM9amFtZXNyb2JlcnRzb24vREM9ZXUwHhcNMjIwMjIzMTk0MjA3WhcN
|
15
|
+
MjMwMjIzMTk0MjA3WjAsMSowKAYDVQQDDCFnZW1tYXN0ZXIvREM9amFtZXNyb2Jl
|
16
|
+
cnRzb24vREM9ZXUwggGiMA0GCSqGSIb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
30
|
+
JZkYT+ZK4m4UompdPSN5OTcOgr7gu4oF6kGgQAMLXF3lHiM25fJhVdwBwxnZjvAg
|
31
|
+
iGM2su3faAmg4477LueW05d6cbCJ+iDHROf/PYSe9QQ4hbPrju00S8KfIDg9zOOj
|
32
|
+
A64uzZRvsfKMs8Fx2vall7sDqHcU3FhMRDZuy1OuMfQC45s7OwEE6sCjPfqvF3j0
|
33
|
+
yhIEw9ItCiYHhE6DxO518tdr6x8HgvLAjNwE2/v73Mj0gHOeMGBD5CfymYltB15y
|
34
|
+
hkZHVlLGEUPCTPfxYmdrxudsEcvYjlv8eRqwIT34hb8q/SvZ4UQ5Ep3h66ny2fBt
|
35
|
+
Gn0CkDQj+j/nOYRHXZh5P4U5CbL9ZrhpNi02sMwBYOGAfy8xGTIaDErxymeFV95A
|
36
|
+
eWFHlR8BTtTjZAXezxMFrlqp
|
37
37
|
-----END CERTIFICATE-----
|
38
|
-
date:
|
38
|
+
date: 2022-02-23 00:00:00.000000000 Z
|
39
39
|
dependencies:
|
40
40
|
- !ruby/object:Gem::Dependency
|
41
41
|
name: dynarex
|
@@ -43,22 +43,22 @@ dependencies:
|
|
43
43
|
requirements:
|
44
44
|
- - "~>"
|
45
45
|
- !ruby/object:Gem::Version
|
46
|
-
version: '1.
|
46
|
+
version: '1.9'
|
47
47
|
- - ">="
|
48
48
|
- !ruby/object:Gem::Version
|
49
|
-
version: 1.
|
49
|
+
version: 1.9.6
|
50
50
|
type: :runtime
|
51
51
|
prerelease: false
|
52
52
|
version_requirements: !ruby/object:Gem::Requirement
|
53
53
|
requirements:
|
54
54
|
- - "~>"
|
55
55
|
- !ruby/object:Gem::Version
|
56
|
-
version: '1.
|
56
|
+
version: '1.9'
|
57
57
|
- - ">="
|
58
58
|
- !ruby/object:Gem::Version
|
59
|
-
version: 1.
|
59
|
+
version: 1.9.6
|
60
60
|
description:
|
61
|
-
email:
|
61
|
+
email: digital.robertson@gmail.com
|
62
62
|
executables: []
|
63
63
|
extensions: []
|
64
64
|
extra_rdoc_files: []
|
@@ -83,7 +83,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
83
83
|
- !ruby/object:Gem::Version
|
84
84
|
version: '0'
|
85
85
|
requirements: []
|
86
|
-
rubygems_version: 3.
|
86
|
+
rubygems_version: 3.2.22
|
87
87
|
signing_key:
|
88
88
|
specification_version: 4
|
89
89
|
summary: Uses hashtags to help reference 1 or more records from an index file.
|
metadata.gz.sig
CHANGED
Binary file
|