ramon 0.2.1 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +1 -0
- data/Gemfile +2 -0
- data/lib/ramon/config.rb +1 -1
- data/lib/ramon/enviroment_data.rb +2 -4
- data/lib/ramon/logger.rb +1 -1
- data/lib/ramon/version.rb +1 -1
- data/spec/config_spec.rb +0 -0
- data/spec/exception_data_spec.rb +58 -0
- data/spec/logger_spec.rb +37 -0
- data/spec/rails_integration_spec.rb +34 -0
- data/spec/remote_spec.rb +0 -0
- data/spec/spec_helper.rb +5 -0
- data/spec/web_spec.rb +16 -0
- metadata +12 -6
- data/init.rb +0 -5
data/.gitignore
CHANGED
data/Gemfile
CHANGED
data/lib/ramon/config.rb
CHANGED
@@ -20,12 +20,10 @@ class ApplicationEnvironment
|
|
20
20
|
end
|
21
21
|
|
22
22
|
def self.language_version_string
|
23
|
-
"#{RUBY_VERSION rescue '?.?.?'} p#{RUBY_PATCHLEVEL rescue '???'}
|
23
|
+
"#{RUBY_VERSION rescue '?.?.?'} p#{RUBY_PATCHLEVEL rescue '???'}
|
24
|
+
#{RUBY_RELEASE_DATE rescue '????-??-??'} #{RUBY_PLATFORM rescue '????'}"
|
24
25
|
end
|
25
26
|
|
26
|
-
def self.get_username
|
27
|
-
ENV['LOGNAME'] || ENV['USER'] || ENV['USERNAME'] || ENV['APACHE_RUN_USER'] || 'UNKNOWN'
|
28
|
-
end
|
29
27
|
|
30
28
|
def self.libraries_loaded
|
31
29
|
begin
|
data/lib/ramon/logger.rb
CHANGED
data/lib/ramon/version.rb
CHANGED
data/spec/config_spec.rb
ADDED
File without changes
|
@@ -0,0 +1,58 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'action_controller'
|
3
|
+
require 'action_controller/test_case'
|
4
|
+
|
5
|
+
module Ramon
|
6
|
+
|
7
|
+
class RamonError < StandardError
|
8
|
+
def backtrace
|
9
|
+
'test'
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
describe Ramon::ControllerExceptionData, 'with request/controller/params' do
|
14
|
+
|
15
|
+
class TestController < ActionController::Base
|
16
|
+
end
|
17
|
+
|
18
|
+
# Only when debugging
|
19
|
+
#after do
|
20
|
+
#puts @json
|
21
|
+
#end
|
22
|
+
|
23
|
+
before :each do
|
24
|
+
@controller = TestController.new
|
25
|
+
@request = ActionController::TestRequest.new({'action' => 'some_action' })
|
26
|
+
@request.stub!(:url).and_return('http://test.host/some_path?var1=abc')
|
27
|
+
@request.stub!(:parameters).and_return({'var1' => 'abc', 'action' => 'some_action'})
|
28
|
+
@request.stub!(:request_method).and_return(:get)
|
29
|
+
@request.stub!(:remote_ip).and_return('1.2.3.4')
|
30
|
+
@request.stub!(:env).and_return({'SOME_VAR' => 'abc', 'HTTP_CONTENT_TYPE' => 'text/html'})
|
31
|
+
@request.session = {"session_data" => "some_data", "more_session_data" => "more_data"}
|
32
|
+
@error = Ramon::RamonError.new('some message')
|
33
|
+
data = Ramon::ControllerExceptionData.new(@error, @controller, @request)
|
34
|
+
@hash = data.to_hash
|
35
|
+
#@json = data.to_json
|
36
|
+
end
|
37
|
+
|
38
|
+
it "Captures request data" do
|
39
|
+
request_hash = @hash['data']['request']
|
40
|
+
request_hash['url'].should == 'http://test.host/some_path?var1=abc'
|
41
|
+
request_hash['controller'].should == 'Ramon::TestController'
|
42
|
+
request_hash['action'].should == 'some_action'
|
43
|
+
request_hash['parameters'].should == {'var1' => 'abc', 'action' => 'some_action', }
|
44
|
+
request_hash['request_method'].should == 'get'
|
45
|
+
request_hash['remote_ip'].should == '1.2.3.4'
|
46
|
+
request_hash['session']['data'].should == {"more_session_data" => "more_data","session_data" => "some_data"}
|
47
|
+
end
|
48
|
+
|
49
|
+
it "Captures exception data" do
|
50
|
+
@hash['message'].should == 'some message'
|
51
|
+
@hash['backtrace'].should == 'test'
|
52
|
+
@hash['exception_class'].should == 'Ramon::RamonError'
|
53
|
+
|
54
|
+
end
|
55
|
+
|
56
|
+
end
|
57
|
+
|
58
|
+
end # module end
|
data/spec/logger_spec.rb
ADDED
@@ -0,0 +1,37 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
module Ramon
|
4
|
+
describe Log do
|
5
|
+
|
6
|
+
it "should return a hash with level - debug and message - test" do
|
7
|
+
@log = Log.log('test', 'debug')
|
8
|
+
@log.should == {"level" => "debug", "message" => "test"}
|
9
|
+
end
|
10
|
+
|
11
|
+
it "should return a hash with level - info and message - test" do
|
12
|
+
@log = Log.log('test', 'info')
|
13
|
+
@log.should == {"level" => "info", "message" => "test"}
|
14
|
+
end
|
15
|
+
|
16
|
+
it "should return a hash with level - notset and message - test" do
|
17
|
+
@log = Log.log('test')
|
18
|
+
@log.should == {"level" => "notset", "message" => "test"}
|
19
|
+
end
|
20
|
+
|
21
|
+
it "should return a hash with level - notset and a message hash" do
|
22
|
+
@log = Log.log({:test => "test value", :more => "even more value"})
|
23
|
+
@log.should == {"level" => "notset", "message"=>{:more=>"even more value", :test=>"test value"}}
|
24
|
+
end
|
25
|
+
|
26
|
+
it "should return a hash with level - debug and a message hash" do
|
27
|
+
@log = Log.log({:test => "test value", :more => "even more value"},'debug')
|
28
|
+
@log.should == {"level" => "debug", "message"=>{:more=>"even more value", :test=>"test value"}}
|
29
|
+
end
|
30
|
+
|
31
|
+
it "should return a hash with level - notset and a message array" do
|
32
|
+
@log = Log.log([1,2,3,4])
|
33
|
+
@log.should == {"level" => "notset", "message"=>[1,2,3,4]}
|
34
|
+
end
|
35
|
+
|
36
|
+
end
|
37
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
require 'rack/mock'
|
3
|
+
require 'ramon/integration/rails'
|
4
|
+
require 'action_controller'
|
5
|
+
|
6
|
+
module Ramon
|
7
|
+
class RamonError < StandardError
|
8
|
+
end
|
9
|
+
|
10
|
+
describe Rack::RailsAmonException do
|
11
|
+
|
12
|
+
class TestingController < ActionController::Base
|
13
|
+
|
14
|
+
def raises_something
|
15
|
+
raise StandardError
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
before(:each) do
|
20
|
+
@error = RamonError.new
|
21
|
+
@app = lambda { |env| raise @error, 'error' }
|
22
|
+
@env = Rack::MockRequest.env_for("/")
|
23
|
+
@env['action_controller.instance'] = TestingController.new
|
24
|
+
end
|
25
|
+
|
26
|
+
it 'Raise the error caught in the middleware' do
|
27
|
+
rr = Rack::RailsAmonException.new(@app)
|
28
|
+
Ramon::Catcher.should_receive(:handle_with_controller)
|
29
|
+
lambda { rr.call(@env)}.should raise_error(RamonError)
|
30
|
+
end
|
31
|
+
|
32
|
+
end
|
33
|
+
|
34
|
+
end # Module end
|
data/spec/remote_spec.rb
ADDED
File without changes
|
data/spec/spec_helper.rb
ADDED
data/spec/web_spec.rb
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
# Works only when the Amon application is started
|
4
|
+
describe 'Web app test' do
|
5
|
+
|
6
|
+
it 'Test logging' do
|
7
|
+
Ramon.log([1,2,3,4]).response.code.should == "200"
|
8
|
+
Ramon.log({:test => 'data', :more_test => 'more_data'}).response.code.should == "200"
|
9
|
+
end
|
10
|
+
|
11
|
+
it 'Test Exceptions' do
|
12
|
+
Ramon.post('exception', {:url => 'test', :exception_class => 'test_me'}).response.code.should == "200"
|
13
|
+
end
|
14
|
+
|
15
|
+
end
|
16
|
+
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ramon
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 19
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
|
-
-
|
9
|
-
-
|
10
|
-
version: 0.
|
8
|
+
- 3
|
9
|
+
- 0
|
10
|
+
version: 0.3.0
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- martinrusev
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-11-
|
18
|
+
date: 2011-11-20 00:00:00 +00:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
@@ -45,7 +45,6 @@ files:
|
|
45
45
|
- .gitignore
|
46
46
|
- Gemfile
|
47
47
|
- Rakefile
|
48
|
-
- init.rb
|
49
48
|
- lib/ramon.rb
|
50
49
|
- lib/ramon/catcher.rb
|
51
50
|
- lib/ramon/config.rb
|
@@ -58,6 +57,13 @@ files:
|
|
58
57
|
- lib/ramon/remote.rb
|
59
58
|
- lib/ramon/version.rb
|
60
59
|
- ramon.gemspec
|
60
|
+
- spec/config_spec.rb
|
61
|
+
- spec/exception_data_spec.rb
|
62
|
+
- spec/logger_spec.rb
|
63
|
+
- spec/rails_integration_spec.rb
|
64
|
+
- spec/remote_spec.rb
|
65
|
+
- spec/spec_helper.rb
|
66
|
+
- spec/web_spec.rb
|
61
67
|
has_rdoc: true
|
62
68
|
homepage: http://amon.cx
|
63
69
|
licenses: []
|