ramon 0.2.1 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/.gitignore CHANGED
@@ -2,3 +2,4 @@
2
2
  .bundle
3
3
  Gemfile.lock
4
4
  pkg/*
5
+ gems
data/Gemfile CHANGED
@@ -2,3 +2,5 @@ source "http://rubygems.org"
2
2
 
3
3
  # Specify your gem's dependencies in ramon.gemspec
4
4
  gemspec
5
+
6
+ gem 'rails', :group => :test
data/lib/ramon/config.rb CHANGED
@@ -6,7 +6,7 @@ class ConfigurationException < StandardError; end
6
6
 
7
7
  class << self
8
8
  DEFAULTS = {
9
- :host => 'http://127.0.0.1',
9
+ :host => '127.0.0.1',
10
10
  :port => 2464
11
11
  }
12
12
 
@@ -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 '???'} #{RUBY_RELEASE_DATE rescue '????-??-??'} #{RUBY_PLATFORM 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
@@ -1,6 +1,6 @@
1
1
  module Ramon
2
2
  class Log
3
- def self.log(message, level)
3
+ def self.log(message, level=nil)
4
4
  level ||= 'notset'
5
5
  log = {"message" => message, "level" => level}
6
6
 
data/lib/ramon/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Ramon
2
- VERSION = "0.2.1"
2
+ VERSION = "0.3.0"
3
3
  end
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
@@ -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
File without changes
@@ -0,0 +1,5 @@
1
+ require 'rubygems'
2
+ require 'rspec'
3
+
4
+ $LOAD_PATH.unshift File.expand_path('../../lib')
5
+ require 'ramon'
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: 21
4
+ hash: 19
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
- - 2
9
- - 1
10
- version: 0.2.1
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-15 00:00:00 +00:00
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: []
data/init.rb DELETED
@@ -1,5 +0,0 @@
1
- require 'ramon'
2
-
3
- require File.join('amon', 'integration', 'rails')
4
-
5
- Rails.configuration.middleware.use "Rack::RailsAmonException"