Permalink
Browse files

Remove Rails functionality.

  • Loading branch information...
1 parent 7310081 commit 4e8c315d0e356b2b11462d6d8978f022920515c5 @marckysharky marckysharky committed Oct 7, 2012
View
@@ -2,4 +2,5 @@
.bundle
Gemfile.lock
pkg/*
-coverage/*
+coverage/*
+.DS_Store
View
@@ -1,7 +1,7 @@
# A sample Guardfile
# More info at https://github.com/guard/guard#readme
-guard 'rspec', :version => 2, :cli => "--color --order random" do
+guard 'rspec', :cli => "--color --order random" do
watch(%r{^spec/.+_spec\.rb$})
watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" }
watch('spec/spec_helper.rb') { "spec" }
View
@@ -16,7 +16,7 @@ Gem::Specification.new do |s|
s.rubyforge_project = "fozzie"
s.files = `git ls-files`.split("\n")
- s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
+ s.test_files = `git ls-files -- {spec,features}/*`.split("\n")
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
s.require_paths = ["lib"]
@@ -26,10 +26,8 @@ Gem::Specification.new do |s|
s.add_development_dependency 'rake'
s.add_development_dependency 'rspec'
s.add_development_dependency 'guard'
- s.add_development_dependency 'rb-inotify'
s.add_development_dependency 'guard-rspec'
+ s.add_development_dependency 'rb-inotify'
s.add_development_dependency 'sinatra'
s.add_development_dependency 'rack-test'
- s.add_development_dependency 'actionpack'
- s.add_development_dependency 'railties'
end
View
@@ -19,11 +19,6 @@ module Fozzie
require "fozzie/bulk_dsl"
require "fozzie/version"
- require "fozzie/rack/middleware"
- require "fozzie/rails/middleware"
-
- require 'fozzie/railtie' if defined?(::Rails)
-
class << self
# Shortcut for `Fozzie.config`
@@ -13,9 +13,9 @@ class Configuration
extend Forwardable
def_delegators :adapter, :delimeter, :safe_separator
-
+
attr_accessor :env, :config_path, :host, :port, :appname, :namespaces,
- :timeout, :monitor_classes, :sniff_envs, :ignore_prefix, :prefix, :enable_rails_middleware
+ :timeout, :monitor_classes, :sniff_envs, :ignore_prefix, :prefix
def initialize(args = {})
merge_and_assign_config(args)
@@ -89,8 +89,7 @@ def self.default_configuration
:monitor_classes => [],
:sniff_envs => [:development, :staging, :production],
:ignore_prefix => false,
- :adapter => :Statsd,
- :enable_rails_middleware => true
+ :adapter => :Statsd
}.dup
end
View
@@ -1,50 +0,0 @@
-require 'uri'
-
-module Fozzie
- class Mill
-
- DELIMETER = ';'
- METRICS = %w{ttfb load}
-
- attr_reader :str, :args
-
- def initialize(str = "")
- @str = str
- escaped_split = str.split(DELIMETER).map!{|x| URI.unescape(x) }
- @args = Hash[*escaped_split]
- end
-
- def self.register(str = "")
- new(str).register
- end
-
- def register
- return self unless self.has_href?
- METRICS.each do |k|
- next unless self.respond_to?(k.to_sym)
- S.timing((namespace << ['page', k]).flatten, self.send(k.to_sym))
- end
-
- self
- end
-
- def load
- @load ||= @args['domComplete'].to_i - @args['fetchStart'].to_i
- end
-
- def ttfb
- @ttfb ||= @args['responseStart'].to_i - @args['fetchStart'].to_i
- end
-
- def has_href?
- !@args['href'].nil?
- end
-
- def namespace
- @uri ||= URI(@args['href'])
- @path ||= @uri.path.strip.split('/').reject(&:empty?)
- @path.dup
- end
-
- end
-end
@@ -1,3 +1,5 @@
+require 'fozzie'
+
module Fozzie
module Rack
View
@@ -1,15 +0,0 @@
-require 'json'
-require 'fozzie/mill'
-
-module Fozzie
- module Rails
- class Engine < ::Rails::Engine
-
- endpoint Proc.new { |env|
- Fozzie::Mill.register(env['QUERY_STRING'].gsub('d=', ''))
- [201, {"Content-Type" => "text/html"}, [""]]
- }
-
- end
- end
-end
@@ -1,39 +0,0 @@
-require 'fozzie/rack/middleware'
-
-module Fozzie
- module Rails
-
- # Time and record each request through a given Rails app
- # This middlewware times server processing for a resource, not view render.
- class Middleware < Fozzie::Rack::Middleware
-
- # Generates the statistics key for the current path
- def generate_key(env)
- path_str = env['PATH_INFO']
- request_method = env['REQUEST_METHOD']
-
- return nil unless path_str
-
- begin
- routing = routing_lookup
- path = routing.recognize_path(path_str, :method => request_method)
- stat = [path[:controller], path[:action], "render"].join('.')
- stat
- rescue => exc
- S.increment "routing.error"
- nil
- end
- end
-
- def routing_lookup
- (rails_version == 3 ? ::Rails.application.routes : ::ActionController::Routing::Routes)
- end
-
- def rails_version
- ::Rails.version.to_i
- end
-
- end
-
- end
-end
View
@@ -1,22 +0,0 @@
-require 'fozzie/rails/engine'
-require 'fozzie/configuration'
-
-class FozzieRailtie < Rails::Railtie
- @fozzie_railtie_block = Proc.new do |app|
- if Fozzie::config.enable_rails_middleware
- # Load up the middleware
- app.middleware.use Fozzie::Rails::Middleware
-
- # Add the Mill route
- app.routes.prepend do
- mount Fozzie::Rails::Engine => '/mill'
- end
- end
- end
-
- class << self
- attr_reader :fozzie_railtie_block
- end
-
- initializer "fozzie_railtie.configure_rails_initialization", &@fozzie_railtie_block
-end
@@ -21,7 +21,6 @@
c.port.should eq 9876
c.appname.should eq 'fozzie'
c.data_prefix.should eq "fozzie#{c.safe_separator}test"
- c.enable_rails_middleware.should be_false
end
it "defaults env" do
@@ -38,17 +37,13 @@
end
end
- describe "#enable_rails_middleware" do
- it("should default to enabled") { subject.enable_rails_middleware.should be_true }
- end
-
describe "#disable_prefix" do
it "sets the data_prefix to nil" do
subject.disable_prefix
subject.data_prefix.should be_nil
end
end
-
+
describe "#prefix and #data_prefix" do
it "creates a #data_prefix" do
subject.stub(:origin_name => "")
@@ -1,43 +0,0 @@
-require 'spec_helper'
-require 'fozzie/mill'
-
-module Fozzie
- describe Mill do
- let(:str) { "userAgent;Mozilla/5.0%20%28Macintosh%3B%20Intel%20Mac%20OS%20X%2010_7_3%29%20AppleWebKit/535.19%20%28KHTML%2C%20like%20Gecko%29%20Chrome/18.0.1025.165%20Safari/535.19;vendorSub;;vendor;Google%20Inc.;onLine;true;appCodeName;Mozilla;cookieEnabled;true;product;Gecko;language;en-US;appVersion;5.0%20%28Macintosh%3B%20Intel%20Mac%20OS%20X%2010_7_3%29%20AppleWebKit/535.19%20%28KHTML%2C%20like%20Gecko%29%20Chrome/18.0.1025.165%20Safari/535.19;appName;Netscape;productSub;20030107;platform;MacIntel;domainLookupStart;1335538507546;domInteractive;1335538508237;domComplete;1335538508323;loadEventEnd;0;requestStart;1335538507546;connectEnd;1335538507546;domContentLoadedEventEnd;1335538508237;unloadEventStart;1335538508050;domainLookupEnd;1335538507546;fetchStart;1335538507545;unloadEventEnd;1335538508050;connectStart;1335538507546;secureConnectionStart;0;redirectEnd;0;domContentLoadedEventStart;1335538508237;loadEventStart;1335538508323;responseStart;1335538508049;redirectStart;0;domLoading;1335538508182;responseEnd;1335538508050;navigationStart;1335538507545;href;http://localhost:8080/" }
- subject { Mill }
-
- describe "with environment arguments" do
-
- it "creates args hash from string" do
- inst = subject.register(str)
- inst.args['appCodeName'].should eq 'Mozilla'
- inst.args['cookieEnabled'].should eq 'true'
- end
-
- it "handles escaped values" do
- inst = subject.register(str)
- inst.args['userAgent'].should eq 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_3) AppleWebKit/535.19 (KHTML, like Gecko) Chrome/18.0.1025.165 Safari/535.19'
- inst.args['appVersion'].should eq '5.0 (Macintosh; Intel Mac OS X 10_7_3) AppleWebKit/535.19 (KHTML, like Gecko) Chrome/18.0.1025.165 Safari/535.19'
- end
-
- it "skips if not passed" do
- S.should_receive(:timing).never
- subject.register("")
- end
-
- describe "registers all mapped metrics" do
- let!(:expects) {
- S.should_receive(:timing).with(["page", "ttfb"], 504)
- S.should_receive(:timing).with(["page", "load"], 778)
- }
-
- it "dom complete" do
- subject.register(str)
- end
-
- end
-
- end
-
- end
-end
@@ -1,12 +1,12 @@
require 'spec_helper'
-require 'sinatra/base'
-require 'rack/test'
+require 'fozzie/rack/middleware'
+
describe Fozzie::Rack::Middleware do
subject do
unless defined?(RackApp)
- RackApp = Class.new { def call(env); env end }
+ RackApp = Class.new { def call(env); env end }
end
Fozzie::Rack::Middleware.new RackApp.new
end
@@ -47,7 +47,6 @@
subject.call(fake_env)
end
end
-
end
describe "#generate_key" do
@@ -69,33 +68,4 @@
end
-end
-
-describe "Sinatra Server with Middleware" do
- include Rack::Test::Methods
-
- def app
- Sinatra.new do
- set :environment, :test
- use Fozzie::Rack::Middleware
- get('/') { "echo" }
- get('/somewhere/nice') { "echo" }
- end
- end
-
- it "sends stats request on root" do
- S.should_receive(:timing).with('index.render', anything, anything)
- get '/'
- last_response.should be_ok
- last_response.body.should == 'echo'
- end
-
- it "sends stats request on nested path" do
- S.should_receive(:timing).with('somewhere.nice.render', anything, anything)
-
- get '/somewhere/nice'
- last_response.should be_ok
- last_response.body.should == 'echo'
- end
-
end
@@ -0,0 +1,31 @@
+require 'fozzie/rack/middleware'
+require 'sinatra/base'
+require 'rack/test'
+
+describe "Sinatra Server with Middleware" do
+ include Rack::Test::Methods
+
+ def app
+ Sinatra.new do
+ set :environment, :test
+ use Fozzie::Rack::Middleware
+ get('/') { "echo" }
+ get('/somewhere/nice') { "echo" }
+ end
+ end
+
+ it "sends stats request on root" do
+ S.should_receive(:timing).with('index.render', anything, anything)
+ get '/'
+ last_response.should be_ok
+ last_response.body.should == 'echo'
+ end
+
+ it "sends stats request on nested path" do
+ S.should_receive(:timing).with('somewhere.nice.render', anything, anything)
+
+ get '/somewhere/nice'
+ last_response.should be_ok
+ last_response.body.should == 'echo'
+ end
+end
Oops, something went wrong.

0 comments on commit 4e8c315

Please sign in to comment.