ecin-rack-probe 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
data/README.markdown ADDED
@@ -0,0 +1,53 @@
1
+ Rack::Probe : dtrace probes for your webapp
2
+ ===========================================
3
+
4
+ status
5
+ ------
6
+
7
+ Rack::Probe (along with Dtracy) is part of the Ruby on Rail's Google Summer of Code '09 Quartet, with development updates and entertainment available at `http://ecin.tumblr.com` Welcome! Sit down, grab a sugary drink, and enjoy the smell of freshly baked code right out of the oven.
8
+
9
+ requirements
10
+ ------------
11
+
12
+ An operating system with support for Dtrace (http://www.sun.com/bigadmin/content/dtrace/) is a must. Mac OS X, Solaris/OpenSolaris and FreeBSD are all acceptable choices, though no testing has been done on FreeBSD.
13
+
14
+ gem dependencies
15
+ ------------
16
+
17
+ * rack
18
+ * ruby-dtrace
19
+
20
+ installing
21
+ ----------
22
+
23
+ `gem sources -a http://gems.github.com`
24
+
25
+ `gem install ecin-rack-probe`
26
+
27
+ setup
28
+ -----
29
+
30
+ Rails Middleware:
31
+
32
+ _Inside your config/environment.rb_
33
+
34
+ `config.gem "ecin-rack-probe", :lib => "rack/probe"`
35
+
36
+ `config.middleware.use "Rack::Probe"`
37
+
38
+ Rack Middleware:
39
+
40
+ _Inside your rackup file_
41
+
42
+ `require 'rack/probe'`
43
+ `use Rack::Probe`
44
+
45
+ use
46
+ ---
47
+
48
+ From a terminal, run `dtrace -n rack*::: -l` to get a list of all the available probes. The number you'll see after 'rack' in the provider field is the PID of the process that's making the probes available.
49
+
50
+ copyright
51
+ ---------
52
+
53
+ Copyright (c) 2009 ecin. See LICENSE for details.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.1
1
+ 0.0.2
data/lib/rack/probe.rb CHANGED
@@ -11,35 +11,37 @@ module Rack
11
11
 
12
12
  gem 'ruby-dtrace', '>= 0.2.7'
13
13
  require 'dtrace/provider'
14
-
15
- Dtrace::Provider.create :rack do |p|
16
- p.probe :get # GET request
17
- p.probe :post # POST request
18
- p.probe :put # PUT request
19
- p.probe :delete # DELETE request
20
- p.probe :ip, :string # IP of the requester
21
- p.probe :path, :string # Path visited
22
- p.probe :referer, :string # Referer
23
- p.probe :xhr # AJAX request
24
- end
25
-
26
- # Provider shortcut
27
- R = Dtrace::Probe::Rack
28
-
14
+
29
15
  def initialize( app, opts = {} )
16
+ # Unless our probes are already defined...
17
+ unless Dtrace::Probe::Rack.instance_of? Dtrace::Provider::Klass
18
+ Dtrace::Provider.create :rack do |p|
19
+ p.probe :get # GET request
20
+ p.probe :post # POST request
21
+ p.probe :put # PUT request
22
+ p.probe :delete # DELETE request
23
+ p.probe :ip, :string # IP of the requester
24
+ p.probe :path, :string # Path visited
25
+ p.probe :referer, :string # Referer
26
+ p.probe :xhr # AJAX request
27
+ end
28
+
29
+ # Provider shortcut
30
+ @R = Dtrace::Probe::Rack
31
+ end
30
32
  @app = app
31
33
  end
32
34
 
33
35
  def call( env )
34
36
  request = Rack::Request.new env
35
- R.get(&:fire) if request.get?
36
- R.post(&:fire) if request.post?
37
- R.put(&:fire) if request.put?
38
- R.delete(&:fire) if request.delete?
39
- R.xhr(&:fire) if request.xhr?
40
- R.path { |p| p.fire(request.path) }
41
- R.ip { |p| p.fire(request.ip) }
42
- R.referer { |p| p.fire(request.referer) }
37
+ @R.get(&:fire) if request.get?
38
+ @R.post(&:fire) if request.post?
39
+ @R.put(&:fire) if request.put?
40
+ @R.delete(&:fire) if request.delete?
41
+ @R.xhr(&:fire) if request.xhr?
42
+ @R.path { |p| p.fire(request.path) }
43
+ @R.ip { |p| p.fire(request.ip) }
44
+ @R.referer { |p| p.fire(request.referer) }
43
45
  @app.call env
44
46
  end
45
47
 
data/rack-probe.gemspec CHANGED
@@ -5,22 +5,22 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{rack-probe}
8
- s.version = "0.0.1"
8
+ s.version = "0.0.2"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["ecin"]
12
- s.date = %q{2009-08-15}
12
+ s.date = %q{2009-08-18}
13
13
  s.description = %q{Rack::Probe provides a set of probes for Rack that fire with each request.}
14
14
  s.email = %q{ecin@copypastel.com}
15
15
  s.extra_rdoc_files = [
16
16
  "LICENSE",
17
- "README.rdoc"
17
+ "README.markdown"
18
18
  ]
19
19
  s.files = [
20
20
  ".document",
21
21
  ".gitignore",
22
22
  "LICENSE",
23
- "README.rdoc",
23
+ "README.markdown",
24
24
  "Rakefile",
25
25
  "VERSION",
26
26
  "lib/rack-probe.rb",
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ecin-rack-probe
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - ecin
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-08-15 00:00:00 -07:00
12
+ date: 2009-08-18 00:00:00 -07:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -50,12 +50,12 @@ extensions: []
50
50
 
51
51
  extra_rdoc_files:
52
52
  - LICENSE
53
- - README.rdoc
53
+ - README.markdown
54
54
  files:
55
55
  - .document
56
56
  - .gitignore
57
57
  - LICENSE
58
- - README.rdoc
58
+ - README.markdown
59
59
  - Rakefile
60
60
  - VERSION
61
61
  - lib/rack-probe.rb
data/README.rdoc DELETED
@@ -1,18 +0,0 @@
1
- = rack-probe
2
-
3
- Description goes here.
4
-
5
- == Note on Patches/Pull Requests
6
-
7
- * Fork the project.
8
- * Make your feature addition or bug fix.
9
- * Add tests for it. This is important so I don't break it in a
10
- future version unintentionally.
11
- * Commit, do not mess with rakefile, version, or history.
12
- (if you want to have your own version, that is fine but
13
- bump version in a commit by itself I can ignore when I pull)
14
- * Send me a pull request. Bonus points for topic branches.
15
-
16
- == Copyright
17
-
18
- Copyright (c) 2009 ecin. See LICENSE for details.