byebug-color-printer 0.1.0
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 +9 -0
- data/Gemfile +3 -0
- data/LICENSE.txt +21 -0
- data/README.md +33 -0
- data/Rakefile +8 -0
- data/bin/console +7 -0
- data/bin/setup +7 -0
- data/byebug-color-printer.gemspec +26 -0
- data/lib/byebug-color-printer.rb +6 -0
- data/lib/byebug-color-printer/base.rb +23 -0
- data/lib/byebug-color-printer/colorizer.rb +32 -0
- data/lib/byebug-color-printer/colorizers/frame_line_colorizer.rb +15 -0
- data/lib/byebug-color-printer/version.rb +3 -0
- data/lib/byebug/printers/color.rb +13 -0
- metadata +114 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 6b1528ff9e03a570fda7a262083724972a6fdc9b
|
4
|
+
data.tar.gz: 6858e00bccfe794b711203917158f95b621ce01a
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: c94ac3126aff3b606585ebdcb35efa326c396b2b327dd1e11fd57d610571989fff8f7a005544b8ed3acc3df87ecb3c0198162227ec5b0771e56db8ed68847848
|
7
|
+
data.tar.gz: d55168c82662cd7b5ca052ff754c00c5634d3fd9a810ea9abba5f902acd889c8874061061c69e871fa50e601089009c767697be7450e7f0a82f5729e15c3788c
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2015 Ahmad Sherif
|
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
ADDED
@@ -0,0 +1,33 @@
|
|
1
|
+
# Byebug-Color-Printer
|
2
|
+
|
3
|
+
Colorizes some of Byebug output for ease of readability. Right now, only the backtrace is colorized, but there's room for other stuff to be colorized.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile then you're all set:
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
gem 'byebug-color-printer'
|
11
|
+
```
|
12
|
+
|
13
|
+
And then execute:
|
14
|
+
|
15
|
+
$ bundle
|
16
|
+
|
17
|
+
Or install it yourself as:
|
18
|
+
|
19
|
+
$ gem install byebug-color-printer
|
20
|
+
|
21
|
+
## Development
|
22
|
+
|
23
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `bin/console` for an interactive prompt that will allow you to experiment.
|
24
|
+
|
25
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release` to create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
26
|
+
|
27
|
+
## Contributing
|
28
|
+
|
29
|
+
1. Fork it ( https://github.com/[my-github-username]/byebug-color-printer/fork )
|
30
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
31
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
32
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
33
|
+
5. Create a new Pull Request
|
data/Rakefile
ADDED
data/bin/console
ADDED
data/bin/setup
ADDED
@@ -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 'byebug-color-printer/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "byebug-color-printer"
|
8
|
+
spec.version = ByebugColorPrinter::VERSION
|
9
|
+
spec.authors = ['Ahmad Sherif']
|
10
|
+
spec.email = ['me@ahmadsherif.com']
|
11
|
+
|
12
|
+
spec.summary = %q{Colorize some Byebug output}
|
13
|
+
spec.homepage = 'https://github.com/ahmadsherif/byebug-color-printer'
|
14
|
+
spec.license = 'MIT'
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
17
|
+
spec.bindir = 'exe'
|
18
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
19
|
+
spec.require_paths = ['lib']
|
20
|
+
|
21
|
+
spec.add_runtime_dependency 'byebug', '~> 4.0'
|
22
|
+
|
23
|
+
spec.add_development_dependency 'bundler', '~> 1.8'
|
24
|
+
spec.add_development_dependency 'minitest'
|
25
|
+
spec.add_development_dependency 'rake', '~> 10.0'
|
26
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
module ByebugColorPrinter
|
2
|
+
class Base
|
3
|
+
@@colorizers = {}
|
4
|
+
|
5
|
+
def self.register_colorizer(path, colorizer)
|
6
|
+
raise ArgumentError.new('colorizer must be an instance of a Colorizer child') unless colorizer.is_a?(Colorizer)
|
7
|
+
|
8
|
+
@@colorizers[path] = colorizer
|
9
|
+
end
|
10
|
+
|
11
|
+
def self.fetch_colorizer(path)
|
12
|
+
@@colorizers[path]
|
13
|
+
end
|
14
|
+
|
15
|
+
def self.apply_colorizer(path, args, &block)
|
16
|
+
colorizer = @@colorizers[path]
|
17
|
+
|
18
|
+
return yield args unless colorizer
|
19
|
+
|
20
|
+
colorizer.colorize(args, &block)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
module ByebugColorPrinter
|
2
|
+
class Colorizer
|
3
|
+
CLEAR = "\e[0m"
|
4
|
+
GREEN = "\e[32m"
|
5
|
+
WHITE = "\e[37m"
|
6
|
+
|
7
|
+
def colorize(args, &block)
|
8
|
+
yield args
|
9
|
+
end
|
10
|
+
|
11
|
+
private
|
12
|
+
|
13
|
+
# Both #set_color and #lookup_color are copied from thor gem,
|
14
|
+
# slightly modified, though
|
15
|
+
def set_color(string, *colors)
|
16
|
+
if colors.compact.empty?
|
17
|
+
string
|
18
|
+
elsif colors.all? { |color| color.is_a?(Symbol) }
|
19
|
+
ansi_colors = colors.map { |color| lookup_color(color) }
|
20
|
+
"#{ansi_colors.join}#{string}#{CLEAR}"
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
def lookup_color(color)
|
25
|
+
return color unless color.is_a?(Symbol)
|
26
|
+
|
27
|
+
self.class.const_get(color.to_s.upcase)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
Dir["#{File.dirname(__FILE__)}/colorizers/*.rb"].each { |f| require f }
|
@@ -0,0 +1,15 @@
|
|
1
|
+
module ByebugColorPrinter
|
2
|
+
module Colorizers
|
3
|
+
class FrameLineColorizer < Colorizer
|
4
|
+
def colorize(args, &block)
|
5
|
+
translated_args = yield args
|
6
|
+
|
7
|
+
color = args[:pos].to_i.even? ? :white : :green
|
8
|
+
|
9
|
+
set_color(translated_args, color)
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
Base.register_colorizer('frame.line', Colorizers::FrameLineColorizer.new)
|
15
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
require 'byebug/printers/plain'
|
2
|
+
|
3
|
+
module Byebug
|
4
|
+
module Printers
|
5
|
+
class Color < Plain
|
6
|
+
def print(path, args = {})
|
7
|
+
ByebugColorPrinter::Base.apply_colorizer(path, args) do |processed_args|
|
8
|
+
super(path, processed_args)
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
metadata
ADDED
@@ -0,0 +1,114 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: byebug-color-printer
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Ahmad Sherif
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-03-13 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: byebug
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '4.0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '4.0'
|
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.8'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.8'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: minitest
|
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
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rake
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '10.0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '10.0'
|
69
|
+
description:
|
70
|
+
email:
|
71
|
+
- me@ahmadsherif.com
|
72
|
+
executables: []
|
73
|
+
extensions: []
|
74
|
+
extra_rdoc_files: []
|
75
|
+
files:
|
76
|
+
- ".gitignore"
|
77
|
+
- Gemfile
|
78
|
+
- LICENSE.txt
|
79
|
+
- README.md
|
80
|
+
- Rakefile
|
81
|
+
- bin/console
|
82
|
+
- bin/setup
|
83
|
+
- byebug-color-printer.gemspec
|
84
|
+
- lib/byebug-color-printer.rb
|
85
|
+
- lib/byebug-color-printer/base.rb
|
86
|
+
- lib/byebug-color-printer/colorizer.rb
|
87
|
+
- lib/byebug-color-printer/colorizers/frame_line_colorizer.rb
|
88
|
+
- lib/byebug-color-printer/version.rb
|
89
|
+
- lib/byebug/printers/color.rb
|
90
|
+
homepage: https://github.com/ahmadsherif/byebug-color-printer
|
91
|
+
licenses:
|
92
|
+
- MIT
|
93
|
+
metadata: {}
|
94
|
+
post_install_message:
|
95
|
+
rdoc_options: []
|
96
|
+
require_paths:
|
97
|
+
- lib
|
98
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
99
|
+
requirements:
|
100
|
+
- - ">="
|
101
|
+
- !ruby/object:Gem::Version
|
102
|
+
version: '0'
|
103
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
104
|
+
requirements:
|
105
|
+
- - ">="
|
106
|
+
- !ruby/object:Gem::Version
|
107
|
+
version: '0'
|
108
|
+
requirements: []
|
109
|
+
rubyforge_project:
|
110
|
+
rubygems_version: 2.4.6
|
111
|
+
signing_key:
|
112
|
+
specification_version: 4
|
113
|
+
summary: Colorize some Byebug output
|
114
|
+
test_files: []
|