delogger 0.1.2 → 0.1.3

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: f152d06fad78d3eee0d34206fa1211f6f8178a99
4
- data.tar.gz: 5c0b64fcb95b0311bc4a4881d87c294441250a55
3
+ metadata.gz: a4025911c0f40b910cdd1b90fe53902113639d16
4
+ data.tar.gz: 1d744eb25a0eeab3623284c222f718192ac77703
5
5
  SHA512:
6
- metadata.gz: ec58169b8e4103751428bcf764c6c1c9d83ca7a110f4ec1754d1b8c41336e12e468568783b54548f95df8ac4f21b65a70d4e34bec74dfbc39a006909650011c6
7
- data.tar.gz: d70e06e1ff3e9097b00c577ebd91cf6a6224f93a1be0eb7a0bc04ed2b09cebb36706faf156ce5ad57b2909ebc9109f3b450ee7477c4f9ba46b38259942ca831b
6
+ metadata.gz: a303b39fa9c473dbbb96a8c68d5db8a7c618deab4709a30164758db5985b0f5be064fe0846855722b05d9fe4dc651e26522364f9b365f07f31ee75b82e20555f
7
+ data.tar.gz: 30dddf9265a80db63e5ba9eecec4fcd0cf565e3c6d5c0609fe4e2ad379ca5f5b4459527e88634085bd90aa2a0c059e73d5ad4046f0daf410db378d4261568a0e
@@ -0,0 +1,9 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec
data/README.md CHANGED
@@ -53,7 +53,7 @@ TODO
53
53
 
54
54
  ## Contributing
55
55
 
56
- Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/delogger.
56
+ Bug reports and pull requests are welcome on GitHub at https://github.com/akxcv/delogger.
57
57
 
58
58
 
59
59
  ## License
@@ -0,0 +1,93 @@
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
+ }
@@ -0,0 +1,12 @@
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)
@@ -0,0 +1,21 @@
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
Binary file
@@ -0,0 +1,7 @@
1
+ require "delogger/version"
2
+ require "delogger/rails"
3
+
4
+ module DeLogger
5
+ class Engine < ::Rails::Engine
6
+ end
7
+ end
@@ -0,0 +1,6 @@
1
+ require "delogger/rails/engine"
2
+
3
+ module DeLogger
4
+ module Rails
5
+ end
6
+ end
@@ -0,0 +1,6 @@
1
+ module DeLogger
2
+ module Rails
3
+ class Engine < ::Rails::Engine
4
+ end
5
+ end
6
+ end
@@ -0,0 +1,3 @@
1
+ module DeLogger
2
+ VERSION = "0.1.3"
3
+ end
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.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alexander Komarov
@@ -73,8 +73,18 @@ executables: []
73
73
  extensions: []
74
74
  extra_rdoc_files: []
75
75
  files:
76
+ - ".gitignore"
77
+ - Gemfile
76
78
  - LICENSE.txt
77
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
78
88
  - vendor/assets/javascripts/delogger.js
79
89
  homepage: https://github.com/akxcv/delogger
80
90
  licenses: