levtera 0.2.4 → 0.2.5
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/Gemfile.lock +1 -1
- data/lib/levtera/concerns/vehicle.rb +7 -3
- data/lib/levtera/concerns/version.rb +2 -2
- data/lib/levtera/version.rb +1 -1
- data/spec/fabricators/vehicle_fabricator.rb +11 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a381dde0dfb7f5dc49f41de8e97b2bacbcdca974
|
4
|
+
data.tar.gz: 7bf49d7a51fc598ec2fbb88f8ac3941c168423aa
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 475010fb08aba83f46552eb1e8c7499cd4b83de944b8a0367a4844b3bb49b1252d21044b98d6d009b5fc66e2cff3df57a585b9a12e1f6e2463d7bc633f7e7b61
|
7
|
+
data.tar.gz: a8ff9708c5890f44a9e1c61d055efac725dc2a5cb001ba559b620630d580b55335e8e1526cdc2578ad189b40c8680f9beaa65a233da5fa0c7e507f754dd753d8
|
data/Gemfile.lock
CHANGED
@@ -1,21 +1,25 @@
|
|
1
1
|
module Levtera::Concerns
|
2
2
|
module Vehicle
|
3
|
-
ENGINE_FEEDINGS_NAMES = %i(gasoline alcohol diesel multifuel)
|
4
3
|
|
5
4
|
extend ActiveSupport::Concern
|
6
5
|
|
6
|
+
ENGINE_FEEDINGS_NAMES = {
|
7
|
+
car: %w(Gasolina Diesel Flex GNV Alcool Hibrido TetraFuel),
|
8
|
+
motorcycle: %w(Gasolina Flex)
|
9
|
+
}
|
10
|
+
|
7
11
|
included do
|
8
12
|
field :fabrication_year , type: Integer
|
9
13
|
field :model_year , type: Integer
|
10
14
|
field :plate , type: String
|
11
|
-
field :engine_feeding , type:
|
15
|
+
field :engine_feeding , type: String
|
12
16
|
|
13
17
|
belongs_to :version
|
14
18
|
|
15
19
|
validates :fabrication_year , numericality: { only_integer: true, allow_nil: true, greater_than: 0 }
|
16
20
|
validates :model_year , numericality: { only_integer: true, allow_nil: true, greater_than: 0 }
|
17
21
|
# Only allowing nil because motorcycle sometimes comes with unknown feeding type
|
18
|
-
validates :engine_feeding , inclusion: { in: ENGINE_FEEDINGS_NAMES, allow_nil: true }
|
22
|
+
validates :engine_feeding , inclusion: { in: -> (vehicle) { ENGINE_FEEDINGS_NAMES[vehicle.version.model.make.vehicle_type.to_sym] }, allow_nil: true }
|
19
23
|
|
20
24
|
|
21
25
|
# TODO implement provider domain creation configuration method on include Provided
|
@@ -6,8 +6,8 @@ module Levtera::Concerns
|
|
6
6
|
|
7
7
|
TRANSMISSION_TYPES = %i(mechanic automatic semi-automatic)
|
8
8
|
BODY_TYPES = {
|
9
|
-
car: %w(Buggy Conversivel Hatch Minivan Perua
|
10
|
-
motorcycle: %w(Cross Naked Scooter
|
9
|
+
car: %w(Buggy Conversivel Hatch Minivan Perua/SW Picape Sedan Utilitario Van SUV),
|
10
|
+
motorcycle: %w(Cross Naked Scooter/Cub Street Trail Custom Quadriciculo Sport Touring Triciculo)
|
11
11
|
}
|
12
12
|
|
13
13
|
included do
|
data/lib/levtera/version.rb
CHANGED
@@ -7,5 +7,15 @@ Fabricator :levtera_vehicle, class_name: 'Vehicle' do
|
|
7
7
|
plate += sprintf "%04d", Forgery::Basic.number(at_most: 9999)
|
8
8
|
end
|
9
9
|
|
10
|
-
engine_feeding {
|
10
|
+
engine_feeding { |attributes|
|
11
|
+
if attributes.has_key? :version
|
12
|
+
type = attributes[:version].model.make.vehicle_type
|
13
|
+
else
|
14
|
+
type = Make::VEHICLE_TYPES.sample
|
15
|
+
end
|
16
|
+
|
17
|
+
raise "Vehicle could not be detected while fabricating vehicle." unless type
|
18
|
+
|
19
|
+
Levtera::Concerns::Vehicle::ENGINE_FEEDINGS_NAMES[type.to_sym].sample.to_s
|
20
|
+
}
|
11
21
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: levtera
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Heitor Salazar Baldelli
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-01-
|
11
|
+
date: 2014-01-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|