awesome_print 1.7.0 → 1.8.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 +4 -4
- data/.gitignore +3 -0
- data/Appraisals +11 -0
- data/CHANGELOG.md +10 -0
- data/CONTRIBUTING.md +1 -1
- data/README.md +47 -38
- data/Rakefile +5 -5
- data/lib/ap.rb +2 -2
- data/lib/awesome_print.rb +18 -17
- data/lib/awesome_print/colorize.rb +1 -1
- data/lib/awesome_print/core_ext/{array.rb → awesome_method_array.rb} +16 -18
- data/lib/awesome_print/core_ext/class.rb +3 -2
- data/lib/awesome_print/core_ext/kernel.rb +1 -1
- data/lib/awesome_print/core_ext/logger.rb +1 -1
- data/lib/awesome_print/core_ext/method.rb +2 -2
- data/lib/awesome_print/core_ext/object.rb +3 -2
- data/lib/awesome_print/core_ext/string.rb +3 -3
- data/lib/awesome_print/custom_defaults.rb +57 -0
- data/lib/awesome_print/ext/action_view.rb +8 -4
- data/lib/awesome_print/ext/active_record.rb +19 -11
- data/lib/awesome_print/ext/active_support.rb +1 -1
- data/lib/awesome_print/ext/mongo_mapper.rb +16 -13
- data/lib/awesome_print/ext/mongoid.rb +8 -6
- data/lib/awesome_print/ext/nobrainer.rb +8 -5
- data/lib/awesome_print/ext/nokogiri.rb +4 -4
- data/lib/awesome_print/ext/ostruct.rb +1 -1
- data/lib/awesome_print/ext/ripple.rb +5 -6
- data/lib/awesome_print/ext/sequel.rb +7 -6
- data/lib/awesome_print/formatter.rb +11 -19
- data/lib/awesome_print/formatters.rb +15 -0
- data/lib/awesome_print/formatters/array_formatter.rb +108 -42
- data/lib/awesome_print/formatters/base_formatter.rb +13 -11
- data/lib/awesome_print/formatters/class_formatter.rb +2 -1
- data/lib/awesome_print/formatters/dir_formatter.rb +1 -1
- data/lib/awesome_print/formatters/file_formatter.rb +1 -1
- data/lib/awesome_print/formatters/hash_formatter.rb +74 -22
- data/lib/awesome_print/formatters/object_formatter.rb +9 -14
- data/lib/awesome_print/formatters/struct_formatter.rb +71 -0
- data/lib/awesome_print/inspector.rb +77 -93
- data/lib/awesome_print/version.rb +2 -2
- data/spec/active_record_helper.rb +8 -2
- data/spec/colors_spec.rb +30 -30
- data/spec/core_ext/logger_spec.rb +43 -0
- data/spec/core_ext/string_spec.rb +20 -0
- data/spec/ext/action_view_spec.rb +18 -0
- data/spec/ext/active_record_spec.rb +252 -0
- data/spec/ext/active_support_spec.rb +26 -0
- data/spec/ext/mongo_mapper_spec.rb +261 -0
- data/spec/ext/mongoid_spec.rb +104 -0
- data/spec/ext/nobrainer_spec.rb +59 -0
- data/spec/ext/nokogiri_spec.rb +46 -0
- data/spec/ext/ostruct_spec.rb +22 -0
- data/spec/ext/ripple_spec.rb +48 -0
- data/spec/formats_spec.rb +193 -165
- data/spec/methods_spec.rb +116 -128
- data/spec/misc_spec.rb +104 -108
- data/spec/objects_spec.rb +70 -28
- data/spec/spec_helper.rb +27 -10
- data/spec/support/active_record_data.rb +20 -0
- data/spec/support/active_record_data/3_2_diana.txt +24 -0
- data/spec/support/active_record_data/3_2_diana_legacy.txt +24 -0
- data/spec/support/active_record_data/3_2_multi.txt +50 -0
- data/spec/support/active_record_data/3_2_multi_legacy.txt +50 -0
- data/spec/support/active_record_data/4_0_diana.txt +98 -0
- data/spec/support/active_record_data/4_0_multi.txt +198 -0
- data/spec/support/active_record_data/4_1_diana.txt +97 -0
- data/spec/support/active_record_data/4_1_multi.txt +196 -0
- data/spec/support/active_record_data/4_2_diana.txt +109 -0
- data/spec/support/active_record_data/4_2_diana_legacy.txt +109 -0
- data/spec/support/active_record_data/4_2_multi.txt +220 -0
- data/spec/support/active_record_data/4_2_multi_legacy.txt +220 -0
- data/spec/support/active_record_data/5_0_diana.txt +105 -0
- data/spec/support/active_record_data/5_0_multi.txt +212 -0
- data/spec/support/ext_verifier.rb +42 -0
- data/spec/support/mongoid_versions.rb +22 -0
- data/spec/support/rails_versions.rb +35 -0
- metadata +79 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cda3844883c76081eb1cbaf6e6188492b51d741d
|
4
|
+
data.tar.gz: be404804711ff00ce4f3720153bf84ba10d012ef
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3a83fe61488d2df035585c6d54f9e93dfa5c950bef2a7e05707fdb334090bf91db46921d88f2fac136edf13904ee0c76393e5a7c4d4d5f53cf9b460a0f724696
|
7
|
+
data.tar.gz: 87d8c72172448c0897c668cbefcfe4713802effa219469297ce8b242307998c70f82a087feeb7f0b485ee34941bd833aa5eb14c322143242f09b8f3e7418bc5c
|
data/.gitignore
CHANGED
data/Appraisals
CHANGED
@@ -4,6 +4,7 @@ end
|
|
4
4
|
|
5
5
|
appraise 'rails-4.0' do
|
6
6
|
gem 'rails', '~> 4.0.0'
|
7
|
+
gem 'json', '~> 1.8', :platforms => :ruby_19 # Json 2.0 requires Ruby >= 2.0
|
7
8
|
|
8
9
|
# The last version that doesn't need Ruby 2.0 and works with version 4.0 of
|
9
10
|
# Rails. This addresses a build problem with Travis for version 1.9.3 of Ruby
|
@@ -26,12 +27,18 @@ appraise 'rails-4.2' do
|
|
26
27
|
gem 'mime-types', '2.6.2', :platforms => :ruby_19
|
27
28
|
end
|
28
29
|
|
30
|
+
appraise 'rails-5.0' do
|
31
|
+
# Only works with Ruby >= 2.2
|
32
|
+
gem 'rails', '>= 5.0.0.racecar1', '< 5.1'
|
33
|
+
end
|
34
|
+
|
29
35
|
appraise 'mongoid-3.0' do
|
30
36
|
gem 'mongoid', '~> 3.0.0'
|
31
37
|
end
|
32
38
|
|
33
39
|
appraise 'mongoid-3.1' do
|
34
40
|
gem 'mongoid', '~> 3.1.0'
|
41
|
+
gem 'json', '~> 1.8', :platforms => :ruby_19 # Json 2.0 requires Ruby >= 2.0
|
35
42
|
end
|
36
43
|
|
37
44
|
appraise 'mongoid-4.0' do
|
@@ -49,4 +56,8 @@ end
|
|
49
56
|
|
50
57
|
appraise 'nobrainer' do
|
51
58
|
gem 'nobrainer'
|
59
|
+
|
60
|
+
# When activesupport 5 was released, it required ruby 2.2.2 as a minimum.
|
61
|
+
# Locking this down to 4.2.6 allows our Ruby 1.9 tests to keep working.
|
62
|
+
gem 'activesupport', '4.2.6', :platforms => :ruby_19
|
52
63
|
end
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,12 @@
|
|
1
1
|
## master (unreleased)
|
2
|
+
- new things!
|
2
3
|
|
4
|
+
## 1.8.0
|
5
|
+
- stat("$HOME/.aprc") once [@kstephens] - [#304]
|
6
|
+
- ActiveRecord: #joins now show the columns #select'ed [@adrianomitre] - [#211]
|
7
|
+
- Handles NoMethodError for IRB implicit `ai` [@jtnegrotto] - [#212]
|
8
|
+
- Replaced Fixnum reference with Integer
|
9
|
+
- Colorize ORM class names [@ixti]
|
3
10
|
|
4
11
|
## 1.7.0
|
5
12
|
- Refactoring by extracting formatters into their own classes [@waldyr] - [#237]
|
@@ -129,6 +136,7 @@
|
|
129
136
|
- Initial Release.
|
130
137
|
|
131
138
|
[#200]: https://github.com/awesome-print/awesome_print/pull/200
|
139
|
+
[#212]: https://github.com/awesome-print/awesome_print/pull/212
|
132
140
|
[#216]: https://github.com/awesome-print/awesome_print/pull/216
|
133
141
|
[#217]: https://github.com/awesome-print/awesome_print/pull/217
|
134
142
|
[#222]: https://github.com/awesome-print/awesome_print/pull/222
|
@@ -145,6 +153,8 @@
|
|
145
153
|
[@clonezone]: https://github.com/clonezone
|
146
154
|
[@cyberdelia]: https://github.com/cyberdelia
|
147
155
|
[@gerrywastaken]: https://github.com/gerrywastaken
|
156
|
+
[@ixti]: https://github.com/ixti
|
157
|
+
[@jtnegrotto]: https://github.com/jtnegrotto
|
148
158
|
[@kemmason]: https://github.com/kemmason
|
149
159
|
[@maurogeorge]: https://github.com/maurogeorge
|
150
160
|
[@MaxPleaner]: https://github.com/MaxPleaner
|
data/CONTRIBUTING.md
CHANGED
@@ -6,7 +6,7 @@ We love pull requests. Here's a quick guide:
|
|
6
6
|
|
7
7
|
1. Create your feature branch (`git checkout -b my-new-feature`)
|
8
8
|
|
9
|
-
1. Update [CHANGELOG.md](https://github.com/
|
9
|
+
1. Update [CHANGELOG.md](https://github.com/awesome-print/awesome_print/blob/master/CHANGELOG.md) with a brief description of your changes under the `unreleased` heading.
|
10
10
|
|
11
11
|
1. Add/Update tests were appropriate
|
12
12
|
|
data/README.md
CHANGED
@@ -5,7 +5,7 @@
|
|
5
5
|
[![Code Climate][code_climate_badge]][code_climate]
|
6
6
|
[![Code Climate Coverage][code_climate_coverage_badge]][code_climate]
|
7
7
|
[![RubyGems][gem_downloads_badge]][ruby_gems]
|
8
|
-
[](https://gitter.im/
|
8
|
+
[](https://gitter.im/awesome-print/awesome_print?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
|
9
9
|
|
10
10
|
|
11
11
|
Awesome Print is a Ruby library that pretty prints Ruby objects in full color
|
@@ -21,7 +21,7 @@ v2.0 will *require* Ruby v1.9.3 or later and Rails v3.0 or later.
|
|
21
21
|
$ gem install awesome_print
|
22
22
|
|
23
23
|
# Cloning the repository
|
24
|
-
$ git clone git://github.com/
|
24
|
+
$ git clone git://github.com/awesome-print/awesome_print.git
|
25
25
|
|
26
26
|
### Usage ###
|
27
27
|
|
@@ -33,34 +33,36 @@ ap object, options = {}
|
|
33
33
|
Default options:
|
34
34
|
|
35
35
|
```ruby
|
36
|
-
:
|
37
|
-
:
|
38
|
-
:
|
39
|
-
:
|
40
|
-
:
|
41
|
-
:
|
42
|
-
:
|
43
|
-
:
|
44
|
-
:
|
45
|
-
|
46
|
-
|
47
|
-
:
|
48
|
-
:
|
49
|
-
:
|
50
|
-
:
|
51
|
-
:
|
52
|
-
:
|
53
|
-
:
|
54
|
-
:
|
55
|
-
:
|
56
|
-
:
|
57
|
-
:
|
58
|
-
:
|
59
|
-
:
|
60
|
-
:
|
61
|
-
:
|
62
|
-
:
|
63
|
-
:
|
36
|
+
indent: 4, # Number of spaces for indenting.
|
37
|
+
index: true, # Display array indices.
|
38
|
+
html: false, # Use ANSI color codes rather than HTML.
|
39
|
+
multiline: true, # Display in multiple lines.
|
40
|
+
plain: false, # Use colors.
|
41
|
+
raw: false, # Do not recursively format instance variables.
|
42
|
+
sort_keys: false, # Do not sort hash keys.
|
43
|
+
sort_vars: true, # Sort instance variables.
|
44
|
+
limit: false, # Limit arrays & hashes. Accepts bool or int.
|
45
|
+
ruby19_syntax: false, # Use Ruby 1.9 hash syntax in output.
|
46
|
+
color: {
|
47
|
+
args: :pale,
|
48
|
+
array: :white,
|
49
|
+
bigdecimal: :blue,
|
50
|
+
class: :yellow,
|
51
|
+
date: :greenish,
|
52
|
+
falseclass: :red,
|
53
|
+
fixnum: :blue,
|
54
|
+
float: :blue,
|
55
|
+
hash: :pale,
|
56
|
+
keyword: :cyan,
|
57
|
+
method: :purpleish,
|
58
|
+
nilclass: :red,
|
59
|
+
rational: :blue,
|
60
|
+
string: :yellowish,
|
61
|
+
struct: :pale,
|
62
|
+
symbol: :cyanish,
|
63
|
+
time: :greenish,
|
64
|
+
trueclass: :green,
|
65
|
+
variable: :cyanish
|
64
66
|
}
|
65
67
|
```
|
66
68
|
|
@@ -303,6 +305,14 @@ With other web frameworks (ex: in Sinatra templates) you can explicitly request
|
|
303
305
|
formatting:
|
304
306
|
|
305
307
|
<%= ap @accounts.first, :html => true %>
|
308
|
+
|
309
|
+
### String Convenience Methods ###
|
310
|
+
Use methods such as `.red` to set string color:
|
311
|
+
|
312
|
+
```ruby
|
313
|
+
irb> puts "red text".red
|
314
|
+
red text # (it's red)
|
315
|
+
```
|
306
316
|
|
307
317
|
### Setting Custom Defaults ###
|
308
318
|
You can set your own default options by creating ``.aprc`` file in your home
|
@@ -325,11 +335,10 @@ AwesomePrint.defaults = {
|
|
325
335
|
AwesomePrint follows the [Semantic Versioning](http://semver.org/) standard.
|
326
336
|
|
327
337
|
### Contributing ###
|
328
|
-
See [
|
329
|
-
for information.
|
338
|
+
See [CONTRIBUTING.md](CONTRIBUTING.md) for information.
|
330
339
|
|
331
340
|
### License ###
|
332
|
-
Copyright (c) 2010-
|
341
|
+
Copyright (c) 2010-2016 Michael Dvorkin and contributors
|
333
342
|
|
334
343
|
http://www.dvorkin.net
|
335
344
|
|
@@ -340,8 +349,8 @@ Released under the MIT license. See LICENSE file for details.
|
|
340
349
|
[gem_version_badge]: https://img.shields.io/gem/v/awesome_print.svg?style=flat
|
341
350
|
[gem_downloads_badge]: http://img.shields.io/gem/dt/awesome_print.svg?style=flat
|
342
351
|
[ruby_gems]: http://rubygems.org/gems/awesome_print
|
343
|
-
[travis_ci]: http://travis-ci.org/
|
344
|
-
[travis_ci_badge]: https://img.shields.io/travis/
|
345
|
-
[code_climate]: https://codeclimate.com/github/
|
346
|
-
[code_climate_badge]: http://img.shields.io/codeclimate/github/
|
347
|
-
[code_climate_coverage_badge]: https://codeclimate.com/github/
|
352
|
+
[travis_ci]: http://travis-ci.org/awesome-print/awesome_print
|
353
|
+
[travis_ci_badge]: https://img.shields.io/travis/awesome-print/awesome_print/master.svg?style=flat
|
354
|
+
[code_climate]: https://codeclimate.com/github/awesome-print/awesome_print
|
355
|
+
[code_climate_badge]: http://img.shields.io/codeclimate/github/awesome-print/awesome_print.svg?style=flat
|
356
|
+
[code_climate_coverage_badge]: https://codeclimate.com/github/awesome-print/awesome_print/badges/coverage.svg
|
data/Rakefile
CHANGED
@@ -1,7 +1,7 @@
|
|
1
|
-
require
|
2
|
-
require
|
1
|
+
require 'rubygems'
|
2
|
+
require 'bundler/setup'
|
3
3
|
|
4
|
-
require
|
4
|
+
require 'bundler'
|
5
5
|
Bundler::GemHelper.install_tasks
|
6
6
|
|
7
7
|
task :default do
|
@@ -16,9 +16,9 @@ task :appraise do
|
|
16
16
|
exec 'appraisal install && appraisal rake'
|
17
17
|
end
|
18
18
|
|
19
|
-
desc
|
19
|
+
desc 'Run all awesome_print gem specs'
|
20
20
|
task :spec do
|
21
21
|
# Run plain rspec command without RSpec::Core::RakeTask overrides.
|
22
|
-
exec
|
22
|
+
exec 'rspec -c spec'
|
23
23
|
end
|
24
24
|
|
data/lib/ap.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# Copyright (c) 2010-
|
1
|
+
# Copyright (c) 2010-2016 Michael Dvorkin and contributors
|
2
2
|
#
|
3
3
|
# Awesome Print is freely distributable under the terms of MIT license.
|
4
4
|
# See LICENSE file or http://www.opensource.org/licenses/mit-license.php
|
@@ -7,4 +7,4 @@
|
|
7
7
|
# Keeping this for backwards compatibility to allow
|
8
8
|
# require "ap"
|
9
9
|
#
|
10
|
-
require File.dirname(__FILE__) +
|
10
|
+
require File.dirname(__FILE__) + '/awesome_print'
|
data/lib/awesome_print.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# Copyright (c) 2010-
|
1
|
+
# Copyright (c) 2010-2016 Michael Dvorkin and contributors
|
2
2
|
#
|
3
3
|
# Awesome Print is freely distributable under the terms of MIT license.
|
4
4
|
# See LICENSE file or http://www.opensource.org/licenses/mit-license.php
|
@@ -8,33 +8,34 @@
|
|
8
8
|
# so do nothing for subsequent requires.
|
9
9
|
#
|
10
10
|
unless defined?(AwesomePrint::Inspector)
|
11
|
-
%w(
|
12
|
-
require
|
11
|
+
%w(awesome_method_array string method object class kernel).each do |file|
|
12
|
+
require "awesome_print/core_ext/#{file}"
|
13
13
|
end
|
14
14
|
|
15
|
-
require
|
16
|
-
require
|
17
|
-
require
|
18
|
-
require
|
15
|
+
require 'awesome_print/custom_defaults'
|
16
|
+
require 'awesome_print/inspector'
|
17
|
+
require 'awesome_print/formatter'
|
18
|
+
require 'awesome_print/version'
|
19
|
+
require 'awesome_print/core_ext/logger' if defined?(Logger)
|
19
20
|
#
|
20
21
|
# Load the following under normal circumstances as well as in Rails
|
21
22
|
# console when required from ~/.irbrc or ~/.pryrc.
|
22
23
|
#
|
23
|
-
require
|
24
|
-
require
|
24
|
+
require 'awesome_print/ext/active_record' if defined?(ActiveRecord) || AwesomePrint.rails_console?
|
25
|
+
require 'awesome_print/ext/active_support' if defined?(ActiveSupport) || AwesomePrint.rails_console?
|
25
26
|
#
|
26
27
|
# Load remaining extensions.
|
27
28
|
#
|
28
29
|
if defined?(ActiveSupport.on_load)
|
29
30
|
ActiveSupport.on_load(:action_view) do
|
30
|
-
require
|
31
|
+
require 'awesome_print/ext/action_view'
|
31
32
|
end
|
32
33
|
end
|
33
|
-
require
|
34
|
-
require
|
35
|
-
require
|
36
|
-
require
|
37
|
-
require
|
38
|
-
require
|
39
|
-
require
|
34
|
+
require 'awesome_print/ext/mongo_mapper' if defined?(MongoMapper)
|
35
|
+
require 'awesome_print/ext/mongoid' if defined?(Mongoid)
|
36
|
+
require 'awesome_print/ext/nokogiri' if defined?(Nokogiri)
|
37
|
+
require 'awesome_print/ext/nobrainer' if defined?(NoBrainer)
|
38
|
+
require 'awesome_print/ext/ripple' if defined?(Ripple)
|
39
|
+
require 'awesome_print/ext/sequel' if defined?(Sequel)
|
40
|
+
require 'awesome_print/ext/ostruct' if defined?(OpenStruct)
|
40
41
|
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
# Copyright (c) 2010-
|
1
|
+
# Copyright (c) 2010-2016 Michael Dvorkin and contributors
|
2
2
|
#
|
3
3
|
# Awesome Print is freely distributable under the terms of MIT license.
|
4
4
|
# See LICENSE file or http://www.opensource.org/licenses/mit-license.php
|
@@ -12,24 +12,24 @@
|
|
12
12
|
#
|
13
13
|
# If you could think of a better way please let me know :-)
|
14
14
|
#
|
15
|
-
|
16
|
-
[ :-, :& ].each do |operator|
|
17
|
-
original_operator = instance_method(operator)
|
15
|
+
module AwesomeMethodArray #:nodoc:
|
18
16
|
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
17
|
+
def -(_other_ary)
|
18
|
+
super.tap do |arr|
|
19
|
+
arr.instance_variable_set(:@__awesome_methods__, self.instance_variable_get(:@__awesome_methods__))
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
def &(_other_ary)
|
24
|
+
super.tap do |arr|
|
25
|
+
arr.instance_variable_set(:@__awesome_methods__, self.instance_variable_get(:@__awesome_methods__))
|
26
26
|
end
|
27
27
|
end
|
28
|
+
|
28
29
|
#
|
29
30
|
# Intercepting Array#grep needs a special treatment since grep accepts
|
30
31
|
# an optional block.
|
31
32
|
#
|
32
|
-
alias :original_grep :grep
|
33
33
|
def grep(pattern, &blk)
|
34
34
|
#
|
35
35
|
# The following looks rather insane and I've sent numerous hours trying
|
@@ -55,9 +55,9 @@ class Array #:nodoc:
|
|
55
55
|
# the comment :-)
|
56
56
|
#
|
57
57
|
arr = unless blk
|
58
|
-
|
58
|
+
super(pattern)
|
59
59
|
else
|
60
|
-
|
60
|
+
super(pattern) do |match|
|
61
61
|
#
|
62
62
|
# The binding can only be used with Ruby-defined methods, therefore
|
63
63
|
# we must rescue potential "ArgumentError: Can't create Binding from
|
@@ -72,10 +72,8 @@ class Array #:nodoc:
|
|
72
72
|
yield match
|
73
73
|
end
|
74
74
|
end
|
75
|
-
|
76
|
-
|
77
|
-
arr.reject! { |item| !(item.is_a?(Symbol) || item.is_a?(String)) } # grep block might return crap.
|
78
|
-
end
|
75
|
+
arr.instance_variable_set(:@__awesome_methods__, self.instance_variable_get(:@__awesome_methods__))
|
76
|
+
arr.reject! { |item| !(item.is_a?(Symbol) || item.is_a?(String)) } # grep block might return crap.
|
79
77
|
arr
|
80
78
|
end
|
81
79
|
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
# Copyright (c) 2010-
|
1
|
+
# Copyright (c) 2010-2016 Michael Dvorkin and contributors
|
2
2
|
#
|
3
3
|
# Awesome Print is freely distributable under the terms of MIT license.
|
4
4
|
# See LICENSE file or http://www.opensource.org/licenses/mit-license.php
|
@@ -15,7 +15,8 @@ class Class #:nodoc:
|
|
15
15
|
|
16
16
|
define_method name do |*args|
|
17
17
|
methods = original_method.bind(self).call(*args)
|
18
|
-
methods.instance_variable_set(
|
18
|
+
methods.instance_variable_set(:@__awesome_methods__, self)
|
19
|
+
methods.extend(AwesomeMethodArray)
|
19
20
|
methods
|
20
21
|
end
|
21
22
|
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
# Copyright (c) 2010-
|
1
|
+
# Copyright (c) 2010-2016 Michael Dvorkin and contributors
|
2
2
|
#
|
3
3
|
# Awesome Print is freely distributable under the terms of MIT license.
|
4
4
|
# See LICENSE file or http://www.opensource.org/licenses/mit-license.php
|
@@ -18,4 +18,4 @@ unless nil.method(:class).respond_to?(:name)
|
|
18
18
|
inspect.split(/[#.>]/)[-1]
|
19
19
|
end
|
20
20
|
end
|
21
|
-
end
|
21
|
+
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
# Copyright (c) 2010-
|
1
|
+
# Copyright (c) 2010-2016 Michael Dvorkin and contributors
|
2
2
|
#
|
3
3
|
# Awesome Print is freely distributable under the terms of MIT license.
|
4
4
|
# See LICENSE file or http://www.opensource.org/licenses/mit-license.php
|
@@ -15,7 +15,8 @@ class Object #:nodoc:
|
|
15
15
|
|
16
16
|
define_method name do |*args|
|
17
17
|
methods = original_method.bind(self).call(*args)
|
18
|
-
methods.instance_variable_set(
|
18
|
+
methods.instance_variable_set(:@__awesome_methods__, self)
|
19
|
+
methods.extend(AwesomeMethodArray)
|
19
20
|
methods
|
20
21
|
end
|
21
22
|
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
# Copyright (c) 2010-
|
1
|
+
# Copyright (c) 2010-2016 Michael Dvorkin and contributors
|
2
2
|
#
|
3
3
|
# Awesome Print is freely distributable under the terms of MIT license.
|
4
4
|
# See LICENSE file or http://www.opensource.org/licenses/mit-license.php
|
@@ -17,11 +17,11 @@ class String
|
|
17
17
|
%w(gray red green yellow blue purple cyan white).zip(
|
18
18
|
%w(black darkred darkgreen brown navy darkmagenta darkcyan slategray)).each_with_index do |(color, shade), i|
|
19
19
|
define_method color do |*html|
|
20
|
-
html[0] ? %Q|<kbd style="color:#{color}">#{self}</kbd>| : "\e[1;#{30+i}m#{self}\e[0m"
|
20
|
+
html[0] ? %Q|<kbd style="color:#{color}">#{self}</kbd>| : "\e[1;#{30 + i}m#{self}\e[0m"
|
21
21
|
end
|
22
22
|
|
23
23
|
define_method "#{color}ish" do |*html|
|
24
|
-
html[0] ? %Q|<kbd style="color:#{shade}">#{self}</kbd>| : "\e[0;#{30+i}m#{self}\e[0m"
|
24
|
+
html[0] ? %Q|<kbd style="color:#{shade}">#{self}</kbd>| : "\e[0;#{30 + i}m#{self}\e[0m"
|
25
25
|
end
|
26
26
|
end
|
27
27
|
|