vindetta 0.3.0 → 0.4.0

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: b9633b4d06861dba171722a55d1694f7132ef876
4
- data.tar.gz: 7593422cea37d67bbb9091dc66190705237cdb8e
3
+ metadata.gz: 97ff2d11e84c7f31eda645c3e72fd992adeabc8e
4
+ data.tar.gz: '0857a33d479739dcb82555f72cb1c34b5e22521c'
5
5
  SHA512:
6
- metadata.gz: cbb2c0a77800aab56c55af7aa133c0e9d13ad054ff1e4019895ab3600940364161f29268ce0ac1e5f46b2cbf9812771a7e785812265549b2676e9335fddff6b5
7
- data.tar.gz: 201d28686e90d464cff0f09abad075d5fc045948ca8d9f41aa4bfc988ee58f3b500ad76a118d850c0489add980fb7a68348fa272362dd809160cb3249adc4c7b
6
+ metadata.gz: f0eaa15fab51ff8ab37ece173052f8ff38b9bc70b58fd731a10ee540d970f0aafd9b4221d067e1cf538fa9cb4b54fc5e4b639b8f21a65b2ef59f300345e9c469
7
+ data.tar.gz: 2993be32724b7749fe21fce2935fb52048a219068abe1046530d90f34a2abb9635e477d0f3074e81af7eed1acb8ffd50c4b53e590d0a8e64feed647041a3d39b
data/.gitignore CHANGED
@@ -8,8 +8,5 @@
8
8
  /spec/reports/
9
9
  /tmp/
10
10
 
11
- # byebug
12
- .byebug_history
13
-
14
11
  # rspec failure tracking
15
12
  .rspec_status
data/README.md CHANGED
@@ -32,10 +32,8 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
32
32
 
33
33
  ## Contributing
34
34
 
35
- Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/vindetta.
36
-
35
+ Bug reports and pull requests are welcome on GitHub at https://github.com/kyledecot/vindetta.
37
36
 
38
37
  ## License
39
38
 
40
39
  The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
41
-
data/Rakefile CHANGED
@@ -1,6 +1,6 @@
1
- require "bundler/gem_tasks"
2
- require "rspec/core/rake_task"
1
+ require 'bundler/gem_tasks'
2
+ require 'rspec/core/rake_task'
3
3
 
4
4
  RSpec::Core::RakeTask.new(:spec)
5
5
 
6
- task :default => :spec
6
+ task default: :spec
data/bin/console CHANGED
@@ -1,14 +1,7 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
- require "bundler/setup"
4
- require "vindetta"
3
+ require 'pry'
4
+ require 'bundler/setup'
5
+ require 'vindetta'
5
6
 
6
- # You can add fixtures and/or initialization code here to make experimenting
7
- # with your gem easier. You can also use a different console, if you like.
8
-
9
- # (If you use this, don't forget to add pry to your Gemfile!)
10
- # require "pry"
11
- # Pry.start
12
-
13
- require "irb"
14
- IRB.start(__FILE__)
7
+ Pry.start
data/bin/setup CHANGED
@@ -1,8 +1,7 @@
1
1
  #!/usr/bin/env bash
2
+
2
3
  set -euo pipefail
3
4
  IFS=$'\n\t'
4
5
  set -vx
5
6
 
6
7
  bundle install
7
-
8
- # Do any other automated setup that you need to do here
data/exe/vindetta CHANGED
@@ -1,19 +1,5 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
- require "vindetta"
4
- require "gli"
3
+ require 'vindetta'
5
4
 
