levtera 0.2.4 → 0.2.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 733cf91d7a81c0fdeea45c057bbb00cb7dbd2efe
4
- data.tar.gz: 3b1d8eeab3e5a3797b6a3a9f6d757d8ebb23dc1e
3
+ metadata.gz: a381dde0dfb7f5dc49f41de8e97b2bacbcdca974
4
+ data.tar.gz: 7bf49d7a51fc598ec2fbb88f8ac3941c168423aa
5
5
  SHA512:
6
- metadata.gz: 43464c353dfd2cab2d0cb81c91fca2ef93b93cb41d2edd1a68c12966f7cdd8eaaf505f7ab46c8645f9baab23f8dcacfbde77689a041ea3277839374b8910456e
7
- data.tar.gz: 967df0fd010f912e102364d4077d3cb4b404850d5937e3f0ea8b1e47c143621ebace2ee13fab144c91b9974fa741bf737b689a7e4071202abe9a5fb741da80ef
6
+ metadata.gz: 475010fb08aba83f46552eb1e8c7499cd4b83de944b8a0367a4844b3bb49b1252d21044b98d6d009b5fc66e2cff3df57a585b9a12e1f6e2463d7bc633f7e7b61
7
+ data.tar.gz: a8ff9708c5890f44a9e1c61d055efac725dc2a5cb001ba559b620630d580b55335e8e1526cdc2578ad189b40c8680f9beaa65a233da5fa0c7e507f754dd753d8
data/Gemfile.lock CHANGED
@@ -11,7 +11,7 @@ GIT
11
11
  PATH
12
12
  remote: .
13
13
  specs:
14
- levtera (0.2.4)
14
+ levtera (0.2.5)
15
15
  mongoid
16
16
  mongoid-rspec
17
17
  rails (>= 3)
@@ -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: Symbol
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\/SW Picape Sedan Utilitario Van SUV),
10
- motorcycle: %w(Cross Naked Scooter\/Cub Street Trail Custom Quadriciculo Sport Touring Triciculo)
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
@@ -2,7 +2,7 @@ require 'active_support'
2
2
 
3
3
  module Levtera
4
4
  # levtera version
5
- VERSION = "0.2.4"
5
+ VERSION = "0.2.5"
6
6
 
7
7
  module Concerns
8
8
  extend ActiveSupport::Autoload
@@ -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 { Levtera::Concerns::Vehicle::ENGINE_FEEDINGS_NAMES.sample }
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
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-17 00:00:00.000000000 Z
11
+ date: 2014-01-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails