duly_noted 1.0.1 → 1.0.2

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -45,9 +45,26 @@ or add
45
45
 
46
46
  to your `gemfile` and run `bundle install`
47
47
 
48
+ ##Configuration
49
+ _New in 1.0.2_
50
+
51
+ You can now configure the \**ahem*\* setting with the `configure` method in an initializer, like so:
52
+
53
+ DulyNoted.configure do |config|
54
+ config.editable_for = 3600 # default is one hour
55
+ end
56
+
57
+ The `editable_for` configuration option will set the expiration on the id keys so your Redis database's key count and size doesn't shoot up crazy high. The default is for them to expire after one hour.
58
+
59
+
48
60
  ##What's New
49
61
 
62
+ ### 1.0.2
63
+ * The motivation behind this release was to restore precious precious redis space back to our user(s)
64
+ * This update adds a `#configure` method which takes a block with one variable and allows you to set configuration setting(s). Currently there's only one configuration option, and that's `editable_for`, which will let you set the expire time on the `id` keys. So if you're not going to edit the meta hashes after a day, you could set it to `1.day`. Alternatively, if you're never going to edit the meta hashes, you could set it to `0`, which will delete them immediately.
65
+
50
66
  ### 1.0.1
67
+ * The main motivation behind this release was to stop using the timestamp as the unique identifier for the tracked metrics. We can only capture the time so precicely with ruby, and redis can take in so many metrics a second, that it would be possible to get duplicate timestamps, even when we measure the time to the millisecond. Using unique ids will make sure that you are not limited by duly_noted, but by the much more capable Redis.
51
68
  * Obliterated `ref_id`s, and everything they stood for. Not really everything they stood for. Now each metric gets its own unique id.
52
69
  * `#track` now returns the id of the metric you just tracked
53
70
  * id's are unique across all of duly_noted, so when you update them with `#update` you don't need to specify which metric_name
data/lib/duly_noted.rb CHANGED
@@ -46,6 +46,7 @@ require "uri"
46
46
  require "duly_noted/helpers"
47
47
  require "duly_noted/version"
48
48
  require "duly_noted/updater"
49
+ require 'duly_noted/configuration'
49
50
 
50
51
  # The **DulyNoted** module contains five main methods:
51
52
 
@@ -58,6 +59,7 @@ require "duly_noted/updater"
58
59
  module DulyNoted
59
60
  include Helpers
60
61
  include Updater
62
+ include Configuration
61
63
  extend self # the following are class methods
62
64
 
63
65
  # ##Parameter Descriptions
@@ -113,6 +115,7 @@ module DulyNoted
113
115
  DulyNoted.redis.sadd build_key("metrics", false), key_without_for
114
116
  DulyNoted.redis.zadd key, options[:generated_at].to_f, "#{key}:#{id}:meta"
115
117
  DulyNoted.redis.set "dnid:#{id}", "#{key}:#{id}:meta" # set alias key
118
+ DulyNoted.redis.expire "dnid:#{id}", DulyNoted::Configuration.editable_for
116
119
  if options[:meta] # set meta data
117
120
  DulyNoted.redis.mapped_hmset "#{key}:#{id}:meta", options[:meta]
118
121
  options[:meta].keys.each do |field|
@@ -369,6 +372,11 @@ module DulyNoted
369
372
  }))
370
373
  )
371
374
  end
375
+
376
+ def configure
377
+ yield DulyNoted::Configuration
378
+ end
379
+
372
380
  class NotValidMetric < StandardError; end
373
381
  class InvalidOptions < StandardError; end
374
382
  class InvalidStep < StandardError; end
@@ -0,0 +1,33 @@
1
+ module DulyNoted
2
+ module Configuration
3
+ extend self
4
+
5
+ @data = {:editable_for => 3600}
6
+
7
+ def update!(data)
8
+ data.each do |key, value|
9
+ self[key] = value
10
+ end
11
+ end
12
+
13
+ def [](key)
14
+ @data[key.to_sym]
15
+ end
16
+
17
+ def []=(key, value)
18
+ if value.class == Hash
19
+ @data[key.to_sym] = Config.new(value)
20
+ else
21
+ @data[key.to_sym] = value
22
+ end
23
+ end
24
+
25
+ def method_missing(sym, *args)
26
+ if sym.to_s =~ /(.+)=$/
27
+ self[$1] = args.first
28
+ else
29
+ self[sym]
30
+ end
31
+ end
32
+ end
33
+ end
@@ -1,11 +1,12 @@
1
1
  require "duly_noted/version"
2
2
  require "duly_noted/helpers"
3
+ require "duly_noted/configuration"
3
4
 
4
5
  module DulyNoted
5
6
  module Updater
6
7
  def update_schema(schema_version, redis)
7
8
  time = Time.now
8
- if schema_version = [1,0,0]
9
+ if schema_version === ["1","0","0"]
9
10
  #update to 1.0.1
10
11
  puts "Updating schema to comply with duly_noted 1.0.1"
11
12
  metrics = redis.smembers "dn:metrics"
@@ -28,7 +29,15 @@ module DulyNoted
28
29
  redis.keys("*:ref:*").each do |ref_keys|
29
30
  redis.del(ref_keys)
30
31
  end
