Trailfinder 0.0.0 → 0.0.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.
- checksums.yaml +4 -4
- data/lib/trailfinder.rb +7 -1
- data/spec/trailfinder_spec.rb +32 -1
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 825f5c8ea4af9140214feccfc135e4acc6c12b2d
|
|
4
|
+
data.tar.gz: a2142dc26711b7c3540eff6238708d9c26ac6187
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 64472f930f0977c396cd71d7f78805cd0cda11fca361fedeeaae535e818442744b5ebfd553643aeff5d3c314f3814092ff48b025e4eda5e776738a7cd35eea70
|
|
7
|
+
data.tar.gz: 64723dc5fe317a6c50b6987916c629c26e795db9fcfbc90edd699664431a93361cfa813e0dae6347fa484b77f749a4a4d46aa1f646c8848d7fa8aaab2c0b2845
|
data/lib/trailfinder.rb
CHANGED
|
@@ -6,10 +6,16 @@ class Trailfinder
|
|
|
6
6
|
|
|
7
7
|
def initialize
|
|
8
8
|
@key = ENV['TRAILFINDER_API_KEY']
|
|
9
|
+
@max_distance = 10
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
def get_trails(latitude:, longitude:)
|
|
13
|
+
response = HTTParty.get("https://www.hikingproject.com/data/get-trails?lat=#{latitude}&lon=#{longitude}&maxDistance=#{@max_distance}&key=#{@key}")
|
|
14
|
+
response['success'] == 1 ? response : []
|
|
9
15
|
end
|
|
10
16
|
|
|
11
17
|
def get_trails_by_id(ids)
|
|
12
18
|
response = HTTParty.get("https://www.hikingproject.com/data/get-trails-by-id?ids=#{ids}&key=#{@key}")
|
|
13
|
-
response['success']
|
|
19
|
+
response['success'] == 1 ? response : []
|
|
14
20
|
end
|
|
15
21
|
end
|
data/spec/trailfinder_spec.rb
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
require_relative '../trailfinder'
|
|
1
|
+
require_relative '../lib/trailfinder'
|
|
2
2
|
|
|
3
3
|
# This is for colors in the terminal
|
|
4
4
|
RSpec.configure do |config|
|
|
@@ -60,4 +60,35 @@ describe Trailfinder do
|
|
|
60
60
|
end
|
|
61
61
|
|
|
62
62
|
end
|
|
63
|
+
|
|
64
|
+
describe '#get_trails' do
|
|
65
|
+
context 'with valid inputs' do
|
|
66
|
+
context 'when there are trails within scope' do
|
|
67
|
+
let(:response) { trail.get_trails(latitude: 40, longitude: -105) }
|
|
68
|
+
let(:subject) { response['trails'].first['name'] }
|
|
69
|
+
|
|
70
|
+
it 'returns a collection of trails' do
|
|
71
|
+
expect(subject).to eq("Teller Farm - The Tank")
|
|
72
|
+
end
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
context 'when there are no trails within scope' do
|
|
76
|
+
let(:response) { trail.get_trails(latitude: 11, longitude: 111) }
|
|
77
|
+
let(:subject) { response['trails'] }
|
|
78
|
+
|
|
79
|
+
it 'returns an empty array' do
|
|
80
|
+
expect(subject).to eq([])
|
|
81
|
+
end
|
|
82
|
+
end
|
|
83
|
+
end
|
|
84
|
+
|
|
85
|
+
context 'with invalid inputs' do
|
|
86
|
+
let(:response) { trail.get_trails(latitude: 'abc', longitude: 'xyz') }
|
|
87
|
+
let(:subject) { response }
|
|
88
|
+
|
|
89
|
+
it 'returns an empty array' do
|
|
90
|
+
expect(subject).to eq([])
|
|
91
|
+
end
|
|
92
|
+
end
|
|
93
|
+
end
|
|
63
94
|
end
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: Trailfinder
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.0.
|
|
4
|
+
version: 0.0.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Josh Nelson
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2019-04-
|
|
11
|
+
date: 2019-04-14 00:00:00.000000000 Z
|
|
12
12
|
dependencies: []
|
|
13
13
|
description: A simple trailfindering api interface
|
|
14
14
|
email: joshcdnelson@gmail.com
|