From 8ec8ab839e6c6bcc943afb2c8bcaee2c2a32ce08 Mon Sep 17 00:00:00 2001 From: Nemo Date: Thu, 26 Mar 2020 16:51:59 +0530 Subject: [PATCH] Initial commit for rubygem --- .gitignore | 18 ++++++++++++----- Gemfile | 6 ++++++ Gemfile.lock | 34 ++++++++++++++++++++++++++++++++ Rakefile | 7 +++++++ bin/console | 14 +++++++++++++ bin/setup | 8 ++++++++ pincode-validator.gemspec | 28 ++++++++++++++++++++++++++ src/pincode_validator.rb | 6 ++++++ src/pincode_validator/version.rb | 3 +++ tests/validate_spec.rb | 9 +++++++++ 10 files changed, 128 insertions(+), 5 deletions(-) create mode 100644 Gemfile create mode 100644 Gemfile.lock create mode 100644 Rakefile create mode 100755 bin/console create mode 100755 bin/setup create mode 100644 pincode-validator.gemspec create mode 100644 src/pincode_validator.rb create mode 100644 src/pincode_validator/version.rb create mode 100644 tests/validate_spec.rb diff --git a/.gitignore b/.gitignore index ad41c1c..76d0aaa 100644 --- a/.gitignore +++ b/.gitignore @@ -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 diff --git a/Gemfile b/Gemfile new file mode 100644 index 0000000..0c032ea --- /dev/null +++ b/Gemfile @@ -0,0 +1,6 @@ +source "https://rubygems.org" + +# Specify your gem's dependencies in pincode-validator.gemspec +gemspec + +gem "rake", "~> 12.0" diff --git a/Gemfile.lock b/Gemfile.lock new file mode 100644 index 0000000..de39f4a --- /dev/null +++ b/Gemfile.lock @@ -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 diff --git a/Rakefile b/Rakefile new file mode 100644 index 0000000..308670b --- /dev/null +++ b/Rakefile @@ -0,0 +1,7 @@ +require "bundler/gem_tasks" + +RSpec::Core::RakeTask.new(:spec) do |t| + t.pattern = 'tests/*_spec.rb' +end + +task :default => :spec diff --git a/bin/console b/bin/console new file mode 100755 index 0000000..978b836 --- /dev/null +++ b/bin/console @@ -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__) diff --git a/bin/setup b/bin/setup new file mode 100755 index 0000000..dce67d8 --- /dev/null +++ b/bin/setup @@ -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 diff --git a/pincode-validator.gemspec b/pincode-validator.gemspec new file mode 100644 index 0000000..ad05672 --- /dev/null +++ b/pincode-validator.gemspec @@ -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 diff --git a/src/pincode_validator.rb b/src/pincode_validator.rb new file mode 100644 index 0000000..4aa3d73 --- /dev/null +++ b/src/pincode_validator.rb @@ -0,0 +1,6 @@ +require "pincode_validator/version" + +module PincodeValidator + class Error < StandardError; end + # Your code goes here... +end diff --git a/src/pincode_validator/version.rb b/src/pincode_validator/version.rb new file mode 100644 index 0000000..8246a87 --- /dev/null +++ b/src/pincode_validator/version.rb @@ -0,0 +1,3 @@ +module PincodeValidator + VERSION = "1.0.3" +end diff --git a/tests/validate_spec.rb b/tests/validate_spec.rb new file mode 100644 index 0000000..0a59546 --- /dev/null +++ b/tests/validate_spec.rb @@ -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