locomotion 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 180738dbb15f07ef04165d0a3dc899ac85294e17
4
+ data.tar.gz: 9a92d1f757b4557bd03d8717386caa95419cc427
5
+ SHA512:
6
+ metadata.gz: 5221aa2bf7100b699ddaf0231f9a4f20d204533f3d7272df269390944cc2ff90993f1151a8c5a04e51ff582d6c448dd5a0a78793597904c6ffabfc85d5eab901
7
+ data.tar.gz: f5b6459b9d0a58f75e89660bef2f641a69c365b7fbb20a8ebb851888f2815e459fafc87a1243f74a67ab78dd2c005593a3276dadeea218870b6b4445d3bda89d
checksums.yaml.gz.sig ADDED
Binary file
data.tar.gz.sig ADDED
@@ -0,0 +1,2 @@
1
+ X�0)v�}���Mr�O����8�5D�'��[�銱n̎K�<�#�Zӫ�z�wȷ{��y�����}�@g�X�V��<\b� ƚl��&N7�F��0#�\1M�Bڸ���PA>h���%��&������}�9�M�)��ƒYmg���f�h�<xIx�*Pea�S��߄��;? �a�
2
+ �}~�EּTuZ4� @�eH��.p>Ώ\ơ���爥 Y�UE�q�:<vԜ
data/.gitignore ADDED
@@ -0,0 +1,18 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
18
+ build/**
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in locomotion.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2013 Jon Rowe
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,29 @@
1
+ # Locomotion
2
+
3
+ TODO: Write a gem description
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'locomotion'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install locomotion
18
+
19
+ ## Usage
20
+
21
+ TODO: Write usage instructions here
22
+
23
+ ## Contributing
24
+
25
+ 1. Fork it
26
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
27
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
28
+ 4. Push to the branch (`git push origin my-new-feature`)
29
+ 5. Create new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,16 @@
1
+ require "bundler/gem_tasks"
2
+ require 'dotenv'
3
+ Dotenv.load
4
+
5
+ $:.unshift("/Library/RubyMotion/lib")
6
+ require 'motion/project/template/ios'
7
+
8
+ $:.unshift("./lib/")
9
+ require './lib/locomotion'
10
+
11
+ Motion::Project::App.setup do |app|
12
+ # Use `rake config' to see complete project settings.
13
+ app.name = 'Locomotion'
14
+ app.identifier = 'com.locomotion.test'
15
+ app.deployment_target = "5.1"
16
+ end
@@ -0,0 +1,18 @@
1
+ class AppDelegate
2
+
3
+ def application application, didFinishLaunchingWithOptions: launchOptions
4
+ @window = UIWindow.alloc.initWithFrame(UIScreen.mainScreen.bounds)
5
+
6
+ @controller = UIViewController.alloc.initWithNibName(nil, bundle:nil)
7
+
8
+ @window.rootViewController = @controller
9
+ @window.makeKeyAndVisible
10
+
11
+ #@label = UILabel.alloc.initWithFrame [ [10,10], [300,100] ]
12
+ #@label.setAccessibilityLabel 'username'
13
+ #@label.setText '...'
14
+ #@controller.view.addSubview @label
15
+
16
+ true
17
+ end
18
+ end
data/lib/locomotion.rb ADDED
@@ -0,0 +1,16 @@
1
+ require "locomotion/version"
2
+
3
+ unless defined?(Motion::Project::Config)
4
+ raise "This file must be required within a RubyMotion project config (usually the Rakefile)."
5
+ end
6
+
7
+ Motion::Project::App.setup do |app|
8
+
9
+ root = File.join( File.dirname(__FILE__), '../motion' )
10
+
11
+ Dir.glob(root+'/**/*.rb').each do |file|
12
+ app.files.unshift(file)
13
+ end
14
+ app.frameworks << 'CoreLocation'
15
+
16
+ end
@@ -0,0 +1,3 @@
1
+ module Locomotion
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,23 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'locomotion/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "locomotion"
8
+ spec.version = Locomotion::VERSION
9
+ spec.authors = ["Jon Rowe"]
10
+ spec.email = ["hello@jonrowe.co.uk"]
11
+ spec.description = %q{Geolocation library for RubyMotion}
12
+ spec.summary = %q{Geolocation library for RubyMotion}
13
+ spec.homepage = "https://github.com/JonRowe/locomotion"
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files`.split($/)
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(spec|app)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_development_dependency "bundler", "~> 1.3"
22
+ spec.add_development_dependency "rake"
23
+ end
@@ -0,0 +1,23 @@
1
+ module Locomotion
2
+ class << self
3
+
4
+ def watch opts = {}, &block
5
+ watchman.process opts
6
+ watchman.listeners << block
7
+ watchman.go
8
+ end
9
+
10
+ def defer time
11
+ watchman.pause time
12
+ end
13
+
14
+ def stop
15
+ watchman.clear
16
+ end
17
+
18
+ def watchman
19
+ @watchman ||= Watchman.alloc.init
20
+ end
21
+
22
+ end
23
+ end
@@ -0,0 +1,40 @@
1
+ module Locomotion
2
+ class Delegate
3
+
4
+ def initWith watchman
5
+ @watchman = watchman
6
+ self
7
+ end
8
+ attr_reader :watchman
9
+
10
+ def locationManager manager, didUpdateToLocation: location, fromLocation: old_location
11
+ @watchman.update location
12
+ end
13
+
14
+ def locationManager manager, didUpdateLocations: locations
15
+ @watchman.update locations[-1]
16
+ end
17
+
18
+ def locationManager manager, didFailWithError: error
19
+ if error.domain == KCLErrorDomain
20
+ case error.code
21
+ when KCLErrorDenied
22
+ @watchman.error :denied
23
+ when KCLErrorLocationUnknown
24
+ manager.stopUpdatingLocation
25
+ manager.startUpdatingLocation
26
+ end
27
+ end
28
+ end
29
+
30
+ def locationManager manager, didChangeAuthorizationStatus:status
31
+ case status
32
+ when KCLAuthorizationStatusRestricted
33
+ @watchman.error :denied
34
+ when KCLAuthorizationStatusDenied
35
+ @watchman.error :denied
36
+ end
37
+ end
38
+
39
+ end
40
+ end
@@ -0,0 +1,43 @@
1
+ module Locomotion
2
+ class Watchman
3
+
4
+ def init location_manager = CLLocationManager
5
+ @location_manager = location_manager.alloc.init
6
+ @location_manager.delegate = Locomotion::Delegate.alloc.initWith(self)
7
+ @location_manager.distanceFilter = KCLDistanceFilterNone
8
+ @location_manager.desiredAccuracy = KCLLocationAccuracyBest
9
+ self
10
+ end
11
+ attr_reader :location_manager
12
+
13
+ def process options = {}
14
+ @location_manager.purpose = options[:purpose] if options[:purpose]
15
+ end
16
+
17
+ def listeners
18
+ @listeners ||= []
19
+ end
20
+
21
+ def go
22
+ @location_manager.startUpdatingLocation
23
+ end
24
+
25
+ def pause time
26
+ @location_manager.allowDeferredLocationUpdatesUntilTraveled 10000, timeout: time
27
+ end
28
+
29
+ def clear
30
+ @location_manager.stopUpdatingLocation
31
+ end
32
+
33
+ def update location
34
+ @listeners.each do |listener|
35
+ listener.call location
36
+ end
37
+ end
38
+
39
+ def error code
40
+ end
41
+
42
+ end
43
+ end
@@ -0,0 +1,69 @@
1
+ describe 'he who watches the watchman (the delegate)' do
2
+
3
+ before do
4
+ watchman = Class.new do
5
+ def update location
6
+ @locations ||= []
7
+ @locations << location
8
+ end
9
+ def error error
10
+ @errors ||= []
11
+ @errors << error
12
+ end
13
+ attr_reader :locations, :errors
14
+ end
15
+ @watchman = watchman.alloc.init
16
+ @delegate = Locomotion::Delegate.alloc.initWith @watchman
17
+ end
18
+
19
+ it 'handles updateToLocation' do
20
+ @delegate.locationManager nil, didUpdateToLocation: "location", fromLocation: "old location"
21
+ @watchman.locations.should.equal ["location"]
22
+ end
23
+
24
+ it 'handles didUpdateLocations' do
25
+ @delegate.locationManager nil, didUpdateLocations: [1,2]
26
+ @watchman.locations.should.equal [2]
27
+ end
28
+
29
+ it 'handles didFailWithError: KCLErrorDenied by notifying the watchman' do
30
+ @delegate.locationManager nil, didFailWithError: NSError.errorWithDomain(KCLErrorDomain, code: KCLErrorDenied, userInfo: {})
31
+ @watchman.errors.should.equal [:denied]
32
+ end
33
+
34
+ it 'handles didFailWithError: other by ignoring' do
35
+ @delegate.locationManager nil, didFailWithError: NSError.errorWithDomain('other', code: 0, userInfo: {})
36
+ @watchman.errors.should.equal nil
37
+ end
38
+
39
+ it 'handles didFailWithError: KCLErrorLocationUnknown by restarting' do
40
+ manager = Class.new do
41
+ def startUpdatingLocation
42
+ commands << :start
43
+ end
44
+ def stopUpdatingLocation
45
+ commands << :stop
46
+ end
47
+ def commands
48
+ @commands ||= []
49
+ end
50
+ end.new
51
+ @delegate.locationManager manager, didFailWithError: NSError.errorWithDomain(KCLErrorDomain, code: KCLErrorLocationUnknown, userInfo: {})
52
+ manager.commands.should.equal [:stop,:start]
53
+ end
54
+
55
+ it 'handles didChangeAuthorizationStatus: restricted by notifying the watchman' do
56
+ @delegate.locationManager nil, didChangeAuthorizationStatus: KCLAuthorizationStatusRestricted
57
+ @watchman.errors.should.equal [:denied]
58
+ end
59
+
60
+ it 'handles didChangeAuthorizationStatus denied notifying the watchman' do
61
+ @delegate.locationManager nil, didChangeAuthorizationStatus: KCLAuthorizationStatusDenied
62
+ @watchman.errors.should.equal [:denied]
63
+ end
64
+
65
+ it 'handles didChangeAuthorizationStatus other' do
66
+ @delegate.locationManager nil, didChangeAuthorizationStatus: nil
67
+ @watchman.errors.should.equal nil
68
+ end
69
+ end
@@ -0,0 +1,65 @@
1
+ describe 'the watchman' do
2
+
3
+ before do
4
+ test_manager = Class.new do
5
+ attr_accessor :delegate, :distanceFilter, :desiredAccuracy, :purpose
6
+
7
+ def startUpdatingLocation
8
+ commands << :start
9
+ end
10
+ def stopUpdatingLocation
11
+ commands << :stop
12
+ end
13
+ def allowDeferredLocationUpdatesUntilTraveled distance, timeout: time
14
+ commands << [:defer,distance,time]
15
+ end
16
+ def commands
17
+ @commands ||= []
18
+ end
19
+ end
20
+ @watchman = Locomotion::Watchman.alloc.init test_manager
21
+ end
22
+
23
+ it 'initialises the location manager with the minimum distance filter' do
24
+ @watchman.location_manager.distanceFilter.should.equal KCLDistanceFilterNone
25
+ end
26
+ it 'initialises the location manager with the best accuracy' do
27
+ @watchman.location_manager.desiredAccuracy.should.equal KCLLocationAccuracyBest
28
+ end
29
+ it 'sets the delegate to be a locomotion delegate' do
30
+ @watchman.location_manager.should.satisfy do |lm|
31
+ lm.delegate.class == Locomotion::Delegate and
32
+ lm.delegate.watchman == @watchman
33
+ end
34
+ end
35
+
36
+ it 'processes purpose' do
37
+ @watchman.process purpose: 'My Purpose'
38
+ @watchman.location_manager.purpose.should.equal 'My Purpose'
39
+ end
40
+
41
+ it 'accepts listeners' do
42
+ @watchman.listeners << :a
43
+ @watchman.listeners.should.equal [:a]
44
+ end
45
+
46
+ it 'tells location manager to start on go' do
47
+ @watchman.go
48
+ @watchman.location_manager.commands.should.equal [:start]
49
+ end
50
+ it 'tells location manager to defer on pause' do
51
+ @watchman.pause 42
52
+ @watchman.location_manager.commands.should.equal [[:defer,10000,42]]
53
+ end
54
+ it 'tells location manager to stop on clear' do
55
+ @watchman.clear
56
+ @watchman.location_manager.commands.should.equal [:stop]
57
+ end
58
+
59
+ it 'tells listeners on update' do
60
+ @watchman.listeners << proc { |location| @location = location }
61
+ @watchman.update [1,1]
62
+ @location.should.equal [1,1]
63
+ end
64
+
65
+ end
metadata ADDED
@@ -0,0 +1,110 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: locomotion
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Jon Rowe
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain:
11
+ - |
12
+ -----BEGIN CERTIFICATE-----
13
+ MIIDVjCCAj6gAwIBAgIBADANBgkqhkiG9w0BAQUFADBRMQ4wDAYDVQQDDAVoZWxs
14
+ bzEXMBUGCgmSJomT8ixkARkWB2pvbnJvd2UxEjAQBgoJkiaJk/IsZAEZFgJjbzES
15
+ MBAGCgmSJomT8ixkARkWAnVrMB4XDTEzMDIwMzA4MTgwNloXDTE0MDIwMzA4MTgw
16
+ NlowUTEOMAwGA1UEAwwFaGVsbG8xFzAVBgoJkiaJk/IsZAEZFgdqb25yb3dlMRIw
17
+ EAYKCZImiZPyLGQBGRYCY28xEjAQBgoJkiaJk/IsZAEZFgJ1azCCASIwDQYJKoZI
18
+ hvcNAQEBBQADggEPADCCAQoCggEBAMhs6ng/SRrYfG7RtQx8liJTZs8tpz7PBnlH
19
+ qyOwuU0weJc7nh6C9C8LGyJzpkbjJJo1rfTMg7huDyL14Py82dfMDomApif8jNNI
20
+ 8KtviAgB1DrWq0fCDLtu/M77+yuVV3OhDdrAFaBkT/euvdJ8cAKrLxbJ+klgvrcB
21
+ FK+c4PUV3/zBKghe0l7FuDhyQCsuLNDbWyFvDS97tPjeN6yWuszwg22vZMDdsuzN
22
+ Cj3M4LLSkbrt+AOUcysEJxI4t6uv2U1bRzHsDfAF0RI/Q7OMtUr+Dtz/2YJ47KKs
23
+ 51ZRjLLGHd10XrIfFSfGyJj1dMbDgLsEBj1sFH4e6dy7gau8TaUCAwEAAaM5MDcw
24
+ CQYDVR0TBAIwADAdBgNVHQ4EFgQULu5JH2g7RAjoXaZt+fbrfNDI9IkwCwYDVR0P
25
+ BAQDAgSwMA0GCSqGSIb3DQEBBQUAA4IBAQAf5A4kB769DPKGjPZ++v42FwVi7X7v
26
+ RpufPs6R4YHyzHXaJmAqnhleZhVJijBgsdb2SigNRbg+IK8XYHg7jkonMgO8OS3D
27
+ C6w8VB5bI0PqyDOwCGcQkYHYlZZWCghAyBTSBowHAekMb9V3QjJtJ8XkizjshETO
28
+ ZCVI2AObjlJi8I10aK2tSo9sv2riCKZ92BVSM13zYWn+C/eCP/m9BDiw37UQtuQq
29
+ 2feWfO4gCNmvfFjULOAYHq9JHEjN5SLSXvj5HdSnDcCyIfJKn5Ya3JahWQaWIsXf
30
+ /NPE/mB57TOwj+d7XUa2NC4HUadF8R51IYEcIB0PpIEzJlKtfXFcOZxO
31
+ -----END CERTIFICATE-----
32
+ date: 2013-05-28 00:00:00.000000000 Z
33
+ dependencies:
34
+ - !ruby/object:Gem::Dependency
35
+ name: bundler
36
+ requirement: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ~>
39
+ - !ruby/object:Gem::Version
40
+ version: '1.3'
41
+ type: :development
42
+ prerelease: false
43
+ version_requirements: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ~>
46
+ - !ruby/object:Gem::Version
47
+ version: '1.3'
48
+ - !ruby/object:Gem::Dependency
49
+ name: rake
50
+ requirement: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ type: :development
56
+ prerelease: false
57
+ version_requirements: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ description: Geolocation library for RubyMotion
63
+ email:
64
+ - hello@jonrowe.co.uk
65
+ executables: []
66
+ extensions: []
67
+ extra_rdoc_files: []
68
+ files:
69
+ - .gitignore
70
+ - Gemfile
71
+ - LICENSE.txt
72
+ - README.md
73
+ - Rakefile
74
+ - app/app_delegate.rb
75
+ - lib/locomotion.rb
76
+ - lib/locomotion/version.rb
77
+ - locomotion.gemspec
78
+ - motion/locomotion.rb
79
+ - motion/locomotion/delegate.rb
80
+ - motion/locomotion/watchman.rb
81
+ - spec/locomotion/delegate_spec.rb
82
+ - spec/locomotion/watchman_spec.rb
83
+ homepage: https://github.com/JonRowe/locomotion
84
+ licenses:
85
+ - MIT
86
+ metadata: {}
87
+ post_install_message:
88
+ rdoc_options: []
89
+ require_paths:
90
+ - lib
91
+ required_ruby_version: !ruby/object:Gem::Requirement
92
+ requirements:
93
+ - - '>='
94
+ - !ruby/object:Gem::Version
95
+ version: '0'
96
+ required_rubygems_version: !ruby/object:Gem::Requirement
97
+ requirements:
98
+ - - '>='
99
+ - !ruby/object:Gem::Version
100
+ version: '0'
101
+ requirements: []
102
+ rubyforge_project:
103
+ rubygems_version: 2.0.3
104
+ signing_key:
105
+ specification_version: 4
106
+ summary: Geolocation library for RubyMotion
107
+ test_files:
108
+ - app/app_delegate.rb
109
+ - spec/locomotion/delegate_spec.rb
110
+ - spec/locomotion/watchman_spec.rb
metadata.gz.sig ADDED
@@ -0,0 +1,2 @@
1
+ n�fO-:;��08i�
2
+ ����p��ͅ����5V��D�3r_��^�ȴ`9��|pe�mVړs[Jz�2C�%�K^�?f���1!�t5d� �ƕ��f���h}XE�3��'+}��x�N��Rl0��O�H��
3
+ *�������_�%����ҵ��T7)O�;q,&���`{��R�$U���pc�bάy���� �D�{r�=�S>=�2=CA�s̡�����,