31
- schema_version = [1,0,1]
32
+ schema_version = ["1","0","1"]
33
+ end
34
+ if schema_version === ["1","0","1"]
35
+ #update to 1.0.2
36
+ puts "Updating schema to comply with duly_noted 1.0.2"
37
+ redis.keys("dnid:*").each do |id_key|
38
+ redis.expire id_key, Configuration.editable_for
39
+ end
40
+ schema_version = ["1","0","2"]
32
41
  end
33
42
  redis.set "dn:version", VERSION
34
43
  puts "All up to date. Completed updates in #{Time.now-time} seconds."
@@ -1,3 +1,3 @@
1
1
  module DulyNoted
2
- VERSION = "1.0.1"
2
+ VERSION = "1.0.2"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: duly_noted
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.0.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -13,7 +13,7 @@ date: 2012-03-13 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: redis
16
- requirement: &70148931411020 !ruby/object:Gem::Requirement
16
+ requirement: &70133075998940 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: '0'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *70148931411020
24
+ version_requirements: *70133075998940
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: rspec
27
- requirement: &70148931410600 !ruby/object:Gem::Requirement
27
+ requirement: &70133075998520 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: '0'
33
33
  type: :development
34
34
  prerelease: false
35
- version_requirements: *70148931410600
35
+ version_requirements: *70133075998520
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: rake
38
- requirement: &70148931410180 !ruby/object:Gem::Requirement
38
+ requirement: &70133075998100 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ! '>='
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: '0'
44
44
  type: :development
45
45
  prerelease: false
46
- version_requirements: *70148931410180
46
+ version_requirements: *70133075998100
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: rb-fsevent
49
- requirement: &70148931409760 !ruby/object:Gem::Requirement
49
+ requirement: &70133075997680 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ! '>='
@@ -54,10 +54,10 @@ dependencies:
54
54
  version: '0'
55
55
  type: :development
56
56
  prerelease: false
57
- version_requirements: *70148931409760
57
+ version_requirements: *70133075997680
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: guard-rspec
60
- requirement: &70148931409340 !ruby/object:Gem::Requirement
60
+ requirement: &70133075997260 !ruby/object:Gem::Requirement
61
61
  none: false
62
62
  requirements:
63
63
  - - ! '>='
@@ -65,10 +65,10 @@ dependencies:
65
65
  version: '0'
66
66
  type: :development
67
67
  prerelease: false
68
- version_requirements: *70148931409340
68
+ version_requirements: *70133075997260
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: guard-bundler
71
- requirement: &70148931408920 !ruby/object:Gem::Requirement
71
+ requirement: &70133075996840 !ruby/object:Gem::Requirement
72
72
  none: false
73
73
  requirements:
74
74
  - - ! '>='
@@ -76,10 +76,10 @@ dependencies:
76
76
  version: '0'
77
77
  type: :development
78
78
  prerelease: false
79
- version_requirements: *70148931408920
79
+ version_requirements: *70133075996840
80
80
  - !ruby/object:Gem::Dependency
81
81
  name: chronic
82
- requirement: &70148931408500 !ruby/object:Gem::Requirement
82
+ requirement: &70133075996420 !ruby/object:Gem::Requirement
83
83
  none: false
84
84
  requirements:
85
85
  - - ! '>='
@@ -87,10 +87,10 @@ dependencies:
87
87
  version: '0'
88
88
  type: :development
89
89
  prerelease: false
90
- version_requirements: *70148931408500
90
+ version_requirements: *70133075996420
91
91
  - !ruby/object:Gem::Dependency
92
92
  name: timecop
93
- requirement: &70148931424440 !ruby/object:Gem::Requirement
93
+ requirement: &70133075996000 !ruby/object:Gem::Requirement
94
94
  none: false
95
95
  requirements:
96
96
  - - ! '>='
@@ -98,10 +98,10 @@ dependencies:
98
98
  version: '0'
99
99
  type: :development
100
100
  prerelease: false
101
- version_requirements: *70148931424440
101
+ version_requirements: *70133075996000
102
102
  - !ruby/object:Gem::Dependency
103
103
  name: ruby_gntp
104
- requirement: &70148931424020 !ruby/object:Gem::Requirement
104
+ requirement: &70133075995580 !ruby/object:Gem::Requirement
105
105
  none: false
106
106
  requirements:
107
107
  - - ! '>='
@@ -109,7 +109,7 @@ dependencies:
109
109
  version: '0'
110
110
  type: :development
111
111
  prerelease: false
112
- version_requirements: *70148931424020
112
+ version_requirements: *70133075995580
113
113
  description: a simple redis based stat-tracker
114
114
  email:
115
115
  - will@willcosgrove.com
@@ -127,6 +127,7 @@ files:
127
127
  - Rakefile
128
128
  - duly_noted.gemspec
129
129
  - lib/duly_noted.rb
130
+ - lib/duly_noted/configuration.rb
130
131
  - lib/duly_noted/helpers.rb
131
132
  - lib/duly_noted/updater.rb
132
133
  - lib/duly_noted/version.rb
@@ -146,7 +147,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
146
147
  version: '0'
147
148
  segments:
148
149
  - 0
149
- hash: -502772928455294375
150
+ hash: -210504055019801151
150
151
  required_rubygems_version: !ruby/object:Gem::Requirement
151
152
  none: false
152
153
  requirements:
@@ -155,7 +156,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
155
156
  version: '0'
156
157
  segments:
157
158
  - 0
158
- hash: -502772928455294375
159
+ hash: -210504055019801151
159
160
  requirements: []
160
161
  rubyforge_project:
161
162
  rubygems_version: 1.8.16