the_arch 1.0.0
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/README.md +120 -0
- data/lib/the_arch.rb +6 -0
- data/lib/the_arch/base.rb +26 -0
- data/lib/the_arch/parser.rb +13 -0
- metadata +112 -0
data/README.md
ADDED
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
## The Arch
|
|
2
|
+
|
|
3
|
+
A Ruby client for The Arch Climbing Wall API. This is the same API that backs the iOS application.
|
|
4
|
+
|
|
5
|
+
## Crags
|
|
6
|
+
|
|
7
|
+
```ruby
|
|
8
|
+
TheArch.crags.first
|
|
9
|
+
#=> {
|
|
10
|
+
"area_id" => "69",
|
|
11
|
+
"area_name" => "Biscuit Factory",
|
|
12
|
+
"crag_access_info" => "",
|
|
13
|
+
"crag_general_info" => "",
|
|
14
|
+
"crag_gridref" => "",
|
|
15
|
+
"crag_guide_book" => "Circuit List",
|
|
16
|
+
"crag_id" => "265",
|
|
17
|
+
"crag_info_short" => "A set of 30 problems using the same coloured holds, each in their own grade band.",
|
|
18
|
+
"crag_is_favourite" => "",
|
|
19
|
+
"crag_latitude" => "51.4939384460449",
|
|
20
|
+
"crag_longitude" => "-0.0626349449157715",
|
|
21
|
+
"crag_map_id" => "0",
|
|
22
|
+
"crag_map_zoom" => "15",
|
|
23
|
+
"crag_name" => "Circuit Problems",
|
|
24
|
+
"crag_nearest_town" => "Bermondsey",
|
|
25
|
+
"crag_parking_info" => "",
|
|
26
|
+
"crag_parking_latitude" => "51.4944763183594",
|
|
27
|
+
"crag_parking_longitude" => "-0.0621628761291504",
|
|
28
|
+
"crag_sector_map_name" => "",
|
|
29
|
+
"crag_sort_order" => "10",
|
|
30
|
+
"crag_type" => "0",
|
|
31
|
+
"date_modified" => "2013-03-03",
|
|
32
|
+
"is_enabled" => "",
|
|
33
|
+
"tap_rect_in_parent_map" => "",
|
|
34
|
+
"version_number" => "1.0",
|
|
35
|
+
"weather_provider_code" => "",
|
|
36
|
+
"weather_provider_name" => ""
|
|
37
|
+
}
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
## Sectors
|
|
41
|
+
|
|
42
|
+
```ruby
|
|
43
|
+
TheArch.sectors.first
|
|
44
|
+
#=> {
|
|
45
|
+
"crag_id" => "265",
|
|
46
|
+
"date_modified" => "2014-03-04",
|
|
47
|
+
"is_enabled" => "",
|
|
48
|
+
"map_id" => "0",
|
|
49
|
+
"sector_id" => "1006",
|
|
50
|
+
"sector_info" => "30 Circuit problems at V0",
|
|
51
|
+
"sector_info_short" => "Set Tuesday 4th March by Scott Bishop and Jethro Whaley ",
|
|
52
|
+
"sector_map_rect_h" => "0",
|
|
53
|
+
"sector_map_rect_w" => "0",
|
|
54
|
+
"sector_map_rect_x" => "0",
|
|
55
|
+
"sector_map_rect_y" => "0",
|
|
56
|
+
"sector_name" => "Spotty Circuit V0",
|
|
57
|
+
"sort_order" => "5",
|
|
58
|
+
"tap_rect_in_parent_map" => "0,0,0,0",
|
|
59
|
+
"topo_name" => "18725d4f-3b53-4940-9b75-dbf9ca40b50e.jpg",
|
|
60
|
+
"topo_type_id" => "1",
|
|
61
|
+
"version_number" => "1.0"
|
|
62
|
+
}
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
## Routes
|
|
66
|
+
|
|
67
|
+
```ruby
|
|
68
|
+
TheArch.routes.first
|
|
69
|
+
#=> {
|
|
70
|
+
"area_id" => "69",
|
|
71
|
+
"crag_id" => "265",
|
|
72
|
+
"date_modified" => "2014-03-14",
|
|
73
|
+
"equipper_date" => "",
|
|
74
|
+
"equipper_name" => "",
|
|
75
|
+
"first_ascent_date" => "",
|
|
76
|
+
"first_ascent_name" => "",
|
|
77
|
+
"grade_bucket_id" => "0",
|
|
78
|
+
"grade_name" => "Boulder",
|
|
79
|
+
"grade_type_id" => "8",
|
|
80
|
+
"is_enabled" => "",
|
|
81
|
+
"rating_name" => "0",
|
|
82
|
+
"route_id" => "4264",
|
|
83
|
+
"route_info" => "",
|
|
84
|
+
"route_length" => "",
|
|
85
|
+
"route_name" => "Problem 1",
|
|
86
|
+
"route_type" => "Indoor Wall",
|
|
87
|
+
"route_type_id" => "4",
|
|
88
|
+
"sector_id" => "752",
|
|
89
|
+
"sort_order" => "1",
|
|
90
|
+
"start_x" => "358",
|
|
91
|
+
"start_y" => "377",
|
|
92
|
+
"tech_grade" => "Middle",
|
|
93
|
+
"version_number" => "1.0"
|
|
94
|
+
}
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
## Note
|
|
98
|
+
|
|
99
|
+
You can access attributes by simply calling methods:
|
|
100
|
+
|
|
101
|
+
```ruby
|
|
102
|
+
crag.area_name
|
|
103
|
+
#=> "Biscuit Factory"
|
|
104
|
+
|
|
105
|
+
sector.sector_name
|
|
106
|
+
#=> "Spotty Circuit V0"
|
|
107
|
+
|
|
108
|
+
route.tech_grade
|
|
109
|
+
#=> "Middle"
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
## Background
|
|
113
|
+
|
|
114
|
+
The API and these methods were discovered by reverse engineering the iOS application. I used [Charles](http://www.charlesproxy.com/) to intercept the HTTPS traffic from my phone and Nokogiri to parse the XML.
|
|
115
|
+
|
|
116
|
+
## Improvements
|
|
117
|
+
|
|
118
|
+
At present, this library provides a relatively thin wrapper for the API. I plan on implementing first-class objects with type coercion and methods to retrieve images, etc.
|
|
119
|
+
|
|
120
|
+
Twitter: [@cpatuzzo](https://twitter.com/cpatuzzo)
|
data/lib/the_arch.rb
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
module TheArch
|
|
2
|
+
UUID = "24928f42-59dd-4e3e-bf10-695f238c2c7a"
|
|
3
|
+
API = "http://thesendtopos.co.uk/appsupport/#{UUID}/"
|
|
4
|
+
|
|
5
|
+
def crags
|
|
6
|
+
@crags ||= get("crag_update")
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
def sectors
|
|
10
|
+
@sectors ||= get("sector_update")
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
def routes
|
|
14
|
+
@routes ||= get("route_update")
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
private
|
|
18
|
+
def get(method)
|
|
19
|
+
url = "#{API}#{method}.ashx"
|
|
20
|
+
xml = Net::HTTP.get(URI(url))
|
|
21
|
+
|
|
22
|
+
Parser.parse(xml)
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
extend self
|
|
26
|
+
end
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
module TheArch::Parser
|
|
2
|
+
def self.parse(xml)
|
|
3
|
+
document = Nokogiri::XML.parse(xml)
|
|
4
|
+
data = document.xpath("/plist/dict/dict")
|
|
5
|
+
|
|
6
|
+
data.map do |node|
|
|
7
|
+
strings = node.children.map(&:text)
|
|
8
|
+
pairs = strings.each_slice(2).to_a
|
|
9
|
+
|
|
10
|
+
Hashie::Mash.new(Hash[pairs])
|
|
11
|
+
end
|
|
12
|
+
end
|
|
13
|
+
end
|
metadata
ADDED
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: the_arch
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 1.0.0
|
|
5
|
+
prerelease:
|
|
6
|
+
platform: ruby
|
|
7
|
+
authors:
|
|
8
|
+
- Chris Patuzzo
|
|
9
|
+
autorequire:
|
|
10
|
+
bindir: bin
|
|
11
|
+
cert_chain: []
|
|
12
|
+
date: 2014-03-30 00:00:00.000000000 Z
|
|
13
|
+
dependencies:
|
|
14
|
+
- !ruby/object:Gem::Dependency
|
|
15
|
+
name: nokogiri
|
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
|
17
|
+
none: false
|
|
18
|
+
requirements:
|
|
19
|
+
- - ! '>='
|
|
20
|
+
- !ruby/object:Gem::Version
|
|
21
|
+
version: '0'
|
|
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: '0'
|
|
30
|
+
- !ruby/object:Gem::Dependency
|
|
31
|
+
name: hashie
|
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
|
33
|
+
none: false
|
|
34
|
+
requirements:
|
|
35
|
+
- - ! '>='
|
|
36
|
+
- !ruby/object:Gem::Version
|
|
37
|
+
version: '0'
|
|
38
|
+
type: :runtime
|
|
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
|
+
- !ruby/object:Gem::Dependency
|
|
47
|
+
name: rspec
|
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
|
49
|
+
none: false
|
|
50
|
+
requirements:
|
|
51
|
+
- - ! '>='
|
|
52
|
+
- !ruby/object:Gem::Version
|
|
53
|
+
version: '0'
|
|
54
|
+
type: :development
|
|
55
|
+
prerelease: false
|
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
57
|
+
none: false
|
|
58
|
+
requirements:
|
|
59
|
+
- - ! '>='
|
|
60
|
+
- !ruby/object:Gem::Version
|
|
61
|
+
version: '0'
|
|
62
|
+
- !ruby/object:Gem::Dependency
|
|
63
|
+
name: fakeweb
|
|
64
|
+
requirement: !ruby/object:Gem::Requirement
|
|
65
|
+
none: false
|
|
66
|
+
requirements:
|
|
67
|
+
- - ! '>='
|
|
68
|
+
- !ruby/object:Gem::Version
|
|
69
|
+
version: '0'
|
|
70
|
+
type: :development
|
|
71
|
+
prerelease: false
|
|
72
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
73
|
+
none: false
|
|
74
|
+
requirements:
|
|
75
|
+
- - ! '>='
|
|
76
|
+
- !ruby/object:Gem::Version
|
|
77
|
+
version: '0'
|
|
78
|
+
description: A Ruby client for The Arch Climbing Wall API.
|
|
79
|
+
email: chris@patuzzo.co.uk
|
|
80
|
+
executables: []
|
|
81
|
+
extensions: []
|
|
82
|
+
extra_rdoc_files: []
|
|
83
|
+
files:
|
|
84
|
+
- README.md
|
|
85
|
+
- lib/the_arch.rb
|
|
86
|
+
- lib/the_arch/base.rb
|
|
87
|
+
- lib/the_arch/parser.rb
|
|
88
|
+
homepage: https://github.com/tuzz/the_arch
|
|
89
|
+
licenses: []
|
|
90
|
+
post_install_message:
|
|
91
|
+
rdoc_options: []
|
|
92
|
+
require_paths:
|
|
93
|
+
- lib
|
|
94
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
95
|
+
none: false
|
|
96
|
+
requirements:
|
|
97
|
+
- - ! '>='
|
|
98
|
+
- !ruby/object:Gem::Version
|
|
99
|
+
version: '0'
|
|
100
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
101
|
+
none: false
|
|
102
|
+
requirements:
|
|
103
|
+
- - ! '>='
|
|
104
|
+
- !ruby/object:Gem::Version
|
|
105
|
+
version: '0'
|
|
106
|
+
requirements: []
|
|
107
|
+
rubyforge_project:
|
|
108
|
+
rubygems_version: 1.8.23
|
|
109
|
+
signing_key:
|
|
110
|
+
specification_version: 3
|
|
111
|
+
summary: The Arch
|
|
112
|
+
test_files: []
|