Initial commit for rubygem

This commit is contained in:
Nemo 2020-03-26 16:51:59 +05:30
parent e625caee29
commit 8ec8ab839e
10 changed files with 128 additions and 5 deletions

18
.gitignore vendored
View File

@ -1,6 +1,14 @@
/vendor/
/node_modules/
composer.lock
__pycache__/
/.bundle/
/.yardoc
/_yardoc/
/coverage/
/dist/
package-lock.json
/doc/
/node_modules/
/pkg/
/spec/reports/
/tmp/
/vendor/
__pycache__/
/composer.lock
/package-lock.json

6
Gemfile Normal file
View File

@ -0,0 +1,6 @@
source "https://rubygems.org"
# Specify your gem's dependencies in pincode-validator.gemspec
gemspec
gem "rake", "~> 12.0"

34
Gemfile.lock Normal file
View File

@ -0,0 +1,34 @@
PATH
remote: .
specs:
pincode_validator (1.0.3)
GEM
remote: https://rubygems.org/
specs:
diff-lcs (1.3)
rake (12.3.3)
rspec (3.9.0)
rspec-core (~> 3.9.0)
rspec-expectations (~> 3.9.0)
rspec-mocks (~> 3.9.0)
rspec-core (3.9.1)
rspec-support (~> 3.9.1)
rspec-expectations (3.9.1)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.9.0)
rspec-mocks (3.9.1)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.9.0)
rspec-support (3.9.2)
PLATFORMS
ruby
DEPENDENCIES
pincode_validator!
rake (~> 12.0)
rspec (~> 3.8)
BUNDLED WITH
2.1.4

7
Rakefile Normal file
View File

@ -0,0 +1,7 @@
require "bundler/gem_tasks"
RSpec::Core::RakeTask.new(:spec) do |t|
t.pattern = 'tests/*_spec.rb'
end
task :default => :spec

14
bin/console Executable file
View File

@ -0,0 +1,14 @@
#!/usr/bin/env ruby
require "bundler/setup"
require "pincode_validator"
# You can add fixtures and/or initialization code here to make experimenting
# with your gem easier. You can also use a different console, if you like.
# (If you use this, don't forget to add pry to your Gemfile!)
# require "pry"
# Pry.start
require "irb"
IRB.start(__FILE__)

8
bin/setup Executable file
View File

@ -0,0 +1,8 @@
#!/usr/bin/env bash
set -euo pipefail
IFS=$'\n\t'
set -vx
bundle install
# Do any other automated setup that you need to do here

28
pincode-validator.gemspec Normal file
View File

@ -0,0 +1,28 @@
require_relative 'src/pincode_validator/version'
Gem::Specification.new do |spec|
spec.name = "pincode_validator"
spec.version = PincodeValidator::VERSION
spec.authors = ["Nemo"]
spec.email = ["rubygems@captnemo.in"]
spec.summary = %q{A simple regex based offline validator for PIN codes in India}
spec.homepage = "https://github.com/captn3m0/india-pincode-regex"
spec.required_ruby_version = Gem::Requirement.new(">= 2.3.0")
spec.metadata["homepage_uri"] = spec.homepage
spec.metadata["source_code_uri"] = "https://github.com/captn3m0/india-pincode-regex"
# Specify which files should be added to the gem when it is released.
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
end
spec.license = 'MIT'
spec.bindir = "exe"
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
spec.require_paths = ["src"]
spec.add_development_dependency 'rake', '~> 13.0'
spec.add_development_dependency 'rspec', '~> 3.8'
end

6
src/pincode_validator.rb Normal file
View File

@ -0,0 +1,6 @@
require "pincode_validator/version"
module PincodeValidator
class Error < StandardError; end
# Your code goes here...
end

View File

@ -0,0 +1,3 @@
module PincodeValidator
VERSION = "1.0.3"
end

9
tests/validate_spec.rb Normal file
View File

@ -0,0 +1,9 @@
require 'pincode_validator'
describe PincodeValidator do
it 'should validate pincodes' do
['244713', '560029', '560030', '110011'].each do |pin|
expect(described_class::valid? pin).to eq(true)
end
end
end