where_was_i 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +22 -0
- data/.rspec +2 -0
- data/Gemfile +4 -0
- data/Guardfile +6 -0
- data/LICENSE.txt +22 -0
- data/README.md +16 -0
- data/Rakefile +17 -0
- data/lib/where_was_i/gpx.rb +69 -0
- data/lib/where_was_i/track.rb +71 -0
- data/lib/where_was_i/version.rb +3 -0
- data/lib/where_was_i.rb +8 -0
- data/spec/data/test.gpx +69 -0
- data/spec/lib/where_was_i/gpx_spec.rb +51 -0
- data/spec/lib/where_was_i/track_spec.rb +70 -0
- data/spec/spec_helper.rb +92 -0
- data/where_was_i.gemspec +33 -0
- metadata +219 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: f76b6b51ae66a959ee39162517a749fe40397d2c
|
4
|
+
data.tar.gz: 639a75c546b03ef5c17c13f7b15db1112b231e7a
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 3f1280bc1b60fd733398f0c011c6bfbb57e72eca637ade33681628232234d4f1916c1ec2f638c78015a2f29d645dc64a97a830af27640f49ec6448f6b1b52ad2
|
7
|
+
data.tar.gz: 74209c3e5c8ab8296bcf86f78942a6e81f2253eeb7ef5aaa4158377056d54f6896af66f7bdff457cf1c252e1ae11d602f958297db1e1c95df7a254ee26066963
|
data/.gitignore
ADDED
@@ -0,0 +1,22 @@
|
|
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
|
+
*.bundle
|
19
|
+
*.so
|
20
|
+
*.o
|
21
|
+
*.a
|
22
|
+
mkmf.log
|
data/.rspec
ADDED
data/Gemfile
ADDED
data/Guardfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2014 Alex Dean
|
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,16 @@
|
|
1
|
+
# WhereWasI
|
2
|
+
|
3
|
+
Given a GPX data file and a time reference, infer a location.
|
4
|
+
|
5
|
+
```ruby
|
6
|
+
w = WhereWasI::Gpx.new(gpx_file: '/home/alex/track.gpx')
|
7
|
+
w.at('2014-01-01T00:00:00Z')
|
8
|
+
#=> {lat: 48.0, lon: 98.0, elevation: 1000}
|
9
|
+
```
|
10
|
+
|
11
|
+
`at` will return `nil` if the supplied time is not covered by the GPX data.
|
12
|
+
```ruby
|
13
|
+
w = WhereWasI::Gpx.new(gpx_file: '/home/alex/track.gpx')
|
14
|
+
w.at('2014-01-02T00:00:00Z')
|
15
|
+
#=> nil
|
16
|
+
```
|
data/Rakefile
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
2
|
+
require "github/markup"
|
3
|
+
require "redcarpet"
|
4
|
+
require "yard"
|
5
|
+
require "yard/rake/yardoc_task"
|
6
|
+
|
7
|
+
|
8
|
+
|
9
|
+
YARD::Rake::YardocTask.new("doc") do |t|
|
10
|
+
t.files = ['lib/**/*.rb']
|
11
|
+
t.options = %w(--output-dir doc/where_was_i --main=README.md - doc/*.md)
|
12
|
+
end
|
13
|
+
|
14
|
+
task :remove_previous do
|
15
|
+
`rm -Rf doc/where_was_i`
|
16
|
+
end
|
17
|
+
task doc: :remove_previous
|
@@ -0,0 +1,69 @@
|
|
1
|
+
require 'nokogiri'
|
2
|
+
|
3
|
+
module WhereWasI
|
4
|
+
|
5
|
+
# Use a GPX file as a data source for location inferences.
|
6
|
+
class Gpx
|
7
|
+
attr_reader :tracks
|
8
|
+
|
9
|
+
# @param [String] gpx_file Path to a GPX file.
|
10
|
+
# @param [String] gpx_data GPX XML data string.
|
11
|
+
#
|
12
|
+
# @example with a gpx file
|
13
|
+
# g = WhereWasI::Gpx.new(gpx_file: '/path/to/data.gpx')
|
14
|
+
# @example with gpx data
|
15
|
+
# g = WhereWasI::Gpx.new(gpx_data: '<?xml version="1.0"><gpx ...')
|
16
|
+
def initialize(gpx_file:nil, gpx_data:nil)
|
17
|
+
if gpx_file
|
18
|
+
@gpx_data = open(gpx_file)
|
19
|
+
elsif gpx_data
|
20
|
+
@gpx_data = gpx_data
|
21
|
+
else
|
22
|
+
raise ArgumentError, "Must supply gpx_file or gpx_data."
|
23
|
+
end
|
24
|
+
|
25
|
+
@tracks_added = false
|
26
|
+
end
|
27
|
+
|
28
|
+
# extract track data from gpx data
|
29
|
+
#
|
30
|
+
# it's not necessary to call this directly
|
31
|
+
def add_tracks
|
32
|
+
@tracks = []
|
33
|
+
doc = Nokogiri::XML(@gpx_data)
|
34
|
+
|
35
|
+
doc.css('xmlns|trk').each do |trk|
|
36
|
+
track = Track.new
|
37
|
+
trk.css('xmlns|trkpt').each do |trkpt|
|
38
|
+
# https://en.wikipedia.org/wiki/GPS_Exchange_Format#Units
|
39
|
+
# decimal degrees, wgs84.
|
40
|
+
# elevation in meters.
|
41
|
+
track.add_point(
|
42
|
+
lat: trkpt.attributes['lat'].text.to_f,
|
43
|
+
lon: trkpt.attributes['lon'].text.to_f,
|
44
|
+
elevation: trkpt.at_css('xmlns|ele').text.to_f,
|
45
|
+
time: Time.parse(trkpt.at_css('xmlns|time').text)
|
46
|
+
)
|
47
|
+
end
|
48
|
+
@tracks << track
|
49
|
+
end
|
50
|
+
@tracks_added = true
|
51
|
+
end
|
52
|
+
|
53
|
+
# infer a location from track data and a time
|
54
|
+
#
|
55
|
+
# @param [Time,String] time
|
56
|
+
# @return [Hash]
|
57
|
+
# @see Track#at
|
58
|
+
def at(time)
|
59
|
+
add_tracks if ! @tracks_added
|
60
|
+
location = nil
|
61
|
+
@tracks.each do |track|
|
62
|
+
location = track.at(time)
|
63
|
+
break if location
|
64
|
+
end
|
65
|
+
location
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
end
|
@@ -0,0 +1,71 @@
|
|
1
|
+
require 'time'
|
2
|
+
require 'interpolate'
|
3
|
+
|
4
|
+
module WhereWasI
|
5
|
+
|
6
|
+
# a series of sequential [lat, lon, elevation] points
|
7
|
+
class Track
|
8
|
+
attr_reader :start_time, :end_time
|
9
|
+
|
10
|
+
def initialize
|
11
|
+
@points = {}
|
12
|
+
end
|
13
|
+
|
14
|
+
# add a point to the track
|
15
|
+
#
|
16
|
+
# @param [Float] lat latitude
|
17
|
+
# @param [Float] lon longitude
|
18
|
+
# @param [Float] elevation elevation
|
19
|
+
# @param [Time] time time at the given location
|
20
|
+
def add_point(lat:, lon:, elevation:, time:)
|
21
|
+
time = Time.parse(time) if ! time.is_a?(Time)
|
22
|
+
|
23
|
+
@start_time = time if @start_time.nil? || time < @start_time
|
24
|
+
@end_time = time if @end_time.nil? || time > @end_time
|
25
|
+
@points[time.to_i] = [lat, lon, elevation]
|
26
|
+
|
27
|
+
true
|
28
|
+
end
|
29
|
+
|
30
|
+
# the time range covered by this track
|
31
|
+
#
|
32
|
+
# @return Range
|
33
|
+
def time_range
|
34
|
+
start_time..end_time
|
35
|
+
end
|
36
|
+
|
37
|
+
# is the supplied time covered by this track?
|
38
|
+
#
|
39
|
+
# @param time [Time]
|
40
|
+
# @return Boolean
|
41
|
+
def in_time_range?(time)
|
42
|
+
time = Time.parse(time) if ! time.is_a?(Time)
|
43
|
+
time_range.cover?(time)
|
44
|
+
end
|
45
|
+
|
46
|
+
# return the interpolated location for the given time
|
47
|
+
# or nil if time is outside the track's start..end
|
48
|
+
#
|
49
|
+
# @example
|
50
|
+
# track.at(time) => {lat:48, lon:98, elevation: 2100}
|
51
|
+
# @param time [String,Time]
|
52
|
+
# @return [Hash,nil]
|
53
|
+
def at(time)
|
54
|
+
return nil if ! in_time_range?(time)
|
55
|
+
if ! time.is_a?(Time)
|
56
|
+
time = Time.parse(time).to_i
|
57
|
+
end
|
58
|
+
time = time.to_i
|
59
|
+
|
60
|
+
@interp ||= Interpolate::Points.new(@points)
|
61
|
+
data = @interp.at(time)
|
62
|
+
|
63
|
+
{
|
64
|
+
lat: data[0],
|
65
|
+
lon: data[1],
|
66
|
+
elevation: data[2]
|
67
|
+
}
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
end
|
data/lib/where_was_i.rb
ADDED
data/spec/data/test.gpx
ADDED
@@ -0,0 +1,69 @@
|
|
1
|
+
<?xml version="1.0"?>
|
2
|
+
<gpx xmlns="http://www.topografix.com/GPX/1/1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:wptx1="http://www.garmin.com/xmlschemas/WaypointExtension/v1" xmlns:gpxtrx="http://www.garmin.com/xmlschemas/GpxExtensions/v3" xmlns:gpxtpx="http://www.garmin.com/xmlschemas/TrackPointExtension/v1" xmlns:gpxx="http://www.garmin.com/xmlschemas/GpxExtensions/v3" xmlns:trp="http://www.garmin.com/xmlschemas/TripExtensions/v1" xmlns:adv="http://www.garmin.com/xmlschemas/AdventuresExtensions/v1" xmlns:prs="http://www.garmin.com/xmlschemas/PressureExtension/v1" xmlns:tmd="http://www.garmin.com/xmlschemas/TripMetaDataExtensions/v1" xmlns:vptm="http://www.garmin.com/xmlschemas/ViaPointTransportationModeExtensions/v1" xmlns:ctx="http://www.garmin.com/xmlschemas/CreationTimeExtension/v1" creator="Garmin Desktop App" version="1.1" xsi:schemaLocation="http://www.topografix.com/GPX/1/1 http://www.topografix.com/GPX/1/1/gpx.xsd http://www.garmin.com/xmlschemas/WaypointExtension/v1 http://www8.garmin.com/xmlschemas/WaypointExtensionv1.xsd http://www.garmin.com/xmlschemas/TrackPointExtension/v1 http://www.garmin.com/xmlschemas/TrackPointExtensionv1.xsd http://www.garmin.com/xmlschemas/GpxExtensions/v3 http://www8.garmin.com/xmlschemas/GpxExtensionsv3.xsd http://www.garmin.com/xmlschemas/ActivityExtension/v1 http://www8.garmin.com/xmlschemas/ActivityExtensionv1.xsd http://www.garmin.com/xmlschemas/AdventuresExtensions/v1 http://www8.garmin.com/xmlschemas/AdventuresExtensionv1.xsd http://www.garmin.com/xmlschemas/PressureExtension/v1 http://www.garmin.com/xmlschemas/PressureExtensionv1.xsd http://www.garmin.com/xmlschemas/TripExtensions/v1 http://www.garmin.com/xmlschemas/TripExtensionsv1.xsd http://www.garmin.com/xmlschemas/TripMetaDataExtensions/v1 http://www.garmin.com/xmlschemas/TripMetaDataExtensionsv1.xsd http://www.garmin.com/xmlschemas/ViaPointTransportationModeExtensions/v1 http://www.garmin.com/xmlschemas/ViaPointTransportationModeExtensionsv1.xsd http://www.garmin.com/xmlschemas/CreationTimeExtensions/v1 http://www.garmin.com/xmlschemas/CreationTimeExtensionsv1.xsd">
|
3
|
+
|
4
|
+
<metadata>
|
5
|
+
<link href="http://www.garmin.com">
|
6
|
+
<text>Garmin International</text>
|
7
|
+
</link>
|
8
|
+
<time>2014-06-28T23:04:25Z</time>
|
9
|
+
<bounds maxlat="48.844004580751061" maxlon="-87.502163182944059" minlat="48.736522514373064" minlon="-87.853165101259947"/>
|
10
|
+
</metadata>
|
11
|
+
|
12
|
+
<trk>
|
13
|
+
<name>Current Track: 16 JUN 2014 12:16</name>
|
14
|
+
<extensions>
|
15
|
+
<gpxx:TrackExtension>
|
16
|
+
<gpxx:DisplayColor>Red</gpxx:DisplayColor>
|
17
|
+
</gpxx:TrackExtension>
|
18
|
+
<gpxtrkx:TrackStatsExtension xmlns:gpxtrkx="http://www.garmin.com/xmlschemas/TrackStatsExtension/v1">
|
19
|
+
<gpxtrkx:Distance>87862</gpxtrkx:Distance>
|
20
|
+
</gpxtrkx:TrackStatsExtension>
|
21
|
+
</extensions>
|
22
|
+
<trkseg>
|
23
|
+
<trkpt lat="48.833804307505488" lon="-87.519973134621978">
|
24
|
+
<ele>186.150000000000006</ele>
|
25
|
+
<time>2014-06-16T16:16:47Z</time>
|
26
|
+
</trkpt>
|
27
|
+
<trkpt lat="48.833793075755239" lon="-87.520076315850019">
|
28
|
+
<ele>186.629999999999995</ele>
|
29
|
+
<time>2014-06-16T16:17:25Z</time>
|
30
|
+
</trkpt>
|
31
|
+
<trkpt lat="48.833776982501149" lon="-87.520153764635324">
|
32
|
+
<ele>185.669999999999987</ele>
|
33
|
+
<time>2014-06-16T16:17:43Z</time>
|
34
|
+
</trkpt>
|
35
|
+
<trkpt lat="48.833690145984292" lon="-87.520155273377895">
|
36
|
+
<ele>183.75</ele>
|
37
|
+
<time>2014-06-16T16:18:05Z</time>
|
38
|
+
</trkpt>
|
39
|
+
</trkseg>
|
40
|
+
</trk>
|
41
|
+
|
42
|
+
<trk>
|
43
|
+
<name>Current Track: 17 JUN 2014 10:39</name>
|
44
|
+
<extensions>
|
45
|
+
<gpxx:TrackExtension>
|
46
|
+
<gpxx:DisplayColor>DarkGray</gpxx:DisplayColor>
|
47
|
+
</gpxx:TrackExtension>
|
48
|
+
</extensions>
|
49
|
+
<trkseg>
|
50
|
+
<trkpt lat="48.747263001278043" lon="-87.618850255385041">
|
51
|
+
<ele>188.080000000000013</ele>
|
52
|
+
<time>2014-06-17T14:39:49Z</time>
|
53
|
+
</trkpt>
|
54
|
+
<trkpt lat="48.747337767854333" lon="-87.618933403864503">
|
55
|
+
<ele>188.080000000000013</ele>
|
56
|
+
<time>2014-06-17T14:40:08Z</time>
|
57
|
+
</trkpt>
|
58
|
+
<trkpt lat="48.747314214706421" lon="-87.618911024183035">
|
59
|
+
<ele>188.080000000000013</ele>
|
60
|
+
<time>2014-06-17T14:40:29Z</time>
|
61
|
+
</trkpt>
|
62
|
+
<trkpt lat="48.747312789782882" lon="-87.618932314217091">
|
63
|
+
<ele>188.080000000000013</ele>
|
64
|
+
<time>2014-06-17T14:40:40Z</time>
|
65
|
+
</trkpt>
|
66
|
+
</trkseg>
|
67
|
+
</trk>
|
68
|
+
|
69
|
+
</gpx>
|
@@ -0,0 +1,51 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
RSpec.describe WhereWasI::Gpx do
|
4
|
+
|
5
|
+
let(:test_filename) {File.realpath(File.join(__FILE__, '/../../../data/test.gpx'))}
|
6
|
+
|
7
|
+
describe "initialization" do
|
8
|
+
|
9
|
+
it "should initialize with a gpx file path" do
|
10
|
+
g = WhereWasI::Gpx.new(gpx_file: test_filename)
|
11
|
+
g.add_tracks
|
12
|
+
expect(g.tracks.size).to eq 2
|
13
|
+
end
|
14
|
+
|
15
|
+
it "should initialize with a gpx data string" do
|
16
|
+
data = File.read(test_filename)
|
17
|
+
g = WhereWasI::Gpx.new(gpx_data: data)
|
18
|
+
g.add_tracks
|
19
|
+
expect(g.tracks.size).to eq 2
|
20
|
+
end
|
21
|
+
|
22
|
+
it "should raise an error on invalid input" do
|
23
|
+
expect {WhereWasI::Gpx.new}.to raise_error(ArgumentError, 'Must supply gpx_file or gpx_data.')
|
24
|
+
end
|
25
|
+
|
26
|
+
end
|
27
|
+
|
28
|
+
describe "at" do
|
29
|
+
|
30
|
+
let(:subject) {WhereWasI::Gpx.new(gpx_file: test_filename)}
|
31
|
+
|
32
|
+
it "should find a time in any of multiple tracks" do
|
33
|
+
expect(subject.at('2014-06-16T16:17:30Z')).to eq({
|
34
|
+
lat: 48.83378860540688,
|
35
|
+
lon: -87.5200978294015,
|
36
|
+
elevation: 186.36333333333332
|
37
|
+
})
|
38
|
+
|
39
|
+
expect(subject.at('2014-06-17T14:40:20Z')).to eq({
|
40
|
+
lat: 48.74732430891267,
|
41
|
+
lon: -87.61892061547509,
|
42
|
+
elevation: 188.08
|
43
|
+
})
|
44
|
+
end
|
45
|
+
|
46
|
+
it "should return nil if time is not covered by any track" do
|
47
|
+
expect(subject.at('2014-06-17T12:00:00Z')).to eq nil
|
48
|
+
end
|
49
|
+
|
50
|
+
end
|
51
|
+
end
|
@@ -0,0 +1,70 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
class String
|
4
|
+
def to_time
|
5
|
+
Time.parse(self)
|
6
|
+
end
|
7
|
+
end
|
8
|
+
|
9
|
+
RSpec.describe WhereWasI::Track do
|
10
|
+
|
11
|
+
before(:each) do
|
12
|
+
subject.add_point(time:'2014-10-13T12:00:00Z', lat:10, lon:10, elevation:100)
|
13
|
+
subject.add_point(time:'2014-10-13T12:00:05Z', lat:15, lon:20, elevation:200)
|
14
|
+
subject.add_point(time:'2014-10-13T12:00:10Z', lat:20, lon:30, elevation:300)
|
15
|
+
end
|
16
|
+
|
17
|
+
describe "time_range" do
|
18
|
+
it "should return a time range describing the time covered by the track" do
|
19
|
+
expect(subject.time_range).to eq(
|
20
|
+
'2014-10-13T12:00:00Z'.to_time..'2014-10-13T12:00:10Z'.to_time
|
21
|
+
)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
describe "in_time_range?" do
|
26
|
+
it "should be true if time is in time_range" do
|
27
|
+
expect(subject.in_time_range?('2014-10-13T12:00:00Z')).to eq true
|
28
|
+
expect(subject.in_time_range?('2014-10-13T12:00:01Z')).to eq true
|
29
|
+
expect(subject.in_time_range?('2014-10-13T12:00:09Z')).to eq true
|
30
|
+
expect(subject.in_time_range?('2014-10-13T12:00:10Z')).to eq true
|
31
|
+
end
|
32
|
+
|
33
|
+
it "should be false if time is outside of time_range" do
|
34
|
+
expect(subject.in_time_range?('2014-10-12T11:59:59Z')).to eq false
|
35
|
+
expect(subject.in_time_range?('2014-10-12T12:00:11Z')).to eq false
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
describe "at" do
|
40
|
+
it "should return nearest latitude" do
|
41
|
+
expect(subject.at('2014-10-13T12:00:03Z')[:lat]).to eq 13
|
42
|
+
expect(subject.at('2014-10-13T12:00:05Z')[:lat]).to eq 15
|
43
|
+
expect(subject.at('2014-10-13T12:00:07Z')[:lat]).to eq 17
|
44
|
+
end
|
45
|
+
|
46
|
+
it "should interpolate nearest longitude" do
|
47
|
+
expect(subject.at('2014-10-13T12:00:03Z')[:lon]).to eq 16
|
48
|
+
expect(subject.at('2014-10-13T12:00:05Z')[:lon]).to eq 20
|
49
|
+
expect(subject.at('2014-10-13T12:00:07Z')[:lon]).to eq 24
|
50
|
+
end
|
51
|
+
|
52
|
+
it "should interpolate nearest elevation" do
|
53
|
+
expect(subject.at('2014-10-13T12:00:03Z')[:elevation]).to eq 160
|
54
|
+
expect(subject.at('2014-10-13T12:00:05Z')[:elevation]).to eq 200
|
55
|
+
expect(subject.at('2014-10-13T12:00:07Z')[:elevation]).to eq 240
|
56
|
+
end
|
57
|
+
|
58
|
+
it "should return nil if time is outside time_range" do
|
59
|
+
expect(subject.at('2014-10-13T12:00:11Z')).to eq nil
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
it "should have a start_time reader" do
|
64
|
+
expect(subject.start_time).to eq '2014-10-13T12:00:00Z'.to_time
|
65
|
+
end
|
66
|
+
|
67
|
+
it "should have an end_time reader" do
|
68
|
+
expect(subject.end_time).to eq '2014-10-13T12:00:10Z'.to_time
|
69
|
+
end
|
70
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,92 @@
|
|
1
|
+
require 'where_was_i'
|
2
|
+
|
3
|
+
# This file was generated by the `rspec --init` command. Conventionally, all
|
4
|
+
# specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
|
5
|
+
# The generated `.rspec` file contains `--require spec_helper` which will cause this
|
6
|
+
# file to always be loaded, without a need to explicitly require it in any files.
|
7
|
+
#
|
8
|
+
# Given that it is always loaded, you are encouraged to keep this file as
|
9
|
+
# light-weight as possible. Requiring heavyweight dependencies from this file
|
10
|
+
# will add to the boot time of your test suite on EVERY test run, even for an
|
11
|
+
# individual file that may not need all of that loaded. Instead, consider making
|
12
|
+
# a separate helper file that requires the additional dependencies and performs
|
13
|
+
# the additional setup, and require it from the spec files that actually need it.
|
14
|
+
#
|
15
|
+
# The `.rspec` file also contains a few flags that are not defaults but that
|
16
|
+
# users commonly want.
|
17
|
+
#
|
18
|
+
# See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
|
19
|
+
RSpec.configure do |config|
|
20
|
+
# rspec-expectations config goes here. You can use an alternate
|
21
|
+
# assertion/expectation library such as wrong or the stdlib/minitest
|
22
|
+
# assertions if you prefer.
|
23
|
+
config.expect_with :rspec do |expectations|
|
24
|
+
# This option will default to `true` in RSpec 4. It makes the `description`
|
25
|
+
# and `failure_message` of custom matchers include text for helper methods
|
26
|
+
# defined using `chain`, e.g.:
|
27
|
+
# be_bigger_than(2).and_smaller_than(4).description
|
28
|
+
# # => "be bigger than 2 and smaller than 4"
|
29
|
+
# ...rather than:
|
30
|
+
# # => "be bigger than 2"
|
31
|
+
expectations.include_chain_clauses_in_custom_matcher_descriptions = true
|
32
|
+
end
|
33
|
+
|
34
|
+
# rspec-mocks config goes here. You can use an alternate test double
|
35
|
+
# library (such as bogus or mocha) by changing the `mock_with` option here.
|
36
|
+
config.mock_with :rspec do |mocks|
|
37
|
+
# Prevents you from mocking or stubbing a method that does not exist on
|
38
|
+
# a real object. This is generally recommended, and will default to
|
39
|
+
# `true` in RSpec 4.
|
40
|
+
mocks.verify_partial_doubles = true
|
41
|
+
end
|
42
|
+
|
43
|
+
# These two settings work together to allow you to limit a spec run
|
44
|
+
# to individual examples or groups you care about by tagging them with
|
45
|
+
# `:focus` metadata. When nothing is tagged with `:focus`, all examples
|
46
|
+
# get run.
|
47
|
+
config.filter_run :focus
|
48
|
+
config.run_all_when_everything_filtered = true
|
49
|
+
|
50
|
+
# The settings below are suggested to provide a good initial experience
|
51
|
+
# with RSpec, but feel free to customize to your heart's content.
|
52
|
+
=begin
|
53
|
+
|
54
|
+
# Limits the available syntax to the non-monkey patched syntax that is recommended.
|
55
|
+
# For more details, see:
|
56
|
+
# - http://myronmars.to/n/dev-blog/2012/06/rspecs-new-expectation-syntax
|
57
|
+
# - http://teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/
|
58
|
+
# - http://myronmars.to/n/dev-blog/2014/05/notable-changes-in-rspec-3#new__config_option_to_disable_rspeccore_monkey_patching
|
59
|
+
config.disable_monkey_patching!
|
60
|
+
|
61
|
+
# This setting enables warnings. It's recommended, but in some cases may
|
62
|
+
# be too noisy due to issues in dependencies.
|
63
|
+
config.warnings = true
|
64
|
+
|
65
|
+
# Many RSpec users commonly either run the entire suite or an individual
|
66
|
+
# file, and it's useful to allow more verbose output when running an
|
67
|
+
# individual spec file.
|
68
|
+
if config.files_to_run.one?
|
69
|
+
# Use the documentation formatter for detailed output,
|
70
|
+
# unless a formatter has already been configured
|
71
|
+
# (e.g. via a command-line flag).
|
72
|
+
config.default_formatter = 'doc'
|
73
|
+
end
|
74
|
+
|
75
|
+
# Print the 10 slowest examples and example groups at the
|
76
|
+
# end of the spec run, to help surface which specs are running
|
77
|
+
# particularly slow.
|
78
|
+
config.profile_examples = 10
|
79
|
+
|
80
|
+
# Run specs in random order to surface order dependencies. If you find an
|
81
|
+
# order dependency and want to debug it, you can fix the order by providing
|
82
|
+
# the seed, which is printed after each run.
|
83
|
+
# --seed 1234
|
84
|
+
config.order = :random
|
85
|
+
|
86
|
+
# Seed global randomization in this process using the `--seed` CLI option.
|
87
|
+
# Setting this allows you to use `--seed` to deterministically reproduce
|
88
|
+
# test failures related to randomization by passing the same `--seed` value
|
89
|
+
# as the one that triggered the failure.
|
90
|
+
Kernel.srand config.seed
|
91
|
+
=end
|
92
|
+
end
|
data/where_was_i.gemspec
ADDED
@@ -0,0 +1,33 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'where_was_i/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "where_was_i"
|
8
|
+
spec.version = WhereWasI::VERSION
|
9
|
+
spec.authors = ["Alex Dean"]
|
10
|
+
spec.email = ["alex@crackpot.org"]
|
11
|
+
spec.summary = %q{Infer where you were using a GPX data file.}
|
12
|
+
spec.description = %q{Given a GPX file and a time reference, return a location.}
|
13
|
+
spec.homepage = ""
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0")
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_dependency 'nokogiri', '~> 1.6.3'
|
22
|
+
spec.add_dependency 'interpolate', '~> 0.3'
|
23
|
+
|
24
|
+
spec.add_development_dependency "bundler", "~> 1.6"
|
25
|
+
spec.add_development_dependency "rake", "~> 10.1.0"
|
26
|
+
spec.add_development_dependency "rspec", "~> 3"
|
27
|
+
spec.add_development_dependency "guard", "~> 2.6"
|
28
|
+
spec.add_development_dependency "guard-rspec", "~> 4.3.1"
|
29
|
+
spec.add_development_dependency "yard", "~> 0.8.7"
|
30
|
+
spec.add_development_dependency "github-markup", "~> 1.3.0"
|
31
|
+
spec.add_development_dependency "redcarpet", "~> 3.2.0"
|
32
|
+
spec.add_development_dependency "ruby_gntp", "~> 0.3.0"
|
33
|
+
end
|
metadata
ADDED
@@ -0,0 +1,219 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: where_was_i
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Alex Dean
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-10-14 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: nokogiri
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 1.6.3
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 1.6.3
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: interpolate
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0.3'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0.3'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: bundler
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '1.6'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '1.6'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rake
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: 10.1.0
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: 10.1.0
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rspec
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '3'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '3'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: guard
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - "~>"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '2.6'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - "~>"
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '2.6'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: guard-rspec
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - "~>"
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: 4.3.1
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - "~>"
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: 4.3.1
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: yard
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - "~>"
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: 0.8.7
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - "~>"
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: 0.8.7
|
125
|
+
- !ruby/object:Gem::Dependency
|
126
|
+
name: github-markup
|
127
|
+
requirement: !ruby/object:Gem::Requirement
|
128
|
+
requirements:
|
129
|
+
- - "~>"
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: 1.3.0
|
132
|
+
type: :development
|
133
|
+
prerelease: false
|
134
|
+
version_requirements: !ruby/object:Gem::Requirement
|
135
|
+
requirements:
|
136
|
+
- - "~>"
|
137
|
+
- !ruby/object:Gem::Version
|
138
|
+
version: 1.3.0
|
139
|
+
- !ruby/object:Gem::Dependency
|
140
|
+
name: redcarpet
|
141
|
+
requirement: !ruby/object:Gem::Requirement
|
142
|
+
requirements:
|
143
|
+
- - "~>"
|
144
|
+
- !ruby/object:Gem::Version
|
145
|
+
version: 3.2.0
|
146
|
+
type: :development
|
147
|
+
prerelease: false
|
148
|
+
version_requirements: !ruby/object:Gem::Requirement
|
149
|
+
requirements:
|
150
|
+
- - "~>"
|
151
|
+
- !ruby/object:Gem::Version
|
152
|
+
version: 3.2.0
|
153
|
+
- !ruby/object:Gem::Dependency
|
154
|
+
name: ruby_gntp
|
155
|
+
requirement: !ruby/object:Gem::Requirement
|
156
|
+
requirements:
|
157
|
+
- - "~>"
|
158
|
+
- !ruby/object:Gem::Version
|
159
|
+
version: 0.3.0
|
160
|
+
type: :development
|
161
|
+
prerelease: false
|
162
|
+
version_requirements: !ruby/object:Gem::Requirement
|
163
|
+
requirements:
|
164
|
+
- - "~>"
|
165
|
+
- !ruby/object:Gem::Version
|
166
|
+
version: 0.3.0
|
167
|
+
description: Given a GPX file and a time reference, return a location.
|
168
|
+
email:
|
169
|
+
- alex@crackpot.org
|
170
|
+
executables: []
|
171
|
+
extensions: []
|
172
|
+
extra_rdoc_files: []
|
173
|
+
files:
|
174
|
+
- ".gitignore"
|
175
|
+
- ".rspec"
|
176
|
+
- Gemfile
|
177
|
+
- Guardfile
|
178
|
+
- LICENSE.txt
|
179
|
+
- README.md
|
180
|
+
- Rakefile
|
181
|
+
- lib/where_was_i.rb
|
182
|
+
- lib/where_was_i/gpx.rb
|
183
|
+
- lib/where_was_i/track.rb
|
184
|
+
- lib/where_was_i/version.rb
|
185
|
+
- spec/data/test.gpx
|
186
|
+
- spec/lib/where_was_i/gpx_spec.rb
|
187
|
+
- spec/lib/where_was_i/track_spec.rb
|
188
|
+
- spec/spec_helper.rb
|
189
|
+
- where_was_i.gemspec
|
190
|
+
homepage: ''
|
191
|
+
licenses:
|
192
|
+
- MIT
|
193
|
+
metadata: {}
|
194
|
+
post_install_message:
|
195
|
+
rdoc_options: []
|
196
|
+
require_paths:
|
197
|
+
- lib
|
198
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
199
|
+
requirements:
|
200
|
+
- - ">="
|
201
|
+
- !ruby/object:Gem::Version
|
202
|
+
version: '0'
|
203
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
204
|
+
requirements:
|
205
|
+
- - ">="
|
206
|
+
- !ruby/object:Gem::Version
|
207
|
+
version: '0'
|
208
|
+
requirements: []
|
209
|
+
rubyforge_project:
|
210
|
+
rubygems_version: 2.2.2
|
211
|
+
signing_key:
|
212
|
+
specification_version: 4
|
213
|
+
summary: Infer where you were using a GPX data file.
|
214
|
+
test_files:
|
215
|
+
- spec/data/test.gpx
|
216
|
+
- spec/lib/where_was_i/gpx_spec.rb
|
217
|
+
- spec/lib/where_was_i/track_spec.rb
|
218
|
+
- spec/spec_helper.rb
|
219
|
+
has_rdoc:
|