motion_print 0.0.5 → 1.0.0

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: 90fedd225e91b75739211636bae39e1519c53dd8
4
- data.tar.gz: dd9842fbd9dfcd7882aa39f7a417b950f0edfb26
3
+ metadata.gz: ffac142eccd2d2f73bf506a2dab1bbf90efb2aff
4
+ data.tar.gz: 12bed335eb67226e364bbb7d6742b009c496d544
5
5
  SHA512:
6
- metadata.gz: 5fa77292a0930532c014975d6d81b51b598937cb7b07785636f3d41d724d1cd2d75d4d561e8653cf4c292d7962e0ab3c6df150cc4e43c73d698ed72d592f8f83
7
- data.tar.gz: 1857234580c00acff1857b4d83931fe22777441eec9f2429d2609203496c82fc6b03c335bd07c7b3c60ff922c3446996b0e86e82d0d95df867656199606ea68e
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 Mohawk Apps, LLC (http://mohawkapps.com)
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
- [![Gem Version](https://badge.fury.io/rb/motion_print.svg)](http://badge.fury.io/rb/motion_print) [![Build Status](https://travis-ci.org/OTGApps/motion_print.svg)](https://travis-ci.org/OTGApps/motion_print) [![Code Climate](https://codeclimate.com/github/MohawkApps/motion_print.png)](https://codeclimate.com/github/MohawkApps/motion_print)
5
+ [![Gem Version](https://badge.fury.io/rb/motion_print.svg)](http://badge.fury.io/rb/motion_print) [![Build Status](https://travis-ci.org/OTGApps/motion_print.svg)](https://travis-ci.org/OTGApps/motion_print) [![Code Climate](https://codeclimate.com/github/OTGapps/motion_print.png)](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: 'MohawkApps/motion_print'
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://www.mohawkapps.com](http://www.mohawkapps.com))
108
+ Mark Rickert ([http://otgapps.io](http://otgapps.io))
103
109
 
104
110
  - [http://twitter.com/markrickert](http://twitter.com/markrickert)
105
- - [mark@mohawkapps.com](mark@mohawkapps.com)
111
+ - [mark@otgapps.io](mark@otgapps.io)
106
112
 
107
113
  ## License
108
114
 
@@ -1,7 +1,7 @@
1
1
  module Kernel
2
2
  def mp(object, options = {})
3
3
  output_stream = RUBYMOTION_ENV == "test" ? $stderr : $stdout
4
- output_stream.puts MotionPrint.logger(object)
4
+ output_stream.puts MotionPrint.logger(object, options)
5
5
  object unless MotionPrint.console?
6
6
  end
7
7
 
@@ -9,95 +9,99 @@ module MotionPrint
9
9
  return CDQManagedObject if defined? CDQManagedObject
10
10
  end
11
11
 
12
- def logger(object, indent_level = 1)
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 object
22
+ l_symbol(object, options)
18
23
  when Array
19
- l_array object, indent_level
24
+ l_array(object, options)
20
25
  when Dir
21
- l_dir object
26
+ l_dir(object, options)
22
27
  when Hash
23
- l_hash object, indent_level
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 object, indent_level
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, indent_level = 1)
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, indent_level)
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, indent_level = 1)
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, indent_level = 1)
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, object)
95
+ def l_symbol(object, options)
96
+ colorize(object, options[:force_color])
92
97
  end
93
98
 
94
- def colorize(object, type = nil)
95
- type = object if type.nil?
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)
@@ -1,3 +1,3 @@
1
1
  module MotionPrint
2
- VERSION = "0.0.5"
2
+ VERSION = "1.0.0"
3
3
  end
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.5
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-03-26 00:00:00.000000000 Z
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/MohawkApps/motion_print
56
+ homepage: https://github.com/OTGApps/motion_print
57
57
  licenses:
58
58
  - MIT
59
59
  metadata: {}