tagcloudbase 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (2) hide show
  1. data/lib/tagcloudbase.rb +27 -0
  2. metadata +66 -0
@@ -0,0 +1,27 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ # file: tagcloudbase.rb
4
+
5
+ require 'dynarex'
6
+
7
+ class TagCloudBase
8
+
9
+ attr_reader :to_dynarex
10
+
11
+ def initialize(all_tags={})
12
+ tags = all_tags.sort_by {|name,count| -count.to_i}
13
+ biggest_tag = tags.first[1].to_i
14
+
15
+ # sort in alphabetical order
16
+ abc_tags = tags.sort_by &:first
17
+
18
+ @to_dynarex = Dynarex.new('tags/tag(name,gauge,count)')
19
+ abc_tags.each do |word, word_size|
20
+ weight = 100 / (biggest_tag / word_size.to_i)
21
+ gauge = (weight / 10).to_i
22
+ gauge = 8 if gauge > 8
23
+ @to_dynarex.create name: word, gauge: gauge.to_s, count: word_size
24
+ end
25
+ end
26
+
27
+ end
metadata ADDED
@@ -0,0 +1,66 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: tagcloudbase
3
+ version: !ruby/object:Gem::Version
4
+ prerelease:
5
+ version: 0.1.0
6
+ platform: ruby
7
+ authors:
8
+ - James Robertson
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+
13
+ date: 2012-04-05 00:00:00 +01:00
14
+ default_executable:
15
+ dependencies:
16
+ - !ruby/object:Gem::Dependency
17
+ name: dynarex
18
+ prerelease: false
19
+ requirement: &id001 !ruby/object:Gem::Requirement
20
+ none: false
21
+ requirements:
22
+ - - ">="
23
+ - !ruby/object:Gem::Version
24
+ version: "0"
25
+ type: :runtime
26
+ version_requirements: *id001
27
+ description:
28
+ email:
29
+ executables: []
30
+
31
+ extensions: []
32
+
33
+ extra_rdoc_files: []
34
+
35
+ files:
36
+ - lib/tagcloudbase.rb
37
+ has_rdoc: true
38
+ homepage:
39
+ licenses: []
40
+
41
+ post_install_message:
42
+ rdoc_options: []
43
+
44
+ require_paths:
45
+ - lib
46
+ required_ruby_version: !ruby/object:Gem::Requirement
47
+ none: false
48
+ requirements:
49
+ - - ">="
50
+ - !ruby/object:Gem::Version
51
+ version: "0"
52
+ required_rubygems_version: !ruby/object:Gem::Requirement
53
+ none: false
54
+ requirements:
55
+ - - ">="
56
+ - !ruby/object:Gem::Version
57
+ version: "0"
58
+ requirements: []
59
+
60
+ rubyforge_project:
61
+ rubygems_version: 1.5.2
62
+ signing_key:
63
+ specification_version: 3
64
+ summary: Build a tagcloud from a Dynarex document
65
+ test_files: []
66
+