Module: LicenseValidator
- Defined in:
- lib/license-validator.rb,
lib/license_validator/driver.rb,
lib/license_validator/states.rb,
lib/license_validator/version.rb,
lib/license_validator/validations/base.rb,
lib/license_validator/validations/state_ak.rb,
lib/license_validator/validations/state_al.rb,
lib/license_validator/validations/state_ar.rb,
lib/license_validator/validations/state_az.rb,
lib/license_validator/validations/state_ca.rb,
lib/license_validator/validations/state_co.rb,
lib/license_validator/validations/state_ct.rb,
lib/license_validator/validations/state_dc.rb,
lib/license_validator/validations/state_de.rb,
lib/license_validator/validations/state_fl.rb,
lib/license_validator/validations/state_ga.rb,
lib/license_validator/validations/state_hi.rb,
lib/license_validator/validations/state_ia.rb,
lib/license_validator/validations/state_id.rb,
lib/license_validator/validations/state_il.rb,
lib/license_validator/validations/state_in.rb,
lib/license_validator/validations/state_ks.rb,
lib/license_validator/validations/state_ky.rb,
lib/license_validator/validations/state_la.rb,
lib/license_validator/validations/state_ma.rb,
lib/license_validator/validations/state_md.rb,
lib/license_validator/validations/state_me.rb,
lib/license_validator/validations/state_mi.rb,
lib/license_validator/validations/state_mn.rb,
lib/license_validator/validations/state_mo.rb,
lib/license_validator/validations/state_ms.rb,
lib/license_validator/validations/state_mt.rb,
lib/license_validator/validations/state_nc.rb,
lib/license_validator/validations/state_nd.rb,
lib/license_validator/validations/state_ne.rb,
lib/license_validator/validations/state_nh.rb,
lib/license_validator/validations/state_nj.rb,
lib/license_validator/validations/state_nm.rb,
lib/license_validator/validations/state_nv.rb,
lib/license_validator/validations/state_ny.rb,
lib/license_validator/validations/state_oh.rb,
lib/license_validator/validations/state_ok.rb,
lib/license_validator/validations/state_or.rb,
lib/license_validator/validations/state_pa.rb,
lib/license_validator/validations/state_ri.rb,
lib/license_validator/validations/state_sc.rb,
lib/license_validator/validations/state_sd.rb,
lib/license_validator/validations/state_tn.rb,
lib/license_validator/validations/state_tx.rb,
lib/license_validator/validations/state_ut.rb,
lib/license_validator/validations/state_va.rb,
lib/license_validator/validations/state_vt.rb,
lib/license_validator/validations/state_wa.rb,
lib/license_validator/validations/state_wi.rb,
lib/license_validator/validations/state_wv.rb,
lib/license_validator/validations/state_wy.rb
Defined Under Namespace
Modules: States, Validations Classes: Driver
Constant Summary collapse
- VERSION =
'1.2.0'
Class Method Summary collapse
-
.generate_state_files ⇒ Object
Only for development.
-
.generate_test_files ⇒ Object
Only for development.
-
.validate!(**kwargs) ⇒ Hash
Validates the provided driver’s DL#.
Class Method Details
.generate_state_files ⇒ Object
Only for development
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/license-validator.rb', line 38 def generate_state_files LicenseValidator::States::ABVS.each do |abv| ruby = <<~RUBY # frozen_string_literal: true module LicenseValidator module Validations class State#{abv.capitalize} < LicenseValidator::Validations::Base def initialize(driver) super(driver) end # @see super def validate super end end end end RUBY File.write("lib/license_validator/validations/state_#{abv.downcase}.rb", ruby) end end |
.generate_test_files ⇒ Object
Only for development
66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 |
# File 'lib/license-validator.rb', line 66 def generate_test_files LicenseValidator::States::ABVS.each do |abv| test = <<~SPEC # frozen_string_literal: true state_klass = LicenseValidator::Validations::State#{abv.capitalize} module ValidAttributes module State#{abv.capitalize} # @see super def valid_attributes super.map do |valid_attrs| valid_attrs end end # @see super def invalid_attributes super.map do |invalid_attrs| invalid_attrs end end private # @see super def valid_license_nums %w[AB123456] end # @see super def invalid_license_nums %w[AB] end # @see super def state '#{abv}' end end end state_klass.extend(ValidAttributes::State#{abv.capitalize}) test_klass(state_klass) SPEC File.write("spec/license_validator/validations/state_#{abv.downcase}_spec.rb", test) end end |
.validate!(**kwargs) ⇒ Hash
Validates the provided driver’s DL#
20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/license-validator.rb', line 20 def validate!(**kwargs) driver = LicenseValidator::Driver.new(**kwargs) validator = LicenseValidator::Validations .const_get("LicenseValidator::Validations::State#{driver.state.capitalize}") .new(driver) validator.validate return validator.validation_results end |