plaid-rails 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
data/.rvmrc ADDED
@@ -0,0 +1,2 @@
1
+ rvm use 1.9.2@plaid
2
+ PS1="\W(\$(~/.rvm/bin/rvm-prompt v g))> "
data/Gemfile ADDED
@@ -0,0 +1,14 @@
1
+ source :rubygems
2
+
3
+ gem 'plaid', :git => 'git@github.com:DirectionSky/plaid.git', :require => 'ruby_prof'
4
+ gem "rack"
5
+ gem "rest-client"
6
+
7
+ group :development do
8
+ gem "jeweler"
9
+ end
10
+
11
+ group :test do
12
+ gem "shoulda", ">= 0"
13
+ gem "rcov", ">= 0"
14
+ end
@@ -0,0 +1,32 @@
1
+ GIT
2
+ remote: git@github.com:DirectionSky/plaid.git
3
+ revision: b4199ab3f1b778be0f1306fcba6d24683b8639c9
4
+ specs:
5
+ plaid (0.11.0)
6
+
7
+ GEM
8
+ remote: http://rubygems.org/
9
+ specs:
10
+ git (1.2.5)
11
+ jeweler (1.6.4)
12
+ bundler (~> 1.0)
13
+ git (>= 1.2.5)
14
+ rake
15
+ mime-types (1.17.2)
16
+ rack (1.4.0)
17
+ rake (0.9.2.2)
18
+ rcov (0.9.11)
19
+ rest-client (1.6.7)
20
+ mime-types (>= 1.16)
21
+ shoulda (2.11.3)
22
+
23
+ PLATFORMS
24
+ ruby
25
+
26
+ DEPENDENCIES
27
+ jeweler
28
+ plaid!
29
+ rack
30
+ rcov
31
+ rest-client
32
+ shoulda
data/README ADDED
File without changes
@@ -0,0 +1,50 @@
1
+ # encoding: utf-8
2
+
3
+ require 'rubygems'
4
+ require 'bundler'
5
+ begin
6
+ Bundler.setup(:default, :development)
7
+ rescue Bundler::BundlerError => e
8
+ $stderr.puts e.message
9
+ $stderr.puts "Run `bundle install` to install missing gems"
10
+ exit e.status_code
11
+ end
12
+ require 'rake'
13
+
14
+ require 'jeweler'
15
+ Jeweler::Tasks.new do |gem|
16
+ gem.name = "plaid-rails"
17
+ gem.homepage = "http://github.com/DirectionSky/plaid-rails"
18
+ gem.summary = %Q{Rack-Plaid integration for Rails}
19
+ gem.description = %Q{A Rack module that intercepts HTTP calls and sends profiling data to the Plaid server. For Rails (and not just Rails?).}
20
+ gem.email = "paolo.nusco.perrotta@gmail.com"
21
+ gem.authors = ["Paolo \"Nusco\" Perrotta"]
22
+ end
23
+ Jeweler::RubygemsDotOrgTasks.new
24
+
25
+ require 'rake/testtask'
26
+ Rake::TestTask.new(:test) do |test|
27
+ test.libs << 'lib' << 'test'
28
+ test.pattern = 'test/**/test_*.rb'
29
+ test.verbose = true
30
+ end
31
+
32
+ require 'rcov/rcovtask'
33
+ Rcov::RcovTask.new do |test|
34
+ test.libs << 'test'
35
+ test.pattern = 'test/**/test_*.rb'
36
+ test.verbose = true
37
+ test.rcov_opts << '--exclude "gems/*"'
38
+ end
39
+
40
+ task :default => :test
41
+
42
+ require 'rake/rdoctask'
43
+ Rake::RDocTask.new do |rdoc|
44
+ version = File.exist?('VERSION') ? File.read('VERSION') : ""
45
+
46
+ rdoc.rdoc_dir = 'rdoc'
47
+ rdoc.title = "plaid-rails #{version}"
48
+ rdoc.rdoc_files.include('README*')
49
+ rdoc.rdoc_files.include('lib/**/*.rb')
50
+ end
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.0.2
@@ -0,0 +1,57 @@
1
+ require 'rack'
2
+ require 'ruby-prof'
3
+ require 'yaml'
4
+ require 'rest-client'
5
+
6
+ # TODO: maybe keep using local server for testing?
7
+ #PLAID_SERVER = 'http://localhost:9292'
8
+ PLAID_SERVER = 'http://plaid-server.heroku.com'
9
+
10
+ # Monkeypatch RubyProf::Result until we find a better way to serialize it
11
+ module RubyProf
12
+ class Result
13
+ def to_h
14
+ result = {}
15
+ threads.each do |thread_id, methods|
16
+ result[thread_id] = methods.map do |method_info|
17
+ { :full_name => method_info.full_name,
18
+ :total_time => method_info.total_time,
19
+ :source_file => method_info.source_file }
20
+ end
21
+ end
22
+ result
23
+ end
24
+ end
25
+ end
26
+
27
+ module Rack
28
+ class Plaid
29
+ def initialize(app)
30
+ @app = app
31
+ @queue = Queue.new
32
+ if ENV['PLAID_MESSENGER'] == 'off'
33
+ puts 'Plaid thread disabled. ' \
34
+ 'No information will be sent to the Plaid server.'
35
+ else
36
+ Thread.new do
37
+ loop do
38
+ RestClient.put PLAID_SERVER,
39
+ @queue.pop.to_h.to_yaml,
40
+ :content_type => 'text/plain'
41
+ end
42
+ end
43
+ end
44
+ ::RubyProf.measure_mode = ::RubyProf::WALL_TIME
45
+ end
46
+
47
+ def call(env)
48
+ return @app.call(env) if env["QUERY_STRING"] =~ /plaid=off/
49
+ ::RubyProf.start
50
+ begin
51
+ @app.call(env)
52
+ ensure
53
+ @queue << ::RubyProf.stop
54
+ end
55
+ end
56
+ end
57
+ end
@@ -0,0 +1,56 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
+ # -*- encoding: utf-8 -*-
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = "plaid-rails"
8
+ s.version = "0.0.2"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["Paolo \"Nusco\" Perrotta"]
12
+ s.date = "2012-01-08"
13
+ s.description = "A Rack module that intercepts HTTP calls and sends profiling data to the Plaid server. For Rails (and not just Rails?)."
14
+ s.email = "paolo.nusco.perrotta@gmail.com"
15
+ s.extra_rdoc_files = [
16
+ "README"
17
+ ]
18
+ s.files = [
19
+ ".rvmrc",
20
+ "Gemfile",
21
+ "Gemfile.lock",
22
+ "README",
23
+ "Rakefile",
24
+ "VERSION",
25
+ "lib/plaid-rails.rb",
26
+ "plaid-rails.gemspec",
27
+ "test/helper.rb",
28
+ "test/test_plaid-rails.rb"
29
+ ]
30
+ s.homepage = "http://github.com/DirectionSky/plaid-rails"
31
+ s.require_paths = ["lib"]
32
+ s.rubygems_version = "1.8.10"
33
+ s.summary = "Rack-Plaid integration for Rails"
34
+
35
+ if s.respond_to? :specification_version then
36
+ s.specification_version = 3
37
+
38
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
39
+ s.add_runtime_dependency(%q<plaid>, [">= 0"])
40
+ s.add_runtime_dependency(%q<rack>, [">= 0"])
41
+ s.add_runtime_dependency(%q<rest-client>, [">= 0"])
42
+ s.add_development_dependency(%q<jeweler>, [">= 0"])
43
+ else
44
+ s.add_dependency(%q<plaid>, [">= 0"])
45
+ s.add_dependency(%q<rack>, [">= 0"])
46
+ s.add_dependency(%q<rest-client>, [">= 0"])
47
+ s.add_dependency(%q<jeweler>, [">= 0"])
48
+ end
49
+ else
50
+ s.add_dependency(%q<plaid>, [">= 0"])
51
+ s.add_dependency(%q<rack>, [">= 0"])
52
+ s.add_dependency(%q<rest-client>, [">= 0"])
53
+ s.add_dependency(%q<jeweler>, [">= 0"])
54
+ end
55
+ end
56
+
@@ -0,0 +1,18 @@
1
+ require 'rubygems'
2
+ require 'bundler'
3
+ begin
4
+ Bundler.setup(:default, :development)
5
+ rescue Bundler::BundlerError => e
6
+ $stderr.puts e.message
7
+ $stderr.puts "Run `bundle install` to install missing gems"
8
+ exit e.status_code
9
+ end
10
+ require 'test/unit'
11
+ require 'shoulda'
12
+
13
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
14
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
15
+ require 'plaid-rails'
16
+
17
+ class Test::Unit::TestCase
18
+ end
@@ -0,0 +1,7 @@
1
+ require 'helper'
2
+
3
+ class TestPlaidRails < Test::Unit::TestCase
4
+ should "probably rename this file and start testing for real" do
5
+ flunk "hey buddy, you should probably rename this file and start testing for real"
6
+ end
7
+ end
metadata ADDED
@@ -0,0 +1,103 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: plaid-rails
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.2
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Paolo "Nusco" Perrotta
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-01-08 00:00:00.000000000Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: plaid
16
+ requirement: &70131120482160 !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: *70131120482160
25
+ - !ruby/object:Gem::Dependency
26
+ name: rack
27
+ requirement: &70131120480340 !ruby/object:Gem::Requirement
28
+ none: false
29
+ requirements:
30
+ - - ! '>='
31
+ - !ruby/object:Gem::Version
32
+ version: '0'
33
+ type: :runtime
34
+ prerelease: false
35
+ version_requirements: *70131120480340
36
+ - !ruby/object:Gem::Dependency
37
+ name: rest-client
38
+ requirement: &70131120459380 !ruby/object:Gem::Requirement
39
+ none: false
40
+ requirements:
41
+ - - ! '>='
42
+ - !ruby/object:Gem::Version
43
+ version: '0'
44
+ type: :runtime
45
+ prerelease: false
46
+ version_requirements: *70131120459380
47
+ - !ruby/object:Gem::Dependency
48
+ name: jeweler
49
+ requirement: &70131120455900 !ruby/object:Gem::Requirement
50
+ none: false
51
+ requirements:
52
+ - - ! '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ type: :development
56
+ prerelease: false
57
+ version_requirements: *70131120455900
58
+ description: A Rack module that intercepts HTTP calls and sends profiling data to
59
+ the Plaid server. For Rails (and not just Rails?).
60
+ email: paolo.nusco.perrotta@gmail.com
61
+ executables: []
62
+ extensions: []
63
+ extra_rdoc_files:
64
+ - README
65
+ files:
66
+ - .rvmrc
67
+ - Gemfile
68
+ - Gemfile.lock
69
+ - README
70
+ - Rakefile
71
+ - VERSION
72
+ - lib/plaid-rails.rb
73
+ - plaid-rails.gemspec
74
+ - test/helper.rb
75
+ - test/test_plaid-rails.rb
76
+ homepage: http://github.com/DirectionSky/plaid-rails
77
+ licenses: []
78
+ post_install_message:
79
+ rdoc_options: []
80
+ require_paths:
81
+ - lib
82
+ required_ruby_version: !ruby/object:Gem::Requirement
83
+ none: false
84
+ requirements:
85
+ - - ! '>='
86
+ - !ruby/object:Gem::Version
87
+ version: '0'
88
+ segments:
89
+ - 0
90
+ hash: -562509056668019227
91
+ required_rubygems_version: !ruby/object:Gem::Requirement
92
+ none: false
93
+ requirements:
94
+ - - ! '>='
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ requirements: []
98
+ rubyforge_project:
99
+ rubygems_version: 1.8.10
100
+ signing_key:
101
+ specification_version: 3
102
+ summary: Rack-Plaid integration for Rails
103
+ test_files: []