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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2c9a02652ffdc0ecdfef3d1e2885570b8df50946
4
- data.tar.gz: 0500d4db38b820ecb5b9e30562b315d78a4e224a
3
+ metadata.gz: 4c0419f44178d4fbf8048806ca43effaa6ed29b9
4
+ data.tar.gz: 901f30272f59276470a16fa937d20d13ca9d8e34
5
5
  SHA512:
6
- metadata.gz: 8cbcd78581a5361b9a54265d307224e2500d4af3ee59ac2fb75876b04ffc1378d69cc92286d41ae49ef7d01b5695c878f1e8039d2f9cd565b7ec5297cba7c207
7
- data.tar.gz: 0e3570edcdf73fc8f7c24f5e3a9866029b37218779e0317986f9d3160b56b7d3f3dafb9450374251ffe01e094b713488e76e3251e547fefeca2fa84527cac941
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
- h = {}
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
- save_dynarex_index(h)
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
- : ['items/item(title,url)', '1']
56
- Dynarex.new(buffer).create(url: url, title: title)\
57
- .save File.join(@tags_path, tagfile)
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
@@ -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.2.2
4
+ version: 0.2.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - James Robertson
metadata.gz.sig CHANGED
Binary file