readable_message 0.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.
- data/.gitignore +21 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +42 -0
- data/Rakefile +1 -0
- data/lib/readable_message/version.rb +3 -0
- data/lib/readable_message.rb +50 -0
- data/readable_message.gemspec +19 -0
- data/spec/readable_message_spec.rb +8 -0
- data/spec/spec_helper.rb +9 -0
- metadata +57 -0
data/.gitignore
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
*.gem
|
|
2
|
+
*.rbc
|
|
3
|
+
.bundle
|
|
4
|
+
.config
|
|
5
|
+
.yardoc
|
|
6
|
+
Gemfile.lock
|
|
7
|
+
InstalledFiles
|
|
8
|
+
_yardoc
|
|
9
|
+
coverage
|
|
10
|
+
doc/
|
|
11
|
+
lib/bundler/man
|
|
12
|
+
pkg
|
|
13
|
+
rdoc
|
|
14
|
+
spec/reports
|
|
15
|
+
test/tmp
|
|
16
|
+
test/version_tmp
|
|
17
|
+
tmp
|
|
18
|
+
# YARD artifacts
|
|
19
|
+
.yardoc
|
|
20
|
+
_yardoc
|
|
21
|
+
doc/
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
Copyright (c) 2012 Brandon Hansen
|
|
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,42 @@
|
|
|
1
|
+
# ReadableMessage
|
|
2
|
+
|
|
3
|
+
Print out exceptions (or any message that responds to :class, :message, and/or :backtrace) to the console
|
|
4
|
+
surrounded by "*" * 80. Makes it a bit easier to debug errors printed to standard out.
|
|
5
|
+
|
|
6
|
+
## Installation
|
|
7
|
+
|
|
8
|
+
Add this line to your application's Gemfile:
|
|
9
|
+
|
|
10
|
+
gem 'readable_message'
|
|
11
|
+
|
|
12
|
+
And then execute:
|
|
13
|
+
|
|
14
|
+
$ bundle
|
|
15
|
+
|
|
16
|
+
Or install it yourself as:
|
|
17
|
+
|
|
18
|
+
$ gem install readable_message
|
|
19
|
+
|
|
20
|
+
## Usage
|
|
21
|
+
|
|
22
|
+
`console(e, *args)` // Takes a string or any object that responds to :class, :message, and/or :backtrace
|
|
23
|
+
or
|
|
24
|
+
`ReadableMessage::Formatter.new(e, *args).to_s`
|
|
25
|
+
|
|
26
|
+
where `*args` is a list of methods that should be called on the object (to_s, to_i, backtrace, etc)
|
|
27
|
+
|
|
28
|
+
The output to console will appear something as-
|
|
29
|
+
|
|
30
|
+
********************************************************************************
|
|
31
|
+
String
|
|
32
|
+
"hi"
|
|
33
|
+
********************************************************************************
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
## Contributing
|
|
37
|
+
|
|
38
|
+
1. Fork it
|
|
39
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
|
40
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
|
41
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
|
42
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
require "bundler/gem_tasks"
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
require "readable_message/version"
|
|
2
|
+
|
|
3
|
+
module ReadableMessage
|
|
4
|
+
|
|
5
|
+
class Formatter
|
|
6
|
+
|
|
7
|
+
def initialize(message, *args)
|
|
8
|
+
@message = message
|
|
9
|
+
@messages = args.concat([:class, :message, :backtrace, :inspect]).flatten.collect { |arg|
|
|
10
|
+
Message.new(@message, arg)
|
|
11
|
+
}
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def to_s
|
|
15
|
+
wrapper { body }
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
private
|
|
19
|
+
|
|
20
|
+
def body
|
|
21
|
+
@messages.each { |msg| puts msg.to_s unless msg.to_s.nil? }
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
def wrapper
|
|
25
|
+
puts "*" * 80
|
|
26
|
+
yield if block_given?
|
|
27
|
+
puts "*" * 80
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
class Message
|
|
33
|
+
|
|
34
|
+
def initialize(str, method)
|
|
35
|
+
@str, @method = str, method
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
def to_s
|
|
39
|
+
@str.send(@method).to_s if @str.respond_to?(@method.to_sym)
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
module Kernel
|
|
47
|
+
def readable(msg, *args)
|
|
48
|
+
ReadableMessage::Formatter.new(msg, args).to_s
|
|
49
|
+
end
|
|
50
|
+
end
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
4
|
+
require 'readable_message/version'
|
|
5
|
+
|
|
6
|
+
Gem::Specification.new do |gem|
|
|
7
|
+
gem.name = "readable_message"
|
|
8
|
+
gem.version = ReadableMessage::VERSION
|
|
9
|
+
gem.authors = ["Brandon Hansen"]
|
|
10
|
+
gem.email = ["brandonh@ibethel.org"]
|
|
11
|
+
gem.description = %q{Prints out an exception message, class name, and backtrace to the console.}
|
|
12
|
+
gem.summary = %q{Prints out an exception message, class name, and backtrace to the console.}
|
|
13
|
+
gem.homepage = "https://github.com/ready4god2513/readable_message"
|
|
14
|
+
|
|
15
|
+
gem.files = `git ls-files`.split($/)
|
|
16
|
+
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
|
17
|
+
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
|
18
|
+
gem.require_paths = ["lib"]
|
|
19
|
+
end
|
data/spec/spec_helper.rb
ADDED
metadata
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: readable_message
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.0.1
|
|
5
|
+
prerelease:
|
|
6
|
+
platform: ruby
|
|
7
|
+
authors:
|
|
8
|
+
- Brandon Hansen
|
|
9
|
+
autorequire:
|
|
10
|
+
bindir: bin
|
|
11
|
+
cert_chain: []
|
|
12
|
+
date: 2012-11-07 00:00:00.000000000 Z
|
|
13
|
+
dependencies: []
|
|
14
|
+
description: Prints out an exception message, class name, and backtrace to the console.
|
|
15
|
+
email:
|
|
16
|
+
- brandonh@ibethel.org
|
|
17
|
+
executables: []
|
|
18
|
+
extensions: []
|
|
19
|
+
extra_rdoc_files: []
|
|
20
|
+
files:
|
|
21
|
+
- .gitignore
|
|
22
|
+
- Gemfile
|
|
23
|
+
- LICENSE.txt
|
|
24
|
+
- README.md
|
|
25
|
+
- Rakefile
|
|
26
|
+
- lib/readable_message.rb
|
|
27
|
+
- lib/readable_message/version.rb
|
|
28
|
+
- readable_message.gemspec
|
|
29
|
+
- spec/readable_message_spec.rb
|
|
30
|
+
- spec/spec_helper.rb
|
|
31
|
+
homepage: https://github.com/ready4god2513/readable_message
|
|
32
|
+
licenses: []
|
|
33
|
+
post_install_message:
|
|
34
|
+
rdoc_options: []
|
|
35
|
+
require_paths:
|
|
36
|
+
- lib
|
|
37
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
38
|
+
none: false
|
|
39
|
+
requirements:
|
|
40
|
+
- - ! '>='
|
|
41
|
+
- !ruby/object:Gem::Version
|
|
42
|
+
version: '0'
|
|
43
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
44
|
+
none: false
|
|
45
|
+
requirements:
|
|
46
|
+
- - ! '>='
|
|
47
|
+
- !ruby/object:Gem::Version
|
|
48
|
+
version: '0'
|
|
49
|
+
requirements: []
|
|
50
|
+
rubyforge_project:
|
|
51
|
+
rubygems_version: 1.8.24
|
|
52
|
+
signing_key:
|
|
53
|
+
specification_version: 3
|
|
54
|
+
summary: Prints out an exception message, class name, and backtrace to the console.
|
|
55
|
+
test_files:
|
|
56
|
+
- spec/readable_message_spec.rb
|
|
57
|
+
- spec/spec_helper.rb
|