location-service-client 0.1.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 +7 -0
- data/.gitignore +10 -0
- data/.rubocop.yml +1164 -0
- data/CHANGELOG.md +20 -0
- data/Gemfile +9 -0
- data/README.md +47 -0
- data/Rakefile +8 -0
- data/lib/location-service-client.rb +4 -0
- data/lib/location.rb +100 -0
- data/lib/version.rb +7 -0
- data/location_service_client.gemspec +30 -0
- data/spec/data/locations.json +84592 -0
- data/spec/lib/location_spec.rb +46 -0
- data/spec/test_helper.rb +7 -0
- metadata +144 -0
@@ -0,0 +1,46 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
RSpec.describe Location, type: :model do
|
4
|
+
|
5
|
+
before(:each) do
|
6
|
+
allow(Location).to receive(:request).and_return(
|
7
|
+
JSON.parse(File.read("spec/data/locations.json"))
|
8
|
+
)
|
9
|
+
end
|
10
|
+
|
11
|
+
context "finder methods" do
|
12
|
+
it "should find a location by ID" do
|
13
|
+
l = Location.find(3520)
|
14
|
+
l.name.should eq "Mytilene Airport"
|
15
|
+
end
|
16
|
+
|
17
|
+
it "should calculate a ruby timezone for a location" do
|
18
|
+
l = Location.find(100)
|
19
|
+
l.name.should eq "Gate 74"
|
20
|
+
l.ruby_timezone.identifier.should eq "America/Los_Angeles"
|
21
|
+
end
|
22
|
+
|
23
|
+
it "should find a location by code" do
|
24
|
+
l = Location.find_by_code("SFO")
|
25
|
+
l.name.should eq "San Francisco International Airport"
|
26
|
+
l = Location.find_by_code("94128-SFO-0019")
|
27
|
+
l.name.should eq "Gate 22"
|
28
|
+
end
|
29
|
+
|
30
|
+
it "should find a gate by airport" do
|
31
|
+
l = Location.find_by_airport_and_gate("SFO", "Gate 22")
|
32
|
+
l.name.should eq "Gate 22"
|
33
|
+
l.code.should eq "94128-SFO-0019"
|
34
|
+
l = Location.find_by_airport_and_gate("SFO", "Gate 24")
|
35
|
+
l.name.should eq "Gate 24"
|
36
|
+
l.code.should eq "94128-SFO-0024"
|
37
|
+
end
|
38
|
+
|
39
|
+
it "should find a leaf node by a crumb trail of codes" do
|
40
|
+
l = Location.find_by_codes(["SFO", "94128-SFO-0019"])
|
41
|
+
l.name.should eq "Gate 22"
|
42
|
+
end
|
43
|
+
|
44
|
+
end
|
45
|
+
|
46
|
+
end
|
data/spec/test_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,144 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: location-service-client
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Josh Buermann
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-06-24 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: config
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: json
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rest-client
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: tzinfo
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: activerecord
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :runtime
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: rspec-rails
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '3.0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '3.0'
|
97
|
+
description: ''
|
98
|
+
email:
|
99
|
+
- josh.buermann@springshot.com
|
100
|
+
executables: []
|
101
|
+
extensions: []
|
102
|
+
extra_rdoc_files: []
|
103
|
+
files:
|
104
|
+
- ".gitignore"
|
105
|
+
- ".rubocop.yml"
|
106
|
+
- CHANGELOG.md
|
107
|
+
- Gemfile
|
108
|
+
- README.md
|
109
|
+
- Rakefile
|
110
|
+
- lib/location-service-client.rb
|
111
|
+
- lib/location.rb
|
112
|
+
- lib/version.rb
|
113
|
+
- location_service_client.gemspec
|
114
|
+
- spec/data/locations.json
|
115
|
+
- spec/lib/location_spec.rb
|
116
|
+
- spec/test_helper.rb
|
117
|
+
homepage: https://github.com/springshot/location_service_client
|
118
|
+
licenses:
|
119
|
+
- ''
|
120
|
+
metadata: {}
|
121
|
+
post_install_message:
|
122
|
+
rdoc_options: []
|
123
|
+
require_paths:
|
124
|
+
- lib
|
125
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
126
|
+
requirements:
|
127
|
+
- - "~>"
|
128
|
+
- !ruby/object:Gem::Version
|
129
|
+
version: '2.0'
|
130
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
131
|
+
requirements:
|
132
|
+
- - ">="
|
133
|
+
- !ruby/object:Gem::Version
|
134
|
+
version: '0'
|
135
|
+
requirements: []
|
136
|
+
rubyforge_project:
|
137
|
+
rubygems_version: 2.4.5
|
138
|
+
signing_key:
|
139
|
+
specification_version: 4
|
140
|
+
summary: ''
|
141
|
+
test_files:
|
142
|
+
- spec/data/locations.json
|
143
|
+
- spec/lib/location_spec.rb
|
144
|
+
- spec/test_helper.rb
|