motion_print 0.0.5 → 1.0.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/LICENSE +1 -1
- data/README.md +10 -4
- data/motion/motion_print/core_ext/kernel.rb +1 -1
- data/motion/motion_print/motion_print.rb +35 -31
- data/motion/motion_print/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ffac142eccd2d2f73bf506a2dab1bbf90efb2aff
|
4
|
+
data.tar.gz: 12bed335eb67226e364bbb7d6742b009c496d544
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 544a094b259d414701ec119bd9a40ab7e645b5f13ae459cc7069f6281c4fd648153cb51538009a1f102c7f5a3758d68d710b5509449a1547c8d349b69406fabc
|
7
|
+
data.tar.gz: 0f26af35ff66f03b926c32fa4dae2a861817f670c6cfb9376e70fb33dd3222d2f9218b1fe43a9b98ca7fbe4a0b32cd8d9bd846dabde6c872296a71706018f17b
|
data/LICENSE
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
The MIT License (MIT)
|
2
2
|
|
3
|
-
Copyright (c) 2014
|
3
|
+
Copyright (c) 2014 Off The Grid Apps, LLC (http://otgapps.io)
|
4
4
|
|
5
5
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
6
|
of this software and associated documentation files (the "Software"), to deal
|
data/README.md
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
A RubyMotion pretty printer.
|
4
4
|
|
5
|
-
[](http://badge.fury.io/rb/motion_print) [](https://travis-ci.org/OTGApps/motion_print) [](http://badge.fury.io/rb/motion_print) [](https://travis-ci.org/OTGApps/motion_print) [](https://codeclimate.com/github/OTGApps/motion_print)
|
6
6
|
|
7
7
|
instead of using `p` or `puts`, use `mp` to log your debug values to the RubyMotion REPL.
|
8
8
|
|
@@ -57,7 +57,7 @@ gem 'motion_print'
|
|
57
57
|
|
58
58
|
Bleeding Edge:
|
59
59
|
```ruby
|
60
|
-
gem 'motion_print', github: '
|
60
|
+
gem 'motion_print', github: 'OTGApps/motion_print'
|
61
61
|
```
|
62
62
|
|
63
63
|
And then execute:
|
@@ -73,6 +73,12 @@ Ruby comes with some great methods for method introspection. These methods look
|
|
73
73
|
|
74
74
|
`mp caller` will trace back up the call stack, so you can see how a method got called.
|
75
75
|
|
76
|
+
You can force a color of the output if you want like this:
|
77
|
+
|
78
|
+
```ruby
|
79
|
+
mp "My String", force_color: :blue # This is usually yellow
|
80
|
+
```
|
81
|
+
|
76
82
|
## Roadmap
|
77
83
|
|
78
84
|
1. Add more core objects people want to output: `UIView`, `Struct`, etc. Please open an issue to make suggestions or just implement it yourself and send me a pull request!
|
@@ -99,10 +105,10 @@ That, coupled with the fact that the developer of awesome_print_motion doesn't s
|
|
99
105
|
|
100
106
|
## Contact
|
101
107
|
|
102
|
-
Mark Rickert ([http://
|
108
|
+
Mark Rickert ([http://otgapps.io](http://otgapps.io))
|
103
109
|
|
104
110
|
- [http://twitter.com/markrickert](http://twitter.com/markrickert)
|
105
|
-
- [mark@
|
111
|
+
- [mark@otgapps.io](mark@otgapps.io)
|
106
112
|
|
107
113
|
## License
|
108
114
|
|
@@ -9,95 +9,99 @@ module MotionPrint
|
|
9
9
|
return CDQManagedObject if defined? CDQManagedObject
|
10
10
|
end
|
11
11
|
|
12
|
-
def logger(object,
|
12
|
+
def logger(object, options = {})
|
13
|
+
options = {
|
14
|
+
indent_level: 1,
|
15
|
+
force_color: nil
|
16
|
+
}.merge(options)
|
17
|
+
|
13
18
|
case object
|
14
19
|
when nil
|
15
|
-
colorize(object)
|
20
|
+
colorize(object, options[:force_color])
|
16
21
|
when Symbol
|
17
|
-
l_symbol
|
22
|
+
l_symbol(object, options)
|
18
23
|
when Array
|
19
|
-
l_array
|
24
|
+
l_array(object, options)
|
20
25
|
when Dir
|
21
|
-
l_dir
|
26
|
+
l_dir(object, options)
|
22
27
|
when Hash
|
23
|
-
l_hash
|
28
|
+
l_hash(object, options)
|
24
29
|
# when File
|
25
30
|
# l_file object
|
26
31
|
# when Struct
|
27
32
|
# l_struct object
|
28
33
|
when cdq_object
|
29
|
-
l_cdq
|
34
|
+
l_cdq(object, options)
|
30
35
|
else
|
31
|
-
colorize(object)
|
36
|
+
colorize(object, options[:force_color])
|
32
37
|
end
|
33
38
|
end
|
34
39
|
|
35
|
-
def l_cdq(c,
|
40
|
+
def l_cdq(c, options)
|
36
41
|
# Requires CDQ > v0.1.10
|
37
42
|
if c.respond_to? :attributes
|
38
|
-
"OID: " + colorize(c.oid.gsub('"','')) + "\n" + l_hash(c.attributes,
|
43
|
+
"OID: " + colorize(c.oid.gsub('"',''), options[:force_color]) + "\n" + l_hash(c.attributes, options)
|
39
44
|
else
|
40
45
|
# old colorless method, still more informative than nothing
|
41
46
|
c.log
|
42
47
|
end
|
43
48
|
end
|
44
49
|
|
45
|
-
def l_array(a,
|
50
|
+
def l_array(a, options)
|
46
51
|
return "[]" if a.empty?
|
47
52
|
out = []
|
48
53
|
|
49
54
|
a.each do |arr|
|
50
55
|
|
51
56
|
if arr.is_a?(Array) || arr.is_a?(Hash)
|
52
|
-
v = logger(arr, indent_level + 1)
|
57
|
+
v = logger(arr, options.merge({indent_level: options[:indent_level] + 1}))
|
53
58
|
else
|
54
|
-
v = logger(arr)
|
59
|
+
v = logger(arr, options)
|
55
60
|
end
|
56
|
-
out << (indent_by(indent_level) << v)
|
61
|
+
out << (indent_by(options[:indent_level]) << v)
|
57
62
|
end
|
58
63
|
|
59
|
-
"[\n" << out.join(",\n") << "\n#{indent_by(indent_level-1)}]"
|
64
|
+
"[\n" << out.join(",\n") << "\n#{indent_by(options[:indent_level]-1)}]"
|
60
65
|
end
|
61
66
|
|
62
|
-
def l_hash(h,
|
67
|
+
def l_hash(h, options)
|
63
68
|
return "{}" if h.empty?
|
64
69
|
data, out = [], []
|
65
70
|
|
66
71
|
h.keys.each do |key|
|
67
|
-
data << [logger(key), h[key]]
|
72
|
+
data << [logger(key, options), h[key]]
|
68
73
|
end
|
69
74
|
|
70
75
|
width = data.map { |key, | key.size }.max || 0
|
71
|
-
width += indent_by(indent_level).length
|
76
|
+
width += indent_by(options[:indent_level]).length
|
72
77
|
|
73
78
|
data.each do |key, value|
|
74
79
|
if value.is_a?(Array) || value.is_a?(Hash)
|
75
|
-
v = logger(value, indent_level + 1)
|
80
|
+
v = logger(value, options.merge({indent_level: options[:indent_level] + 1}))
|
76
81
|
else
|
77
|
-
v = logger(value)
|
82
|
+
v = logger(value, options)
|
78
83
|
end
|
79
|
-
out << (align(key, width, indent_level) << hash_rocket << v)
|
84
|
+
out << (align(key, width, options[:indent_level]) << hash_rocket(options[:force_color]) << v)
|
80
85
|
end
|
81
86
|
|
82
|
-
"{\n" << out.join(",\n") << "\n#{indent_by(indent_level-1)}}"
|
87
|
+
"{\n" << out.join(",\n") << "\n#{indent_by(options[:indent_level]-1)}}"
|
83
88
|
end
|
84
89
|
|
85
|
-
def l_dir(d)
|
90
|
+
def l_dir(d, options)
|
86
91
|
ls = `ls -alF #{d.path.shellescape}`
|
87
|
-
colorize(ls.empty? ? d.inspect : "#{d.inspect}\n#{ls.chop}")
|
92
|
+
colorize(ls.empty? ? d.inspect : "#{d.inspect}\n#{ls.chop}", options[:force_color])
|
88
93
|
end
|
89
94
|
|
90
|
-
def l_symbol(object)
|
91
|
-
colorize(object,
|
95
|
+
def l_symbol(object, options)
|
96
|
+
colorize(object, options[:force_color])
|
92
97
|
end
|
93
98
|
|
94
|
-
def colorize(object,
|
95
|
-
|
96
|
-
Colorizer.send(decide_color(type), object.inspect)
|
99
|
+
def colorize(object, force_color = nil)
|
100
|
+
Colorizer.send(force_color || decide_color(object), object.inspect)
|
97
101
|
end
|
98
102
|
|
99
|
-
def hash_rocket
|
100
|
-
Colorizer.send(decide_color(:hash), " => ")
|
103
|
+
def hash_rocket(force_color = nil)
|
104
|
+
Colorizer.send(force_color || decide_color(:hash), " => ")
|
101
105
|
end
|
102
106
|
|
103
107
|
def decide_color(object)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: motion_print
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mark Rickert
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-04-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bacon
|
@@ -53,7 +53,7 @@ files:
|
|
53
53
|
- motion/motion_print/core_ext/string.rb
|
54
54
|
- motion/motion_print/motion_print.rb
|
55
55
|
- motion/motion_print/version.rb
|
56
|
-
homepage: https://github.com/
|
56
|
+
homepage: https://github.com/OTGApps/motion_print
|
57
57
|
licenses:
|
58
58
|
- MIT
|
59
59
|
metadata: {}
|