console.log 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +31 -21
- data/console.log.gemspec +1 -1
- data/lib/console.log/core_ext.rb +8 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: abbc34ca5d758827282059135a30646b65cbb984
|
4
|
+
data.tar.gz: 2c0b8f5ed9c23e255ca67855b391ccf5378d2c37
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a61786517d3769a7cc2057ea896368c04594d070a93d188806ad915fb7215beb6bdc7a2f6e017c2ab3291d54a739ca51fcc777c50abcf2da83eb627d17d3f4cd
|
7
|
+
data.tar.gz: 2599adc2194f1bf35fc7f7893dba60b7a7be49fff42374062dd83f33c2b30cf8d05eebd9b992ebf31065afe2344d131a58ecdb52ba72683c1a98fc4e6c9ac54a
|
data/README.md
CHANGED
@@ -1,37 +1,38 @@
|
|
1
|
-
The `console.log` gem allows you to
|
1
|
+
The `console.log` gem allows you to log to the Javascript console from ruby/rails apps.
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
3
|
+
## Usage
|
4
|
+
|
5
|
+
1. Call `console.log` in rails.
|
6
|
+
|
7
|
+
```ruby
|
8
|
+
def load_user
|
9
|
+
user = User.where(email: 'foo@bar.com')
|
10
|
+
console.log "User: ", user
|
11
|
+
user
|
12
|
+
end
|
13
|
+
```
|
14
|
+
|
15
|
+
2. Open your browser's developer console.
|
16
|
+
|
17
|
+
![Screen shot](http://i.imgur.com/QJjjmjf.png)
|
18
|
+
|
19
|
+
3. (optional) Scream with delight!
|
8
20
|
|
9
21
|
## Installation
|
10
22
|
|
11
23
|
1. Add `gem "console.log"` to your Gemfile.
|
24
|
+
|
12
25
|
```ruby
|
13
26
|
gem "console.log" # makes console.log available in ruby
|
14
27
|
```
|
28
|
+
|
15
29
|
2. Bundle install
|
30
|
+
|
16
31
|
```shell
|
17
32
|
bundle install
|
18
33
|
```
|
19
34
|
|
20
|
-
##
|
21
|
-
|
22
|
-
In rails you can now use console.log for debugging. This means you don't need
|
23
|
-
to have the rails logs open (which is hard with servers like Pow), because log
|
24
|
-
messages will go to your browser console.
|
25
|
-
|
26
|
-
```ruby
|
27
|
-
def load_user
|
28
|
-
user = User.where(email: 'foo@bar.com')
|
29
|
-
console.log user
|
30
|
-
user
|
31
|
-
end
|
32
|
-
```
|
33
|
-
|
34
|
-
![Screen shot](http://i.imgur.com/QJjjmjf.png)
|
35
|
+
## Reference
|
35
36
|
|
36
37
|
### `console.log`
|
37
38
|
|
@@ -47,6 +48,15 @@ If you want a little yellow triangle beside your message, call `console.warn` in
|
|
47
48
|
|
48
49
|
If you want your text to be bright red, call `console.error` instead of `console.log`.
|
49
50
|
|
51
|
+
## Why??
|
52
|
+
|
53
|
+
I wrote it to solve 2 problems:
|
54
|
+
|
55
|
+
1. It's hard to use rails logs for debugging because they're noisy, or (if you use something like pow)
|
56
|
+
completely hidden. Using `console.log` lets you easily see only log messages in this request.
|
57
|
+
1. When working on the js for [Bugsnag](https://bugsnag.com/) I kept accidentally typing `console.log`
|
58
|
+
into Rails. Now that works!
|
59
|
+
|
50
60
|
## License
|
51
61
|
|
52
62
|
`console.log` is licensed under the MIT license, see LICENSE.MIT for details.
|
data/console.log.gemspec
CHANGED
data/lib/console.log/core_ext.rb
CHANGED
@@ -1,7 +1,13 @@
|
|
1
1
|
module ConsoleLog
|
2
2
|
module CoreExt
|
3
|
-
|
4
|
-
|
3
|
+
# This is a method_missing because `be rails c` does
|
4
|
+
# wierd stuff with console methods.
|
5
|
+
def method_missing(name)
|
6
|
+
if name.to_s == "console"
|
7
|
+
LSpace[:console] ||= Console.new
|
8
|
+
else
|
9
|
+
super
|
10
|
+
end
|
5
11
|
end
|
6
12
|
end
|
7
13
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: console.log
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Conrad Irwin
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-09-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: lspace
|