debugmotion 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore ADDED
@@ -0,0 +1,11 @@
1
+ .repl_history
2
+ build
3
+ resources/*.nib
4
+ resources/*.momd
5
+ resources/*.storyboardc
6
+ .DS_STORE
7
+ *.gem
8
+ .bundle
9
+ Gemfile.lock
10
+ pkg/*
11
+ .rvmrc
@@ -0,0 +1,19 @@
1
+ # -*- encoding: utf-8 -*-
2
+ require File.expand_path('../lib/debugmotion/version', __FILE__)
3
+
4
+ Gem::Specification.new do |s|
5
+ s.name = "debugmotion"
6
+ s.version = Debugmotion::VERSION
7
+ s.authors = ["Joffrey Jafeux"]
8
+ s.email = ["j.jaffeux@gmail.com"]
9
+ s.homepage = "https://github.com/jjaffeux/Debugmotion"
10
+ s.summary = "Log live debug informations on your device for rubymotion"
11
+ s.description = "Log live debug informations on your device for rubymotion"
12
+
13
+ s.files = `git ls-files`.split($\)
14
+ s.test_files = s.files.grep(%r{^(test|spec|features)/})
15
+ s.require_paths = ["lib"]
16
+
17
+ s.add_dependency "bubble-wrap", ">= 1.1.3"
18
+ s.add_development_dependency 'rake'
19
+ end
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ source :rubygems
2
+
3
+ gem "rake"
4
+ gem 'bubble-wrap', ">=1.1.3"
5
+
6
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License
2
+
3
+ Copyright (c) 2010 Joffrey Jaffeux <j.jaffeux@gmail.com>
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,44 @@
1
+ # Debugmotion
2
+
3
+
4
+ ## Overview
5
+
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
+
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.
9
+
10
+ ### Setup
11
+
12
+ **Loot at the rakefile and the demo app for fast example**
13
+
14
+ 1. gem install debugmotion
15
+ 2. require 'debugmotion' (Rakefile)
16
+
17
+ ### Usage
18
+
19
+
20
+ ## In your app_delegate
21
+ ````ruby
22
+ class AppDelegate
23
+
24
+ def application(application, didFinishLaunchingWithOptions:launchOptions)
25
+ @window = UIWindow.alloc.initWithFrame(UIScreen.mainScreen.bounds)
26
+ @view_controller = TestViewController.alloc.init
27
+ @view_controller.view.backgroundColor = UIColor.grayColor
28
+ @window.rootViewController = @view_controller
29
+ @window.makeKeyAndVisible
30
+
31
+ #must be after @window.makeKeyAndVisible
32
+ Debugmotion.start
33
+
34
+ true
35
+ end
36
+
37
+ end
38
+ ````
39
+
40
+ ## In your code
41
+ ````ruby
42
+ #for example to track informations about your connexion
43
+ Debugmotion.log("Connexion status : #{connexion_status}")
44
+ ````
data/Rakefile ADDED
@@ -0,0 +1,13 @@
1
+ $:.unshift("/Library/RubyMotion/lib")
2
+ require 'motion/project'
3
+ require 'bubble-wrap/core'
4
+ require 'bubble-wrap/reactor'
5
+ # require "bundler/gem_tasks"
6
+ # require "bundler/setup"
7
+
8
+ $:.unshift("./lib/")
9
+ require './lib/debugmotion'
10
+
11
+ Motion::Project::App.setup do |app|
12
+ app.name = 'Debugmotion'
13
+ end
@@ -0,0 +1,15 @@
1
+ class AppDelegate
2
+
3
+ def application(application, didFinishLaunchingWithOptions:launchOptions)
4
+ @window = UIWindow.alloc.initWithFrame(UIScreen.mainScreen.bounds)
5
+ @view_controller = TestViewController.alloc.init
6
+ @view_controller.view.backgroundColor = UIColor.grayColor
7
+ @window.rootViewController = @view_controller
8
+ @window.makeKeyAndVisible
9
+
10
+ Debugmotion.start
11
+
12
+ true
13
+ end
14
+
15
+ end
@@ -0,0 +1,14 @@
1
+ class TestViewController < UIViewController
2
+
3
+ def viewDidLoad
4
+ super
5
+ Debugmotion.log('TestViewController -> viewDidLoad')
6
+ Debugmotion.log("View height : #{self.view.size.height}")
7
+ Debugmotion.log("View width : #{self.view.size.width}")
8
+ end
9
+
10
+ def viewWillAppear(animated)
11
+ Debugmotion.log('TestViewController -> viewWillAppear')
12
+ end
13
+
14
+ end
@@ -0,0 +1,51 @@
1
+ module Debugmotion
2
+
3
+ class Console < UIView
4
+
5
+ def initWithFrame(frame)
6
+ super
7
+ move_me
8
+ @text_view = text_view
9
+ self
10
+ end
11
+
12
+ def append_text(text)
13
+ @text_view.text = "#{@text_view.text} \n #{text}"
14
+ @text_view.scrollRangeToVisible(NSMakeRange(@text_view.text.length - 1, 1))
15
+ end
16
+
17
+ def touchesMoved(touches, withEvent:event)
18
+ touch = touches.anyObject
19
+ previous_location = touch.previousLocationInView(self.superview )
20
+ current_location = touch.locationInView(self.superview )
21
+ center = self.center
22
+ center.x += current_location.x - previous_location.x
23
+ center.y += current_location.y - previous_location.y
24
+ self.center = center
25
+ end
26
+
27
+ private
28
+
29
+ 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)
37
+ end
38
+ end
39
+
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)
46
+ end
47
+ end
48
+
49
+ end
50
+
51
+ end
@@ -0,0 +1,11 @@
1
+ module Debugmotion
2
+
3
+ def self.log(value)
4
+ Logger.instance.log(value)
5
+ end
6
+
7
+ def self.start(frame = [[10, 40],[300, 100]])
8
+ Logger.instance.start(frame)
9
+ end
10
+
11
+ end
@@ -0,0 +1,35 @@
1
+ module Debugmotion
2
+
3
+ class Logger
4
+
5
+ @@instance = nil
6
+
7
+ def self.instance
8
+ return @@instance unless @@instance.nil?
9
+ @@instance = Logger.alloc.init
10
+ end
11
+
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
21
+ end
22
+
23
+ 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)
28
+ else
29
+ App.run_after(0.1) { log(value) }
30
+ end
31
+ end
32
+
33
+ end
34
+
35
+ end
@@ -0,0 +1,3 @@
1
+ module Debugmotion
2
+ VERSION = "1.0.0"
3
+ end
@@ -0,0 +1,4 @@
1
+ require 'bubble-wrap/core'
2
+ require "debugmotion/version"
3
+
4
+ BW.require File.expand_path('../debugmotion/**/*.rb', __FILE__)
@@ -0,0 +1,12 @@
1
+ describe "Debugmotion/Debugmotion" do
2
+ tests TestViewController
3
+
4
+ it "should open the debugmotion console" do
5
+ #Fixme : It's seems like Debugmotion::Console view is removed
6
+ # when the test starts, wen can see it during half a second and it
7
+ # disappears, if you know a way to test this, please tell me
8
+ p "FIXME"
9
+ true.should == true
10
+ end
11
+
12
+ end
metadata ADDED
@@ -0,0 +1,92 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: debugmotion
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Joffrey Jafeux
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-09-05 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: bubble-wrap
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: 1.1.3
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: 1.1.3
30
+ - !ruby/object:Gem::Dependency
31
+ name: rake
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ! '>='
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
38
+ type: :development
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
46
+ description: Log live debug informations on your device for rubymotion
47
+ email:
48
+ - j.jaffeux@gmail.com
49
+ executables: []
50
+ extensions: []
51
+ extra_rdoc_files: []
52
+ files:
53
+ - .gitignore
54
+ - Debugmotion.gemspec
55
+ - Gemfile
56
+ - LICENSE
57
+ - README.md
58
+ - Rakefile
59
+ - app/app_delegate.rb
60
+ - app/test_view_controller.rb
61
+ - lib/debugmotion.rb
62
+ - lib/debugmotion/console.rb
63
+ - lib/debugmotion/debugmotion.rb
64
+ - lib/debugmotion/logger.rb
65
+ - lib/debugmotion/version.rb
66
+ - spec/debugmotion_spec.rb
67
+ homepage: https://github.com/jjaffeux/Debugmotion
68
+ licenses: []
69
+ post_install_message:
70
+ rdoc_options: []
71
+ require_paths:
72
+ - lib
73
+ required_ruby_version: !ruby/object:Gem::Requirement
74
+ none: false
75
+ requirements:
76
+ - - ! '>='
77
+ - !ruby/object:Gem::Version
78
+ version: '0'
79
+ required_rubygems_version: !ruby/object:Gem::Requirement
80
+ none: false
81
+ requirements:
82
+ - - ! '>='
83
+ - !ruby/object:Gem::Version
84
+ version: '0'
85
+ requirements: []
86
+ rubyforge_project:
87
+ rubygems_version: 1.8.24
88
+ signing_key:
89
+ specification_version: 3
90
+ summary: Log live debug informations on your device for rubymotion
91
+ test_files:
92
+ - spec/debugmotion_spec.rb