delogger 0.1.3 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a4025911c0f40b910cdd1b90fe53902113639d16
4
- data.tar.gz: 1d744eb25a0eeab3623284c222f718192ac77703
3
+ metadata.gz: 9fbef0668a642331e5096b767f11653c6d5b2617
4
+ data.tar.gz: 8e01c55ea71d437d25e005cdaac787c7fc15b53b
5
5
  SHA512:
6
- metadata.gz: a303b39fa9c473dbbb96a8c68d5db8a7c618deab4709a30164758db5985b0f5be064fe0846855722b05d9fe4dc651e26522364f9b365f07f31ee75b82e20555f
7
- data.tar.gz: 30dddf9265a80db63e5ba9eecec4fcd0cf565e3c6d5c0609fe4e2ad379ca5f5b4459527e88634085bd90aa2a0c059e73d5ad4046f0daf410db378d4261568a0e
6
+ metadata.gz: 3f49acb8a053f32bac14bccbf7322aa7f6fa571091b79cdcbaa8d2e5054fbbe9d56a00b98bb225c884b3442304e4a246d48cf78e708d55811e9d8af8a634a334
7
+ data.tar.gz: 7ff26d70e023c4df3342dc0f56ebe61d12e468cadec4d03147081fb29bf3ebc4de6155dc8c29e05fc37e55635c650510443a50c9ed955c47c6dab7b786ca32cf
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: delogger
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alexander Komarov
@@ -66,26 +66,27 @@ dependencies:
66
66
  - - ">="
67
67
  - !ruby/object:Gem::Version
68
68
  version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: sass
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
69
83
  description: Format your browser console output with colors, badges and more
70
84
  email:
71
85
  - ak@akxcv.com
72
86
  executables: []
73
87
  extensions: []
74
88
  extra_rdoc_files: []
75
- files:
76
- - ".gitignore"
77
- - Gemfile
78
- - LICENSE.txt
79
- - README.md
80
- - assets/javascripts/delogger.coffee
81
- - bin/compile
82
- - delogger.gemspec
83
- - images/example.png
84
- - lib/delogger.rb
85
- - lib/delogger/rails.rb
86
- - lib/delogger/rails/engine.rb
87
- - lib/delogger/version.rb
88
- - vendor/assets/javascripts/delogger.js
89
+ files: []
89
90
  homepage: https://github.com/akxcv/delogger
90
91
  licenses:
91
92
  - MIT
