nhtsa 0.1.0 → 0.2.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 +4 -4
- data/.travis.yml +6 -0
- data/README.md +3 -1
- data/lib/nhtsa/child_safety_seat_inspection_station_locator/get_by_geo_location.rb +19 -0
- data/lib/nhtsa/child_safety_seat_inspection_station_locator/get_by_state.rb +26 -0
- data/lib/nhtsa/child_safety_seat_inspection_station_locator/get_by_zip_code.rb +26 -0
- data/lib/nhtsa/child_safety_seat_inspection_station_locator.rb +4 -64
- data/lib/nhtsa/civil_penalties/civil_penalties.rb +13 -0
- data/lib/nhtsa/civil_penalties/civil_penalties_by_year.rb +17 -0
- data/lib/nhtsa/civil_penalties.rb +3 -26
- data/lib/nhtsa/complaints/complaints.rb +19 -0
- data/lib/nhtsa/complaints/complaints_by_odi_number.rb +17 -0
- data/lib/nhtsa/complaints/manufacturers.rb +17 -0
- data/lib/nhtsa/complaints/models.rb +18 -0
- data/lib/nhtsa/complaints/years.rb +13 -0
- data/lib/nhtsa/complaints.rb +6 -71
- data/lib/nhtsa/recalls/campaign_recalls.rb +17 -0
- data/lib/nhtsa/recalls/manufacturers.rb +17 -0
- data/lib/nhtsa/recalls/models.rb +18 -0
- data/lib/nhtsa/recalls/recalls.rb +19 -0
- data/lib/nhtsa/recalls/years.rb +14 -0
- data/lib/nhtsa/recalls.rb +6 -71
- data/lib/nhtsa/safety_ratings/manufacturer.rb +26 -0
- data/lib/nhtsa/safety_ratings/manufacturers.rb +30 -0
- data/lib/nhtsa/safety_ratings/model.rb +31 -0
- data/lib/nhtsa/safety_ratings/models.rb +27 -0
- data/lib/nhtsa/safety_ratings/rating.rb +57 -0
- data/lib/nhtsa/safety_ratings/ratings.rb +27 -0
- data/lib/nhtsa/safety_ratings/trim.rb +29 -0
- data/lib/nhtsa/safety_ratings/trims.rb +40 -0
- data/lib/nhtsa/safety_ratings/year.rb +17 -0
- data/lib/nhtsa/safety_ratings/years.rb +25 -0
- data/lib/nhtsa/safety_ratings.rb +11 -84
- data/lib/nhtsa/version.rb +1 -1
- metadata +28 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 536615ab56a8f47955aa3bd6336e558c3b1dd9a1
|
4
|
+
data.tar.gz: 41da4ed80c9d77f85b7e27f20d63d2d5f37e7b71
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7dc2a07f2e662a23de75cb6c1f0da5c709e0a912d69e1cd4756d0fa03ad185cd4eb2b480651b0eac17186f848e57e07014a7d0033975fc9eaea246950a549406
|
7
|
+
data.tar.gz: dc882e39342d6341ef5e731216daa5311c2ed0809d3e2a672ac481b1aa721c86c47df4d05e66abb05aeacdf192d493dcd2d3117cc2dc7e7c212ebd0a5f7d3d3f
|
data/.travis.yml
ADDED
data/README.md
CHANGED
@@ -0,0 +1,19 @@
|
|
1
|
+
module Nhtsa
|
2
|
+
module ChildSafetySeatInspectionStationLocator
|
3
|
+
class GetByGeoLocation
|
4
|
+
def initialize(latitude, longitude, radius)
|
5
|
+
@latitude = latitude
|
6
|
+
@longitude = longitude
|
7
|
+
@radius = radius
|
8
|
+
end
|
9
|
+
|
10
|
+
def url
|
11
|
+
"http://webapi.nhtsa.gov/api/CSSIStation?lat=#{@latitude}&long=#{@longitude}&miles=#{@radius}&format=json"
|
12
|
+
end
|
13
|
+
|
14
|
+
def inspection_stations
|
15
|
+
JSON.parse(open(url).read)["Results"]
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
module Nhtsa
|
2
|
+
module ChildSafetySeatInspectionStationLocator
|
3
|
+
class GetByState
|
4
|
+
def initialize(state_abbreviation, filters = {spanish: false, cpsweek: false})
|
5
|
+
@state_abbreviation = state_abbreviation
|
6
|
+
@filters = filters
|
7
|
+
end
|
8
|
+
|
9
|
+
def url
|
10
|
+
if @filters[:spanish] && @filters[:cpsweek]
|
11
|
+
BASE_URI + END_POINT + "/state/#{@state_abbreviation}" + CPS_WEEK + SPANISH + DEFAULT_PARAMS
|
12
|
+
elsif @filters[:spanish]
|
13
|
+
BASE_URI + END_POINT + "/state/#{@state_abbreviation}" + SPANISH + DEFAULT_PARAMS
|
14
|
+
elsif @filters[:cpsweek]
|
15
|
+
BASE_URI + END_POINT + "/state/#{@state_abbreviation}" + CPS_WEEK + DEFAULT_PARAMS
|
16
|
+
else
|
17
|
+
BASE_URI + END_POINT + "/state/#{@state_abbreviation}" + DEFAULT_PARAMS
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
def inspection_stations
|
22
|
+
JSON.parse(open(url).read)["Results"]
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
module Nhtsa
|
2
|
+
module ChildSafetySeatInspectionStationLocator
|
3
|
+
class GetByZipCode
|
4
|
+
def initialize(zip_code, filters = {:spanish => false, :cpsweek => false})
|
5
|
+
@zip_code = zip_code
|
6
|
+
@filters = filters
|
7
|
+
end
|
8
|
+
|
9
|
+
def url
|
10
|
+
if @filters[:spanish] && @filters[:cpsweek]
|
11
|
+
BASE_URI + END_POINT + "/zip/#{@zip_code}" + CPS_WEEK + SPANISH + DEFAULT_PARAMS
|
12
|
+
elsif @filters[:spanish]
|
13
|
+
BASE_URI + END_POINT + "/zip/#{@zip_code}" + SPANISH + DEFAULT_PARAMS
|
14
|
+
elsif @filters[:cpsweek]
|
15
|
+
BASE_URI + END_POINT + "/zip/#{@zip_code}" + CPS_WEEK + DEFAULT_PARAMS
|
16
|
+
else
|
17
|
+
BASE_URI + END_POINT + "/zip/#{@zip_code}" + DEFAULT_PARAMS
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
def inspection_stations
|
22
|
+
JSON.parse(open(url).read)["Results"]
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -1,74 +1,14 @@
|
|
1
1
|
# NHTSA Child Safety Seat Inspection Station Locator
|
2
2
|
# http://webapi.nhtsa.gov/Default.aspx?CSSIStations/API/80
|
3
3
|
|
4
|
+
require_relative "child_safety_seat_inspection_station_locator/get_by_zip_code"
|
5
|
+
require_relative "child_safety_seat_inspection_station_locator/get_by_state"
|
6
|
+
require_relative "child_safety_seat_inspection_station_locator/get_by_geo_location"
|
7
|
+
|
4
8
|
module Nhtsa
|
5
9
|
module ChildSafetySeatInspectionStationLocator
|
6
|
-
|
7
10
|
END_POINT = "/CSSIStation"
|
8
11
|
CPS_WEEK = "/cpsweek"
|
9
12
|
SPANISH = "/lang/spanish"
|
10
|
-
|
11
|
-
class GetByZipCode
|
12
|
-
def initialize(zip_code, filters = {:spanish => false, :cpsweek => false})
|
13
|
-
@zip_code = zip_code
|
14
|
-
@filters = filters
|
15
|
-
end
|
16
|
-
|
17
|
-
def url
|
18
|
-
if @filters[:spanish] && @filters[:cpsweek]
|
19
|
-
BASE_URI + END_POINT + "/zip/#{@zip_code}" + CPS_WEEK + SPANISH + DEFAULT_PARAMS
|
20
|
-
elsif @filters[:spanish]
|
21
|
-
BASE_URI + END_POINT + "/zip/#{@zip_code}" + SPANISH + DEFAULT_PARAMS
|
22
|
-
elsif @filters[:cpsweek]
|
23
|
-
BASE_URI + END_POINT + "/zip/#{@zip_code}" + CPS_WEEK + DEFAULT_PARAMS
|
24
|
-
else
|
25
|
-
BASE_URI + END_POINT + "/zip/#{@zip_code}" + DEFAULT_PARAMS
|
26
|
-
end
|
27
|
-
end
|
28
|
-
|
29
|
-
def inspection_stations
|
30
|
-
JSON.parse(open(url).read)["Results"]
|
31
|
-
end
|
32
|
-
end
|
33
|
-
|
34
|
-
class GetByState
|
35
|
-
def initialize(state_abbreviation, filters = {spanish: false, cpsweek: false})
|
36
|
-
@state_abbreviation = state_abbreviation
|
37
|
-
@filters = filters
|
38
|
-
end
|
39
|
-
|
40
|
-
def url
|
41
|
-
if @filters[:spanish] && @filters[:cpsweek]
|
42
|
-
BASE_URI + END_POINT + "/state/#{@state_abbreviation}" + CPS_WEEK + SPANISH + DEFAULT_PARAMS
|
43
|
-
elsif @filters[:spanish]
|
44
|
-
BASE_URI + END_POINT + "/state/#{@state_abbreviation}" + SPANISH + DEFAULT_PARAMS
|
45
|
-
elsif @filters[:cpsweek]
|
46
|
-
BASE_URI + END_POINT + "/state/#{@state_abbreviation}" + CPS_WEEK + DEFAULT_PARAMS
|
47
|
-
else
|
48
|
-
BASE_URI + END_POINT + "/state/#{@state_abbreviation}" + DEFAULT_PARAMS
|
49
|
-
end
|
50
|
-
end
|
51
|
-
|
52
|
-
def inspection_stations
|
53
|
-
JSON.parse(open(url).read)["Results"]
|
54
|
-
end
|
55
|
-
end
|
56
|
-
|
57
|
-
class GetByGeoLocation
|
58
|
-
def initialize(latitude, longitude, radius)
|
59
|
-
@latitude = latitude
|
60
|
-
@longitude = longitude
|
61
|
-
@radius = radius
|
62
|
-
end
|
63
|
-
|
64
|
-
def url
|
65
|
-
"http://webapi.nhtsa.gov/api/CSSIStation?lat=#{@latitude}&long=#{@longitude}&miles=#{@radius}&format=json"
|
66
|
-
end
|
67
|
-
|
68
|
-
def inspection_stations
|
69
|
-
JSON.parse(open(url).read)["Results"]
|
70
|
-
end
|
71
|
-
end
|
72
|
-
|
73
13
|
end
|
74
14
|
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module Nhtsa
|
2
|
+
module CivilPenalties
|
3
|
+
class CivilPenaltiesByYear
|
4
|
+
def initialize(year)
|
5
|
+
@year = year
|
6
|
+
end
|
7
|
+
|
8
|
+
def url
|
9
|
+
BASE_URI + END_POINT + "/#{@year}" + DEFAULT_PARAMS
|
10
|
+
end
|
11
|
+
|
12
|
+
def civil_penalties_by_year
|
13
|
+
JSON.parse(open(url).read)["Results"]
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -1,34 +1,11 @@
|
|
1
1
|
# NHTSA Civil Penalty Payments
|
2
2
|
# http://webapi.nhtsa.gov/Default.aspx?CivilPenalties/API/251
|
3
3
|
|
4
|
+
require_relative "civil_penalties/civil_penalties"
|
5
|
+
require_relative "civil_penalties/civil_penalties_by_year"
|
6
|
+
|
4
7
|
module Nhtsa
|
5
8
|
module CivilPenalties
|
6
|
-
|
7
9
|
END_POINT = "/CivilPenalties"
|
8
|
-
|
9
|
-
class CivilPenalties
|
10
|
-
def url
|
11
|
-
BASE_URI + END_POINT + DEFAULT_PARAMS
|
12
|
-
end
|
13
|
-
|
14
|
-
def civil_penalties
|
15
|
-
JSON.parse(open(url).read)["Results"]
|
16
|
-
end
|
17
|
-
end
|
18
|
-
|
19
|
-
class CivilPenaltyByYear
|
20
|
-
def initialize(year)
|
21
|
-
@year = year
|
22
|
-
end
|
23
|
-
|
24
|
-
def url
|
25
|
-
BASE_URI + END_POINT + "/#{@year}" + DEFAULT_PARAMS
|
26
|
-
end
|
27
|
-
|
28
|
-
def civil_penalties_by_year
|
29
|
-
JSON.parse(open(url).read)["Results"]
|
30
|
-
end
|
31
|
-
end
|
32
|
-
|
33
10
|
end
|
34
11
|
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module Nhtsa
|
2
|
+
module Complaints
|
3
|
+
class Complaints
|
4
|
+
def initialize(year, manufacturer, model)
|
5
|
+
@year = year
|
6
|
+
@manufacturer = URI::encode(manufacturer)
|
7
|
+
@model = URI::encode(model)
|
8
|
+
end
|
9
|
+
|
10
|
+
def url
|
11
|
+
BASE_URI + END_POINT + "/#{@year}/#{@manufacturer}/#{@model}" + DEFAULT_PARAMS
|
12
|
+
end
|
13
|
+
|
14
|
+
def complaints
|
15
|
+
JSON.parse(open(url).read)["Results"]
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module Nhtsa
|
2
|
+
module Complaints
|
3
|
+
class ComplaintsByOdiNumber
|
4
|
+
def initialize(odi_number)
|
5
|
+
@odi_number = odi_number
|
6
|
+
end
|
7
|
+
|
8
|
+
def url
|
9
|
+
BASE_URI + END_POINT + "/odinumber/#{@odi_number}" + DEFAULT_PARAMS
|
10
|
+
end
|
11
|
+
|
12
|
+
def complaints_by_odi_number
|
13
|
+
JSON.parse(open(url).read)["Results"]
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module Nhtsa
|
2
|
+
module Complaints
|
3
|
+
class Manufacturers
|
4
|
+
def initialize(year)
|
5
|
+
@year = year
|
6
|
+
end
|
7
|
+
|
8
|
+
def url
|
9
|
+
BASE_URI + END_POINT + "/#{@year}" + DEFAULT_PARAMS
|
10
|
+
end
|
11
|
+
|
12
|
+
def manufacturers
|
13
|
+
JSON.parse(open(url).read)["Results"].collect{|manufacturer| manufacturer["Make"]}
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
module Nhtsa
|
2
|
+
module Complaints
|
3
|
+
class Models
|
4
|
+
def initialize(year, manufacturer)
|
5
|
+
@year = year
|
6
|
+
@manufacturer = URI::encode(manufacturer)
|
7
|
+
end
|
8
|
+
|
9
|
+
def url
|
10
|
+
BASE_URI + END_POINT + "/#{@year}/#{@manufacturer}" + DEFAULT_PARAMS
|
11
|
+
end
|
12
|
+
|
13
|
+
def models
|
14
|
+
JSON.parse(open(url).read)["Results"].collect{|model| model["Model"]}
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
data/lib/nhtsa/complaints.rb
CHANGED
@@ -1,79 +1,14 @@
|
|
1
1
|
# http://webapi.nhtsa.gov/Default.aspx?Complaints/API/81
|
2
2
|
# NHTSA's Office of Defects Investigation (ODI) - Complaints
|
3
3
|
|
4
|
+
require_relative "complaints/years"
|
5
|
+
require_relative "complaints/manufacturers"
|
6
|
+
require_relative "complaints/models"
|
7
|
+
require_relative "complaints/complaints"
|
8
|
+
require_relative "complaints/complaints_by_odi_number"
|
9
|
+
|
4
10
|
module Nhtsa
|
5
11
|
module Complaints
|
6
|
-
|
7
12
|
END_POINT = "/Complaints/vehicle"
|
8
|
-
|
9
|
-
class Years
|
10
|
-
def url
|
11
|
-
BASE_URI + END_POINT + DEFAULT_PARAMS
|
12
|
-
end
|
13
|
-
|
14
|
-
def years
|
15
|
-
JSON.parse(open(url).read)["Results"].collect{|year| year["ModelYear"]}
|
16
|
-
end
|
17
|
-
end
|
18
|
-
|
19
|
-
class Manufacturers
|
20
|
-
def initialize(year)
|
21
|
-
@year = year
|
22
|
-
end
|
23
|
-
|
24
|
-
def url
|
25
|
-
BASE_URI + END_POINT + "/#{@year}" + DEFAULT_PARAMS
|
26
|
-
end
|
27
|
-
|
28
|
-
def manufacturers
|
29
|
-
JSON.parse(open(url).read)["Results"].collect{|manufacturer| manufacturer["Make"]}
|
30
|
-
end
|
31
|
-
end
|
32
|
-
|
33
|
-
class Models
|
34
|
-
def initialize(year, manufacturer)
|
35
|
-
@year = year
|
36
|
-
@manufacturer = URI::encode(manufacturer)
|
37
|
-
end
|
38
|
-
|
39
|
-
def url
|
40
|
-
BASE_URI + END_POINT + "/#{@year}/#{@manufacturer}" + DEFAULT_PARAMS
|
41
|
-
end
|
42
|
-
|
43
|
-
def models
|
44
|
-
JSON.parse(open(url).read)["Results"].collect{|model| model["Model"]}
|
45
|
-
end
|
46
|
-
end
|
47
|
-
|
48
|
-
class Complaints
|
49
|
-
def initialize(year, manufacturer, model)
|
50
|
-
@year = year
|
51
|
-
@manufacturer = URI::encode(manufacturer)
|
52
|
-
@model = URI::encode(model)
|
53
|
-
end
|
54
|
-
|
55
|
-
def url
|
56
|
-
BASE_URI + END_POINT + "/#{@year}/#{@manufacturer}/#{@model}" + DEFAULT_PARAMS
|
57
|
-
end
|
58
|
-
|
59
|
-
def complaints
|
60
|
-
JSON.parse(open(url).read)["Results"]
|
61
|
-
end
|
62
|
-
end
|
63
|
-
|
64
|
-
class ComplaintsByOdiNumber
|
65
|
-
def initialize(odi_number)
|
66
|
-
@odi_number = odi_number
|
67
|
-
end
|
68
|
-
|
69
|
-
def url
|
70
|
-
BASE_URI + END_POINT + "/odinumber/#{@odi_number}" + DEFAULT_PARAMS
|
71
|
-
end
|
72
|
-
|
73
|
-
def complaints_by_odi_number
|
74
|
-
JSON.parse(open(url).read)["Results"]
|
75
|
-
end
|
76
|
-
end
|
77
|
-
|
78
13
|
end
|
79
14
|
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module Nhtsa
|
2
|
+
module Recalls
|
3
|
+
class CampaignRecalls
|
4
|
+
def initialize(campaign_number)
|
5
|
+
@campaign_number = campaign_number
|
6
|
+
end
|
7
|
+
|
8
|
+
def url
|
9
|
+
BASE_URI + END_POINT + "/CampaignNumber/#{@campaign_number}" + DEFAULT_PARAMS
|
10
|
+
end
|
11
|
+
|
12
|
+
def campaign_recalls
|
13
|
+
JSON.parse(open(url).read)["Results"]
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module Nhtsa
|
2
|
+
module Recalls
|
3
|
+
class Manufacturers
|
4
|
+
def initialize(year)
|
5
|
+
@year = year
|
6
|
+
end
|
7
|
+
|
8
|
+
def url
|
9
|
+
BASE_URI + END_POINT + "/#{@year}" + DEFAULT_PARAMS
|
10
|
+
end
|
11
|
+
|
12
|
+
def manufacturers
|
13
|
+
JSON.parse(open(url).read)["Results"].collect{|manufacturer| manufacturer["Make"]}
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
module Nhtsa
|
2
|
+
module Recalls
|
3
|
+
class Models
|
4
|
+
def initialize(year, manufacturer)
|
5
|
+
@year = year
|
6
|
+
@manufacturer = URI::encode(manufacturer)
|
7
|
+
end
|
8
|
+
|
9
|
+
def url
|
10
|
+
BASE_URI + END_POINT + "/#{@year}/#{@manufacturer}" + DEFAULT_PARAMS
|
11
|
+
end
|
12
|
+
|
13
|
+
def models
|
14
|
+
JSON.parse(open(url).read)["Results"].collect{|model| model["Model"]}
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module Nhtsa
|
2
|
+
module Recalls
|
3
|
+
class Recalls
|
4
|
+
def initialize(year, manufacturer, model)
|
5
|
+
@year = year
|
6
|
+
@manufacturer = URI::encode(manufacturer)
|
7
|
+
@model = URI::encode(model)
|
8
|
+
end
|
9
|
+
|
10
|
+
def url
|
11
|
+
BASE_URI + END_POINT + "/#{@year}/#{@manufacturer}/#{@model}" + DEFAULT_PARAMS
|
12
|
+
end
|
13
|
+
|
14
|
+
def recalls
|
15
|
+
JSON.parse(open(url).read)["Results"]
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
data/lib/nhtsa/recalls.rb
CHANGED
@@ -1,78 +1,13 @@
|
|
1
1
|
# http://webapi.nhtsa.gov/api/Recalls/vehicle?format=json
|
2
2
|
|
3
|
+
require_relative "recalls/years"
|
4
|
+
require_relative "recalls/manufacturers"
|
5
|
+
require_relative "recalls/models"
|
6
|
+
require_relative "recalls/recalls"
|
7
|
+
require_relative "recalls/campaign_recalls"
|
8
|
+
|
3
9
|
module Nhtsa
|
4
10
|
module Recalls
|
5
|
-
|
6
11
|
END_POINT = "/Recalls/vehicle"
|
7
|
-
|
8
|
-
class Years
|
9
|
-
def url
|
10
|
-
BASE_URI + END_POINT + DEFAULT_PARAMS
|
11
|
-
end
|
12
|
-
|
13
|
-
def years
|
14
|
-
JSON.parse(open(url).read)["Results"].collect{|year| year["ModelYear"]}
|
15
|
-
end
|
16
|
-
end
|
17
|
-
|
18
|
-
class Manufacturers
|
19
|
-
def initialize(year)
|
20
|
-
@year = year
|
21
|
-
end
|
22
|
-
|
23
|
-
def url
|
24
|
-
BASE_URI + END_POINT + "/#{@year}" + DEFAULT_PARAMS
|
25
|
-
end
|
26
|
-
|
27
|
-
def manufacturers
|
28
|
-
JSON.parse(open(url).read)["Results"].collect{|manufacturer| manufacturer["Make"]}
|
29
|
-
end
|
30
|
-
end
|
31
|
-
|
32
|
-
class Models
|
33
|
-
def initialize(year, manufacturer)
|
34
|
-
@year = year
|
35
|
-
@manufacturer = URI::encode(manufacturer)
|
36
|
-
end
|
37
|
-
|
38
|
-
def url
|
39
|
-
BASE_URI + END_POINT + "/#{@year}/#{@manufacturer}" + DEFAULT_PARAMS
|
40
|
-
end
|
41
|
-
|
42
|
-
def models
|
43
|
-
JSON.parse(open(url).read)["Results"].collect{|model| model["Model"]}
|
44
|
-
end
|
45
|
-
end
|
46
|
-
|
47
|
-
class Recalls
|
48
|
-
def initialize(year, manufacturer, model)
|
49
|
-
@year = year
|
50
|
-
@manufacturer = URI::encode(manufacturer)
|
51
|
-
@model = URI::encode(model)
|
52
|
-
end
|
53
|
-
|
54
|
-
def url
|
55
|
-
BASE_URI + END_POINT + "/#{@year}/#{@manufacturer}/#{@model}" + DEFAULT_PARAMS
|
56
|
-
end
|
57
|
-
|
58
|
-
def recalls
|
59
|
-
JSON.parse(open(url).read)["Results"]
|
60
|
-
end
|
61
|
-
end
|
62
|
-
|
63
|
-
class CampaignRecalls
|
64
|
-
def initialize(campaign_number)
|
65
|
-
@campaign_number = campaign_number
|
66
|
-
end
|
67
|
-
|
68
|
-
def url
|
69
|
-
BASE_URI + END_POINT + "/CampaignNumber/#{@campaign_number}" + DEFAULT_PARAMS
|
70
|
-
end
|
71
|
-
|
72
|
-
def campaign_recalls
|
73
|
-
JSON.parse(open(url).read)["Results"]
|
74
|
-
end
|
75
|
-
end
|
76
|
-
|
77
12
|
end
|
78
13
|
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
module Nhtsa
|
2
|
+
module SafetyRatings
|
3
|
+
class Manufacturer
|
4
|
+
def initialize(year, manufacturer_name)
|
5
|
+
@year = (year.is_a? Nhtsa::SafetyRatings::Year) ? year : Nhtsa::SafetyRatings::Year.new(year)
|
6
|
+
@manufacturer_name = manufacturer_name
|
7
|
+
end
|
8
|
+
|
9
|
+
def year
|
10
|
+
@year
|
11
|
+
end
|
12
|
+
|
13
|
+
def name
|
14
|
+
@manufacturer_name
|
15
|
+
end
|
16
|
+
|
17
|
+
def manufacturer_name
|
18
|
+
@manufacturer_name
|
19
|
+
end
|
20
|
+
|
21
|
+
def to_s
|
22
|
+
"#{@manufacturer_name}"
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
module Nhtsa
|
2
|
+
module SafetyRatings
|
3
|
+
class Manufacturers
|
4
|
+
def initialize(year)
|
5
|
+
@year = Year.new(year)
|
6
|
+
@manufacturers = JSON.parse(open(url).read)["Results"].collect{|manufacturer| Manufacturer.new(@year, manufacturer["Make"])}
|
7
|
+
end
|
8
|
+
|
9
|
+
def url
|
10
|
+
BASE_URI + END_POINT + "/#{@year}" + DEFAULT_PARAMS
|
11
|
+
end
|
12
|
+
|
13
|
+
def manufacturers
|
14
|
+
@manufacturers
|
15
|
+
end
|
16
|
+
|
17
|
+
def year
|
18
|
+
@year
|
19
|
+
end
|
20
|
+
|
21
|
+
def values
|
22
|
+
@manufacturers.map(&:name)
|
23
|
+
end
|
24
|
+
|
25
|
+
def to_s
|
26
|
+
@manufacturers.map(&:to_s)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
module Nhtsa
|
2
|
+
module SafetyRatings
|
3
|
+
class Model
|
4
|
+
def initialize(year, manufacturer, model_name)
|
5
|
+
@year = (year.is_a? Nhtsa::SafetyRatings::Year) ? year : Nhtsa::SafetyRatings::Year.new(year)
|
6
|
+
@manufacturer = (manufacturer.is_a? Nhtsa::SafetyRatings::Manufacturer) ? manufacturer : Nhtsa::SafetyRatings::Manufacturer.new(year, manufacturer)
|
7
|
+
@model_name = model_name
|
8
|
+
end
|
9
|
+
|
10
|
+
def year
|
11
|
+
@year
|
12
|
+
end
|
13
|
+
|
14
|
+
def manufacturer
|
15
|
+
@manufacturer
|
16
|
+
end
|
17
|
+
|
18
|
+
def name
|
19
|
+
@model_name
|
20
|
+
end
|
21
|
+
|
22
|
+
def model_name
|
23
|
+
@model_name
|
24
|
+
end
|
25
|
+
|
26
|
+
def to_s
|
27
|
+
"#{@year} #{@manufacturer} #{@model_name}"
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
module Nhtsa
|
2
|
+
module SafetyRatings
|
3
|
+
class Models
|
4
|
+
def initialize(year, manufacturer)
|
5
|
+
@year = Year.new(year)
|
6
|
+
@manufacturer = Manufacturer.new(year, manufacturer)
|
7
|
+
@models = JSON.parse(open(url).read)["Results"].collect{|model| Model.new(@year, @manufacturer, model["Model"])}
|
8
|
+
end
|
9
|
+
|
10
|
+
def url
|
11
|
+
BASE_URI + END_POINT + "/#{@year}/#{URI.encode(@manufacturer.name)}" + DEFAULT_PARAMS
|
12
|
+
end
|
13
|
+
|
14
|
+
def models
|
15
|
+
@models
|
16
|
+
end
|
17
|
+
|
18
|
+
def model_names
|
19
|
+
@models.map(&:model_name)
|
20
|
+
end
|
21
|
+
|
22
|
+
def to_s
|
23
|
+
@models.inject(""){|model_string, model| model_string << "#{model}\n"}
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,57 @@
|
|
1
|
+
module Nhtsa
|
2
|
+
module SafetyRatings
|
3
|
+
class Rating
|
4
|
+
def initialize(ratings_hash)
|
5
|
+
@ratings_hash = ratings_hash.nil? ? {} : ratings_hash
|
6
|
+
end
|
7
|
+
|
8
|
+
def name
|
9
|
+
@ratings_hash["VehicleDescription"]
|
10
|
+
end
|
11
|
+
|
12
|
+
def vehicle_picture
|
13
|
+
@ratings_hash["VehiclePicture"]
|
14
|
+
end
|
15
|
+
|
16
|
+
def overall_rating
|
17
|
+
@ratings_hash["OverallRating"]
|
18
|
+
end
|
19
|
+
|
20
|
+
def overall_front_crash_rating
|
21
|
+
@ratings_hash["OverallFrontCrashRating"]
|
22
|
+
end
|
23
|
+
|
24
|
+
def overall_side_crash_rating
|
25
|
+
@ratings_hash["OverallSideCrashRating"]
|
26
|
+
end
|
27
|
+
|
28
|
+
def rollover_rating
|
29
|
+
@ratings_hash["RolloverRating"]
|
30
|
+
end
|
31
|
+
|
32
|
+
def rollover_possibility
|
33
|
+
@ratings_hash["RolloverPossibility"]
|
34
|
+
end
|
35
|
+
|
36
|
+
def complaints_count
|
37
|
+
@ratings_hash["ComplaintsCount"]
|
38
|
+
end
|
39
|
+
|
40
|
+
def recalls_count
|
41
|
+
@ratings_hash["RecallsCount"]
|
42
|
+
end
|
43
|
+
|
44
|
+
def investigation_count
|
45
|
+
@ratings_hash["InvestigationCount"]
|
46
|
+
end
|
47
|
+
|
48
|
+
def values
|
49
|
+
@ratings_hash
|
50
|
+
end
|
51
|
+
|
52
|
+
def to_s
|
53
|
+
@ratings_hash.inject(""){ |rating_string, (rating_key, rating_value)| rating_string << "#{rating_key}\n\t#{rating_value}\n" }
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
module Nhtsa
|
2
|
+
module SafetyRatings
|
3
|
+
class Ratings
|
4
|
+
def initialize(*vehicle_ids)
|
5
|
+
raise ArgumentError, "At Least 1 vehicle id is required" if vehicle_ids.empty?
|
6
|
+
@vehicle_ids = Array(vehicle_ids).flatten
|
7
|
+
@ratings = @vehicle_ids.collect{|vehicle_id| Rating.new(JSON.parse(open(url(vehicle_id)).read)["Results"].first)}
|
8
|
+
end
|
9
|
+
|
10
|
+
def url(vehicle_id)
|
11
|
+
BASE_URI + END_POINT + "/VehicleId/#{vehicle_id}" + DEFAULT_PARAMS
|
12
|
+
end
|
13
|
+
|
14
|
+
def ratings
|
15
|
+
@ratings
|
16
|
+
end
|
17
|
+
|
18
|
+
def values
|
19
|
+
@ratings.map(&:values)
|
20
|
+
end
|
21
|
+
|
22
|
+
def to_s
|
23
|
+
@ratings.map(&:to_s).join("\n#{'='*50}\n\n")
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
module Nhtsa
|
2
|
+
module SafetyRatings
|
3
|
+
class Trim
|
4
|
+
def initialize(trim_information)
|
5
|
+
@trim_information = trim_information
|
6
|
+
end
|
7
|
+
|
8
|
+
def name
|
9
|
+
@trim_information["VehicleDescription"]
|
10
|
+
end
|
11
|
+
|
12
|
+
def trim_information
|
13
|
+
@trim_information
|
14
|
+
end
|
15
|
+
|
16
|
+
def trim_id
|
17
|
+
@trim_information["VehicleId"]
|
18
|
+
end
|
19
|
+
|
20
|
+
def trim_description
|
21
|
+
@trim_information["VehicleDescription"]
|
22
|
+
end
|
23
|
+
|
24
|
+
def to_s
|
25
|
+
"id: #{trim_id}\n\t#{trim_description}"
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
module Nhtsa
|
2
|
+
module SafetyRatings
|
3
|
+
class Trims
|
4
|
+
def initialize(year, manufacturer, model)
|
5
|
+
@year = Year.new(year)
|
6
|
+
@manufacturer = Manufacturer.new(year, manufacturer)
|
7
|
+
@model = Model.new(year, manufacturer, model)
|
8
|
+
@trims = JSON.parse(open(url).read)["Results"].collect{|trim| Trim.new(trim)}
|
9
|
+
end
|
10
|
+
|
11
|
+
def url
|
12
|
+
BASE_URI + END_POINT + "/#{@year}/#{URI.encode(@manufacturer.name)}/#{URI.encode(@model.name)}" + DEFAULT_PARAMS
|
13
|
+
end
|
14
|
+
|
15
|
+
def year
|
16
|
+
@year
|
17
|
+
end
|
18
|
+
|
19
|
+
def manufacturer
|
20
|
+
@manufacturer
|
21
|
+
end
|
22
|
+
|
23
|
+
def model
|
24
|
+
@model
|
25
|
+
end
|
26
|
+
|
27
|
+
def trims
|
28
|
+
@trims
|
29
|
+
end
|
30
|
+
|
31
|
+
def descriptions
|
32
|
+
@trims.map(&:trim_description)
|
33
|
+
end
|
34
|
+
|
35
|
+
def ids
|
36
|
+
@trims.map(&:trim_id)
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
module Nhtsa
|
2
|
+
module SafetyRatings
|
3
|
+
class Years
|
4
|
+
def initialize
|
5
|
+
@years = JSON.parse(open(url).read)["Results"].collect{|year| Year.new(year["ModelYear"])}
|
6
|
+
end
|
7
|
+
|
8
|
+
def url
|
9
|
+
BASE_URI + END_POINT + DEFAULT_PARAMS
|
10
|
+
end
|
11
|
+
|
12
|
+
def years
|
13
|
+
@years
|
14
|
+
end
|
15
|
+
|
16
|
+
def values
|
17
|
+
@years.map(&:name)
|
18
|
+
end
|
19
|
+
|
20
|
+
def to_s
|
21
|
+
@years.map(&:to_s)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
data/lib/nhtsa/safety_ratings.rb
CHANGED
@@ -1,92 +1,19 @@
|
|
1
1
|
# New Car Assessment Program (NCAP) - 5 Star Safety Ratings
|
2
2
|
# http://webapi.nhtsa.gov/Default.aspx?SafetyRatings/API/5
|
3
3
|
|
4
|
+
require_relative "safety_ratings/years"
|
5
|
+
require_relative "safety_ratings/year"
|
6
|
+
require_relative "safety_ratings/manufacturers"
|
7
|
+
require_relative "safety_ratings/manufacturer"
|
8
|
+
require_relative "safety_ratings/models"
|
9
|
+
require_relative "safety_ratings/model"
|
10
|
+
require_relative "safety_ratings/trims"
|
11
|
+
require_relative "safety_ratings/trim"
|
12
|
+
require_relative "safety_ratings/ratings"
|
13
|
+
require_relative "safety_ratings/rating"
|
14
|
+
|
4
15
|
module Nhtsa
|
5
16
|
module SafetyRatings
|
6
|
-
|
7
17
|
END_POINT = "/SafetyRatings"
|
8
|
-
|
9
|
-
class Years
|
10
|
-
def url
|
11
|
-
BASE_URI + END_POINT + DEFAULT_PARAMS
|
12
|
-
end
|
13
|
-
|
14
|
-
def years
|
15
|
-
JSON.parse(open(url).read)["Results"].collect{|year| year["ModelYear"]}
|
16
|
-
end
|
17
|
-
end
|
18
|
-
|
19
|
-
class Manufacturers
|
20
|
-
def initialize(year)
|
21
|
-
@year = year
|
22
|
-
end
|
23
|
-
|
24
|
-
def url
|
25
|
-
BASE_URI + END_POINT + "/#{@year}" + DEFAULT_PARAMS
|
26
|
-
end
|
27
|
-
|
28
|
-
def manufacturers
|
29
|
-
JSON.parse(open(url).read)["Results"].collect{|manufacturer| manufacturer["Make"]}
|
30
|
-
end
|
31
|
-
end
|
32
|
-
|
33
|
-
class Models
|
34
|
-
def initialize(year, manufacturer)
|
35
|
-
@year = year
|
36
|
-
@manufacturer = URI::encode(manufacturer)
|
37
|
-
end
|
38
|
-
|
39
|
-
def url
|
40
|
-
BASE_URI + END_POINT + "/#{@year}/#{@manufacturer}" + DEFAULT_PARAMS
|
41
|
-
end
|
42
|
-
|
43
|
-
def models
|
44
|
-
JSON.parse(open(url).read)["Results"].collect{|model| model["Model"]}
|
45
|
-
end
|
46
|
-
end
|
47
|
-
|
48
|
-
class Trims
|
49
|
-
def initialize(year, manufacturer, model)
|
50
|
-
@year = year
|
51
|
-
@manufacturer = URI::encode(manufacturer)
|
52
|
-
@model = URI::encode(model)
|
53
|
-
end
|
54
|
-
|
55
|
-
def url
|
56
|
-
BASE_URI + END_POINT + "/#{@year}/#{@manufacturer}/#{@model}" + DEFAULT_PARAMS
|
57
|
-
end
|
58
|
-
|
59
|
-
def trims
|
60
|
-
JSON.parse(open(url).read)["Results"].collect do |trim|
|
61
|
-
{
|
62
|
-
:description => trim["VehicleDescription"],
|
63
|
-
:id => trim["VehicleId"]
|
64
|
-
}
|
65
|
-
end
|
66
|
-
end
|
67
|
-
|
68
|
-
def trim_descriptions
|
69
|
-
JSON.parse(open(url).read)["Results"].collect{|trim| trim["VehicleDescription"]}
|
70
|
-
end
|
71
|
-
|
72
|
-
def trim_ids
|
73
|
-
JSON.parse(open(url).read)["Results"].collect{|trim| trim["VehicleId"]}
|
74
|
-
end
|
75
|
-
end
|
76
|
-
|
77
|
-
class Ratings
|
78
|
-
def initialize(vehicle_id)
|
79
|
-
@vehicle_id = vehicle_id
|
80
|
-
end
|
81
|
-
|
82
|
-
def url
|
83
|
-
BASE_URI + END_POINT + "/VehicleId/#{@vehicle_id}" + DEFAULT_PARAMS
|
84
|
-
end
|
85
|
-
|
86
|
-
def ratings
|
87
|
-
JSON.parse(open(url).read)["Results"].first
|
88
|
-
end
|
89
|
-
end
|
90
|
-
|
91
18
|
end
|
92
19
|
end
|
data/lib/nhtsa/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: nhtsa
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mwaki Harri Magotswi
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2016-09-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -77,6 +77,7 @@ extensions: []
|
|
77
77
|
extra_rdoc_files: []
|
78
78
|
files:
|
79
79
|
- ".gitignore"
|
80
|
+
- ".travis.yml"
|
80
81
|
- CODE_OF_CONDUCT.md
|
81
82
|
- Gemfile
|
82
83
|
- LICENSE.txt
|
@@ -87,10 +88,35 @@ files:
|
|
87
88
|
- bin/setup
|
88
89
|
- lib/nhtsa.rb
|
89
90
|
- lib/nhtsa/child_safety_seat_inspection_station_locator.rb
|
91
|
+
- lib/nhtsa/child_safety_seat_inspection_station_locator/get_by_geo_location.rb
|
92
|
+
- lib/nhtsa/child_safety_seat_inspection_station_locator/get_by_state.rb
|
93
|
+
- lib/nhtsa/child_safety_seat_inspection_station_locator/get_by_zip_code.rb
|
90
94
|
- lib/nhtsa/civil_penalties.rb
|
95
|
+
- lib/nhtsa/civil_penalties/civil_penalties.rb
|
96
|
+
- lib/nhtsa/civil_penalties/civil_penalties_by_year.rb
|
91
97
|
- lib/nhtsa/complaints.rb
|
98
|
+
- lib/nhtsa/complaints/complaints.rb
|
99
|
+
- lib/nhtsa/complaints/complaints_by_odi_number.rb
|
100
|
+
- lib/nhtsa/complaints/manufacturers.rb
|
101
|
+
- lib/nhtsa/complaints/models.rb
|
102
|
+
- lib/nhtsa/complaints/years.rb
|
92
103
|
- lib/nhtsa/recalls.rb
|
104
|
+
- lib/nhtsa/recalls/campaign_recalls.rb
|
105
|
+
- lib/nhtsa/recalls/manufacturers.rb
|
106
|
+
- lib/nhtsa/recalls/models.rb
|
107
|
+
- lib/nhtsa/recalls/recalls.rb
|
108
|
+
- lib/nhtsa/recalls/years.rb
|
93
109
|
- lib/nhtsa/safety_ratings.rb
|
110
|
+
- lib/nhtsa/safety_ratings/manufacturer.rb
|
111
|
+
- lib/nhtsa/safety_ratings/manufacturers.rb
|
112
|
+
- lib/nhtsa/safety_ratings/model.rb
|
113
|
+
- lib/nhtsa/safety_ratings/models.rb
|
114
|
+
- lib/nhtsa/safety_ratings/rating.rb
|
115
|
+
- lib/nhtsa/safety_ratings/ratings.rb
|
116
|
+
- lib/nhtsa/safety_ratings/trim.rb
|
117
|
+
- lib/nhtsa/safety_ratings/trims.rb
|
118
|
+
- lib/nhtsa/safety_ratings/year.rb
|
119
|
+
- lib/nhtsa/safety_ratings/years.rb
|
94
120
|
- lib/nhtsa/version.rb
|
95
121
|
- nhtsa.gemspec
|
96
122
|
homepage: https://github.com/omundu/nhtsa
|