vindetta 0.6.0 → 0.7.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 116289faa3a0129f9e29570b59c210a82e75e9a7
4
- data.tar.gz: a293cb4c27e424b7ab8cd0464ccfbeead07ad8a4
3
+ metadata.gz: f2396851ea95b9d4316fdfd6264415f569cd4031
4
+ data.tar.gz: e2fafae216be76b8ff1fef39dc7d2efbfbc969f5
5
5
  SHA512:
6
- metadata.gz: 3ec17abf80a633fdb381058b750784c1ceaa8e0c085e7805c76186600d0d11752e1f7284ce672c95d291a874fa625a828116394bb030e155b80c2fe4fdc630be
7
- data.tar.gz: 35b097021e4ee89a87c26822ad7f0f4ed4621f4e94efc31420c0d0b1ec375f58a30d28e5364d88dc48a338769662366473117e07e1be030c391bc1778a020314
6
+ metadata.gz: c2cce9e236fff4b20f2a0ff138d53769acc842b2ac735b112f8fe7b91f925892f72f3287c747ae92916c0d22adcf21f5972db70106c3ab8887b70c88cd71474c
7
+ data.tar.gz: ff995b0a3646ccbedc48e4c37edf824e89e1389a47ac86fafae169003f0a9ad70738d67356abd5b0608195d91352e1744def5aceda85d88c298b7be4880105f9
data/Gemfile CHANGED
@@ -1,4 +1,3 @@
1
1
  source 'https://rubygems.org'
2
2
 
3
- # Specify your gem's dependencies in vindetta.gemspec
4
3
  gemspec
data/lib/vindetta/cli.rb CHANGED
@@ -8,7 +8,7 @@ module Vindetta
8
8
 
9
9
  desc 'Transliterates a VIN character'
10
10
  arg_name 'character'
11
- command :transliterate do |c|
11
+ command [:transliterate, :t] do |c|
12
12
  c.action do |_global, _options, args|
13
13
  puts Vindetta::Transliterator.run(args.first)
14
14
  end
@@ -1,7 +1,17 @@
1
+ require 'active_model'
2
+
1
3
  module Vindetta
2
- class Validator
3
- def self.run(vin)
4
- Vin.new(vin).valid?
4
+ class Validator < ActiveModel::Validator
5
+ LENGTH = 17
6
+
7
+ def self.run(value)
8
+ Vin.new(value).valid?
9
+ end
10
+
11
+ def validate(record)
12
+ if record.value.length != LENGTH
13
+ record.errors.add(:value, "Invalid Length") # TODO: Move to I18n
14
+ end
5
15
  end
6
16
  end
7
17
  end
@@ -1,3 +1,3 @@
1
1
  module Vindetta
2
- VERSION = '0.6.0'.freeze
2
+ VERSION = '0.7.0'.freeze
3
3
  end
data/lib/vindetta/vin.rb CHANGED
@@ -3,12 +3,10 @@ require 'active_model'
3
3
 
4
4
  module Vindetta
5
5
  class Vin
6
- LENGTH = 17
7
-
8
6
  attr_reader :value
9
7
  include ActiveModel::Validations
10
8
 
11
- validates_length_of :value, is: LENGTH
9
+ validates_with Validator
12
10
 
13
11
  def initialize(value)
14
12
  @value = value
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vindetta
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.0
4
+ version: 0.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kyle Decot