geocaching 0.4.0 → 0.4.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/lib/geocaching/log.rb +1 -1
- data/lib/geocaching/pq.rb +72 -0
- data/lib/geocaching/version.rb +1 -1
- data/spec/cache/webcam.rb +1 -1
- data/spec/cache_spec.rb +3 -0
- metadata +4 -3
data/lib/geocaching/log.rb
CHANGED
@@ -173,7 +173,7 @@ module Geocaching
|
|
173
173
|
|
174
174
|
elements = @doc.search("#ctl00_ContentBody_LogBookPanel1_lbLogText > a")
|
175
175
|
|
176
|
-
if elements.size ==
|
176
|
+
if elements.size == 3 and elements[1]["href"]
|
177
177
|
elements[1]["href"] =~ /guid=([a-f0-9-]{36})/
|
178
178
|
$1
|
179
179
|
else
|
@@ -0,0 +1,72 @@
|
|
1
|
+
module Geocaching
|
2
|
+
class PQ
|
3
|
+
|
4
|
+
# A waypoint inside a Pocket Query.
|
5
|
+
class Waypoint
|
6
|
+
def initialize(attributes)
|
7
|
+
attributes.each do |key, value|
|
8
|
+
instance_variable_set("@#{key.to_s}", value)
|
9
|
+
attr_reader key
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
# Return the owner as a Geocaching::User object.
|
14
|
+
def owner
|
15
|
+
@owner
|
16
|
+
end
|
17
|
+
|
18
|
+
# Return
|
19
|
+
end
|
20
|
+
|
21
|
+
# Create a new instance with the content of +file+.
|
22
|
+
# The given file must be a GPX document.
|
23
|
+
def self.from_file(file)
|
24
|
+
pq = new(File.read(file))
|
25
|
+
rescue Errno
|
26
|
+
nil
|
27
|
+
end
|
28
|
+
|
29
|
+
# Create a new instance with the GPX XML data given as an argument.
|
30
|
+
def initialize(xml)
|
31
|
+
@doc = Nokogiri::XML(xml)
|
32
|
+
end
|
33
|
+
|
34
|
+
# Return the name of the Pocket Query.
|
35
|
+
def name
|
36
|
+
@name ||= begin
|
37
|
+
@doc.xpath("/xmlns:gpx/xmlns:name").content
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
# Return the bounds of the Pocket Query. The returned object is a
|
42
|
+
# Hash with the following keys:
|
43
|
+
#
|
44
|
+
# * +:minlat+
|
45
|
+
# * +:minlon+
|
46
|
+
# * +:maxlat+
|
47
|
+
# * +:maxlon+
|
48
|
+
#
|
49
|
+
def bounds
|
50
|
+
@bounds ||= begin
|
51
|
+
bounds = @doc.xpath("/xmlns:gpx/xmlns:bounds")
|
52
|
+
|
53
|
+
{
|
54
|
+
:minlat =>
|
55
|
+
}
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
def waypoints
|
60
|
+
@waypoints ||= begin
|
61
|
+
@doc.xpath("/xmlns:gpx/xmlns:wpt").map do |wpt|
|
62
|
+
|
63
|
+
Waypoint.new({
|
64
|
+
:latitude => wpt.to_f,
|
65
|
+
|
66
|
+
:description => wpt.desc,
|
67
|
+
})
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
data/lib/geocaching/version.rb
CHANGED
data/spec/cache/webcam.rb
CHANGED
@@ -54,7 +54,7 @@ describe "Geocaching::Cache for 8cd0976c-42cf-40a2-ae02-ed87ad52d5b1 (Webcam)" d
|
|
54
54
|
end
|
55
55
|
|
56
56
|
it "should return the correct number of logs" do
|
57
|
-
@cache.logs.size.should
|
57
|
+
@cache.logs.size.should >= 86
|
58
58
|
end
|
59
59
|
|
60
60
|
it "should return cache has been archived" do
|
data/spec/cache_spec.rb
CHANGED
@@ -7,5 +7,8 @@ require "geocaching"
|
|
7
7
|
require "#{dir}/helper"
|
8
8
|
|
9
9
|
Geocaching::CacheType::TYPES.to_a.map { |a| a[0].to_s }.each do |type|
|
10
|
+
# Locationless caches have completely been disabled on geocaching.com
|
11
|
+
next if type == "locationless"
|
12
|
+
|
10
13
|
require "#{dir}/cache/#{type}"
|
11
14
|
end
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 4
|
8
|
-
-
|
9
|
-
version: 0.4.
|
8
|
+
- 1
|
9
|
+
version: 0.4.1
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Thomas Cyron
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2010-08-
|
17
|
+
date: 2010-08-31 00:00:00 +02:00
|
18
18
|
default_executable:
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
@@ -63,6 +63,7 @@ files:
|
|
63
63
|
- lib/geocaching/log.rb
|
64
64
|
- lib/geocaching/log_type.rb
|
65
65
|
- lib/geocaching/my_logs.rb
|
66
|
+
- lib/geocaching/pq.rb
|
66
67
|
- lib/geocaching/user.rb
|
67
68
|
- lib/geocaching/version.rb
|
68
69
|
- lib/geocaching.rb
|