6
- include GLI::App
7
-
8
- program_desc 'Utility for generating Vehicle Identification Numbers (VINs)'
9
-
10
- command :generate do |c|
11
- c.desc "Generates a random VIN"
12
-
13
- c.action do
14
- puts Vindetta::Generator.generate
15
- end
16
- end
17
-
18
-
19
- exit run(ARGV)
5
+ Vindetta::CLI.run(ARGV)
@@ -0,0 +1,24 @@
1
+ require 'gli'
2
+
3
+ module Vindetta
4
+ class CLI
5
+ extend GLI::App
6
+
7
+ program_desc 'Vehicle Identification Number (VIN) CLI'
8
+
9
+ desc 'Transliterates a VIN character'
10
+ arg_name 'character'
11
+ command :transliterate do |c|
12
+ c.action do |_global, _options, args|
13
+ puts Vindetta::Transliterator.run(args.first)
14
+ end
15
+ end
16
+
17
+ desc 'Generates a random vin'
18
+ command :generate do |c|
19
+ c.action do |_global, options, _args|
20
+ puts Vindetta::Generator.generate(options)
21
+ end
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,7 @@
1
+ module Vindetta
2
+ class InvalidCharacter < StandardError
3
+ end
4
+
5
+ class InvalidVin < StandardError
6
+ end
7
+ end
@@ -1,15 +1,9 @@
1
+ require 'net/http'
2
+
1
3
  module Vindetta
2
4
  class Generator
3
- VINS = [
4
- "KNAFX4A67E5095888",
5
- "1FTRX12W18KE97487",
6
- "2HGFA1F38BH525824",
7
- "1C4GP64L5YB667678"
8
- ].freeze
9
-
10
-
11
- def self.generate(options = {})
12
- VINS.sample
5
+ def self.generate
6
+ Net::HTTP.get('randomvin.com', '/getvin.php')
13
7
  end
14
8
  end
15
9
  end
@@ -0,0 +1,11 @@
1
+ module Vindetta
2
+ class Transliterator
3
+ MAPPING = '0123456789.ABCDEFGH..JKLMN.P.R..STUVWXYZ'.split('').freeze
4
+
5
+ def self.run(character)
6
+ index = MAPPING.find_index(character)
7
+ raise Vindetta::InvalidCharacter.new(character) unless index
8
+ index % 10
9
+ end
10
+ end
11
+ end
@@ -1,3 +1,3 @@
1
1
  module Vindetta
2
- VERSION = "0.3.0"
2
+ VERSION = '0.4.0'.freeze
3
3
  end
@@ -0,0 +1,17 @@
1
+ require 'active_support'
2
+ require 'active_model'
3
+
4
+ module Vindetta
5
+ class Vin
6
+ LENGTH = 17
7
+
8
+ attr_reader :value
9
+ include ActiveModel::Validations
10
+
11
+ validates_length_of :value, is: LENGTH
12
+
13
+ def initialize(value)
14
+ @value = value
15
+ end
16
+ end
17
+ end
data/lib/vindetta.rb CHANGED
@@ -1,5 +1,9 @@
1
- require "vindetta/version"
2
- require "vindetta/generator"
1
+ require 'vindetta/version'
2
+ require 'vindetta/generator'
3
+ require 'vindetta/cli'
4
+ require 'vindetta/errors'
5
+ require 'vindetta/transliterator'
6
+ require 'vindetta/vin'
3
7
 
4
8
  module Vindetta
5
9
  def self.generate(options = {})
data/rubocop.yml ADDED
File without changes
data/vindetta.gemspec CHANGED
@@ -1,30 +1,34 @@
1
1
  # coding: utf-8
2
+
2
3
  lib = File.expand_path('../lib', __FILE__)
3
4
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
5
  require 'vindetta/version'
5
6
 
6
7
  Gem::Specification.new do |spec|
7
- spec.name = "vindetta"
8
+ spec.name = 'vindetta'
8
9
  spec.version = Vindetta::VERSION
9
- spec.authors = ["Kyle Decot"]
10
- spec.email = ["kyle@joinroot.com"]
10
+ spec.authors = ['Kyle Decot']
11
+ spec.email = ['kyle@joinroot.com']
11
12
 
