logger-jquery-rails 1.2.0.1
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.
- checksums.yaml +7 -0
- data/.gitignore +17 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +46 -0
- data/Rakefile +1 -0
- data/lib/logger-jquery-rails.rb +2 -0
- data/lib/logger-jquery-rails/engine.rb +6 -0
- data/lib/logger-jquery-rails/version.rb +12 -0
- data/logger-jquery-rails.gemspec +26 -0
- data/vendor/assets/javascripts/jquery.log.js +203 -0
- metadata +97 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 41c97b20150df1c5c858454c91fcf35273f650f8
|
4
|
+
data.tar.gz: 220a0948818edc5c877039b1f9e0e469ff182a5e
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 53dd6a5f03c0d59ce23bd6046173ec78b488fdd98e064ad512447800b145457283453a4398a7248c30091cd6615017638e6f8a94550696fbec415106bca5f97e
|
7
|
+
data.tar.gz: 9a0c9fe9f1cd68ef76796b92d50139a69175e7fe722131c98bdc1660d3c4f80a9fa17f432ba224300d1a54fde109e82cf3b3a24f271de948bd824b45b924e2d3
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2013 Doc Walker
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,46 @@
|
|
1
|
+
# logger-jquery-rails [](http://badge.fury.io/rb/logger-jquery-rails)
|
2
|
+
|
3
|
+
> Created by Doc Walker
|
4
|
+
|
5
|
+
Provides the `logger` jQuery plugin packaged for the Rails 3.1+ asset pipeline.
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
Add these lines to your application's Gemfile:
|
10
|
+
|
11
|
+
# logger jquery plugin packaged for the rails asset pipeline
|
12
|
+
gem 'logger-jquery-rails', '~> 1.2'
|
13
|
+
|
14
|
+
And then execute:
|
15
|
+
|
16
|
+
$ bundle
|
17
|
+
|
18
|
+
Or install it yourself as:
|
19
|
+
|
20
|
+
$ gem install logger-jquery-rails
|
21
|
+
|
22
|
+
Gem version notes:
|
23
|
+
|
24
|
+
- x.y.z version will track the `logger` plugin version;
|
25
|
+
- It may contain a suffix to differentiate versions of the gem based on the same `logger` plugin version;
|
26
|
+
|
27
|
+
## Usage
|
28
|
+
|
29
|
+
Add these lines to `app/assets/javascripts/application.js`
|
30
|
+
|
31
|
+
// provides logging facility for jQuery from gem 'logger-jquery-rails':
|
32
|
+
//= require jquery.log.js
|
33
|
+
|
34
|
+
## Contributing
|
35
|
+
|
36
|
+
1. Fork it
|
37
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
38
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
39
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
40
|
+
5. Create new Pull Request
|
41
|
+
|
42
|
+
## Acknowledgements
|
43
|
+
|
44
|
+
- [logger](https://github.com/ApmeM/jquery-logger) jQuery plugin
|
45
|
+
- [RailsCast #245](http://railscasts.com/episodes/245-new-gem-with-bundler) New Gem with Bundler -- inspiration
|
46
|
+
- [Gemify Assets for Rails](http://prioritized.net/blog/gemify-assets-for-rails/) -- guidance
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
@@ -0,0 +1,12 @@
|
|
1
|
+
module LoggerJquery
|
2
|
+
module Rails
|
3
|
+
# Use logger version; append a pre-release version identifier if gem
|
4
|
+
# is updated without updating version of logger.
|
5
|
+
# Examples:
|
6
|
+
# "2.0.0.rc1"
|
7
|
+
# "2.0.0.pre"
|
8
|
+
# "2.0.0.beta"
|
9
|
+
# Refer to Semantic Versioning 2.0.0 (http://semver.org).
|
10
|
+
VERSION = "1.2.0.1"
|
11
|
+
end
|
12
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'logger-jquery-rails/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "logger-jquery-rails"
|
8
|
+
spec.version = LoggerJquery::Rails::VERSION
|
9
|
+
spec.authors = ["Doc Walker"]
|
10
|
+
spec.email = ["doc.walker@jameshardie.com"]
|
11
|
+
spec.description = %q{logger jQuery plugin}
|
12
|
+
spec.summary = %q{logger packaged for the Rails 3.1+ asset pipeline.}
|
13
|
+
spec.homepage = "https://github.com/jhx/gem-logger-jquery-rails"
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files`.split($/)
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_dependency "railties", "~> 3.1"
|
22
|
+
spec.requirements << "jQuery"
|
23
|
+
|
24
|
+
spec.add_development_dependency "bundler", "~> 1.3"
|
25
|
+
spec.add_development_dependency "rake"
|
26
|
+
end
|
@@ -0,0 +1,203 @@
|
|
1
|
+
/**
|
2
|
+
* Extension for jQuery for log any data and objects into
|
3
|
+
* console.log, error console or specified HTML element
|
4
|
+
* (for example div).
|
5
|
+
* Created by Artem Votincev (apmem.org)
|
6
|
+
* Copyiright (c) 2011 Artem Votincev (apmem.org)
|
7
|
+
* Distributed under BSD license
|
8
|
+
*
|
9
|
+
* @requires jQuery.js
|
10
|
+
* @version 1.2
|
11
|
+
* @author artem
|
12
|
+
* @download https://github.com/ApmeM/jquery-logger
|
13
|
+
* @usage
|
14
|
+
* $.log({"name": "value", "test": "test"});
|
15
|
+
* $("#logDiv").log({"name": "value", "test": "test"});
|
16
|
+
*
|
17
|
+
* WARNING:
|
18
|
+
* Use $("#logDiv").log($(document)); only in ff and opera.
|
19
|
+
* Other browsers hang up on this large objects
|
20
|
+
*/
|
21
|
+
|
22
|
+
(function($){
|
23
|
+
|
24
|
+
/**
|
25
|
+
* global configuration for the whole plugin
|
26
|
+
*/
|
27
|
+
var config = {
|
28
|
+
// Logger can be disabled on production sites
|
29
|
+
loggerEnabled: true,
|
30
|
+
|
31
|
+
// Recursion behaviour trigger when object, that detected in current logging process is logged again.
|
32
|
+
// Possible values:
|
33
|
+
// * 'stop' - if recursion detected - show it as regular string and do not go deeper
|
34
|
+
// * 'skip' - if recursion detected - it will be expanded anyway until maxLevel level not reached
|
35
|
+
// be carefull if maxLevel is less then 0 and recursionBehaviour is set to 'skip' - iterations will never stopped and browser will hang up
|
36
|
+
recursionBehaviour: 'stop',
|
37
|
+
|
38
|
+
// Maximum iteration level (0 means no properties should be displayed). less then 0 means no maximum level is set (at least maxint level :) ).
|
39
|
+
maxLevel: -1,
|
40
|
+
|
41
|
+
// Default logger element will be used if $.log() is called. if element is null - browser console will be used.
|
42
|
+
defaultElement: null,
|
43
|
+
|
44
|
+
// Prefix for all properties to log into HTML elements.
|
45
|
+
prefix: 'args'
|
46
|
+
};
|
47
|
+
|
48
|
+
/**
|
49
|
+
* Configure logger with non-default parameters
|
50
|
+
* @param settings - new configuration settings
|
51
|
+
*/
|
52
|
+
$.logConfig = function(settings){
|
53
|
+
if (settings) $.extend(config, settings);
|
54
|
+
}
|
55
|
+
|
56
|
+
/**
|
57
|
+
* Constants used in code to view log in iappropriate format
|
58
|
+
* for error console it should be displayed as text
|
59
|
+
* for html controls it should be displayed as html
|
60
|
+
*/
|
61
|
+
var LOG_HTML = 1;
|
62
|
+
var LOG_TEXT = 2;
|
63
|
+
|
64
|
+
/**
|
65
|
+
* Print name-value pair into string with provided logType
|
66
|
+
* Replace html special chars to be sure we will not run script once again
|
67
|
+
*/
|
68
|
+
var logPrint = function(name, value, logType){
|
69
|
+
if(logType == 'html')
|
70
|
+
{
|
71
|
+
value = ("" + value).replace(/&/gi, '&').replace(/</gi, '<').replace(/>/gi, '>');
|
72
|
+
return "<b>" + name + "</b> = " + value + "<br />";
|
73
|
+
}
|
74
|
+
else if(logType == 'text')
|
75
|
+
return name + " = " + value + "\n";
|
76
|
+
else
|
77
|
+
throw new Error('Index out of range exception: logType = ', logType);
|
78
|
+
}
|
79
|
+
|
80
|
+
/**
|
81
|
+
* Recursive function that check all properties and display
|
82
|
+
* them in specified format
|
83
|
+
* @param obj is object to display
|
84
|
+
* @param objName is text representation of the object
|
85
|
+
* @param curLevel show current recursion level. If it become 0 - recursion vill be stopped.
|
86
|
+
* @throw index out of range exception (logType is not supplied)
|
87
|
+
* @return string with all properies of provided object
|
88
|
+
* @private
|
89
|
+
*/
|
90
|
+
var logExpand = function(obj, objName, curLevel, currentConfig){
|
91
|
+
var result = "";
|
92
|
+
// We have reached the top level
|
93
|
+
// Or recursion detected and should be stopped
|
94
|
+
if
|
95
|
+
(
|
96
|
+
curLevel == 0 ||
|
97
|
+
(
|
98
|
+
$.inArray(obj, currentConfig.visitedObjs) != -1 &&
|
99
|
+
currentConfig.recursionBehaviour == 'stop'
|
100
|
+
)
|
101
|
+
)
|
102
|
+
{
|
103
|
+
return logPrint(objName, obj, currentConfig.logType);
|
104
|
+
}
|
105
|
+
|
106
|
+
currentConfig.visitedObjs.push(obj);
|
107
|
+
|
108
|
+
// Check all properties of the current object
|
109
|
+
for (var i in obj) {
|
110
|
+
var objVal = obj[i];
|
111
|
+
if(
|
112
|
+
// We need to log all objects
|
113
|
+
// except nsXPCComponent (it will throw permission denied error)
|
114
|
+
typeof(objVal) == 'object' &&
|
115
|
+
Object.prototype.toString.call(objVal) != '[object nsXPCComponents]'
|
116
|
+
){
|
117
|
+
try {
|
118
|
+
result += logExpand(objVal, objName + '.' + i, curLevel - 1, currentConfig);
|
119
|
+
} catch(e){
|
120
|
+
result += logPrint(objName + "." + i, objVal + " " + e, currentConfig.logType);
|
121
|
+
}
|
122
|
+
} else{
|
123
|
+
// If this is not an object - just show its value
|
124
|
+
result += logPrint(objName + "." + i, objVal, currentConfig.logType);
|
125
|
+
}
|
126
|
+
}
|
127
|
+
return result;
|
128
|
+
}
|
129
|
+
|
130
|
+
var logConsole = function(obj, currentConfig) {
|
131
|
+
// If we can write into console - we will do it:
|
132
|
+
// firefox (with firebug), chrome and opera know what to do with it
|
133
|
+
if(window.console && window.console.log) {
|
134
|
+
if(window.console.log.apply) {
|
135
|
+
console.log.apply(window.console, obj);
|
136
|
+
} else {
|
137
|
+
console.log(obj);
|
138
|
+
}
|
139
|
+
} else {
|
140
|
+
// Firebug is not installed (or this browser do not support console)
|
141
|
+
// expand object and throw an error to log it into error log
|
142
|
+
$.extend(currentConfig, {logType: 'text', visitedObjs: []});
|
143
|
+
var expanded = logExpand(obj, currentConfig.prefix, currentConfig.maxLevel, currentConfig);
|
144
|
+
throw new Error(expanded);
|
145
|
+
}
|
146
|
+
}
|
147
|
+
/**
|
148
|
+
* main logging function
|
149
|
+
*/
|
150
|
+
var log = function(element, arg){
|
151
|
+
if (!config.loggerEnabled)
|
152
|
+
return true;
|
153
|
+
|
154
|
+
// Going to log into the specified control
|
155
|
+
if(arg.length == 0) // Nothing to log, everything logged successfully :)
|
156
|
+
return true;
|
157
|
+
|
158
|
+
if (element == null){
|
159
|
+
element = config.defaultElement;
|
160
|
+
}
|
161
|
+
|
162
|
+
var currentConfig = {};
|
163
|
+
$.extend(currentConfig, config);
|
164
|
+
|
165
|
+
|
166
|
+
// Make logging in separate thread to not stop main thread if something fail.
|
167
|
+
setTimeout(function(){
|
168
|
+
// Splice arguments object into array of objects
|
169
|
+
// (it have a very strange behavior)
|
170
|
+
var obj = [].slice.call(arg);
|
171
|
+
|
172
|
+
// No element set, and default element is not set eather
|
173
|
+
// Will log into the browser console
|
174
|
+
if (element == null){
|
175
|
+
logConsole(obj);
|
176
|
+
}
|
177
|
+
|
178
|
+
$.extend(currentConfig, {logType: 'html', visitedObjs: []});
|
179
|
+
var text = logExpand(obj, currentConfig.prefix, currentConfig.maxLevel, currentConfig);
|
180
|
+
$(element).html($(element).html() + "<hr>" + text);
|
181
|
+
}, 0);
|
182
|
+
}
|
183
|
+
|
184
|
+
/**
|
185
|
+
* jQuery extension $.log print all arguments of the function into window.console
|
186
|
+
* or if it is not exist - to error console with the help of throw Error in separate thread.
|
187
|
+
* @member $
|
188
|
+
*/
|
189
|
+
$.log = function(){
|
190
|
+
log(null, arguments);
|
191
|
+
return true;
|
192
|
+
};
|
193
|
+
|
194
|
+
/**
|
195
|
+
* jQuery extension $.fn.log print all arguments of the function into the html object
|
196
|
+
* @member $
|
197
|
+
*/
|
198
|
+
$.fn.log = function() {
|
199
|
+
log(this, arguments);
|
200
|
+
return true;
|
201
|
+
}
|
202
|
+
})(jQuery);
|
203
|
+
|
metadata
ADDED
@@ -0,0 +1,97 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: logger-jquery-rails
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.2.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Doc Walker
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2013-07-28 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: railties
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ~>
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '3.1'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ~>
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '3.1'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: bundler
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ~>
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1.3'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ~>
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.3'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rake
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ! '>='
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ! '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
description: logger jQuery plugin
|
56
|
+
email:
|
57
|
+
- doc.walker@jameshardie.com
|
58
|
+
executables: []
|
59
|
+
extensions: []
|
60
|
+
extra_rdoc_files: []
|
61
|
+
files:
|
62
|
+
- .gitignore
|
63
|
+
- Gemfile
|
64
|
+
- LICENSE.txt
|
65
|
+
- README.md
|
66
|
+
- Rakefile
|
67
|
+
- lib/logger-jquery-rails.rb
|
68
|
+
- lib/logger-jquery-rails/engine.rb
|
69
|
+
- lib/logger-jquery-rails/version.rb
|
70
|
+
- logger-jquery-rails.gemspec
|
71
|
+
- vendor/assets/javascripts/jquery.log.js
|
72
|
+
homepage: https://github.com/jhx/gem-logger-jquery-rails
|
73
|
+
licenses:
|
74
|
+
- MIT
|
75
|
+
metadata: {}
|
76
|
+
post_install_message:
|
77
|
+
rdoc_options: []
|
78
|
+
require_paths:
|
79
|
+
- lib
|
80
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
81
|
+
requirements:
|
82
|
+
- - ! '>='
|
83
|
+
- !ruby/object:Gem::Version
|
84
|
+
version: '0'
|
85
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ! '>='
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
requirements:
|
91
|
+
- jQuery
|
92
|
+
rubyforge_project:
|
93
|
+
rubygems_version: 2.0.3
|
94
|
+
signing_key:
|
95
|
+
specification_version: 4
|
96
|
+
summary: logger packaged for the Rails 3.1+ asset pipeline.
|
97
|
+
test_files: []
|