rails-firephp 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/ChangeLog ADDED
@@ -0,0 +1,3 @@
1
+ 0.0.1 (12.09.2008):
2
+ - Initial Version
3
+
data/MIT-LICENSE ADDED
@@ -0,0 +1,43 @@
1
+ #--
2
+ # Copyright (c) 2008 Stephan Toggweiler
3
+ #
4
+ # Permission is hereby granted, free of charge, to any person obtaining
5
+ # a copy of this software and associated documentation files (the
6
+ # "Software"), to deal in the Software without restriction, including
7
+ # without limitation the rights to use, copy, modify, merge, publish,
8
+ # distribute, sublicense, and/or sell copies of the Software, and to
9
+ # permit persons to whom the Software is furnished to do so, subject to
10
+ # the following conditions:
11
+ #
12
+ # The above copyright notice and this permission notice shall be
13
+ # included in all copies or substantial portions of the Software.
14
+ #
15
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16
+ # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17
+ # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18
+ # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
19
+ # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
20
+ # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
21
+ # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22
+ #++
23
+
24
+ Copyright (c) 2005-06 Stephan Toggweiler
25
+
26
+ Permission is hereby granted, free of charge, to any person obtaining
27
+ a copy of this software and associated documentation files (the
28
+ "Software"), to deal in the Software without restriction, including
29
+ without limitation the rights to use, copy, modify, merge, publish,
30
+ distribute, sublicense, and/or sell copies of the Software, and to
31
+ permit persons to whom the Software is furnished to do so, subject to
32
+ the following conditions:
33
+
34
+ The above copyright notice and this permission notice shall be
35
+ included in all copies or substantial portions of the Software.
36
+
37
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
38
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
39
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
40
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
41
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
42
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
43
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README ADDED
@@ -0,0 +1,38 @@
1
+ #####################
2
+ FirePHP for Rails
3
+ #####################
4
+
5
+ FirePHP for Rails can be used for easy print out some variables with Rails and Passenger
6
+ without visiting the log-files.
7
+
8
+ Requirements:
9
+ - Ruby (Tested 1.8.6)
10
+ - Rails (Tested 2.1.1)
11
+ - Mozilla Firefox (Tested 3.0.1)
12
+ - Firebug (http://getfirebug.com/)
13
+ - FirePHP (http://www.firephp.org/)
14
+
15
+ Installing:
16
+ $ (sudo) gem install rails-firephp
17
+
18
+ Setup:
19
+ add the following line in config/environement.rb (somewere by the other config.gem's):
20
+
21
+ config.gem "rails-firephp", :lib => "firephp/firephp_filter"
22
+
23
+ add an after_filter in app/controllers/application.rb:
24
+
25
+ after_filter :firephp_filter
26
+
27
+ Using:
28
+ the following commands can now be used:
29
+
30
+ firephp_headers :
31
+ sends the header variables to FirePHP
32
+
33
+ firephp_params :
34
+ send the params to FirePHP
35
+
36
+ firephp(text|obj,"WARN"|"INFO"|"ERROR"|Default:"LOG") :
37
+ send the text or the obj to FirePHP
38
+
@@ -0,0 +1,54 @@
1
+ module ActionController
2
+ class Base
3
+
4
+ private
5
+ def firephp(_obj, _type="LOG")
6
+ @firephp||={}
7
+ _type.upcase!
8
+ _type="LOG" if !(_type=~/^(INFO|WARN|ERROR)$/)
9
+ @firephp[_type]||=[]
10
+ @firephp[_type]<<_obj
11
+ end
12
+
13
+ def firephp_params
14
+ @firephp["params"]=true
15
+ end
16
+
17
+ def firephp_headers
18
+ @firephp["headers"]=true
19
+ end
20
+
21
+ def firephp_filter
22
+ #-Add headers only when browser has FirePHP-Plugin
23
+ return if !(request.headers["HTTP_USER_AGENT"]=~/FirePHP\//)
24
+ return if @firephp.blank?
25
+
26
+ headers["X-FirePHP-Data-100000000001"]='{'
27
+ headers["X-FirePHP-Data-200000000001"]='"FirePHP.Dump":{'
28
+ headers["X-FirePHP-Data-200000000002"]="\"RailsVersion\":\"#{RAILS_GEM_VERSION}\","
29
+ headers["X-FirePHP-Data-299999999999"]='"__SKIP__":"__SKIP__"},'
30
+ headers["X-FirePHP-Data-300000000001"]='"FirePHP.Firebug.Console":['
31
+ count=2
32
+ @firephp.each do |type, arr|
33
+ next if !(type=~/^(LOG|INFO|WARN|ERROR)$/)
34
+ arr.each do |a|
35
+ headers["X-FirePHP-Data-3#{sprintf("%011d", count)}"]="[\"#{type}\",#{a.to_json}],"
36
+ count+=1
37
+ end
38
+ end
39
+ #headers["X-FirePHP-Data-3#{sprintf("%011d", count)}"]="[\"INFO\",#{["RailsFirebug",@firephp].to_json}],"
40
+ #count+=1
41
+ if !@firephp["params"].blank?
42
+ headers["X-FirePHP-Data-3#{sprintf("%011d", count)}"]="[\"INFO\",#{["RailsParams",params].to_json}],"
43
+ count+=1
44
+ end
45
+ if !@firephp["headers"].blank?
46
+ headers["X-FirePHP-Data-3#{sprintf("%011d", count)}"]="[\"INFO\",#{["RailsHeaders",request.headers].to_json}],"
47
+ count+=1
48
+ end
49
+ headers["X-FirePHP-Data-399999999999"]='["__SKIP__"]],'
50
+ headers["X-FirePHP-Data-999999999999"]='"__SKIP__":"__SKIP__"}'
51
+ end
52
+
53
+ end
54
+ end
metadata ADDED
@@ -0,0 +1,59 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: rails-firephp
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Stephan Toggweiler
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2008-09-18 00:00:00 +02:00
13
+ default_executable:
14
+ dependencies: []
15
+
16
+ description:
17
+ email: railspki at rheoli.net
18
+ executables: []
19
+
20
+ extensions: []
21
+
22
+ extra_rdoc_files:
23
+ - README
24
+ - ChangeLog
25
+ - MIT-LICENSE
26
+ files:
27
+ - lib/firephp
28
+ - lib/firephp/firephp_filter.rb
29
+ - README
30
+ - ChangeLog
31
+ - MIT-LICENSE
32
+ has_rdoc: true
33
+ homepage: http://rubyforge.org/projects/rails-firephp
34
+ post_install_message:
35
+ rdoc_options: []
36
+
37
+ require_paths:
38
+ - lib
39
+ required_ruby_version: !ruby/object:Gem::Requirement
40
+ requirements:
41
+ - - ">="
42
+ - !ruby/object:Gem::Version
43
+ version: "0"
44
+ version:
45
+ required_rubygems_version: !ruby/object:Gem::Requirement
46
+ requirements:
47
+ - - ">="
48
+ - !ruby/object:Gem::Version
49
+ version: "0"
50
+ version:
51
+ requirements: []
52
+
53
+ rubyforge_project:
54
+ rubygems_version: 1.2.0
55
+ signing_key:
56
+ specification_version: 2
57
+ summary: Rails plugin to send messages to FirePHP (plugin of FireBug)
58
+ test_files: []
59
+