dynarex-tags 0.2.2 → 0.2.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +0 -0
- data/lib/dynarex-tags.rb +15 -18
- metadata +1 -1
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4c0419f44178d4fbf8048806ca43effaa6ed29b9
|
4
|
+
data.tar.gz: 901f30272f59276470a16fa937d20d13ca9d8e34
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d7e3d7d8266558b0087061f3d27b5b343198c3bd99e15f0efaa93630b9e712bb7a038b828ba138f72e73792995464dc99cd3fd65aa2a59b450cd664a7af1b501
|
7
|
+
data.tar.gz: e98ee49dd11a1445f74e82c6bab5c54fdeda769aeeeb3149574fe3e44fa77858203743ab37ba6cd5a92499d7cff1d1dee18a5125dc8df900ead492949fc96cfa
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data.tar.gz.sig
CHANGED
Binary file
|
data/lib/dynarex-tags.rb
CHANGED
@@ -11,13 +11,17 @@ class DynarexTags
|
|
11
11
|
|
12
12
|
@tags_path = File.join(tags_parent_path, 'tags')
|
13
13
|
FileUtils.mkdir_p @tags_path
|
14
|
-
@index_filename = File.join(tags_parent_path, 'dxtags.xml')
|
14
|
+
@index_filename = File.join(tags_parent_path, 'dxtags.xml')
|
15
15
|
|
16
16
|
end
|
17
17
|
|
18
18
|
def generate(category_url, &blk)
|
19
|
-
|
20
|
-
|
19
|
+
|
20
|
+
s = File.exists?(@index_filename) ? \
|
21
|
+
@index_filename : 'tags/tag(keyword,count)'
|
22
|
+
dxindex = Dynarex.new s
|
23
|
+
h = dxindex.all.inject({}) {|r,x| r.merge(x.keyword => x.count) }
|
24
|
+
|
21
25
|
dx = Dynarex.new category_url
|
22
26
|
|
23
27
|
dx.all.each do |x|
|
@@ -29,32 +33,25 @@ class DynarexTags
|
|
29
33
|
.map{|tag| [tag, x.title, x.url]}
|
30
34
|
end
|
31
35
|
|
32
|
-
a.each {|tag, title, url| save_tag(h, tag, title, url)}
|
36
|
+
a.each {|tag, title, url| save_tag(h, tag.downcase, title, url)}
|
33
37
|
end
|
38
|
+
|
39
|
+
h.each {|tag,count| dxindex.create keyword: tag, count: count.to_s}
|
34
40
|
|
35
|
-
|
41
|
+
dxindex.save @index_filename
|
36
42
|
end
|
37
43
|
|
38
44
|
|
39
45
|
private
|
40
46
|
|
41
|
-
def save_dynarex_index(h)
|
42
|
-
|
43
|
-
s = File.exists?(@index_filename) ? \
|
44
|
-
@index_filename : 'tags/tag(keyword,count)'
|
45
|
-
dx = Dynarex.new s
|
46
|
-
h.each {|tag,count| dx.create keyword: tag, count: count.to_s}
|
47
|
-
|
48
|
-
dx.save @index_filename
|
49
|
-
end
|
50
47
|
|
51
48
|
def save_tag(h, tag, title, url)
|
52
49
|
|
53
|
-
tagfile = tag + '.xml'
|
50
|
+
tagfile = File.join(@tags_path, tag + '.xml')
|
54
51
|
buffer, h[tag] = h[tag] ? [tagfile, h[tag].succ] \
|
55
|
-
|
56
|
-
|
57
|
-
|
52
|
+
: ['items/item(title,url)', '1']
|
53
|
+
|
54
|
+
Dynarex.new(buffer).create(url: url, title: title).save tagfile
|
58
55
|
end
|
59
56
|
|
60
57
|
end
|
metadata
CHANGED
metadata.gz.sig
CHANGED
Binary file
|