request_lumberjack 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/.document ADDED
@@ -0,0 +1,5 @@
1
+ README.rdoc
2
+ lib/**/*.rb
3
+ bin/*
4
+ features/**/*.feature
5
+ LICENSE
data/.gitignore ADDED
@@ -0,0 +1,9 @@
1
+ .DS_Store
2
+ coverage
3
+ rdoc
4
+ pkg
5
+ bin/*
6
+ vendor/gems/*
7
+ !vendor/gems/cache/
8
+ *.db
9
+ *.sqlite*
data/Gemfile ADDED
@@ -0,0 +1,27 @@
1
+
2
+ gem 'bundler'
3
+ gem 'sinatra', '~>0.9.4'
4
+ gem 'shotgun'
5
+ gem 'rake'
6
+
7
+ gem 'do_sqlite3', '>=0.10.0'
8
+ gem 'dm-core', '>=0.10.1'
9
+ gem 'dm-validations', '>=0.10.1'
10
+ gem 'dm-timestamps', '>=0.10.1'
11
+
12
+ only :test do
13
+ gem 'rake'
14
+ gem 'rspec', :require_as => 'spec'
15
+ gem 'rcov'
16
+ gem 'autotest-growl'
17
+ gem 'autotest-fsevent'
18
+ gem 'actionpack', '2.3.5'
19
+ gem 'bundler', '>=0.7.0'
20
+ gem 'cucumber'
21
+ gem 'webrat', '~>0.5.0'
22
+ gem 'rack-test', '~>0.5.2', :require_as => 'rack/test'
23
+ gem 'fakeweb', '>=1.2.5'
24
+ gem 'ParseTree', '>=3.0.4', :require_as => [ ]
25
+ gem 'randexp', '>=0.1.4'
26
+ end
27
+ # vim:ft=ruby
data/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2009 Alex Sharp
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.rdoc ADDED
@@ -0,0 +1,22 @@
1
+ = Request Lumberjack: Because flat log files blow
2
+
3
+ This is a simple middleware for saving arbitrary
4
+ information pertaining to requests and responses in your rack-based web
5
+ apps.
6
+
7
+ Currently it only supports rails, but I plan to add support for plain
8
+ rack apps.
9
+
10
+ == Note on Patches/Pull Requests
11
+
12
+ * Fork the project.
13
+ * Make your feature addition or bug fix.
14
+ * Add tests for it. This is important so I don't break it in a
15
+ future version unintentionally.
16
+ * Commit, do not mess with rakefile, version, or history.
17
+ (if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)
18
+ * Send me a pull request. Bonus points for topic branches.
19
+
20
+ == Copyright
21
+
22
+ Copyright (c) 2010 Alex Sharp. See LICENSE for details.
data/Rakefile ADDED
@@ -0,0 +1,45 @@
1
+ require 'rubygems'
2
+ require 'rake'
3
+
4
+ begin
5
+ require 'jeweler'
6
+ Jeweler::Tasks.new do |gem|
7
+ gem.name = "request_lumberjack"
8
+ gem.summary = %Q{A simple request logger to be used with Rails and other Rack apps.}
9
+ gem.description = %Q{A simple request logger to be used with Rails and other Rack apps.}
10
+ gem.email = "ajsharp@gmail.com"
11
+ gem.homepage = "http://github.com/ajsharp/request_lumberjack"
12
+ gem.authors = ["Alex Sharp"]
13
+ gem.add_development_dependency "rspec", ">= 1.2.9"
14
+ # gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
15
+ end
16
+ Jeweler::GemcutterTasks.new
17
+ rescue LoadError
18
+ puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
19
+ end
20
+
21
+ require 'spec/rake/spectask'
22
+ Spec::Rake::SpecTask.new(:spec) do |spec|
23
+ spec.libs << 'lib' << 'spec'
24
+ spec.spec_files = FileList['spec/**/*_spec.rb']
25
+ end
26
+
27
+ Spec::Rake::SpecTask.new(:rcov) do |spec|
28
+ spec.libs << 'lib' << 'spec'
29
+ spec.pattern = 'spec/**/*_spec.rb'
30
+ spec.rcov = true
31
+ end
32
+
33
+ task :spec => :check_dependencies
34
+
35
+ task :default => :spec
36
+
37
+ require 'rake/rdoctask'
38
+ Rake::RDocTask.new do |rdoc|
39
+ version = File.exist?('VERSION') ? File.read('VERSION') : ""
40
+
41
+ rdoc.rdoc_dir = 'rdoc'
42
+ rdoc.title = "request_lumberjack #{version}"
43
+ rdoc.rdoc_files.include('README*')
44
+ rdoc.rdoc_files.include('lib/**/*.rb')
45
+ end
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.0.1
data/bin/autospec ADDED
@@ -0,0 +1,3 @@
1
+ #!/usr/local/bin/ruby
2
+ require File.expand_path(File.join(File.dirname(__FILE__), "../vendor/gems/ruby/1.8/environment"))
3
+ load File.expand_path(File.join(File.dirname(__FILE__), "../vendor/gems/ruby/1.8/gems/rspec-1.3.0/bin/autospec"))
data/bin/autotest ADDED
@@ -0,0 +1,3 @@
1
+ #!/usr/local/bin/ruby -ws
2
+ require File.expand_path(File.join(File.dirname(__FILE__), "../vendor/gems/ruby/1.8/environment"))
3
+ load File.expand_path(File.join(File.dirname(__FILE__), "../vendor/gems/ruby/1.8/gems/ZenTest-4.2.1/bin/autotest"))
data/bin/cucumber ADDED
@@ -0,0 +1,3 @@
1
+ #!/usr/local/bin/ruby
2
+ require File.expand_path(File.join(File.dirname(__FILE__), "../vendor/gems/ruby/1.8/environment"))
3
+ load File.expand_path(File.join(File.dirname(__FILE__), "../vendor/gems/ruby/1.8/gems/cucumber-0.6.1/bin/cucumber"))
data/bin/edit_json.rb ADDED
@@ -0,0 +1,3 @@
1
+ #!/usr/local/bin/ruby
2
+ require File.expand_path(File.join(File.dirname(__FILE__), "../vendor/gems/ruby/1.8/environment"))
3
+ load File.expand_path(File.join(File.dirname(__FILE__), "../vendor/gems/ruby/1.8/gems/json_pure-1.2.0/bin/edit_json.rb"))
data/bin/htmldiff ADDED
@@ -0,0 +1,3 @@
1
+ #!/usr/local/bin/ruby
2
+ require File.expand_path(File.join(File.dirname(__FILE__), "../vendor/gems/ruby/1.8/environment"))
3
+ load File.expand_path(File.join(File.dirname(__FILE__), "../vendor/gems/ruby/1.8/gems/diff-lcs-1.1.2/bin/htmldiff"))
data/bin/launchy ADDED
@@ -0,0 +1,3 @@
1
+ #!/usr/local/bin/ruby
2
+ require File.expand_path(File.join(File.dirname(__FILE__), "../vendor/gems/ruby/1.8/environment"))
3
+ load File.expand_path(File.join(File.dirname(__FILE__), "../vendor/gems/ruby/1.8/gems/launchy-0.3.5/bin/launchy"))
data/bin/ldiff ADDED
@@ -0,0 +1,3 @@
1
+ #!/usr/local/bin/ruby
2
+ require File.expand_path(File.join(File.dirname(__FILE__), "../vendor/gems/ruby/1.8/environment"))
3
+ load File.expand_path(File.join(File.dirname(__FILE__), "../vendor/gems/ruby/1.8/gems/diff-lcs-1.1.2/bin/ldiff"))
data/bin/multigem ADDED
@@ -0,0 +1,3 @@
1
+ #!/usr/local/bin/ruby -w
2
+ require File.expand_path(File.join(File.dirname(__FILE__), "../vendor/gems/ruby/1.8/environment"))
3
+ load File.expand_path(File.join(File.dirname(__FILE__), "../vendor/gems/ruby/1.8/gems/ZenTest-4.2.1/bin/multigem"))
data/bin/multiruby ADDED
@@ -0,0 +1,3 @@
1
+ #!/usr/local/bin/ruby -w
2
+ require File.expand_path(File.join(File.dirname(__FILE__), "../vendor/gems/ruby/1.8/environment"))
3
+ load File.expand_path(File.join(File.dirname(__FILE__), "../vendor/gems/ruby/1.8/gems/ZenTest-4.2.1/bin/multiruby"))
@@ -0,0 +1,3 @@
1
+ #!/usr/local/bin/ruby -w
2
+ require File.expand_path(File.join(File.dirname(__FILE__), "../vendor/gems/ruby/1.8/environment"))
3
+ load File.expand_path(File.join(File.dirname(__FILE__), "../vendor/gems/ruby/1.8/gems/ZenTest-4.2.1/bin/multiruby_setup"))
data/bin/nokogiri ADDED
@@ -0,0 +1,3 @@
1
+ #!/usr/local/bin/ruby
2
+ require File.expand_path(File.join(File.dirname(__FILE__), "../vendor/gems/ruby/1.8/environment"))
3
+ load File.expand_path(File.join(File.dirname(__FILE__), "../vendor/gems/ruby/1.8/gems/nokogiri-1.4.1/bin/nokogiri"))
@@ -0,0 +1,3 @@
1
+ #!/usr/local/bin/ruby -ws
2
+ require File.expand_path(File.join(File.dirname(__FILE__), "../vendor/gems/ruby/1.8/environment"))
3
+ load File.expand_path(File.join(File.dirname(__FILE__), "../vendor/gems/ruby/1.8/gems/ParseTree-3.0.4/bin/parse_tree_abc"))
@@ -0,0 +1,3 @@
1
+ #!/usr/local/bin/ruby -w
2
+ require File.expand_path(File.join(File.dirname(__FILE__), "../vendor/gems/ruby/1.8/environment"))
3
+ load File.expand_path(File.join(File.dirname(__FILE__), "../vendor/gems/ruby/1.8/gems/ParseTree-3.0.4/bin/parse_tree_audit"))
@@ -0,0 +1,3 @@
1
+ #!/usr/local/bin/ruby -ws
2
+ require File.expand_path(File.join(File.dirname(__FILE__), "../vendor/gems/ruby/1.8/environment"))
3
+ load File.expand_path(File.join(File.dirname(__FILE__), "../vendor/gems/ruby/1.8/gems/ParseTree-3.0.4/bin/parse_tree_deps"))
@@ -0,0 +1,3 @@
1
+ #!/usr/local/bin/ruby -ws
2
+ require File.expand_path(File.join(File.dirname(__FILE__), "../vendor/gems/ruby/1.8/environment"))
3
+ load File.expand_path(File.join(File.dirname(__FILE__), "../vendor/gems/ruby/1.8/gems/ParseTree-3.0.4/bin/parse_tree_show"))
@@ -0,0 +1,3 @@
1
+ #!/usr/local/bin/ruby
2
+ require File.expand_path(File.join(File.dirname(__FILE__), "../vendor/gems/ruby/1.8/environment"))
3
+ load File.expand_path(File.join(File.dirname(__FILE__), "../vendor/gems/ruby/1.8/gems/json_pure-1.2.0/bin/prettify_json.rb"))
data/bin/rackup ADDED
@@ -0,0 +1,3 @@
1
+ #!/usr/local/bin/ruby
2
+ require File.expand_path(File.join(File.dirname(__FILE__), "../vendor/gems/ruby/1.8/environment"))
3
+ load File.expand_path(File.join(File.dirname(__FILE__), "../vendor/gems/ruby/1.8/gems/rack-1.0.1/bin/rackup"))
data/bin/rake ADDED
@@ -0,0 +1,3 @@
1
+ #!/usr/local/bin/ruby
2
+ require File.expand_path(File.join(File.dirname(__FILE__), "../vendor/gems/ruby/1.8/environment"))
3
+ load File.expand_path(File.join(File.dirname(__FILE__), "../vendor/gems/ruby/1.8/gems/rake-0.8.7/bin/rake"))
data/bin/rcov ADDED
@@ -0,0 +1,3 @@
1
+ #!/usr/local/bin/ruby
2
+ require File.expand_path(File.join(File.dirname(__FILE__), "../vendor/gems/ruby/1.8/environment"))
3
+ load File.expand_path(File.join(File.dirname(__FILE__), "../vendor/gems/ruby/1.8/gems/rcov-0.9.7.1/bin/rcov"))
data/bin/shotgun ADDED
@@ -0,0 +1,3 @@
1
+ #!/usr/local/bin/ruby
2
+ require File.expand_path(File.join(File.dirname(__FILE__), "../vendor/gems/ruby/1.8/environment"))
3
+ load File.expand_path(File.join(File.dirname(__FILE__), "../vendor/gems/ruby/1.8/gems/shotgun-0.4/bin/shotgun"))
data/bin/spec ADDED
@@ -0,0 +1,3 @@
1
+ #!/usr/local/bin/ruby
2
+ require File.expand_path(File.join(File.dirname(__FILE__), "../vendor/gems/ruby/1.8/environment"))
3
+ load File.expand_path(File.join(File.dirname(__FILE__), "../vendor/gems/ruby/1.8/gems/rspec-1.3.0/bin/spec"))
data/bin/tt ADDED
@@ -0,0 +1,3 @@
1
+ #!/usr/local/bin/ruby
2
+ require File.expand_path(File.join(File.dirname(__FILE__), "../vendor/gems/ruby/1.8/environment"))
3
+ load File.expand_path(File.join(File.dirname(__FILE__), "../vendor/gems/ruby/1.8/gems/treetop-1.4.3/bin/tt"))
data/bin/unit_diff ADDED
@@ -0,0 +1,3 @@
1
+ #!/usr/local/bin/ruby -ws
2
+ require File.expand_path(File.join(File.dirname(__FILE__), "../vendor/gems/ruby/1.8/environment"))
3
+ load File.expand_path(File.join(File.dirname(__FILE__), "../vendor/gems/ruby/1.8/gems/ZenTest-4.2.1/bin/unit_diff"))
data/bin/zentest ADDED
@@ -0,0 +1,3 @@
1
+ #!/usr/local/bin/ruby -swI .
2
+ require File.expand_path(File.join(File.dirname(__FILE__), "../vendor/gems/ruby/1.8/environment"))
3
+ load File.expand_path(File.join(File.dirname(__FILE__), "../vendor/gems/ruby/1.8/gems/ZenTest-4.2.1/bin/zentest"))
data/init.rb ADDED
@@ -0,0 +1,4 @@
1
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), "lib"))
2
+
3
+ require "request_lumberjack"
4
+
@@ -0,0 +1,28 @@
1
+ $:.unshift(File.dirname(__FILE__))
2
+ Bundler.require_env
3
+
4
+ require "vendor/gems/environment"
5
+
6
+ require 'request_lumberjack/config'
7
+ require 'request_lumberjack/logged_response'
8
+
9
+ module RequestLumberjack
10
+
11
+ def self.configure(db_uri)
12
+ Config.database db_uri
13
+ end
14
+
15
+ class App
16
+ def initialize(app)
17
+ @app = app
18
+ end
19
+
20
+ def call(env)
21
+ status, headers, response = @app.call(env)
22
+ Thread.new { LoggedResponse.create_from_response(response) }
23
+ [status, headers, response]
24
+ end
25
+ end
26
+
27
+ end
28
+
@@ -0,0 +1,11 @@
1
+ require 'yaml'
2
+
3
+ module RequestLumberjack
4
+
5
+ class Config
6
+ def self.database(uri)
7
+ @database ||= DataMapper.setup(:default, uri)
8
+ end
9
+ end
10
+
11
+ end
@@ -0,0 +1,28 @@
1
+
2
+ module RequestLumberjack
3
+ class LoggedResponse
4
+ include DataMapper::Resource
5
+
6
+ property :id, Serial
7
+ property :request_uri, String, :required => true
8
+ property :status, Integer, :required => true
9
+ property :request_method, String, :required => true
10
+ property :user_id, Integer
11
+
12
+ class << self
13
+ def create_from_rails_response(response)
14
+ logged_request = LoggedResponse.create(
15
+ :request_uri => response.request.request_uri,
16
+ :status => response.status,
17
+ :request_method => response.request.request_method
18
+ )
19
+ end
20
+
21
+ def create_from_response(response)
22
+ create_from_rails_response(response) if defined?(RAILS_ENV)
23
+ end
24
+ end
25
+
26
+ end
27
+
28
+ end
@@ -0,0 +1,66 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
4
+ # -*- encoding: utf-8 -*-
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = %q{request_lumberjack}
8
+ s.version = "0.0.1"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["Alex Sharp"]
12
+ s.date = %q{2010-01-16}
13
+ s.description = %q{A simple request logger to be used with Rails and other Rack apps.}
14
+ s.email = %q{ajsharp@gmail.com}
15
+ s.executables = ["autospec", "autotest", "cucumber", "edit_json.rb", "htmldiff", "launchy", "ldiff", "multigem", "multiruby", "multiruby_setup", "nokogiri", "parse_tree_abc", "parse_tree_audit", "parse_tree_deps", "parse_tree_show", "prettify_json.rb", "rackup", "rake", "rcov", "shotgun", "spec", "tt", "unit_diff", "zentest"]
16
+ s.extra_rdoc_files = [
17
+ "LICENSE",
18
+ "README.rdoc"
19
+ ]
20
+ s.files = [
21
+ ".document",
22
+ ".gitignore",
23
+ "Gemfile",
24
+ "LICENSE",
25
+ "README.rdoc",
26
+ "Rakefile",
27
+ "VERSION",
28
+ "init.rb",
29
+ "lib/request_lumberjack.rb",
30
+ "lib/request_lumberjack/config.rb",
31
+ "lib/request_lumberjack/logged_response.rb",
32
+ "request_lumberjack.gemspec",
33
+ "spec/app_spec.rb",
34
+ "spec/config_spec.rb",
35
+ "spec/logged_response_spec.rb",
36
+ "spec/request_lumberjack_spec.rb",
37
+ "spec/spec.opts",
38
+ "spec/spec_helper.rb"
39
+ ]
40
+ s.homepage = %q{http://github.com/ajsharp/request_lumberjack}
41
+ s.rdoc_options = ["--charset=UTF-8"]
42
+ s.require_paths = ["lib"]
43
+ s.rubygems_version = %q{1.3.5}
44
+ s.summary = %q{A simple request logger to be used with Rails and other Rack apps.}
45
+ s.test_files = [
46
+ "spec/app_spec.rb",
47
+ "spec/config_spec.rb",
48
+ "spec/logged_response_spec.rb",
49
+ "spec/request_lumberjack_spec.rb",
50
+ "spec/spec_helper.rb"
51
+ ]
52
+
53
+ if s.respond_to? :specification_version then
54
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
55
+ s.specification_version = 3
56
+
57
+ if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
58
+ s.add_development_dependency(%q<rspec>, [">= 1.2.9"])
59
+ else
60
+ s.add_dependency(%q<rspec>, [">= 1.2.9"])
61
+ end
62
+ else
63
+ s.add_dependency(%q<rspec>, [">= 1.2.9"])
64
+ end
65
+ end
66
+
data/spec/app_spec.rb ADDED
@@ -0,0 +1,39 @@
1
+ require 'spec_helper'
2
+ require 'action_controller'
3
+
4
+ module RequestLumberjack
5
+
6
+ describe App do
7
+ it "should accept a configuration file path" do
8
+ env = lambda { |env| [200, {}, "body"] }
9
+ @app = App.new(env)
10
+ end
11
+ end
12
+
13
+ describe App, "when being invoked from rails" do
14
+ before :all do
15
+ RAILS_ENV='development' unless defined?(RAILS_ENV)
16
+ end
17
+
18
+ before :each do
19
+ @response = get_rails_response
20
+ @env = lambda { |env| [200, @response.headers, @response] }
21
+ @app = App.new(@env)
22
+ end
23
+
24
+ it "should attempt to save a new response" do
25
+ LoggedResponse.should_receive(:create_from_response)
26
+ @app.call(@env)
27
+ end
28
+
29
+ it "should attempt to save a new rails response" do
30
+ LoggedResponse.should_receive(:create_from_rails_response)
31
+ @app.call(@response)
32
+ end
33
+
34
+ it "should return a successfull response" do
35
+ @app.call(@response)[0].should == 200
36
+ end
37
+ end
38
+
39
+ end
@@ -0,0 +1,13 @@
1
+ require 'spec_helper'
2
+
3
+ module RequestLumberjack
4
+
5
+ describe Config, ".database" do
6
+ it "should return a sqlite3 database connection" do
7
+ Config.database(nil).should be_instance_of DataMapper::Adapters::Sqlite3Adapter
8
+ end
9
+ end
10
+
11
+ end
12
+
13
+
@@ -0,0 +1,77 @@
1
+ require 'spec_helper'
2
+ require 'action_controller'
3
+
4
+ module RequestLumberjack
5
+ describe LoggedResponse do
6
+ before :each do
7
+ @logger = LoggedResponse.new
8
+ end
9
+
10
+ it "should have an id" do
11
+ @logger.should respond_to :id
12
+ end
13
+
14
+ it "should have a request_uri string field" do
15
+ @logger.should respond_to :request_uri
16
+ end
17
+
18
+ it "should have a status integer field" do
19
+ @logger.should respond_to :status
20
+ end
21
+
22
+ it "should have a user_id integer field" do
23
+ @logger.should respond_to :user_id
24
+ end
25
+
26
+ it "should have a request method field" do
27
+ @logger.should respond_to :request_method
28
+ end
29
+
30
+ it "should require a request_uri" do
31
+ @logger.should_not be_valid
32
+ @logger.errors.on(:request_uri).should_not be_blank
33
+ end
34
+
35
+ it "should require a status" do
36
+ @logger.should_not be_valid
37
+ @logger.errors.on(:status).should_not be_blank
38
+ end
39
+
40
+ it "should require the request method" do
41
+ @logger.should_not be_valid
42
+ @logger.errors.on(:request_method).should_not be_blank
43
+ end
44
+ end
45
+
46
+ describe LoggedResponse, ".create_from_response" do
47
+ it "should recognize a rails response" do
48
+ RAILS_ENV = 'something'
49
+ LoggedResponse.should_receive(:create_from_rails_response)
50
+ LoggedResponse.create_from_response("RESPONSE")
51
+ end
52
+ end
53
+
54
+ describe LoggedResponse, ".create_from_rails_response" do
55
+ before :each do
56
+ @response = get_rails_response
57
+ @logged_response = LoggedResponse.create_from_rails_response @response
58
+ end
59
+
60
+ it "should save a new response" do
61
+ @logged_response.should_not be_new
62
+ end
63
+
64
+ it "should save the response code" do
65
+ @logged_response.status.should == 200
66
+ end
67
+
68
+ it "should save the request method" do
69
+ @logged_response.request_method.should == "get"
70
+ end
71
+
72
+ it "should save the request uri" do
73
+ @logged_response.request_uri.should == "/controller/action"
74
+ end
75
+ end
76
+
77
+ end
@@ -0,0 +1,22 @@
1
+ require 'spec_helper'
2
+ require 'action_controller'
3
+
4
+ describe RequestLumberjack::App, "#call" do
5
+ before :each do
6
+ response = get_rails_response
7
+ @env = lambda { |env| [200, {}, response] }
8
+ @rl = RequestLumberjack::App.new(@env)
9
+ end
10
+
11
+ it "should respond to call" do
12
+ @rl.should respond_to(:call)
13
+ end
14
+
15
+ it "should return an array" do
16
+ @rl.call([]).should be_instance_of Array
17
+ end
18
+
19
+ it "should return a status code in the first element" do
20
+ @rl.call([]).first.should be_instance_of Fixnum
21
+ end
22
+ end
data/spec/spec.opts ADDED
@@ -0,0 +1 @@
1
+ --color
@@ -0,0 +1,23 @@
1
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
2
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
3
+
4
+ require 'request_lumberjack'
5
+ require 'spec'
6
+ require 'spec/autorun'
7
+
8
+
9
+ Spec::Runner.configure do |config|
10
+ def get_rails_response(opts = {})
11
+ env = { 'REQUEST_METHOD' => 'GET', 'REQUEST_URI' => 'http://example.com/controller/action' }.merge(opts)
12
+ request = ActionController::Request.new env
13
+ response = ActionController::Response.new
14
+ response.request = request
15
+ response
16
+ end
17
+
18
+ config.before(:all) do
19
+ RequestLumberjack::Config.database "sqlite3://#{Dir.pwd}/request_lumberjack_test.sqlite3"
20
+ DataMapper.auto_migrate!
21
+ end
22
+
23
+ end
metadata ADDED
@@ -0,0 +1,109 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: request_lumberjack
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Alex Sharp
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2010-01-16 00:00:00 -08:00
13
+ default_executable:
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: rspec
17
+ type: :development
18
+ version_requirement:
19
+ version_requirements: !ruby/object:Gem::Requirement
20
+ requirements:
21
+ - - ">="
22
+ - !ruby/object:Gem::Version
23
+ version: 1.2.9
24
+ version:
25
+ description: A simple request logger to be used with Rails and other Rack apps.
26
+ email: ajsharp@gmail.com
27
+ executables:
28
+ - autospec
29
+ - autotest
30
+ - cucumber
31
+ - edit_json.rb
32
+ - htmldiff
33
+ - launchy
34
+ - ldiff
35
+ - multigem
36
+ - multiruby
37
+ - multiruby_setup
38
+ - nokogiri
39
+ - parse_tree_abc
40
+ - parse_tree_audit
41
+ - parse_tree_deps
42
+ - parse_tree_show
43
+ - prettify_json.rb
44
+ - rackup
45
+ - rake
46
+ - rcov
47
+ - shotgun
48
+ - spec
49
+ - tt
50
+ - unit_diff
51
+ - zentest
52
+ extensions: []
53
+
54
+ extra_rdoc_files:
55
+ - LICENSE
56
+ - README.rdoc
57
+ files:
58
+ - .document
59
+ - .gitignore
60
+ - Gemfile
61
+ - LICENSE
62
+ - README.rdoc
63
+ - Rakefile
64
+ - VERSION
65
+ - init.rb
66
+ - lib/request_lumberjack.rb
67
+ - lib/request_lumberjack/config.rb
68
+ - lib/request_lumberjack/logged_response.rb
69
+ - request_lumberjack.gemspec
70
+ - spec/app_spec.rb
71
+ - spec/config_spec.rb
72
+ - spec/logged_response_spec.rb
73
+ - spec/request_lumberjack_spec.rb
74
+ - spec/spec.opts
75
+ - spec/spec_helper.rb
76
+ has_rdoc: true
77
+ homepage: http://github.com/ajsharp/request_lumberjack
78
+ licenses: []
79
+
80
+ post_install_message:
81
+ rdoc_options:
82
+ - --charset=UTF-8
83
+ require_paths:
84
+ - lib
85
+ required_ruby_version: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: "0"
90
+ version:
91
+ required_rubygems_version: !ruby/object:Gem::Requirement
92
+ requirements:
93
+ - - ">="
94
+ - !ruby/object:Gem::Version
95
+ version: "0"
96
+ version:
97
+ requirements: []
98
+
99
+ rubyforge_project:
100
+ rubygems_version: 1.3.5
101
+ signing_key:
102
+ specification_version: 3
103
+ summary: A simple request logger to be used with Rails and other Rack apps.
104
+ test_files:
105
+ - spec/app_spec.rb
106
+ - spec/config_spec.rb
107
+ - spec/logged_response_spec.rb
108
+ - spec/request_lumberjack_spec.rb
109
+ - spec/spec_helper.rb