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 CHANGED
@@ -1,6 +1,8 @@
1
1
  source :rubygems
2
2
 
3
3
  gem "rake"
4
- gem 'bubble-wrap', ">=1.1.3"
4
+ gem 'bubble-wrap', :git => "git://github.com/rubymotion/BubbleWrap.git", :branch => "master"
5
+ gem "motion-cocoapods", '~> 1.1.2'
6
+ gem "cocoapods", '~> 0.13.0'
5
7
 
6
8
  gemspec
data/README.md CHANGED
@@ -5,7 +5,7 @@
5
5
 
6
6
  ![Example](http://f.cl.ly/items/010V130Y00472L3Z0J1N/Capture%20d%E2%80%99%C3%A9cran%202012-09-05%20%C3%A0%2018.58.12.png)
7
7
 
8
- **Debugmotion**, is a tiny gem to help you debug your app when using your device. It allows you to see a console with debug informations you setup in live while you are using your app in real conditions.
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
@@ -2,6 +2,7 @@ $:.unshift("/Library/RubyMotion/lib")
2
2
  require 'motion/project'
3
3
  require 'bubble-wrap/core'
4
4
  require 'bubble-wrap/reactor'
5
+ require 'bubble-wrap/location'
5
6
  # require "bundler/gem_tasks"
6
7
  # require "bundler/setup"
7
8
 
@@ -9,6 +9,11 @@ class TestViewController < UIViewController
9
9
 
10
10
  def viewWillAppear(animated)
11
11
  Debugmotion.log('TestViewController -> viewWillAppear')
12
+
13
+
14
+ BW::Location.get do |result|
15
+ Debugmotion.log(result)
16
+ end
12
17
  end
13
18
 
14
19
  end
@@ -4,20 +4,26 @@ module Debugmotion
4
4
 
5
5
  def initWithFrame(frame)
6
6
  super
7
- move_me
8
- @text_view = text_view
7
+ self.backgroundColor = UIColor.darkGrayColor
8
+ UIApplication.sharedApplication.keyWindow.addSubview(self)
9
9
  self
10
10
  end
11
11
 
12
- def append_text(text)
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(NSMakeRange(@text_view.text.length - 1, 1))
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
- [self.frame.size.width - 10.0, self.frame.size.height - 25.0]]).tap do |text_view|
32
- text_view.backgroundColor = UIColor.blackColor
33
- text_view.editable = false
34
- text_view.font = UIFont.boldSystemFontOfSize(12.0)
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 move_me
41
- UILabel.alloc.initWithFrame([[self.frame.size.width - 60, 3],[60, 15]]).tap do |label|
42
- label.text = "Move me"
43
- label.backgroundColor = UIColor.clearColor
44
- label.font = UIFont.boldSystemFontOfSize(12.0)
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
 
@@ -4,7 +4,7 @@ module Debugmotion
4
4
  Logger.instance.log(value)
5
5
  end
6
6
 
7
- def self.start(frame = [[10, 40],[300, 100]])
7
+ def self.start(frame = [[10, 40],[300, 200]])
8
8
  Logger.instance.start(frame)
9
9
  end
10
10
 
@@ -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
- @debug_view = Console.alloc.initWithFrame(frame)
14
- @debug_view.backgroundColor = UIColor.darkGrayColor
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
- # hack for when you try to use debug motion in your root view controller
25
- # and your application:didFinishLaunchingWithOptions: has not yet ended
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
- App.run_after(0.1) { log(value) }
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
@@ -1,3 +1,3 @@
1
1
  module Debugmotion
2
- VERSION = "1.0.0"
2
+ VERSION = "1.0.1"
3
3
  end
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.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-05 00:00:00.000000000 Z
12
+ date: 2012-09-25 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bubble-wrap