data/.gitignore DELETED
@@ -1,9 +0,0 @@
1
- /.bundle/
2
- /.yardoc
3
- /Gemfile.lock
4
- /_yardoc/
5
- /coverage/
6
- /doc/
7
- /pkg/
8
- /spec/reports/
9
- /tmp/
data/Gemfile DELETED
@@ -1,3 +0,0 @@
1
- source 'https://rubygems.org'
2
-
3
- gemspec
data/LICENSE.txt DELETED
@@ -1,21 +0,0 @@
1
- The MIT License (MIT)
2
-
3
- Copyright (c) 2017 Alexander Komarov
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in
13
- all copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
- THE SOFTWARE.
data/README.md DELETED
@@ -1,61 +0,0 @@
1
- # Delogger
2
-
3
- This gem is a work in progress.
4
- TODO
5
-
6
- ## Installation
7
-
8
- Add this line to your application's Gemfile:
9
-
10
- ```ruby
11
- gem 'delogger'
12
- ```
13
-
14
- And then execute:
15
-
16
- $ bundle
17
-
18
- Or install it yourself as:
19
-
20
- $ gem install delogger
21
-
22
- ## Usage
23
-
24
- These methods work similarly to `console.log`, but they support [formatting](#formatting):
25
- - `DeLogger.debug`
26
- - `DeLogger.warn`
27
- - `DeLogger.error`
28
-
29
- By default, DeLogger is **disabled**. To enable it, use `DeLogger.enable()`. You can disable it again
30
- using `DeLogger.disable()`.
31
-
32
- ## Logging levels
33
-
34
- DeLogger has three logging levels: `debug`, `warn` and `error`. Level can be set using `DeLogger.level`
35
- (default is `debug`). (TODO)
36
-
37
- ## Formatting
38
-
39
- DeLogger supports string formatting. Syntax: `"(my text).class1.class2"`. Classes are specific for
40
- the logger and are not being fetched from stylesheets.
41
- Supported classes: `badge`, `debug`, `warn`, `error`, `bold`, `italic`.
42
- Example:
43
- ```js
44
- DeLogger.log("(MyClass#myMethod).badge", "(@akxcv).badge.warn", "(bold).bold", { foo: 'bar' })
45
- ```
46
- ![Example output](/images/example.png?raw=true)
47
-
48
- TODO
49
-
50
- ## Development
51
-
52
- TODO
53
-
54
- ## Contributing
55
-
56
- Bug reports and pull requests are welcome on GitHub at https://github.com/akxcv/delogger.
57
-
58
-
59
- ## License
60
-
61
- The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
@@ -1,93 +0,0 @@
1
- class @DeLogger
2
- @debug: (args...) ->
3
- print('debug', getStyle('badge', 'debug'), args...)
4
-
5
- @warn: (args...) ->
6
- print('warn', getStyle('badge', 'warn'), args...)
7
-
8
- @error: (args...) ->
9
- print('error', getStyle('badge', 'error'), args...)
10
-
11
- @enable: ->
12
- localStorage.setItem("deloggerEnabled", true)
13
-
14
- @disable: ->
15
- localStorage.removeItem("deloggerEnabled")
16
-
17
- @setLevel: (level) ->
18
- localStorage.setItem("deloggerLevel", level)
19
-
20
- # private
21
-
22
- print = (level, initialStyles, args...) ->
23
- return unless canPrint(level)
24
- text = "%c#{level}"
25
- styles = [initialStyles]
26
- formattedArgumentCount = 0
27
-
28
- for arg in args
29
- break unless typeof arg is 'string'
30
- [string, style] = parseString(arg)
31
- text += string
32
- styles.push(style)
33
- formattedArgumentCount += 1
34
-
35
- args.splice(0, formattedArgumentCount)
36
- console.log text, styles..., args...
37
-
38
- canPrint = (level) ->
39
- localStorage.deloggerEnabled? and availableLevels().indexOf(level) != -1
40
-
41
- availableLevels = ->
42
- switch localStorage.deloggerLevel
43
- when 'debug' then ['debug', 'warn', 'error']
44
- when 'warn' then ['warn', 'error']
45
- when 'error' then ['error']
46
- else ['debug', 'warn', 'error']
47
-
48
- parseString = (string) ->
49
- if match = string.match(/^\((.+)\)(\..+)$/)
50
- classes = match[2].split('.')
51
- css = getStyle(classes..., 'after')
52
- return ["%c#{match[1]}", css]
53
- ["%c#{string}", getStyle('default', 'after')]
54
-
55
- getStyle = (classes...) ->
56
- style = ''
57
- for klass in classes
58
- style += ("#{key}:#{value};" for key, value of styles()[klass]).join('')
59
- style
60
-
61
- styles = ->
62
- 'default': {},
63
-
64
- 'badge': {
65
- 'color': 'white',
66
- 'background': 'black',
67
- 'border-radius': '9px',
68
- 'padding': '1px 5px'
69
- },
70
-
71
- 'debug': {
72
- 'background': 'blue'
73
- },
74
-
75
- 'warn': {
76
- 'background': 'orange'
77
- },
78
-
79
- 'error': {
80
- 'background': 'red'
81
- },
82
-
83
- 'bold': {
84
- 'font-weight': 'bold'
85
- },
86
-
87
- 'italic': {
88
- 'font-style': 'italic'
89
- },
90
-
91
- 'after': {
92
- 'margin-left': '3px'
93
- }
data/bin/compile DELETED
@@ -1,12 +0,0 @@
1
- #!/usr/bin/env ruby
2
- require 'bundler/setup'
3
- Bundler.setup
4
-
5
- require 'coffee-script'
6
- require 'uglifier'
7
-
8
- IN_PATH = 'assets/javascripts/delogger.coffee'
9
- OUT_PATH = 'vendor/assets/javascripts/delogger.js'
10
-
11
- compiled_coffee = CoffeeScript.compile(File.read(IN_PATH))
12
- File.write OUT_PATH, Uglifier.compile(compiled_coffee)
data/delogger.gemspec DELETED
@@ -1,21 +0,0 @@
1
- # coding: utf-8
2
- lib = File.expand_path('../lib', __FILE__)
3
- $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
- require 'delogger/version'
5
-
6
- Gem::Specification.new do |spec|
7
- spec.name = "delogger"
8
- spec.version = DeLogger::VERSION
9
- spec.authors = ["Alexander Komarov"]
10
- spec.email = ["ak@akxcv.com"]
11
-
12
- spec.summary = %q{Pretty output for browser console}
13
- spec.description = %q{Format your browser console output with colors, badges and more}
14
- spec.homepage = "https://github.com/akxcv/delogger"
15
- spec.license = "MIT"
16
-
17
- spec.require_path = "lib"
18
- spec.files = `git ls-files`.split("\n")
19
-
20
- %w[bundler coffee-script coffee-script-source uglifier].each { |x| spec.add_development_dependency x }
21
- end
data/images/example.png DELETED
Binary file
data/lib/delogger.rb DELETED
@@ -1,7 +0,0 @@
1
- require "delogger/version"
2
- require "delogger/rails"
3
-
4
- module DeLogger
5
- class Engine < ::Rails::Engine
6
- end
7
- end
@@ -1,6 +0,0 @@
1
- require "delogger/rails/engine"
2
-
3
- module DeLogger
4
- module Rails
5
- end
6
- end
@@ -1,6 +0,0 @@
1
- module DeLogger
2
- module Rails
3
- class Engine < ::Rails::Engine
4
- end
5
- end
6
- end
@@ -1,3 +0,0 @@
1
- module DeLogger
2
- VERSION = "0.1.3"
3
- end
@@ -1 +0,0 @@
1
- (function(){var r=[].slice;this.DeLogger=function(){function e(){}var n,l,a,t,o,c;return e.debug=function(){var e;return e=1<=arguments.length?r.call(arguments,0):[],o.apply(null,["debug",a("badge","debug")].concat(r.call(e)))},e.warn=function(){var e;return e=1<=arguments.length?r.call(arguments,0):[],o.apply(null,["warn",a("badge","warn")].concat(r.call(e)))},e.error=function(){var e;return e=1<=arguments.length?r.call(arguments,0):[],o.apply(null,["error",a("badge","error")].concat(r.call(e)))},e.enable=function(){return localStorage.setItem("deloggerEnabled",!0)},e.disable=function(){return localStorage.removeItem("deloggerEnabled")},e.setLevel=function(r){return localStorage.setItem("deloggerLevel",r)},o=function(){var e,n,a,o,c,u,g,i,d,f,b,p;if(g=arguments[0],c=arguments[1],n=3<=arguments.length?r.call(arguments,2):[],l(g)){for(p="%c"+g,b=[c],a=0,o=0,u=n.length;o<u&&(e=n[o],"string"==typeof e);o++)i=t(e),d=i[0],f=i[1],p+=d,b.push(f),a+=1;return n.splice(0,a),console.log.apply(console,[p].concat(r.call(b),r.call(n)))}},l=function(r){return null!=localStorage.deloggerEnabled&&n().indexOf(r)!==-1},n=function(){switch(localStorage.deloggerLevel){case"debug":return["debug","warn","error"];case"warn":return["warn","error"];case"error":return["error"];default:return["debug","warn","error"]}},t=function(e){var n,l,t;return(t=e.match(/^\((.+)\)(\..+)$/))?(n=t[2].split("."),l=a.apply(null,r.call(n).concat(["after"])),["%c"+t[1],l]):["%c"+e,a("default","after")]},a=function(){var e,n,l,a,t,o,u;for(e=1<=arguments.length?r.call(arguments,0):[],o="",n=0,t=e.length;n<t;n++)a=e[n],o+=function(){var r,e;r=c()[a],e=[];for(l in r)u=r[l],e.push(l+":"+u+";");return e}().join("");return o},c=function(){return{"default":{},badge:{color:"white",background:"black","border-radius":"9px",padding:"1px 5px"},debug:{background:"blue"},warn:{background:"orange"},error:{background:"red"},bold:{"font-weight":"bold"},italic:{"font-style":"italic"},after:{"margin-left":"3px"}}},e}()}).call(this);