burninator 0.5.3 → 0.6.0

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/README.md CHANGED
@@ -49,8 +49,8 @@ gem "burninator"
49
49
  #### Add `config/initializers/burninator.rb`
50
50
 
51
51
  ```ruby
52
- burninator = Burninator.new(redis: $redis, percentage: 25)
53
- burninator.broadcast
52
+ burninator = Burninator.new($redis)
53
+ burninator.broadcast(:percentage => 25)
54
54
  ```
55
55
 
56
56
  If you leave off the `redis` parameter, it will create a new connection
@@ -58,6 +58,9 @@ using what's configured in the environment as `REDIS_URL`.
58
58
 
59
59
  `percentage` will default to 5%.
60
60
 
61
+ If either WARM_TARGET_URL is missing or REDIS_URL is missing and a `redis`
62
+ parameter is not provided, a `Burninator::EnvironmentError` will be raised.
63
+
61
64
  #### Add the process in your Procfile:
62
65
 
63
66
  ```ruby
data/lib/burninator.rb CHANGED
@@ -8,9 +8,8 @@ class Burninator
8
8
 
9
9
  EnvironmentError = Class.new(ArgumentError)
10
10
 
11
- def initialize(options = {})
12
- @redis = options[:redis]
13
- @percentage = options.fetch(:percentage, DEFAULT_PERCENTAGE)
11
+ def initialize(redis = nil)
12
+ @redis = redis
14
13
  end
15
14
 
16
15
  def warm
@@ -19,8 +18,16 @@ class Burninator
19
18
  Burninator::Warmer.new(redis, channel, database).run
20
19
  end
21
20
 
22
- def broadcast
23
- Burninator::Broadcaster.new(redis, channel, @percentage).run
21
+ def broadcast(options = {})
22
+ percentage = options.fetch(:percentage, DEFAULT_PERCENTAGE)
23
+ ignore = options[:ignore]
24
+
25
+ broadcaster = Burninator::Broadcaster.new(redis, channel,
26
+ :ignore => ignore,
27
+ :percentage => percentage
28
+ )
29
+
30
+ broadcaster.run
24
31
  end
25
32
 
26
33
  def channel
@@ -7,10 +7,11 @@ class Burninator
7
7
  class Broadcaster
8
8
  KEY = "sql.active_record"
9
9
 
10
- def initialize(redis, channel, percentage)
10
+ def initialize(redis, channel, options = {})
11
11
  @redis = redis
12
12
  @channel = channel
13
- @percentage = percentage
13
+ @percentage = options.fetch(:percentage)
14
+ @ignore = options.fetch(:ignore)
14
15
  end
15
16
 
16
17
  def run
@@ -32,7 +33,8 @@ class Burninator
32
33
 
33
34
  def publish?(sql)
34
35
  return false unless sql =~ /\Aselect /i
35
- return false if sql =~ /for update\z/i
36
+ return false if sql =~ / for (update|share)\z/i
37
+ return false if sql =~ @ignore if @ignore
36
38
 
37
39
  SecureRandom.random_number(100 / @percentage) == 0
38
40
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: burninator
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.3
4
+ version: 0.6.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,14 +9,14 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-04-15 00:00:00.000000000 Z
12
+ date: 2013-04-16 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails
16
16
  requirement: !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
- - - '>='
19
+ - - ! '>='
20
20
  - !ruby/object:Gem::Version
21
21
  version: 3.2.0
22
22
  type: :runtime
@@ -24,7 +24,7 @@ dependencies:
24
24
  version_requirements: !ruby/object:Gem::Requirement
25
25
  none: false
26
26
  requirements:
27
- - - '>='
27
+ - - ! '>='
28
28
  - !ruby/object:Gem::Version
29
29
  version: 3.2.0
30
30
  - !ruby/object:Gem::Dependency
@@ -85,19 +85,20 @@ require_paths:
85
85
  required_ruby_version: !ruby/object:Gem::Requirement
86
86
  none: false
87
87
  requirements:
88
- - - '>='
88
+ - - ! '>='
89
89
  - !ruby/object:Gem::Version
90
90
  version: '0'
91
91
  required_rubygems_version: !ruby/object:Gem::Requirement
92
92
  none: false
93
93
  requirements:
94
- - - '>='
94
+ - - ! '>='
95
95
  - !ruby/object:Gem::Version
96
96
  version: '0'
97
97
  requirements: []
98
98
  rubyforge_project:
99
- rubygems_version: 1.8.25
99
+ rubygems_version: 1.8.24
100
100
  signing_key:
101
101
  specification_version: 3
102
102
  summary: Keep your follower database warm
103
103
  test_files: []
104
+ has_rdoc: