Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

reorganize requires so that 'oink/cli' is only require necessary for

cli and 'oink' is only require necessary for rails apps (using middleware)
  • Loading branch information...
commit eff91ae9c1a094709aca344473621242540f28c4 1 parent 8db061d
Noah Davis authored
View
2  bin/oink
@@ -1,5 +1,5 @@
#!/usr/bin/env ruby
-require File.dirname(__FILE__) + "/../lib/oink.rb"
+require File.dirname(__FILE__) + "/../lib/oink/cli.rb"
Oink::Cli.new(ARGV.dup).process
View
9 lib/oink.rb
@@ -1,8 +1 @@
-require "oink/reports/memory_usage_report"
-require "oink/reports/active_record_instantiation_report"
-require 'oink/utils/hash_utils'
-require "oink/cli"
-
-if defined?(Rails)
- require 'oink/rails'
-end
+require 'oink/middleware'
View
3  lib/oink/cli.rb
@@ -1,4 +1,7 @@
require 'optparse'
+require 'oink/reports/base'
+require 'oink/reports/active_record_instantiation_report'
+require 'oink/reports/memory_usage_report'
module Oink
class Cli
View
2  lib/oink/instrumentation.rb
@@ -0,0 +1,2 @@
+require 'oink/instrumentation/active_record'
+require 'oink/instrumentation/memory_snapshot'
View
4 lib/oink/middleware.rb
@@ -1,3 +1,7 @@
+require 'hodel_3000_compliant_logger'
+require 'oink/utils/hash_utils'
+require 'oink/instrumentation'
+
module Oink
class Middleware
View
1  lib/oink/rails/instance_type_counter.rb
@@ -1,4 +1,5 @@
require 'oink/instrumentation/active_record'
+require 'oink/utils/hash_utils'
module Oink
View
1  spec/oink/middleware_spec.rb
@@ -1,7 +1,6 @@
require File.expand_path(File.dirname(__FILE__) + "/../spec_helper")
require "oink/middleware"
require 'rack/test'
-require 'logger'
describe Oink::Middleware do
include Rack::Test::Methods
View
2  ...nk/rails/instance_type_controller_spec.rb → .../oink/rails/instance_type_counter_spec.rb
@@ -22,7 +22,7 @@ def two_pigs
end
-describe Oink::MemoryUsageLogger do
+describe Oink::InstanceTypeCounter do
before do
Pig.delete_all
View
6 ...ink/rails/memory_usage_controller_spec.rb → spec/oink/rails/memory_usage_logger_spec.rb
@@ -1,6 +1,6 @@
require File.expand_path(File.dirname(__FILE__) + "/../../spec_helper")
-class UseMemoryLoggerApplicationController < FakeApplicationController
+class MemoryLoggerApplicationController < FakeApplicationController
include Oink::MemoryUsageLogger
end
@@ -8,14 +8,14 @@ class UseMemoryLoggerApplicationController < FakeApplicationController
it "should return memory usage info from the snapshot" do
Oink::Instrumentation::MemorySnapshot.should_receive("memory").and_return(42)
log_output = StringIO.new
- controller = UseMemoryLoggerApplicationController.new(Logger.new(log_output))
+ controller = MemoryLoggerApplicationController.new(Logger.new(log_output))
controller.index
log_output.string.should include("Memory usage: 42 | PID: #{$$}")
end
it "should log an error message if cannot find a memory snapshot strategy" do
Oink::Instrumentation::MemorySnapshot.should_receive("memory").and_raise(Oink::Instrumentation::MemoryDataUnavailableError)
- controller = UseMemoryLoggerApplicationController.new
+ controller = MemoryLoggerApplicationController.new
lambda {
controller.index
}.should_not raise_error
View
8 spec/spec_helper.rb
@@ -2,15 +2,13 @@
require "ostruct"
require "logger"
-dir = File.dirname(__FILE__)
-require File.join(dir, "/../lib/oink.rb")
-require "oink/rails/instance_type_counter"
-require "oink/rails/memory_usage_logger"
-
require 'helpers/database'
require 'fakes/fake_application_controller'
require 'fakes/psuedo_output'
+require 'oink/cli'
+require 'oink/rails'
+
RSpec.configure do |config|
config.before :suite do
Please sign in to comment.
Something went wrong with that request. Please try again.