koa-utils 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: c29ecf358e66300ada06b41bec4024f76bf7f1ca
4
+ data.tar.gz: dda6d264286488e2eb65de411df781f7cdc3151a
5
+ SHA512:
6
+ metadata.gz: 22f8c1a33330559b2a6a03bb9b84a7eaaf4ac40bb9babf91230219622d3ad766d91b8f426b523eccc1b1ff4559ee3e39c88ce0540d3e82da54190605347b0af8
7
+ data.tar.gz: 5563c5411e9e84a0e4639f70aa4cc7d95b2dd1855fe9ff28499c1e2fdacf1918025220cdd8ad985fd3468ed0f57de20da4ee2e0fbd83731ef8bd116d20669ff9
@@ -0,0 +1,48 @@
1
+ $stdout.sync = true
2
+
3
+ module KOAUtils::Logger
4
+
5
+ def self.prefix(name)
6
+ if defined? ::Rails
7
+ Rails.application.class.parent_name.downcase+"."+name
8
+ else
9
+ name
10
+ end
11
+ end
12
+
13
+ def self.librato_log(type, name, val, data)
14
+ name = prefix(name)
15
+ data["#{type}##{name}"] = val
16
+ log(data)
17
+ end
18
+
19
+ def self.log(data)
20
+ $stdout.puts(stringify(data))
21
+ end
22
+
23
+ def self.measure_block(name, data = {})
24
+ start = Time.now
25
+ result = yield
26
+ elapsed = (Time.now.to_f - start.to_f) * 1000
27
+ measure(name, elapsed.round.to_s+"ms")
28
+ result
29
+ end
30
+
31
+ def self.count(name, val, data = {})
32
+ librato_log("count", name, val, data)
33
+ end
34
+
35
+ def self.measure(name, val, data = {})
36
+ librato_log("measure", name, val, data)
37
+ end
38
+
39
+ def self.sample(name, val, data = {})
40
+ librato_log("sample", name, val, data)
41
+ end
42
+
43
+ def self.stringify(data)
44
+ data.reduce(out=String.new) do |s, tup|
45
+ s << [tup.first, tup.last].join("=") << " "
46
+ end
47
+ end
48
+ end
data/lib/koa_utils.rb ADDED
@@ -0,0 +1,5 @@
1
+ module KOAUtils
2
+
3
+ end
4
+
5
+ require 'koa_utils/logger'
metadata ADDED
@@ -0,0 +1,45 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: koa-utils
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Eric Rykwalder
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2013-10-09 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: Gem of tools for KOA
14
+ email: eric@albumatic.com
15
+ executables: []
16
+ extensions: []
17
+ extra_rdoc_files: []
18
+ files:
19
+ - lib/koa_utils/logger.rb
20
+ - lib/koa_utils.rb
21
+ homepage: http://github.com/albumatic
22
+ licenses:
23
+ - MIT
24
+ metadata: {}
25
+ post_install_message:
26
+ rdoc_options: []
27
+ require_paths:
28
+ - lib
29
+ required_ruby_version: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - '>='
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ required_rubygems_version: !ruby/object:Gem::Requirement
35
+ requirements:
36
+ - - '>='
37
+ - !ruby/object:Gem::Version
38
+ version: '0'
39
+ requirements: []
40
+ rubyforge_project:
41
+ rubygems_version: 2.0.5
42
+ signing_key:
43
+ specification_version: 4
44
+ summary: KOA tools
45
+ test_files: []