rt-watchman 0.6.0 → 0.7.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 587c0ec89be179caee4a0e3ac13bb2ba38a4df2b
4
- data.tar.gz: ea5f5a91054141741c82331fbe0461504b4abe46
3
+ metadata.gz: 4357d1bedf41f88aaa7eb347953ca9dfbd4fd76d
4
+ data.tar.gz: c7fbe92bd341a5a2a5b001f32c28ecfeb2b2125e
5
5
  SHA512:
6
- metadata.gz: df12524ac71c3ce2d97eeabbc4822a1a68723ea71aa4ad30373f3e0727405f0f0d3f1aa7695cca0313eb7e5863619ba74c5f2a9631d9b89fa4c4211e5719e55b
7
- data.tar.gz: 4a4ee43021e4f32e617ec8af450390ee9141812d758c3145f2dc4e13efefe7bd4892983bab0a9f56aa992d3e19660ba3928c2c07054d981ba4d3b995bd5c68dc
6
+ metadata.gz: 8386887ab93b52f9ec3cfdbd14d6b5a4c207284cd39c7340aa4793ca7458d93b4bdb9c1e4fcbadf952607eac25bf40525d438fab0cf2609091ba7017899d9072
7
+ data.tar.gz: 210d9fb9a0a4396ab88ba366c3e9c2d4e80bc56320ee6f19377588441878f1da5c6c0d3c282be282b01fb06e2e1bca0eec3abcc50698973c8915bb6e697a983e
data/README.md CHANGED
@@ -52,3 +52,14 @@ Then, all your metrics will be saved with that prefix. For example:
52
52
  ``` ruby
53
53
  Watchman.submit("high.score", 100) # => production.server1.high.score = 100
54
54
  ```
55
+
56
+ ## Test mode for Watchman
57
+
58
+ In tests you can set the following:
59
+
60
+ ``` ruby
61
+ Watchman.test_mode = true
62
+ ```
63
+
64
+ That way watchman will use a stubbed client, and won't send any data to the
65
+ metric server.
@@ -0,0 +1,11 @@
1
+ class Watchman
2
+ class MockStatsd
3
+
4
+ # Used in test environments
5
+
6
+ def gauge(metric, value); end
7
+ def timing(metric, value); end
8
+ def count(metric, value); end
9
+
10
+ end
11
+ end
@@ -1,3 +1,3 @@
1
1
  class Watchman
2
- VERSION = "0.6.0"
2
+ VERSION = "0.7.0"
3
3
  end
data/lib/watchman.rb CHANGED
@@ -1,4 +1,5 @@
1
1
  require "watchman/version"
2
+ require "watchman/mock_statsd"
2
3
  require "benchmark"
3
4
  require "statsd"
4
5
 
@@ -9,6 +10,7 @@ class Watchman
9
10
  attr_accessor :prefix
10
11
  attr_accessor :host
11
12
  attr_accessor :port
13
+ attr_accessor :test_mode
12
14
 
13
15
  def submit(name, value, type = :gauge)
14
16
  metric = metric_name_with_prefix(name)
@@ -44,10 +46,14 @@ class Watchman
44
46
  private
45
47
 
46
48
  def statsd_client
47
- @client ||= Statsd.new(@host, @port)
49
+ if @test_mode == true
50
+ Watchman::MockStatsd.new
51
+ else
52
+ @client ||= Statsd.new(@host, @port)
53
+ end
48
54
  end
49
55
 
50
- def metric_name_with_prefix(name)
56
+ def metric_name_with_prefix(name)
51
57
  if @prefix
52
58
  "#{@prefix}.#{name}"
53
59
  else
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rt-watchman
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.0
4
+ version: 0.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rendered Text
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-09-07 00:00:00.000000000 Z
11
+ date: 2016-10-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: statsd-ruby
@@ -83,6 +83,7 @@ files:
83
83
  - bin/console
84
84
  - bin/setup
85
85
  - lib/watchman.rb
86
+ - lib/watchman/mock_statsd.rb
86
87
  - lib/watchman/version.rb
87
88
  - watchman.gemspec
88
89
  homepage: