recognizer 0.1.5 → 0.1.6

Sign up to get free protection for your applications and to get access to all the features.
@@ -2,6 +2,10 @@ require "rubygems"
2
2
  require "thread"
3
3
  require "bunny"
4
4
 
5
+ if RUBY_PLATFORM == "java"
6
+ require File.join(File.dirname(__FILE__), "patches", "openssl")
7
+ end
8
+
5
9
  module Recognizer
6
10
  class AMQP
7
11
  def initialize(carbon_queue, logger, options)
@@ -1,7 +1,7 @@
1
1
  require "rubygems"
2
2
  require "json"
3
3
 
4
- require File.join(File.dirname(__FILE__), 'patches', 'hash')
4
+ require File.join(File.dirname(__FILE__), "patches", "hash")
5
5
 
6
6
  module Recognizer
7
7
  class Config
@@ -10,7 +10,7 @@ module Recognizer
10
10
  raise "Missing config file path"
11
11
  end
12
12
  if File.readable?(options[:config_file])
13
- config_file_contents = File.open(options[:config_file], 'r').read
13
+ config_file_contents = File.open(options[:config_file], "r").read
14
14
  begin
15
15
  @config = JSON.parse(config_file_contents)
16
16
  rescue JSON::ParserError => error
@@ -3,7 +3,11 @@ require "recognizer/version"
3
3
  require "thread"
4
4
  require "librato/metrics"
5
5
 
6
- require File.join(File.dirname(__FILE__), 'patches', 'float')
6
+ require File.join(File.dirname(__FILE__), "patches", "float")
7
+
8
+ if RUBY_PLATFORM == "java"
9
+ require File.join(File.dirname(__FILE__), "patches", "openssl")
10
+ end
7
11
 
8
12
  module Recognizer
9
13
  class Librato
@@ -30,11 +34,11 @@ module Recognizer
30
34
  mutex.synchronize do
31
35
  begin
32
36
  librato.submit
37
+ logger.info("Successfully flushed metrics to Librato")
33
38
  rescue => error
34
39
  logger.error("Encountered an error when flushing metrics to Librato :: #{error}")
35
40
  end
36
41
  end
37
- logger.info("Successfully flushed metrics to Librato")
38
42
  end
39
43
  end
40
44
  end
@@ -62,6 +66,9 @@ module Recognizer
62
66
  unless parts.first =~ /^[A-Za-z0-9\._-]*$/
63
67
  raise "metric name must only consist of alpha-numeric characters, periods, underscores, and dashes"
64
68
  end
69
+ unless parts.last =~ /^[0-9]{10}$/
70
+ raise "metric timestamp must be epoch, 10 digits"
71
+ end
65
72
 
66
73
  path = parts.shift.split(".")
67
74
  value = Float(parts.shift).pretty
@@ -1,20 +1,10 @@
1
1
  class Hash
2
- def symbolize_keys(item=self)
3
- case item
4
- when Array
5
- item.map do |i|
6
- symbolize_keys(i)
7
- end
8
- when Hash
9
- Hash[
10
- item.map do |key, value|
11
- new_key = key.is_a?(String) ? key.to_sym : key
12
- new_value = symbolize_keys(value)
13
- [new_key, new_value]
14
- end
15
- ]
16
- else
17
- item
2
+ def symbolize_keys
3
+ inject(Hash.new) do |result, (key, value)|
4
+ new_key = key.is_a?(String) ? key.to_sym : key
5
+ new_value = value.is_a?(Hash) ? value.symbolize_keys : value
6
+ result[new_key] = new_value
7
+ result
18
8
  end
19
9
  end
20
10
  end
@@ -0,0 +1,8 @@
1
+ require "openssl"
2
+
3
+ module OpenSSL
4
+ module SSL
5
+ remove_const(:VERIFY_PEER)
6
+ const_set(:VERIFY_PEER, VERIFY_NONE)
7
+ end
8
+ end
@@ -1,3 +1,3 @@
1
1
  module Recognizer
2
- VERSION = "0.1.5"
2
+ VERSION = "0.1.6"
3
3
  end
data/recognizer.gemspec CHANGED
@@ -20,5 +20,5 @@ Gem::Specification.new do |s|
20
20
  s.add_dependency("json")
21
21
  s.add_dependency("mixlib-cli", ">= 1.1.0")
22
22
  s.add_dependency("bunny", "0.7.9")
23
- s.add_dependency("librato-metrics", "0.4.2")
23
+ s.add_dependency("librato-metrics", "0.6.0.pre3")
24
24
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: recognizer
3
3
  version: !ruby/object:Gem::Version
4
- hash: 17
4
+ hash: 23
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 1
9
- - 5
10
- version: 0.1.5
9
+ - 6
10
+ version: 0.1.6
11
11
  platform: ruby
12
12
  authors:
13
13
  - Sean Porter
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2012-04-12 00:00:00 -07:00
18
+ date: 2012-04-26 00:00:00 -07:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -72,12 +72,13 @@ dependencies:
72
72
  requirements:
73
73
  - - "="
74
74
  - !ruby/object:Gem::Version
75
- hash: 11
75
+ hash: -1876988210
76
76
  segments:
77
77
  - 0
78
- - 4
79
- - 2
80
- version: 0.4.2
78
+ - 6
79
+ - 0
80
+ - pre3
81
+ version: 0.6.0.pre3
81
82
  type: :runtime
82
83
  version_requirements: *id004
83
84
  description: A drop-in replacement for Graphite Carbon (TCP & AMQP), sending metrics to Librato Metrics.
@@ -97,6 +98,7 @@ files:
97
98
  - lib/recognizer/librato.rb
98
99
  - lib/recognizer/patches/float.rb
99
100
  - lib/recognizer/patches/hash.rb
101
+ - lib/recognizer/patches/openssl.rb
100
102
  - lib/recognizer/tcp.rb
101
103
  - lib/recognizer/version.rb
102
104
  - lib/recognizer.rb