canvas_statsd 1.0.4 → 1.0.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 7f93d09a249a24e64798dd4e4b1554b1132cf2e5
4
- data.tar.gz: c104aae22f8fe8bf5f86d2e92aa2cda2218f1fb0
3
+ metadata.gz: 59016469f4db4d82cf1461666d4d7454821dc900
4
+ data.tar.gz: e45d90741f862de134f4e687d029e24f05f17856
5
5
  SHA512:
6
- metadata.gz: dfe9e66cff26fe7687e592d6d668295609577228dfa46ae7c3f81cdd2295585cbe9ec571f1547554e0df429012d02d3d68111fb9167ae2ecb63dc70380d3ebc8
7
- data.tar.gz: ab4ffc4acf17efc36669900d9e26400a18fc59e547162e59974e15146599129edae89dd4ef190a5e46e62ce9dea43cfb0b1795e4e46fb6f6d774d2c67ca9c6aa
6
+ metadata.gz: e4604014954d5f4a9db66e4de69d6cc97d3fa740dc541558e8bf0f00e4e34a6f0200865ab4d1c3984e432b651932674560a798752aa6465fd2d2a923b46cc29a
7
+ data.tar.gz: 3d8c4895afaecc1cd100124e0d69aa87a7df6532fc12c67e95350eaca225bd71053730e4d2ea4f33137e0d23c11492d6e666659b937388a837f73359dcef66c9
@@ -39,7 +39,7 @@ module CanvasStatsd
39
39
  module Statsd
40
40
  # replace "." in key names with another character to avoid creating spurious sub-folders in graphite
41
41
  def self.escape(str, replacement = '_')
42
- str.gsub('.', replacement)
42
+ str.respond_to?(:gsub)? str.gsub('.', replacement) : str
43
43
  end
44
44
 
45
45
  def self.hostname
data/lib/canvas_statsd.rb CHANGED
@@ -36,11 +36,11 @@ module CanvasStatsd
36
36
  def self.convert_bool(hash, key)
37
37
  value = hash[key]
38
38
  return if value.nil?
39
- unless ['true', 'false', true, false].include?(value)
39
+ unless ['true', 'True', 'false', 'False', true, false].include?(value)
40
40
  message = "#{key} must be a boolean, or the string representation of a boolean, got: #{value}"
41
41
  raise CanvasStatsd::ConfigurationError, message
42
42
  end
43
- hash[key] = (value == 'true' || value == true) ? true : false
43
+ hash[key] = ['true', 'True', true].include?(value)
44
44
  end
45
45
 
46
46
  def self.track_default_metrics options={}
@@ -72,6 +72,11 @@ describe CanvasStatsd do
72
72
  CanvasStatsd.convert_bool(config, :potential_string_bool)
73
73
  expect(config[:potential_string_bool]).to be(true)
74
74
  end
75
+ it 'sets string True values to boolean true' do
76
+ config = {potential_string_bool: 'True'}
77
+ CanvasStatsd.convert_bool(config, :potential_string_bool)
78
+ expect(config[:potential_string_bool]).to be(true)
79
+ end
75
80
  it 'sets boolean true values to boolean true' do
76
81
  config = {potential_string_bool: true}
77
82
  CanvasStatsd.convert_bool(config, :potential_string_bool)
@@ -82,6 +87,11 @@ describe CanvasStatsd do
82
87
  CanvasStatsd.convert_bool(config, :potential_string_bool)
83
88
  expect(config[:potential_string_bool]).to be(false)
84
89
  end
90
+ it 'sets False strings to boolean false' do
91
+ config = {potential_string_bool: 'False'}
92
+ CanvasStatsd.convert_bool(config, :potential_string_bool)
93
+ expect(config[:potential_string_bool]).to be(false)
94
+ end
85
95
  it 'sets false booleans to boolean false' do
86
96
  config = {potential_string_bool: false}
87
97
  CanvasStatsd.convert_bool(config, :potential_string_bool)
@@ -68,6 +68,26 @@ describe CanvasStatsd::Statsd do
68
68
  expect(instance.namespace).to eq "test"
69
69
  end
70
70
 
71
+ describe ".escape" do
72
+ it "replaces any dots in str with a _ when no replacment given" do
73
+ result = CanvasStatsd::Statsd.escape("lots.of.dots")
74
+ expect(result).to eq "lots_of_dots"
75
+ end
76
+
77
+ it "replaces any dots in str with replacement arg" do
78
+ result = CanvasStatsd::Statsd.escape("lots.of.dots", "/")
79
+ expect(result).to eq "lots/of/dots"
80
+ end
81
+
82
+ it "returns str when given a str that doesnt respond to gsub" do
83
+ result = CanvasStatsd::Statsd.escape(nil)
84
+ expect(result).to eq nil
85
+ hash = {foo: 'bar'}
86
+ result = CanvasStatsd::Statsd.escape(hash)
87
+ expect(result).to eq hash
88
+ end
89
+ end
90
+
71
91
  after do
72
92
  CanvasStatsd::Statsd.reset_instance
73
93
  end
metadata CHANGED
@@ -1,14 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: canvas_statsd
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.4
4
+ version: 1.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nick Cloward
8
+ - Jason Madsen
8
9
  autorequire:
9
10
  bindir: bin
10
11
  cert_chain: []
11
- date: 2015-06-19 00:00:00.000000000 Z
12
+ date: 2015-07-02 00:00:00.000000000 Z
12
13
  dependencies:
13
14
  - !ruby/object:Gem::Dependency
14
15
  name: statsd-ruby
@@ -83,6 +84,7 @@ dependencies:
83
84
  description:
84
85
  email:
85
86
  - ncloward@instructure.com
87
+ - jmadsen@instructure.com
86
88
  executables: []
87
89
  extensions: []
88
90
  extra_rdoc_files: []