Trailfinder 0.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.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 62bc8f69aedadc8f162f9f67f2f75dbc4ba6ee3e
4
+ data.tar.gz: ad097d3ca46fda393775cedfa7f2d9e1a87217a9
5
+ SHA512:
6
+ metadata.gz: d6ec70169425fa2f88210a0599ec79555b81dc0d0db7dd5c963f68e52ed026960016527ab7ae99eccb8b6cf34bb3992bed151c861fe8596cbc47b98e6a3eec82
7
+ data.tar.gz: b82c945030c4ac3263fd995d2714cde3efc3624cea6faa624f95c5741aba14d125031b053e1702a4a95ff78404f43bc24bc51b78dfe9956f5f8d00bf23bc5eed
@@ -0,0 +1,15 @@
1
+ require 'httparty'
2
+ require 'pry'
3
+
4
+ class Trailfinder
5
+ include HTTParty
6
+
7
+ def initialize
8
+ @key = ENV['TRAILFINDER_API_KEY']
9
+ end
10
+
11
+ def get_trails_by_id(ids)
12
+ response = HTTParty.get("https://www.hikingproject.com/data/get-trails-by-id?ids=#{ids}&key=#{@key}")
13
+ response['success'] === 1 ? response : []
14
+ end
15
+ end
@@ -0,0 +1,63 @@
1
+ require_relative '../trailfinder'
2
+
3
+ # This is for colors in the terminal
4
+ RSpec.configure do |config|
5
+ config.failure_color = :red
6
+ config.tty = true
7
+ config.color = true
8
+ end
9
+
10
+ describe Trailfinder do
11
+ let(:trail) { Trailfinder.new }
12
+
13
+ describe '#get_trails_by_id' do
14
+ context 'when a single id is given' do
15
+ context 'when the id is valid'
16
+ let(:response) { trail.get_trails_by_id(7000108)}
17
+ let(:subject) { response['trails'].first['name']}
18
+
19
+ it 'returns the trail data' do
20
+ expect(subject).to eq('Angels Landing')
21
+ end
22
+
23
+ context 'when the id is invalid' do
24
+ let(:response) { trail.get_trails_by_id(1)}
25
+ let(:subject) { response }
26
+
27
+ it 'returns a blank array' do
28
+ expect(subject).to eq([])
29
+ end
30
+ end
31
+ end
32
+
33
+ context 'when an array of valid ids is given' do
34
+ context 'when all the values are valid' do
35
+ let(:response) { trail.get_trails_by_id([7001635, 7002742]) }
36
+ let(:subject) { response['trails'].size }
37
+
38
+ it 'returns an array of trails' do
39
+ expect(subject).to eq(2)
40
+ end
41
+ end
42
+
43
+ context 'when some of the values are valid' do
44
+ let(:response) { trail.get_trails_by_id([7001635, 999999999]) }
45
+ let(:subject) { response['trails'].size }
46
+
47
+ it 'returns only the valid trails' do
48
+ expect(subject).to eq(1)
49
+ end
50
+ end
51
+
52
+ context 'when none of the values are valid' do
53
+ let(:response) { trail.get_trails_by_id([99999998, 999999999]) }
54
+ let(:subject) { response }
55
+
56
+ it 'returns no trails' do
57
+ expect(subject).to eq([])
58
+ end
59
+ end
60
+ end
61
+
62
+ end
63
+ end
metadata ADDED
@@ -0,0 +1,45 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: Trailfinder
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Josh Nelson
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2019-04-13 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: A simple trailfindering api interface
14
+ email: joshcdnelson@gmail.com
15
+ executables: []
16
+ extensions: []
17
+ extra_rdoc_files: []
18
+ files:
19
+ - lib/trailfinder.rb
20
+ - spec/trailfinder_spec.rb
21
+ homepage:
22
+ licenses:
23
+ - MIT
24
+ metadata: {}
25
+ post_install_message:
26
+ rdoc_options: []
27
+ require_paths:
28
+ - lib
29
+ required_ruby_version: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ required_rubygems_version: !ruby/object:Gem::Requirement
35
+ requirements:
36
+ - - ">="
37
+ - !ruby/object:Gem::Version
38
+ version: '0'
39
+ requirements: []
40
+ rubyforge_project:
41
+ rubygems_version: 2.5.1
42
+ signing_key:
43
+ specification_version: 4
44
+ summary: Just getting the bare bones gem up and running
45
+ test_files: []