monitr-rails 1.2.1

Sign up to get free protection for your applications and to get access to all the features.
data/LICENSE.txt ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2011 Mark Brassard
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,25 @@
1
+ == Welcome to monitr-rails
2
+
3
+ monitr-rails is a rails logging program.
4
+
5
+ == Copyright
6
+
7
+ Copyright (c) 2011 Mark Brassard. See LICENSE.txt for
8
+ further details.
9
+
10
+ monitr-rails is a rails logging program.
11
+
12
+ == Version 1.2.0
13
+ Changed the fields that get passed in to monitr.
14
+
15
+ == Download
16
+
17
+ * gem install monitr-rails
18
+
19
+ === Usage
20
+
21
+ * require 'monitr-rails'
22
+
23
+ == Authors
24
+ * Mark Brassard (mailto:mark@kontexto.com)
25
+ * Rick VanWell (mailto:rick@kontexto.com)
data/Rakefile ADDED
@@ -0,0 +1,8 @@
1
+ require 'rake/testtask'
2
+
3
+ Rake::TestTask.new do |t|
4
+ t.libs << 'test'
5
+ end
6
+
7
+ desc "Run tests"
8
+ task :default => :test
@@ -0,0 +1,45 @@
1
+ require "open-uri"
2
+ require "cgi"
3
+
4
+ class Monitr
5
+
6
+ def initialize(account_id)
7
+ @account_id = account_id
8
+ @monitr_request_start = Time.now.to_f
9
+ end
10
+
11
+ def log(controller, params = {})
12
+ env_fields = %W( HTTP_USER_AGENT REQUEST_PATH CONTROLLER_NAME PATH_INFO REMOTE_ADDR ACCOUNT_ID REQUEST_PROCESS_TIME REQUEST_URI)
13
+ env_fields.each do |label|
14
+ params[label] = controller.request.env[label]
15
+ end
16
+
17
+ if @monitr_request_start
18
+ params["REQUEST_PROCESS_TIME"] = Time.now.to_f - @monitr_request_start
19
+ end
20
+
21
+ params["CONTROLLER_NAME"] = controller.controller_name
22
+ params["ACTION_NAME"] = controller.action_name
23
+ params["ACCOUNT_ID"] = @account_id
24
+
25
+ begin
26
+ params = data_to_cgi(params)
27
+ url = "http://monitr/cgi-bin/monitr?" + params
28
+ fp = open(url)
29
+ data = fp.read
30
+ fp.close
31
+ rescue
32
+ end
33
+ end
34
+
35
+ private
36
+
37
+ def data_to_cgi(data)
38
+ params = ""
39
+ data.each do |label, value|
40
+ params += "#{CGI.escape(label.to_s)}=#{CGI.escape(value.to_s)}&"
41
+ end
42
+ params
43
+ end
44
+
45
+ end
@@ -0,0 +1,21 @@
1
+ require 'test/unit'
2
+ require 'monitr-rails'
3
+
4
+ class MonitrRailsTest < Test::Unit::TestCase
5
+ def test_monitr_connectivity
6
+ assert_equal "nack\n",
7
+ connect_to_monitr
8
+ end
9
+
10
+ def connect_to_monitr
11
+ begin
12
+ url = "http://events.monitr.com/cgi-bin/monitr"
13
+ fp = open(url)
14
+ data = fp.read
15
+ fp.close
16
+ rescue
17
+ end
18
+
19
+ return data
20
+ end
21
+ end
metadata ADDED
@@ -0,0 +1,60 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: monitr-rails
3
+ version: !ruby/object:Gem::Version
4
+ prerelease:
5
+ version: 1.2.1
6
+ platform: ruby
7
+ authors:
8
+ - Mark Brassard
9
+ - Rick VanWell
10
+ autorequire:
11
+ bindir: bin
12
+ cert_chain: []
13
+
14
+ date: 2011-08-11 00:00:00 Z
15
+ dependencies: []
16
+
17
+ description: monitr-rails will allow you to monitor your Rails apps. By adding the gem to your Rails apps, you can see who is using a specific controller or method and track analytics for them as well.
18
+ email: mark@kontexto.com
19
+ executables: []
20
+
21
+ extensions: []
22
+
23
+ extra_rdoc_files:
24
+ - LICENSE.txt
25
+ - README.rdoc
26
+ files:
27
+ - LICENSE.txt
28
+ - README.rdoc
29
+ - Rakefile
30
+ - lib/monitr-rails.rb
31
+ - test/test_monitr-rails.rb
32
+ homepage: http://kontexto.com
33
+ licenses:
34
+ - MIT
35
+ post_install_message:
36
+ rdoc_options: []
37
+
38
+ require_paths:
39
+ - lib
40
+ required_ruby_version: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ">="
44
+ - !ruby/object:Gem::Version
45
+ version: "0"
46
+ required_rubygems_version: !ruby/object:Gem::Requirement
47
+ none: false
48
+ requirements:
49
+ - - ">="
50
+ - !ruby/object:Gem::Version
51
+ version: "0"
52
+ requirements: []
53
+
54
+ rubyforge_project:
55
+ rubygems_version: 1.8.5
56
+ signing_key:
57
+ specification_version: 3
58
+ summary: Monitor your Rails apps
59
+ test_files: []
60
+