lost 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.autotest +23 -0
- data/History.txt +6 -0
- data/Manifest.txt +10 -0
- data/README.txt +58 -0
- data/Rakefile +12 -0
- data/bin/lost +5 -0
- data/ext/lost/core_loc.m +95 -0
- data/ext/lost/extconf.rb +5 -0
- data/ext/lost/lost.c +30 -0
- data/lib/lost.rb +7 -0
- metadata +122 -0
data/.autotest
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
# -*- ruby -*-
|
2
|
+
|
3
|
+
require 'autotest/restart'
|
4
|
+
|
5
|
+
# Autotest.add_hook :initialize do |at|
|
6
|
+
# at.extra_files << "../some/external/dependency.rb"
|
7
|
+
#
|
8
|
+
# at.libs << ":../some/external"
|
9
|
+
#
|
10
|
+
# at.add_exception 'vendor'
|
11
|
+
#
|
12
|
+
# at.add_mapping(/dependency.rb/) do |f, _|
|
13
|
+
# at.files_matching(/test_.*rb$/)
|
14
|
+
# end
|
15
|
+
#
|
16
|
+
# %w(TestA TestB).each do |klass|
|
17
|
+
# at.extra_class_map[klass] = "test/test_misc.rb"
|
18
|
+
# end
|
19
|
+
# end
|
20
|
+
|
21
|
+
# Autotest.add_hook :run_command do |at|
|
22
|
+
# system "rake build"
|
23
|
+
# end
|
data/History.txt
ADDED
data/Manifest.txt
ADDED
data/README.txt
ADDED
@@ -0,0 +1,58 @@
|
|
1
|
+
= lost
|
2
|
+
|
3
|
+
* http://github.com/evanphx/lost
|
4
|
+
|
5
|
+
== DESCRIPTION:
|
6
|
+
|
7
|
+
Find where you are with CoreLocation!
|
8
|
+
|
9
|
+
== FEATURES/PROBLEMS:
|
10
|
+
|
11
|
+
* Uses OS X's CoreLocation to provide the current latitude and longitude
|
12
|
+
|
13
|
+
== SYNOPSIS:
|
14
|
+
|
15
|
+
require 'lost'
|
16
|
+
p Lost.current_position
|
17
|
+
|
18
|
+
== REQUIREMENTS:
|
19
|
+
|
20
|
+
* CoreLocation to work (wifi hotspots around)
|
21
|
+
|
22
|
+
== INSTALL:
|
23
|
+
|
24
|
+
* gem install lost
|
25
|
+
|
26
|
+
== DEVELOPERS:
|
27
|
+
|
28
|
+
After checking out the source, run:
|
29
|
+
|
30
|
+
$ rake newb
|
31
|
+
|
32
|
+
This task will install any missing dependencies, run the tests/specs,
|
33
|
+
and generate the RDoc.
|
34
|
+
|
35
|
+
== LICENSE:
|
36
|
+
|
37
|
+
(The MIT License)
|
38
|
+
|
39
|
+
Copyright (c) 2012 Evan Phoenix
|
40
|
+
|
41
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
42
|
+
a copy of this software and associated documentation files (the
|
43
|
+
'Software'), to deal in the Software without restriction, including
|
44
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
45
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
46
|
+
permit persons to whom the Software is furnished to do so, subject to
|
47
|
+
the following conditions:
|
48
|
+
|
49
|
+
The above copyright notice and this permission notice shall be
|
50
|
+
included in all copies or substantial portions of the Software.
|
51
|
+
|
52
|
+
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
53
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
54
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
55
|
+
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
56
|
+
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
57
|
+
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
58
|
+
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/Rakefile
ADDED
data/bin/lost
ADDED
data/ext/lost/core_loc.m
ADDED
@@ -0,0 +1,95 @@
|
|
1
|
+
//
|
2
|
+
// Using CoreLocation on Mac OS X with command-line
|
3
|
+
// $ clang CoreLocationTest.m -framework cocoa -framework CoreLocation
|
4
|
+
// $ ./a.out
|
5
|
+
// location service enabled
|
6
|
+
// 2011-12-01 21:03:01.839 a.out[10214:903] latitude,logitude : 35.606647, 140.695538
|
7
|
+
// 2011-12-01 21:03:01.842 a.out[10214:903] timestamp : 2011-12-01 21:01:36 +0900
|
8
|
+
// tmiz moo@tmiz.net
|
9
|
+
//
|
10
|
+
//
|
11
|
+
#import <cocoa/cocoa.h>
|
12
|
+
#import <CoreLocation/CoreLocation.h>
|
13
|
+
|
14
|
+
@interface LLHolder : NSObject {
|
15
|
+
double latitude;
|
16
|
+
double longitude;
|
17
|
+
}
|
18
|
+
|
19
|
+
- (void)latitude:(double*)lat longitude:(double*)log;
|
20
|
+
|
21
|
+
- (void)logLonLat:(CLLocation*)location;
|
22
|
+
- (void)locationManager:(CLLocationManager *)manager
|
23
|
+
didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation;
|
24
|
+
- (void)locationManager:(CLLocationManager *)manager didFailWithError:(NSError *)error;
|
25
|
+
@end
|
26
|
+
|
27
|
+
@implementation LLHolder
|
28
|
+
- (void)latitude:(double*)lat longitude:(double*)log
|
29
|
+
{
|
30
|
+
*lat = latitude;
|
31
|
+
*log = longitude;
|
32
|
+
}
|
33
|
+
|
34
|
+
- (void)logLonLat:(CLLocation*)location
|
35
|
+
{
|
36
|
+
CLLocationCoordinate2D coordinate = location.coordinate;
|
37
|
+
latitude = coordinate.latitude;
|
38
|
+
longitude = coordinate.longitude;
|
39
|
+
|
40
|
+
CFRunLoopStop(CFRunLoopGetCurrent());
|
41
|
+
}
|
42
|
+
|
43
|
+
- (void)locationManager:(CLLocationManager *)manager
|
44
|
+
didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation {
|
45
|
+
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
|
46
|
+
[self logLonLat:newLocation];
|
47
|
+
[pool drain];
|
48
|
+
}
|
49
|
+
|
50
|
+
- (void)locationManager:(CLLocationManager *)manager didFailWithError:(NSError *)error{
|
51
|
+
latitude = 0.0;
|
52
|
+
longitude = 0.0;
|
53
|
+
CFRunLoopStop(CFRunLoopGetCurrent());
|
54
|
+
}
|
55
|
+
@end
|
56
|
+
|
57
|
+
id g_lm = nil;
|
58
|
+
|
59
|
+
int int_coreloc_enable() {
|
60
|
+
if ([CLLocationManager locationServicesEnabled]) {
|
61
|
+
g_lm = [[CLLocationManager alloc] init];
|
62
|
+
return 1;
|
63
|
+
}
|
64
|
+
|
65
|
+
return 0;
|
66
|
+
}
|
67
|
+
|
68
|
+
void int_coreloc_get(double* lat, double* log) {
|
69
|
+
LLHolder* obj = [[LLHolder alloc] init];
|
70
|
+
[g_lm setDelegate:obj];
|
71
|
+
[g_lm startUpdatingLocation];
|
72
|
+
|
73
|
+
CFRunLoopRun();
|
74
|
+
|
75
|
+
[obj release];
|
76
|
+
|
77
|
+
[obj latitude: lat longitude: log];
|
78
|
+
}
|
79
|
+
|
80
|
+
// int main(int ac,char *av[])
|
81
|
+
// {
|
82
|
+
// id obj = [[NSObject alloc] init];
|
83
|
+
// id lm = nil;
|
84
|
+
// if ([CLLocationManager locationServicesEnabled]) {
|
85
|
+
// printf("location service enabled\n");
|
86
|
+
// lm = [[CLLocationManager alloc] init];
|
87
|
+
// [lm setDelegate:obj];
|
88
|
+
// [lm startUpdatingLocation];
|
89
|
+
// }
|
90
|
+
|
91
|
+
// CFRunLoopRun();
|
92
|
+
// [lm release];
|
93
|
+
// [obj release];
|
94
|
+
// return 0;
|
95
|
+
// }
|
data/ext/lost/extconf.rb
ADDED
data/ext/lost/lost.c
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
#include "ruby.h"
|
2
|
+
#include "intern.h"
|
3
|
+
|
4
|
+
int int_coreloc_enable();
|
5
|
+
void int_coreloc_get(double* lat, double* log);
|
6
|
+
|
7
|
+
VALUE coreloc_enable(VALUE r_self) {
|
8
|
+
if(int_coreloc_enable()) {
|
9
|
+
return Qtrue;
|
10
|
+
}
|
11
|
+
|
12
|
+
return Qfalse;
|
13
|
+
}
|
14
|
+
|
15
|
+
VALUE coreloc_pos(VALUE r_self) {
|
16
|
+
double lat, log;
|
17
|
+
|
18
|
+
int_coreloc_get(&lat, &log);
|
19
|
+
|
20
|
+
return rb_ary_new3(2, rb_float_new(lat),
|
21
|
+
rb_float_new(log));
|
22
|
+
}
|
23
|
+
|
24
|
+
void Init_lost() {
|
25
|
+
VALUE mod = rb_define_module("Lost");
|
26
|
+
|
27
|
+
rb_define_singleton_method(mod, "coreloc_enable", coreloc_enable, 0);
|
28
|
+
rb_define_singleton_method(mod, "current_position", coreloc_pos, 0);
|
29
|
+
}
|
30
|
+
|
data/lib/lost.rb
ADDED
metadata
ADDED
@@ -0,0 +1,122 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: lost
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 23
|
5
|
+
prerelease:
|
6
|
+
segments:
|
7
|
+
- 1
|
8
|
+
- 0
|
9
|
+
- 0
|
10
|
+
version: 1.0.0
|
11
|
+
platform: ruby
|
12
|
+
authors:
|
13
|
+
- Evan Phoenix
|
14
|
+
autorequire:
|
15
|
+
bindir: bin
|
16
|
+
cert_chain: []
|
17
|
+
|
18
|
+
date: 2012-08-07 00:00:00 Z
|
19
|
+
dependencies:
|
20
|
+
- !ruby/object:Gem::Dependency
|
21
|
+
name: rdoc
|
22
|
+
prerelease: false
|
23
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
24
|
+
none: false
|
25
|
+
requirements:
|
26
|
+
- - ~>
|
27
|
+
- !ruby/object:Gem::Version
|
28
|
+
hash: 19
|
29
|
+
segments:
|
30
|
+
- 3
|
31
|
+
- 10
|
32
|
+
version: "3.10"
|
33
|
+
type: :development
|
34
|
+
version_requirements: *id001
|
35
|
+
- !ruby/object:Gem::Dependency
|
36
|
+
name: rake-compiler
|
37
|
+
prerelease: false
|
38
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
39
|
+
none: false
|
40
|
+
requirements:
|
41
|
+
- - ~>
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
hash: 5
|
44
|
+
segments:
|
45
|
+
- 0
|
46
|
+
- 7
|
47
|
+
version: "0.7"
|
48
|
+
type: :development
|
49
|
+
version_requirements: *id002
|
50
|
+
- !ruby/object:Gem::Dependency
|
51
|
+
name: hoe
|
52
|
+
prerelease: false
|
53
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
54
|
+
none: false
|
55
|
+
requirements:
|
56
|
+
- - ~>
|
57
|
+
- !ruby/object:Gem::Version
|
58
|
+
hash: 7
|
59
|
+
segments:
|
60
|
+
- 3
|
61
|
+
- 0
|
62
|
+
version: "3.0"
|
63
|
+
type: :development
|
64
|
+
version_requirements: *id003
|
65
|
+
description: Find where you are with CoreLocation!
|
66
|
+
email:
|
67
|
+
- evan@phx.io
|
68
|
+
executables:
|
69
|
+
- lost
|
70
|
+
extensions:
|
71
|
+
- ext/lost/extconf.rb
|
72
|
+
extra_rdoc_files:
|
73
|
+
- History.txt
|
74
|
+
- Manifest.txt
|
75
|
+
- README.txt
|
76
|
+
files:
|
77
|
+
- .autotest
|
78
|
+
- History.txt
|
79
|
+
- Manifest.txt
|
80
|
+
- README.txt
|
81
|
+
- Rakefile
|
82
|
+
- bin/lost
|
83
|
+
- ext/lost/core_loc.m
|
84
|
+
- ext/lost/extconf.rb
|
85
|
+
- ext/lost/lost.c
|
86
|
+
- lib/lost.rb
|
87
|
+
homepage: http://github.com/evanphx/lost
|
88
|
+
licenses: []
|
89
|
+
|
90
|
+
post_install_message:
|
91
|
+
rdoc_options:
|
92
|
+
- --main
|
93
|
+
- README.txt
|
94
|
+
require_paths:
|
95
|
+
- lib
|
96
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
97
|
+
none: false
|
98
|
+
requirements:
|
99
|
+
- - ">="
|
100
|
+
- !ruby/object:Gem::Version
|
101
|
+
hash: 3
|
102
|
+
segments:
|
103
|
+
- 0
|
104
|
+
version: "0"
|
105
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
106
|
+
none: false
|
107
|
+
requirements:
|
108
|
+
- - ">="
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
hash: 3
|
111
|
+
segments:
|
112
|
+
- 0
|
113
|
+
version: "0"
|
114
|
+
requirements: []
|
115
|
+
|
116
|
+
rubyforge_project: lost
|
117
|
+
rubygems_version: 1.8.24
|
118
|
+
signing_key:
|
119
|
+
specification_version: 3
|
120
|
+
summary: Find where you are with CoreLocation!
|
121
|
+
test_files: []
|
122
|
+
|