automobile 0.1.2 → 0.1.3
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.
- data/lib/automobile.rb +0 -10
- data/lib/automobile/fallback.rb +11 -0
- data/lib/automobile/relationships.rb +15 -0
- data/lib/test_support/automobile_record.rb +1 -21
- metadata +6 -4
data/lib/automobile.rb
CHANGED
@@ -3,15 +3,5 @@ require 'emitter'
|
|
3
3
|
module BrighterPlanet
|
4
4
|
module Automobile
|
5
5
|
extend BrighterPlanet::Emitter
|
6
|
-
|
7
|
-
def self.automobile_model
|
8
|
-
if Object.const_defined? 'Automobile'
|
9
|
-
::Automobile
|
10
|
-
elsif Object.const_defined? 'AutomobileRecord'
|
11
|
-
AutomobileRecord
|
12
|
-
else
|
13
|
-
raise 'There is no automobile model'
|
14
|
-
end
|
15
|
-
end
|
16
6
|
end
|
17
7
|
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
module BrighterPlanet
|
2
|
+
module Automobile
|
3
|
+
module Fallback
|
4
|
+
def self.included(base)
|
5
|
+
base.falls_back_on :fuel_efficiency => 20.182.miles_per_gallon.to(:kilometres_per_litre), # mpg https://brighterplanet.sifterapp.com/projects/30/issues/428
|
6
|
+
:urbanity => 0.43, # EPA via Ian https://brighterplanet.sifterapp.com/projects/30/issues/428
|
7
|
+
:annual_distance_estimate => 11819.miles.to(:kilometres) # miles https://brighterplanet.sifterapp.com/projects/30/issues/428
|
8
|
+
end
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
module BrighterPlanet
|
2
|
+
module Automobile
|
3
|
+
module Relationships
|
4
|
+
def self.included(target)
|
5
|
+
target.belongs_to :make, :class_name => 'AutomobileMake', :foreign_key => 'make_name'
|
6
|
+
target.belongs_to :make_year, :class_name => 'AutomobileMakeYear', :foreign_key => 'make_year_name'
|
7
|
+
target.belongs_to :make_model, :class_name => 'AutomobileMakeModel', :foreign_key => 'make_model_name'
|
8
|
+
target.belongs_to :make_model_year, :class_name => 'AutomobileMakeModelYear', :foreign_key => 'make_model_year_name'
|
9
|
+
target.belongs_to :make_model_year_variant, :class_name => 'AutomobileMakeModelYearVariant', :foreign_key => 'make_model_year_variant_row_hash'
|
10
|
+
target.belongs_to :fuel_type, :class_name => 'AutomobileFuelType', :foreign_key => 'fuel_type_code'
|
11
|
+
target.belongs_to :size_class, :class_name => 'AutomobileSizeClass'
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -4,26 +4,6 @@ require 'automobile'
|
|
4
4
|
require 'sniff'
|
5
5
|
|
6
6
|
class AutomobileRecord < ActiveRecord::Base
|
7
|
-
class << self
|
8
|
-
def n
|
9
|
-
new :make => AutomobileMake.find_by_name('Nissan')
|
10
|
-
end
|
11
|
-
|
12
|
-
def add_implicit_characteristics
|
13
|
-
decisions[:emission].committees.map(&:name).reject { |c| characteristics.keys.unshift(:emission).include? c }.each do |c|
|
14
|
-
characterize { has c }
|
15
|
-
end
|
16
|
-
end
|
17
|
-
end
|
18
|
-
|
19
|
-
include BrighterPlanet::Automobile
|
20
7
|
include Sniff::Emitter
|
21
|
-
|
22
|
-
belongs_to :make, :class_name => 'AutomobileMake', :foreign_key => 'make_name'
|
23
|
-
belongs_to :make_year, :class_name => 'AutomobileMakeYear', :foreign_key => 'make_year_name'
|
24
|
-
belongs_to :make_model, :class_name => 'AutomobileMakeModel', :foreign_key => 'make_model_name'
|
25
|
-
belongs_to :make_model_year, :class_name => 'AutomobileMakeModelYear', :foreign_key => 'make_model_year_name'
|
26
|
-
belongs_to :make_model_year_variant, :class_name => 'AutomobileMakeModelYearVariant', :foreign_key => 'make_model_year_variant_row_hash'
|
27
|
-
belongs_to :fuel_type, :class_name => 'AutomobileFuelType', :foreign_key => 'fuel_type_code'
|
28
|
-
belongs_to :size_class, :class_name => 'AutomobileSizeClass'
|
8
|
+
include BrighterPlanet::Automobile
|
29
9
|
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: automobile
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 29
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 1
|
9
|
-
-
|
10
|
-
version: 0.1.
|
9
|
+
- 3
|
10
|
+
version: 0.1.3
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Andy Rossmeissl
|
@@ -19,7 +19,7 @@ autorequire:
|
|
19
19
|
bindir: bin
|
20
20
|
cert_chain: []
|
21
21
|
|
22
|
-
date: 2010-12-
|
22
|
+
date: 2010-12-07 00:00:00 -06:00
|
23
23
|
default_executable:
|
24
24
|
dependencies:
|
25
25
|
- !ruby/object:Gem::Dependency
|
@@ -190,6 +190,8 @@ files:
|
|
190
190
|
- lib/automobile/carbon_model.rb
|
191
191
|
- lib/automobile/characterization.rb
|
192
192
|
- lib/automobile/data.rb
|
193
|
+
- lib/automobile/fallback.rb
|
194
|
+
- lib/automobile/relationships.rb
|
193
195
|
- lib/automobile/summarization.rb
|
194
196
|
- lib/test_support/automobile_record.rb
|
195
197
|
- features/support/env.rb
|