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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 62bc8f69aedadc8f162f9f67f2f75dbc4ba6ee3e
4
- data.tar.gz: ad097d3ca46fda393775cedfa7f2d9e1a87217a9
3
+ metadata.gz: 825f5c8ea4af9140214feccfc135e4acc6c12b2d
4
+ data.tar.gz: a2142dc26711b7c3540eff6238708d9c26ac6187
5
5
  SHA512:
6
- metadata.gz: d6ec70169425fa2f88210a0599ec79555b81dc0d0db7dd5c963f68e52ed026960016527ab7ae99eccb8b6cf34bb3992bed151c861fe8596cbc47b98e6a3eec82
7
- data.tar.gz: b82c945030c4ac3263fd995d2714cde3efc3624cea6faa624f95c5741aba14d125031b053e1702a4a95ff78404f43bc24bc51b78dfe9956f5f8d00bf23bc5eed
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'] === 1 ? response : []
19
+ response['success'] == 1 ? response : []
14
20
  end
15
21
  end
@@ -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.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-13 00:00:00.000000000 Z
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