footpad 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +7 -0
  2. data/lib/footpad.rb +75 -0
  3. metadata +59 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: b480247214ad47a118c2033abe623b8a4294a928
4
+ data.tar.gz: 056bdcffde6ee2668fe8974589ccbce78ad2d444
5
+ SHA512:
6
+ metadata.gz: 5eeb6f95db839cb5410ffbb4ba469fcff903f2dc74b68c1da231932e99d6562a4f1f568a9ed3bfa611ff84ab11fd76e39435d3aef2f976203b9625b8e8a56afd
7
+ data.tar.gz: a9bc2d281f76e852b543120fcac1d0495daa551380f536f92cfe6519eb70c43c9f3cc17349db60a4b0fb0b531cc48e7509202f9249b5d81abe25d4acc653b36b
data/lib/footpad.rb ADDED
@@ -0,0 +1,75 @@
1
+ require 'JSON'
2
+
3
+ module Footpad
4
+
5
+ def number_and_secondary_stat(primary_value, options = {})
6
+ all_types = [:reverse, :absolute, :time_duration, :item]
7
+ item = Hash.new
8
+ result = Hash.new
9
+
10
+ item[:value] = primary_value
11
+ options.each do |key, value|
12
+ item[key] = value unless all_types.include?(key) or key == :trendline
13
+ end
14
+
15
+ all_types.each do |type|
16
+ if type === :item
17
+ if options.has_key?(:trendline)
18
+ result[:item] = [item,options[:trendline]]
19
+ else
20
+ result[:item] = [item]
21
+ end
22
+ else
23
+ result[type] = options[type] unless options[type].nil?
24
+ end
25
+ end
26
+
27
+ result.to_json
28
+ end
29
+ alias_method :nss, :number_and_secondary_stat
30
+
31
+
32
+ def leaderboard(primary_value, options = {})
33
+ result = Hash.new
34
+ values = Array.new
35
+
36
+ primary_value.each do |t|
37
+ if t[2].nil?
38
+ values << {
39
+ label: t[0],
40
+ value: t[1]
41
+ }
42
+ else
43
+ values << {
44
+ label: t[0],
45
+ value: t[1],
46
+ previous_rank: t[2]
47
+ }
48
+ end
49
+ end
50
+
51
+ result[:format] = options[:format] if options.has_key?(:format)
52
+ result[:unit] = options[:unit] if options.has_key?(:unit)
53
+ result[:items] = values
54
+
55
+ result.to_json
56
+ end
57
+ alias_method :lb, :leaderboard
58
+
59
+
60
+ def linechart(primary_value, options = {})
61
+ result = Hash.new
62
+
63
+ result[:item] = primary_value
64
+ result[:settings] = Hash.new
65
+
66
+ options.each do |key, value|
67
+ result[:settings][key] = value
68
+ end
69
+
70
+ result.to_json
71
+ end
72
+
73
+
74
+
75
+ end
metadata ADDED
@@ -0,0 +1,59 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: footpad
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.5.0
5
+ platform: ruby
6
+ authors:
7
+ - Ken Stipek
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-11-24 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: json
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ description: A Gem to help create custom Geckoboard data.
28
+ email: ken@kenstipek.com
29
+ executables: []
30
+ extensions: []
31
+ extra_rdoc_files: []
32
+ files:
33
+ - lib/footpad.rb
34
+ homepage: http://rubygems.org/gems/footpad
35
+ licenses:
36
+ - MIT
37
+ metadata: {}
38
+ post_install_message:
39
+ rdoc_options: []
40
+ require_paths:
41
+ - lib
42
+ required_ruby_version: !ruby/object:Gem::Requirement
43
+ requirements:
44
+ - - ">="
45
+ - !ruby/object:Gem::Version
46
+ version: '0'
47
+ required_rubygems_version: !ruby/object:Gem::Requirement
48
+ requirements:
49
+ - - ">="
50
+ - !ruby/object:Gem::Version
51
+ version: '0'
52
+ requirements: []
53
+ rubyforge_project:
54
+ rubygems_version: 2.4.3
55
+ signing_key:
56
+ specification_version: 4
57
+ summary: Geckoboard.com Ready Data
58
+ test_files: []
59
+ has_rdoc: