vanity-source 0.3 → 0.4

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.
data/CHANGELOG CHANGED
@@ -1,3 +1,15 @@
1
+ 2010-08-19 v0.4 Metrics that set and increment
2
+
3
+ Revised setup method to change special values metric.name and metric.columns
4
+ (was name and column).
5
+
6
+ There are two types of metrics, those that collect totals and those that
7
+ collect daily/hourly values. The setup method indicates that by setting the
8
+ value metric.total (defaults to false).
9
+
10
+ Revised update method to allow either setting current value (:set) or
11
+ incrementing current value (:inc).
12
+
1
13
  2010-08-11 v0.3 Always be sending changes
2
14
 
3
15
  Changed: Collector update methods accepts inc and timestamp arguments (but set
data/Gemfile CHANGED
@@ -1,4 +1,5 @@
1
1
  source "http://rubygems.org/"
2
+ gemspec
2
3
 
3
4
  group :development do
4
5
  gem "rake"
data/lib/vanity/source.rb CHANGED
@@ -27,11 +27,17 @@ module Vanity
27
27
  # is a Hash that can store basic Ruby values (nil, String, boolean, Numeric,
28
28
  # Array and Hash).
29
29
  #
30
- # In particular, #setup must set two special values: name and columns. The
31
- # first is the name for the collector, e.g. our Twitter source might produce
32
- # the name "Twitter Mentions of @vanitydash". The second denotes all the
33
- # columns that could be used in a metric. This value is an array, where each
34
- # item describes a single column with a hash using the following keys:
30
+ # In particular, #setup must set specific values for each collector:
31
+ # * metric.name -- The name of the metric, e.g. Twitter source might pick the
32
+ # name "Twitter mentions of @vanitydash".
33
+ # * metric.columns -- Specifies the columns (at least one) that make up this
34
+ # metric. The value if an array where each item describes a single column,
35
+ # see below for more details.
36
+ # * metric.totals -- True if this metric collects totals (life-time values,
37
+ # e.g. downloads, user accounts), false if it only collects daily values
38
+ # (e.g. average response time, number of instances in cluster).
39
+ #
40
+ # For metric.columns, each item can use the following keys:
35
41
  # * id -- Column identifier (if missing, derived from column name)
36
42
  # * name -- Column name (required)
37
43
  #
@@ -53,6 +59,9 @@ module Vanity
53
59
  # of times with any combination of arguments.
54
60
  #
55
61
  # The named arguments are:
62
+ # * set -- Columns to set (metric). Records the most recent value for this
63
+ # metric. This is a hash where the keys are column ids (or indexes), the
64
+ # values are integers or floats.
56
65
  # * inc -- Columns to increment (metric). Records a change in value which may
57
66
  # be positive or negative. This is a hash where the keys are column ids (or
58
67
  # indexes), the values are integers or floats.
@@ -23,8 +23,9 @@ module Vanity
23
23
 
24
24
  def setup(context, params)
25
25
  gem_name = params["gem_name"].to_s.strip
26
- context["name"] = "RubyGems: #{gem_name}"
27
- context["columns"] = [{ id: "downloads", label: "Downloads" }]
26
+ context["metric.name"] = "RubyGems: #{gem_name}"
27
+ context["metric.columns"] = [{ id: "downloads", label: "Downloads" }]
28
+ context["metric.totals"] = true
28
29
  context["gem_name"] = gem_name
29
30
  end
30
31
 
@@ -40,9 +41,7 @@ module Vanity
40
41
  json = JSON.parse(response.body)
41
42
  context["version"] = json["version"]
42
43
  context.update json.slice(*%w{homepage_uri project_uri info authors info})
43
- current, previous = json["downloads"], context["downloads"]
44
- yield :inc=>{ :downloads=>(current - previous) } if previous && current > previous
45
- context["downloads"] = current
44
+ yield :set=>{ :downloads=>json["downloads"] }
46
45
  when Net::HTTPNotFound
47
46
  raise "Could not find the Gem \"#{context["gem_name"]}\""
48
47
  end
@@ -53,7 +52,6 @@ module Vanity
53
52
  { text: context["info"] },
54
53
  { title: "Version", text: context["version"] },
55
54
  { title: "Authors", text: context["authors"] },
56
- { title: "Downloads", text: context["downloads"] },
57
55
  { title: "Source", text: "RubyGems", url: context["project_uri"] } ]
58
56
  end
59
57
 
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |spec|
2
2
  spec.name = "vanity-source"
3
- spec.version = "0.3"
3
+ spec.version = "0.4"
4
4
  spec.author = "Assaf Arkin"
5
5
  spec.email = "assaf@labnotes.org"
6
6
  spec.homepage = "http://vanitydash.com"
metadata CHANGED
@@ -1,12 +1,12 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vanity-source
3
3
  version: !ruby/object:Gem::Version
4
- hash: 13
4
+ hash: 3
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
- - 3
9
- version: "0.3"
8
+ - 4
9
+ version: "0.4"
10
10
  platform: ruby
11
11
  authors:
12
12
  - Assaf Arkin
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2010-08-11 00:00:00 -07:00
17
+ date: 2010-08-18 00:00:00 -07:00
18
18
  default_executable:
19
19
  dependencies: []
20
20
 
@@ -43,7 +43,7 @@ licenses: []
43
43
  post_install_message:
44
44
  rdoc_options:
45
45
  - --title
46
- - Vanity::Source 0.3
46
+ - Vanity::Source 0.4
47
47
  - --main
48
48
  - README.rdoc
49
49
  - --webcvs