metrics_spy 0.0.2
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 +7 -0
- data/.gitignore +1 -0
- data/README.md +19 -0
- data/bin/metrics_spy_service +25 -0
- data/lib/metrics_spy/application/app.rb +80 -0
- data/lib/metrics_spy/application/images/spy.jpg +0 -0
- data/lib/metrics_spy/application/stylesheets/reset.css +102 -0
- data/lib/metrics_spy/application/stylesheets/style.css +122 -0
- data/lib/metrics_spy/application/views/home.erb +10 -0
- data/lib/metrics_spy/application/views/layout.erb +24 -0
- data/lib/metrics_spy/version.rb +3 -0
- data/metrics_spy.gemspec +27 -0
- metadata +114 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 4594998fe737059b47393b0cbd4b2965737d26b4
|
4
|
+
data.tar.gz: 3631968b538b7e36cc13e83cb2f1aee1f6db958b
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 03e0879f3a998678d6f2ee8c651be013e7e1eb0684e80062ad3b1e5d9eff0234c25c8eb5dea42bdf036499a80d513cd02ef33a132c7f96e1d9c2235203fcca41
|
7
|
+
data.tar.gz: cb2d24dcf1aa192729571cb85e0c986618a6f5d467ec35dc9c4f9d2f61562dc7376c6e383597d043e04989887ffdca86db6ed2d3079c89b4f70f07b659d90016
|
data/.gitignore
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
.idea
|
data/README.md
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
**Metrics Spy
|
2
|
+
**
|
3
|
+
|
4
|
+
Metrics spy is a simple sinatra server. On starting the server, it takes stage on http://localhost:9191 and tracks all the GET requests to the staged port.
|
5
|
+
|
6
|
+
On calling http://localhost:9191/getmetrics , it provides the captured requests with query strings as hash. After returning the stored metrics, it clears the store and starts listening fresh.
|
7
|
+
|
8
|
+
The server is under development and more features will be added soon!
|
9
|
+
|
10
|
+
**Installation**
|
11
|
+
|
12
|
+
gem install metrics_spy
|
13
|
+
|
14
|
+
**Usage**
|
15
|
+
|
16
|
+
The gem come with a binary metrics_spy_service. One can use this to start and stop the server.
|
17
|
+
|
18
|
+
|
19
|
+
|
@@ -0,0 +1,25 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
#
|
3
|
+
|
4
|
+
begin
|
5
|
+
|
6
|
+
require 'metrics_spy/application/app.rb'
|
7
|
+
require 'daemons'
|
8
|
+
rescue
|
9
|
+
|
10
|
+
require 'rubygems'
|
11
|
+
require 'daemons'
|
12
|
+
path = File.expand_path '../../lib',__FILE__
|
13
|
+
$:.unshift(path) if File.directory?(path) && !$:.include?(path)
|
14
|
+
require 'metrics_spy/application/app.rb'
|
15
|
+
|
16
|
+
end
|
17
|
+
|
18
|
+
|
19
|
+
Daemons.run_proc(
|
20
|
+
'metrics_spy_service', # name of daemon
|
21
|
+
:log_output => true
|
22
|
+
) do
|
23
|
+
|
24
|
+
MetricsSpy.run!
|
25
|
+
end
|
@@ -0,0 +1,80 @@
|
|
1
|
+
require 'sinatra'
|
2
|
+
require 'data_mapper'
|
3
|
+
require 'json'
|
4
|
+
require 'sinatra/config_file'
|
5
|
+
require 'sinatra/respond_with'
|
6
|
+
|
7
|
+
#DataMapper::setup(:default, "sqlite3://#{File.expand_path(__FILE__)}/lib/metrics_spy/application/database/metrics_spy.db")
|
8
|
+
|
9
|
+
DataMapper.setup(:default, "sqlite3::memory:")
|
10
|
+
|
11
|
+
|
12
|
+
class Metric
|
13
|
+
include DataMapper::Resource
|
14
|
+
property :id, Serial
|
15
|
+
property :data, Text, :required => true
|
16
|
+
property :created_at, DateTime
|
17
|
+
end
|
18
|
+
|
19
|
+
|
20
|
+
DataMapper.finalize.auto_upgrade!
|
21
|
+
|
22
|
+
|
23
|
+
class MetricsSpy < Sinatra::Base
|
24
|
+
|
25
|
+
use Rack::MethodOverride
|
26
|
+
set :static, true # set up static file routing
|
27
|
+
set :public_folder, File.expand_path('..', __FILE__) # set up the static dir (with images/js/css inside)
|
28
|
+
|
29
|
+
set :views, File.expand_path('../views', __FILE__) # set up the views dir
|
30
|
+
configure :development do
|
31
|
+
set :server, %w[thin mongrel webrick]
|
32
|
+
set :port, 9191
|
33
|
+
enable :logging
|
34
|
+
|
35
|
+
puts 'Metrics Spy :: Development Environment'
|
36
|
+
end
|
37
|
+
|
38
|
+
helpers do
|
39
|
+
include Rack::Utils
|
40
|
+
alias_method :make_valid_string, :escape_html
|
41
|
+
end
|
42
|
+
|
43
|
+
SITE_TITLE = "The Metrics Spy"
|
44
|
+
SITE_DESCRIPTION = "I’m not spying! I’m evaluating !"
|
45
|
+
|
46
|
+
get '/' do
|
47
|
+
@all_metrics = Metric.all
|
48
|
+
erb :'/home'
|
49
|
+
end
|
50
|
+
|
51
|
+
|
52
|
+
get '/eluminate' do
|
53
|
+
unless params.empty?
|
54
|
+
metric = Metric.new
|
55
|
+
metric.data = params.to_s
|
56
|
+
metric.created_at = Time.now
|
57
|
+
metric.save
|
58
|
+
end
|
59
|
+
redirect '/'
|
60
|
+
end
|
61
|
+
|
62
|
+
get '/getmetrics' do
|
63
|
+
@metrics = Metric.all
|
64
|
+
content_type :json
|
65
|
+
if @metrics.empty?
|
66
|
+
{ :content => 'No metrics recorded.' }.to_json
|
67
|
+
else
|
68
|
+
response = { :content => Array(@metrics)}.to_json
|
69
|
+
delete_all_metrics
|
70
|
+
response
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
def delete_all_metrics
|
75
|
+
Metric.destroy
|
76
|
+
end
|
77
|
+
|
78
|
+
end
|
79
|
+
|
80
|
+
#MetricsSpy.run!
|
Binary file
|
@@ -0,0 +1,102 @@
|
|
1
|
+
/*
|
2
|
+
html5doctor.com Reset Stylesheet
|
3
|
+
v1.6.1
|
4
|
+
Last Updated: 2010-09-17
|
5
|
+
Author: Richard Clark - http://richclarkdesign.com
|
6
|
+
Twitter: @rich_clark
|
7
|
+
*/
|
8
|
+
|
9
|
+
html, body, div, span, object, iframe,
|
10
|
+
h1, h2, h3, h4, h5, h6, p, blockquote, pre,
|
11
|
+
abbr, address, cite, code,
|
12
|
+
del, dfn, em, img, ins, kbd, q, samp,
|
13
|
+
small, strong, sub, sup, var,
|
14
|
+
b, i,
|
15
|
+
dl, dt, dd, ol, ul, li,
|
16
|
+
fieldset, form, label, legend,
|
17
|
+
table, caption, tbody, tfoot, thead, tr, th, td,
|
18
|
+
article, aside, canvas, details, figcaption, figure,
|
19
|
+
footer, header, hgroup, menu, nav, section, summary,
|
20
|
+
time, mark, audio, video {
|
21
|
+
margin:0;
|
22
|
+
padding:0;
|
23
|
+
border:0;
|
24
|
+
outline:0;
|
25
|
+
font-size:100%;
|
26
|
+
vertical-align:baseline;
|
27
|
+
background:transparent;
|
28
|
+
}
|
29
|
+
|
30
|
+
body {
|
31
|
+
line-height:1;
|
32
|
+
}
|
33
|
+
|
34
|
+
article,aside,details,figcaption,figure,
|
35
|
+
footer,header,hgroup,menu,nav,section {
|
36
|
+
display:block;
|
37
|
+
}
|
38
|
+
|
39
|
+
nav ul {
|
40
|
+
list-style:none;
|
41
|
+
}
|
42
|
+
|
43
|
+
blockquote, q {
|
44
|
+
quotes:none;
|
45
|
+
}
|
46
|
+
|
47
|
+
blockquote:before, blockquote:after,
|
48
|
+
q:before, q:after {
|
49
|
+
content:'';
|
50
|
+
content:none;
|
51
|
+
}
|
52
|
+
|
53
|
+
a {
|
54
|
+
margin:0;
|
55
|
+
padding:0;
|
56
|
+
font-size:100%;
|
57
|
+
vertical-align:baseline;
|
58
|
+
background:transparent;
|
59
|
+
}
|
60
|
+
|
61
|
+
/* change colours to suit your needs */
|
62
|
+
ins {
|
63
|
+
background-color:#ff9;
|
64
|
+
color:#000;
|
65
|
+
text-decoration:none;
|
66
|
+
}
|
67
|
+
|
68
|
+
/* change colours to suit your needs */
|
69
|
+
mark {
|
70
|
+
background-color:#ff9;
|
71
|
+
color:#000;
|
72
|
+
font-style:italic;
|
73
|
+
font-weight:bold;
|
74
|
+
}
|
75
|
+
|
76
|
+
del {
|
77
|
+
text-decoration: line-through;
|
78
|
+
}
|
79
|
+
|
80
|
+
abbr[title], dfn[title] {
|
81
|
+
border-bottom:1px dotted;
|
82
|
+
cursor:help;
|
83
|
+
}
|
84
|
+
|
85
|
+
table {
|
86
|
+
border-collapse:collapse;
|
87
|
+
border-spacing:0;
|
88
|
+
}
|
89
|
+
|
90
|
+
/* change border colour to suit your needs */
|
91
|
+
hr {
|
92
|
+
display:block;
|
93
|
+
height:1px;
|
94
|
+
border:0;
|
95
|
+
border-top:1px solid #cccccc;
|
96
|
+
margin:1em 0;
|
97
|
+
padding:0;
|
98
|
+
}
|
99
|
+
|
100
|
+
input, select {
|
101
|
+
vertical-align:middle;
|
102
|
+
}
|
@@ -0,0 +1,122 @@
|
|
1
|
+
body {
|
2
|
+
margin: 35px auto;
|
3
|
+
width: 640px;
|
4
|
+
color: #009933;
|
5
|
+
background-image: url("bg3.png");
|
6
|
+
}
|
7
|
+
|
8
|
+
header {
|
9
|
+
text-align: center;
|
10
|
+
margin: 0 0 20px;
|
11
|
+
}
|
12
|
+
|
13
|
+
header h1 {
|
14
|
+
text-shadow: 1px 0px #eee, 0px 0.5px #ccc,
|
15
|
+
2px 1px #eee, 1px 2px #ccc,
|
16
|
+
3px 2px #eee, 2px 3px #ccc,
|
17
|
+
4px 3px #eee, 3px 4px #ccc,
|
18
|
+
5px 4px #eee, 4px 5px #ccc,
|
19
|
+
6px 5px #eee, 5px 6px #ccc,
|
20
|
+
7px 6px #eee, 6px 7px #ccc,
|
21
|
+
8px 7px #eee, 7px 8px #ccc,
|
22
|
+
8px 8px #eee;
|
23
|
+
font-size:40px;
|
24
|
+
}
|
25
|
+
|
26
|
+
header h1 a:link, header h1 a:visited {
|
27
|
+
color: #33CC33;
|
28
|
+
text-decoration: none;
|
29
|
+
}
|
30
|
+
|
31
|
+
header h2 {
|
32
|
+
font-size: 16px;
|
33
|
+
font-style: italic;
|
34
|
+
color: #333300;
|
35
|
+
}
|
36
|
+
|
37
|
+
#main {
|
38
|
+
margin: 0 0 20px;
|
39
|
+
}
|
40
|
+
|
41
|
+
#add {
|
42
|
+
margin: 0 0 20px;
|
43
|
+
}
|
44
|
+
|
45
|
+
#add textarea {
|
46
|
+
height: 30px;
|
47
|
+
width: 510px;
|
48
|
+
padding: 10px;
|
49
|
+
border: 1px solid #ddd;
|
50
|
+
}
|
51
|
+
|
52
|
+
#add input {
|
53
|
+
height: 50px;
|
54
|
+
width: 100px;
|
55
|
+
margin: -50px 0 0;
|
56
|
+
border: 1px solid #ddd;
|
57
|
+
background: white;
|
58
|
+
}
|
59
|
+
|
60
|
+
#edit textarea {
|
61
|
+
height: 30px;
|
62
|
+
width: 480px;
|
63
|
+
padding: 10px;
|
64
|
+
border: 1px solid #ddd;
|
65
|
+
}
|
66
|
+
|
67
|
+
#edit input[type=submit] {
|
68
|
+
height: 50px;
|
69
|
+
width: 100px;
|
70
|
+
margin: -50px 0 0;
|
71
|
+
border: 1px solid #ddd;
|
72
|
+
background: white;
|
73
|
+
}
|
74
|
+
|
75
|
+
#edit input[type=checkbox] {
|
76
|
+
height: 50px;
|
77
|
+
width: 20px;
|
78
|
+
}
|
79
|
+
|
80
|
+
article {
|
81
|
+
border: 1px solid #eee;
|
82
|
+
border-top: none;
|
83
|
+
padding: 15px 10px;
|
84
|
+
}
|
85
|
+
|
86
|
+
article:first-of-type {
|
87
|
+
border: 1px solid #eee;
|
88
|
+
}
|
89
|
+
|
90
|
+
article:nth-child(even) {
|
91
|
+
background: #fafafa;
|
92
|
+
}
|
93
|
+
|
94
|
+
article.complete {
|
95
|
+
background: #fedae3;
|
96
|
+
}
|
97
|
+
|
98
|
+
article span {
|
99
|
+
font-size: 0.8em;
|
100
|
+
}
|
101
|
+
|
102
|
+
p {
|
103
|
+
margin: 0 0 5px;
|
104
|
+
}
|
105
|
+
|
106
|
+
.meta {
|
107
|
+
font-size: 0.8em;
|
108
|
+
font-style: italic;
|
109
|
+
color: #333300;
|
110
|
+
}
|
111
|
+
|
112
|
+
.links {
|
113
|
+
font-size: 1.8em;
|
114
|
+
line-height: 0.8em;
|
115
|
+
float: right;
|
116
|
+
margin: -10px 0 0;
|
117
|
+
}
|
118
|
+
|
119
|
+
.links a {
|
120
|
+
display: block;
|
121
|
+
text-decoration: none;
|
122
|
+
}
|
@@ -0,0 +1,24 @@
|
|
1
|
+
<!doctype html>
|
2
|
+
<html lang="en">
|
3
|
+
<head>
|
4
|
+
<meta charset="utf8">
|
5
|
+
<title><%= "#{SITE_TITLE}" %></title>
|
6
|
+
<link rel='shortcut icon' href='../images/spy.jpg'>
|
7
|
+
<link href="../stylesheets/reset.css" rel="stylesheet">
|
8
|
+
<link href="../stylesheets/style.css" rel="stylesheet">
|
9
|
+
</head>
|
10
|
+
<body>
|
11
|
+
<header>
|
12
|
+
<img border="0" src="../images/spy.jpg" alt="The Metrics Spy" width="100" height="100">
|
13
|
+
<hgroup>
|
14
|
+
<h1><a href="/"><%= SITE_TITLE %></a></h1>
|
15
|
+
<h2><%= SITE_DESCRIPTION %></h2>
|
16
|
+
</hgroup>
|
17
|
+
</header>
|
18
|
+
|
19
|
+
<div id="main">
|
20
|
+
<%= yield %>
|
21
|
+
</div>
|
22
|
+
|
23
|
+
</body>
|
24
|
+
</html>
|
data/metrics_spy.gemspec
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
|
3
|
+
lib = File.expand_path('../lib', __FILE__)
|
4
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
5
|
+
require 'metrics_spy/version'
|
6
|
+
|
7
|
+
Gem::Specification.new do |spec|
|
8
|
+
spec.name = 'metrics_spy'
|
9
|
+
spec.version = MetricsSpy::VERSION
|
10
|
+
spec.authors = ["Rakesh Panicker"]
|
11
|
+
spec.email = ["rakesh.chandran1@gmail.com"]
|
12
|
+
spec.summary = %q{ MetricsSpy is a simple sinatra server which captures and returns fixtures for a given route }
|
13
|
+
spec.description = %q{This gem is useful for development where we need to capture and validate the request parameters.}
|
14
|
+
spec.homepage = 'https://bitbucket.org/rakesh_panicker/metrics_spy'
|
15
|
+
spec.license = 'MIT'
|
16
|
+
|
17
|
+
spec.files = `git ls-files -z`.split("\x0")
|
18
|
+
spec.executables = ['metrics_spy_service']
|
19
|
+
spec.default_executable = 'metrics_spy_service'
|
20
|
+
|
21
|
+
spec.add_runtime_dependency "sinatra", "~> 1.4"
|
22
|
+
|
23
|
+
spec.add_development_dependency "json_spec", "~> 1.1"
|
24
|
+
spec.add_development_dependency "bundler", "~> 1.5"
|
25
|
+
spec.add_development_dependency "rake", "~> 10.1"
|
26
|
+
|
27
|
+
end
|
metadata
ADDED
@@ -0,0 +1,114 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: metrics_spy
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.2
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Rakesh Panicker
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-09-08 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: sinatra
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.4'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.4'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: json_spec
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1.1'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.1'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: bundler
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '1.5'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '1.5'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rake
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '10.1'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '10.1'
|
69
|
+
description: This gem is useful for development where we need to capture and validate
|
70
|
+
the request parameters.
|
71
|
+
email:
|
72
|
+
- rakesh.chandran1@gmail.com
|
73
|
+
executables:
|
74
|
+
- metrics_spy_service
|
75
|
+
extensions: []
|
76
|
+
extra_rdoc_files: []
|
77
|
+
files:
|
78
|
+
- ".gitignore"
|
79
|
+
- README.md
|
80
|
+
- bin/metrics_spy_service
|
81
|
+
- lib/metrics_spy/application/app.rb
|
82
|
+
- lib/metrics_spy/application/images/spy.jpg
|
83
|
+
- lib/metrics_spy/application/stylesheets/reset.css
|
84
|
+
- lib/metrics_spy/application/stylesheets/style.css
|
85
|
+
- lib/metrics_spy/application/views/home.erb
|
86
|
+
- lib/metrics_spy/application/views/layout.erb
|
87
|
+
- lib/metrics_spy/version.rb
|
88
|
+
- metrics_spy.gemspec
|
89
|
+
homepage: https://bitbucket.org/rakesh_panicker/metrics_spy
|
90
|
+
licenses:
|
91
|
+
- MIT
|
92
|
+
metadata: {}
|
93
|
+
post_install_message:
|
94
|
+
rdoc_options: []
|
95
|
+
require_paths:
|
96
|
+
- lib
|
97
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
98
|
+
requirements:
|
99
|
+
- - ">="
|
100
|
+
- !ruby/object:Gem::Version
|
101
|
+
version: '0'
|
102
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
103
|
+
requirements:
|
104
|
+
- - ">="
|
105
|
+
- !ruby/object:Gem::Version
|
106
|
+
version: '0'
|
107
|
+
requirements: []
|
108
|
+
rubyforge_project:
|
109
|
+
rubygems_version: 2.2.2
|
110
|
+
signing_key:
|
111
|
+
specification_version: 4
|
112
|
+
summary: MetricsSpy is a simple sinatra server which captures and returns fixtures
|
113
|
+
for a given route
|
114
|
+
test_files: []
|