drone_json 0.0.1 → 1.0.1

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.
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: drone_json
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.0.1
5
+ version: 1.0.1
6
6
  platform: ruby
7
7
  authors:
8
8
  - Julien Ammous
@@ -10,7 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2011-04-21 00:00:00 Z
13
+ date: 2011-05-09 00:00:00 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: drone
@@ -98,18 +98,8 @@ extensions: []
98
98
 
99
99
  extra_rdoc_files: []
100
100
 
101
- files:
102
- - .gitignore
103
- - Gemfile
104
- - LICENSE
105
- - README.md
106
- - Rakefile
107
- - drone_json.gemspec
108
- - examples/json.rb
109
- - lib/drone_json.rb
110
- - lib/drone_json/json.rb
111
- - lib/drone_json/version.rb
112
- - specs/common.rb
101
+ files: []
102
+
113
103
  homepage: ""
114
104
  licenses: []
115
105
 
data/.gitignore DELETED
@@ -1,4 +0,0 @@
1
- *.gem
2
- .bundle
3
- Gemfile.lock
4
- pkg/*
data/Gemfile DELETED
@@ -1,6 +0,0 @@
1
- source "http://rubygems.org"
2
-
3
- # Specify your gem's dependencies in drone_json.gemspec
4
- gemspec
5
-
6
- gem 'drone', :path => "/Users/schmurfy/Dev/personal/drone"
data/LICENSE DELETED
@@ -1,20 +0,0 @@
1
- Copyright (c) 2011-2011 Julien Ammous
2
-
3
- Permission is hereby granted, free of charge, to any person obtaining
4
- a copy of this software and associated documentation files (the
5
- "Software"), to deal in the Software without restriction, including
6
- without limitation the rights to use, copy, modify, merge, publish,
7
- distribute, sublicense, and/or sell copies of the Software, and to
8
- permit persons to whom the Software is furnished to do so, subject to
9
- the following conditions:
10
-
11
- The above copyright notice and this permission notice shall be
12
- included in all copies or substantial portions of the Software.
13
-
14
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
- NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
- LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
- OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
- WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md DELETED
@@ -1,9 +0,0 @@
1
- # What is this ?
2
-
3
- It's a module for Drone to serve the data via json with a Thin server.<br/>
4
- You can find more about Drone [here](https://github.com/schmurfy/drone)
5
-
6
- # Supported Runtimes
7
-
8
- - MRI 1.8.7+
9
- - Rubinius 1.2.2+
data/Rakefile DELETED
@@ -1,2 +0,0 @@
1
- require 'bundler'
2
- Bundler::GemHelper.install_tasks
data/drone_json.gemspec DELETED
@@ -1,34 +0,0 @@
1
- # -*- encoding: utf-8 -*-
2
- $:.push File.expand_path("../lib", __FILE__)
3
- require "drone_json/version"
4
-
5
- Gem::Specification.new do |s|
6
- s.name = "drone_json"
7
- s.version = DroneJson::VERSION
8
- s.platform = Gem::Platform::RUBY
9
- s.authors = ["Julien Ammous"]
10
- s.email = []
11
- s.homepage = ""
12
- s.summary = %q{Drone Interface}
13
- s.description = %q{JSON Interface for Drone}
14
-
15
- s.rubyforge_project = "drone_json"
16
-
17
- s.files = `git ls-files`.split("\n")
18
- s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
19
- s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
20
- s.require_paths = ["lib"]
21
-
22
- s.add_dependency('drone')
23
- s.add_dependency('thin')
24
-
25
- if RUBY_VERSION < "1.9.1"
26
- s.add_dependency('json')
27
- end
28
-
29
- s.add_development_dependency("mocha")
30
- s.add_development_dependency("bacon")
31
- s.add_development_dependency("schmurfy-em-spec")
32
- s.add_development_dependency("delorean")
33
- s.add_development_dependency("simplecov")
34
- end
data/examples/json.rb DELETED
@@ -1,51 +0,0 @@
1
- require 'rubygems'
2
- require 'bundler/setup'
3
- require 'drone'
4
-
5
- $LOAD_PATH.unshift(File.expand_path('../../lib', __FILE__))
6
- require 'drone_json'
7
-
8
-
9
- Drone::init_drone()
10
- Drone::register_gauge("cpu:0/user"){ rand(200) }
11
-
12
- class User
13
- include Drone::Monitoring
14
-
15
- def initialize(name)
16
- @name = name
17
- end
18
-
19
- monitor_rate("users:rename")
20
- def rename(new_name)
21
- @name = new_name
22
- end
23
-
24
- monitor_time("users:do_something")
25
- def do_something
26
- # just eat some cpu
27
- 0.upto(rand(2000)) do |n|
28
- str = "a"
29
- 200.times{ str << "b" }
30
- end
31
- end
32
- end
33
-
34
- EM::run do
35
- Drone::add_output(:json, '127.0.0.1', 3001)
36
- Drone::start_monitoring()
37
-
38
- counter1 = Drone::register_counter("something_counted")
39
- counter1.increment()
40
-
41
- a = User.new("bob")
42
-
43
- EM::add_periodic_timer(2) do
44
- rand(100).times{|n| a.rename("user#{n}") }
45
- counter1.increment()
46
- end
47
-
48
- EM::add_periodic_timer(1) do
49
- a.do_something()
50
- end
51
- end
@@ -1,98 +0,0 @@
1
- require 'thin'
2
- require 'json'
3
-
4
- module Drone
5
- module Interfaces
6
-
7
- class Json < Base
8
- def initialize(address = '0.0.0.0', port = 3001)
9
- me = self
10
- Thin::Server.start(address, port) do
11
- map('/'){ run(me) }
12
- end
13
- end
14
-
15
- def call(env)
16
- ret = {}
17
-
18
- Drone::each_metric do |m|
19
- case m
20
- when Metrics::Gauge
21
- ret[m.name] = gauge_hash(m)
22
-
23
- when Metrics::Counter
24
- ret[m.name] = counter_hash(m)
25
-
26
- when Metrics::Timer
27
- tmp = {
28
- 'type' => 'timer'
29
- }
30
-
31
- tmp = histogram_hash(m, tmp)
32
-
33
- ret[m.name] = tmp
34
-
35
- when Metrics::Meter
36
- ret[m.name] = meter_hash(m, { 'type' => 'meter' })
37
-
38
- when Metrics::Histogram
39
- ret[m.name] = histogram_hash(m, { 'type' => 'histogram' })
40
-
41
- else
42
- puts "Unknown metric: #{m}"
43
- end
44
- end
45
-
46
-
47
- [
48
- 200,
49
- {'Content-Type' => 'application/json'},
50
- ret.to_json
51
- ]
52
- end
53
-
54
- private
55
- def gauge_hash(m)
56
- {
57
- 'type' => 'gauge',
58
- 'value' => m.value
59
- }
60
- end
61
-
62
- def counter_hash(m)
63
- {
64
- 'type' => 'counter',
65
- 'value' => m.value
66
- }
67
- end
68
-
69
- def meter_hash(m, h = {})
70
- h.merge({
71
- 'count' => m.count,
72
- 'mean_rate' => m.mean_rate,
73
- 'rate_1' => m.one_minute_rate,
74
- 'rate_5' => m.five_minutes_rate,
75
- 'rate_15' => m.fifteen_minutes_rate
76
- })
77
- end
78
-
79
- def histogram_hash(m, h = {})
80
- percentiles = m.percentiles(0.5, 0.75, 0.95, 0.98, 0.99, 0.999)
81
-
82
- h.merge({
83
- 'min' => m.min,
84
- 'max' => m.max,
85
- 'mean' => m.mean,
86
- 'stddev' => m.stdDev,
87
- 'median' => percentiles[0],
88
- '75p' => percentiles[1],
89
- '95p' => percentiles[2],
90
- '98p' => percentiles[3],
91
- '99p' => percentiles[4],
92
- '999p' => percentiles[5]
93
- })
94
- end
95
- end
96
-
97
- end
98
- end
@@ -1,3 +0,0 @@
1
- module DroneJson
2
- VERSION = "0.0.1"
3
- end
data/lib/drone_json.rb DELETED
@@ -1,8 +0,0 @@
1
- module DroneJson
2
- def self.require_lib(path)
3
- require File.expand_path("../#{path}", __FILE__)
4
- end
5
-
6
- require_lib('drone_json/version')
7
- require_lib('drone_json/json')
8
- end
data/specs/common.rb DELETED
@@ -1,63 +0,0 @@
1
- $:.reject! { |e| e.include? 'TextMate' }
2
-
3
- require 'rubygems'
4
-
5
- puts "Testing with ruby #{RUBY_VERSION} and rubygems #{Gem::VERSION}"
6
-
7
- require 'bundler/setup'
8
-
9
- if (RUBY_VERSION >= "1.9") && ENV['COVERAGE']
10
- require 'simplecov'
11
- ROOT = File.expand_path('../../', __FILE__)
12
-
13
- puts "[[ SimpleCov enabled ]]"
14
-
15
- SimpleCov.start do
16
- add_filter '/gems/'
17
- add_filter '/specs/'
18
-
19
- root(ROOT)
20
- end
21
- end
22
-
23
- require 'bacon'
24
- require 'mocha'
25
- require 'delorean'
26
- require 'em-spec/bacon'
27
- EM.spec_backend = EventMachine::Spec::Bacon
28
-
29
- $LOAD_PATH << File.expand_path('../../lib', __FILE__)
30
-
31
- module Bacon
32
- module MochaRequirementsCounter
33
- def self.increment
34
- Counter[:requirements] += 1
35
- end
36
- end
37
-
38
- class Context
39
- include Mocha::API
40
-
41
- alias_method :it_before_mocha, :it
42
-
43
- def it(description)
44
- it_before_mocha(description) do
45
- begin
46
- mocha_setup
47
- yield
48
- mocha_verify(MochaRequirementsCounter)
49
- rescue Mocha::ExpectationError => e
50
- raise Error.new(:failed, "#{e.message}\n#{e.backtrace[0...10].join("\n")}")
51
- ensure
52
- mocha_teardown
53
- end
54
- end
55
- end
56
- end
57
- end
58
-
59
- def focus(test_label)
60
- Bacon.const_set(:RestrictName, %r{#{test_label}})
61
- end
62
-
63
- Bacon.summary_on_exit()