debugmotion 1.0.0 → 1.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/Gemfile +3 -1
- data/README.md +1 -1
- data/Rakefile +1 -0
- data/app/test_view_controller.rb +5 -0
- data/lib/debugmotion/console.rb +22 -19
- data/lib/debugmotion/debugmotion.rb +1 -1
- data/lib/debugmotion/logger.rb +27 -14
- data/lib/debugmotion/version.rb +1 -1
- metadata +2 -2
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -5,7 +5,7 @@
|
|
5
5
|
|
6
6
|

|
7
7
|
|
8
|
-
**Debugmotion**, is a tiny gem to help you debug your app when using your device. It
|
8
|
+
**Debugmotion**, is a tiny gem to help you debug your app when using your device. It is thought for debugging strange network/gps behaviors. You define data you want to track and users/yourself can see the whole trace, to have more context.
|
9
9
|
|
10
10
|
### Setup
|
11
11
|
|
data/Rakefile
CHANGED
data/app/test_view_controller.rb
CHANGED
data/lib/debugmotion/console.rb
CHANGED
@@ -4,20 +4,26 @@ module Debugmotion
|
|
4
4
|
|
5
5
|
def initWithFrame(frame)
|
6
6
|
super
|
7
|
-
|
8
|
-
|
7
|
+
self.backgroundColor = UIColor.darkGrayColor
|
8
|
+
UIApplication.sharedApplication.keyWindow.addSubview(self)
|
9
9
|
self
|
10
10
|
end
|
11
11
|
|
12
|
-
def
|
12
|
+
def layoutSubviews
|
13
|
+
@text_view = text_view
|
14
|
+
@move_label = move_label
|
15
|
+
[@move_label, @text_view].each {|v| self.addSubview(v)}
|
16
|
+
end
|
17
|
+
|
18
|
+
def append(text)
|
13
19
|
@text_view.text = "#{@text_view.text} \n #{text}"
|
14
|
-
@text_view.scrollRangeToVisible(
|
20
|
+
@text_view.scrollRangeToVisible([@text_view.text.length - 1, 1])
|
15
21
|
end
|
16
22
|
|
17
23
|
def touchesMoved(touches, withEvent:event)
|
18
24
|
touch = touches.anyObject
|
19
|
-
previous_location = touch.previousLocationInView(self.superview
|
20
|
-
current_location = touch.locationInView(self.superview
|
25
|
+
previous_location = touch.previousLocationInView(self.superview)
|
26
|
+
current_location = touch.locationInView(self.superview)
|
21
27
|
center = self.center
|
22
28
|
center.x += current_location.x - previous_location.x
|
23
29
|
center.y += current_location.y - previous_location.y
|
@@ -27,22 +33,19 @@ module Debugmotion
|
|
27
33
|
private
|
28
34
|
|
29
35
|
def text_view
|
30
|
-
UITextView.alloc.initWithFrame([[5.0, 20.0],
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
text_view.textColor = UIColor.greenColor
|
36
|
-
self.addSubview(text_view)
|
36
|
+
UITextView.alloc.initWithFrame([[5.0, 20.0], [self.frame.size.width - 10.0, self.frame.size.height - 25.0]]).tap do |t|
|
37
|
+
t.backgroundColor = UIColor.blackColor
|
38
|
+
t.editable = false
|
39
|
+
t.font = UIFont.boldSystemFontOfSize(12.0)
|
40
|
+
t.textColor = UIColor.greenColor
|
37
41
|
end
|
38
42
|
end
|
39
43
|
|
40
|
-
def
|
41
|
-
UILabel.alloc.initWithFrame([[self.frame.size.width - 60, 3],[60, 15]]).tap do |
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
self.addSubview(label)
|
44
|
+
def move_label
|
45
|
+
UILabel.alloc.initWithFrame([[self.frame.size.width - 60, 3],[60, 15]]).tap do |l|
|
46
|
+
l.text = "Move me"
|
47
|
+
l.backgroundColor = UIColor.clearColor
|
48
|
+
l.font = UIFont.boldSystemFontOfSize(12.0)
|
46
49
|
end
|
47
50
|
end
|
48
51
|
|
data/lib/debugmotion/logger.rb
CHANGED
@@ -3,33 +3,46 @@ module Debugmotion
|
|
3
3
|
class Logger
|
4
4
|
|
5
5
|
@@instance = nil
|
6
|
-
|
6
|
+
|
7
7
|
def self.instance
|
8
8
|
return @@instance unless @@instance.nil?
|
9
9
|
@@instance = Logger.alloc.init
|
10
10
|
end
|
11
11
|
|
12
12
|
def start(frame)
|
13
|
-
@
|
14
|
-
|
15
|
-
UIApplication.sharedApplication.keyWindow.addSubview(@debug_view)
|
16
|
-
|
17
|
-
App.notification_center.observe "DebugMotionEventLogged" do |notification|
|
18
|
-
time = Time.new
|
19
|
-
@debug_view.append_text("[#{time.hour}:#{time.min}:#{time.sec}] #{notification.object}")
|
20
|
-
end
|
13
|
+
@console = Console.alloc.initWithFrame(frame)
|
14
|
+
start_tracking_log_events
|
21
15
|
end
|
22
16
|
|
23
17
|
def log(value)
|
24
|
-
|
25
|
-
|
26
|
-
unless UIApplication.sharedApplication.keyWindow.nil?
|
27
|
-
App.notification_center.post("DebugMotionEventLogged", value)
|
18
|
+
unless window_unavailable?
|
19
|
+
App.notification_center.post("DMEventLogged", value)
|
28
20
|
else
|
29
|
-
|
21
|
+
delay_logging(value)
|
30
22
|
end
|
31
23
|
end
|
32
24
|
|
25
|
+
private
|
26
|
+
|
27
|
+
def window_unavailable?
|
28
|
+
UIApplication.sharedApplication.keyWindow.nil?
|
29
|
+
end
|
30
|
+
|
31
|
+
def delay_logging(value)
|
32
|
+
App.run_after(0.1) { log(value) }
|
33
|
+
end
|
34
|
+
|
35
|
+
def start_tracking_log_events
|
36
|
+
App.notification_center.observe "DMEventLogged" do |notification|
|
37
|
+
@console.append("[#{pretty_time}] #{notification.object}")
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
def pretty_time
|
42
|
+
time = Time.new
|
43
|
+
"#{time.hour}:#{time.min}:#{time.sec}"
|
44
|
+
end
|
45
|
+
|
33
46
|
end
|
34
47
|
|
35
48
|
end
|
data/lib/debugmotion/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: debugmotion
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-09-
|
12
|
+
date: 2012-09-25 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bubble-wrap
|