12
- spec.summary = "Ruby gem for generating VINs"
13
- spec.description = "Ruby gem for generating VINs"
14
- spec.homepage = "https://github.com/kyledecot/vindetta"
15
- spec.license = "MIT"
13
+ spec.summary = 'Ruby gem for generating VINs'
14
+ spec.description = 'Ruby gem for generating VINs'
15
+ spec.homepage = 'https://github.com/kyledecot/vindetta'
16
+ spec.license = 'MIT'
16
17
 
17
18
  spec.files = `git ls-files -z`.split("\x0").reject do |f|
18
19
  f.match(%r{^(test|spec|features)/})
19
20
  end
20
- spec.bindir = "exe"
21
+ spec.bindir = 'exe'
21
22
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
22
- spec.require_paths = ["lib"]
23
+ spec.require_paths = ['lib']
23
24
 
24
- spec.add_dependency "gli", "~> 2.16"
25
+ spec.add_dependency 'gli', '~> 2.16'
26
+ spec.add_dependency 'activemodel', '~> 5.1'
27
+ spec.add_dependency 'activesupport', '~> 5.1'
25
28
 
26
- spec.add_development_dependency "bundler", "~> 1.14"
27
- spec.add_development_dependency "rake", "~> 10.0"
28
- spec.add_development_dependency "rspec", "~> 3.0"
29
- spec.add_development_dependency "byebug", "~> 9.0"
29
+ spec.add_development_dependency 'bundler', '~> 1.14'
30
+ spec.add_development_dependency 'rake', '~> 10.0'
31
+ spec.add_development_dependency 'rspec', '~> 3.0'
32
+ spec.add_development_dependency 'pry'
33
+ spec.add_development_dependency 'rubocop'
30
34
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vindetta
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kyle Decot
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-08-17 00:00:00.000000000 Z
11
+ date: 2017-08-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: gli
@@ -24,6 +24,34 @@ dependencies:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
26
  version: '2.16'
27
+ - !ruby/object:Gem::Dependency
28
+ name: activemodel
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '5.1'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '5.1'
41
+ - !ruby/object:Gem::Dependency
42
+ name: activesupport
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '5.1'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '5.1'
27
55
  - !ruby/object:Gem::Dependency
28
56
  name: bundler
29
57
  requirement: !ruby/object:Gem::Requirement
@@ -67,19 +95,33 @@ dependencies:
67
95
  - !ruby/object:Gem::Version
68
96
  version: '3.0'
69
97
  - !ruby/object:Gem::Dependency
70
- name: byebug
98
+ name: pry
71
99
  requirement: !ruby/object:Gem::Requirement
72
100
  requirements:
73
- - - "~>"
101
+ - - ">="
74
102
  - !ruby/object:Gem::Version
75
- version: '9.0'
103
+ version: '0'
76
104
  type: :development
77
105
  prerelease: false
78
106
  version_requirements: !ruby/object:Gem::Requirement
79
107
  requirements:
80
- - - "~>"
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
+ - !ruby/object:Gem::Dependency
112
+ name: rubocop
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - ">="
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - ">="
81
123
  - !ruby/object:Gem::Version
82
- version: '9.0'
124
+ version: '0'
83
125
  description: Ruby gem for generating VINs
84
126
  email:
85
127
  - kyle@joinroot.com
@@ -99,8 +141,13 @@ files:
99
141
  - bin/setup
100
142
  - exe/vindetta
101
143
  - lib/vindetta.rb
144
+ - lib/vindetta/cli.rb
145
+ - lib/vindetta/errors.rb
102
146
  - lib/vindetta/generator.rb
147
+ - lib/vindetta/transliterator.rb
103
148
  - lib/vindetta/version.rb
149
+ - lib/vindetta/vin.rb
150
+ - rubocop.yml
104
151
  - vindetta.gemspec
105
152
  homepage: https://github.com/kyledecot/vindetta
106
153
  licenses: